Skip to content

Code_player

lemmiix edited this page Nov 5, 2025 · 3 revisions

Player documentation

player.h

extern struct enemy_manager* get_enemy_manager();

This function is declared as extern and is initialized in enemy.c.
Detailed explanation can be found here.
@return the enemy manager


typedef struct player_ship {
	SDL_Vertex shape[3];
	SDL_Vertex reference_shape[3];
	int health;
	int score;
} Player_ship;

This declares a new type definition Player_ship which will represent the player object.
@member shape[]: simple triangle vertex shape, will be rendered as the controllable character
@member reference_shape[]: same triangle as shape, which will MOVE with the player, but will not be rotated. This is uses as reference for movement calculations
@member health: is actually not used in the project, but provided to maybe enable a health-system in the future
@member score: player score. This increases if enemy destroyed or decreases if window border is hit


void create_player(Player_ship* player);

This initializes the player object from the typedef Player_ship. It sets the default values for each member.
@param player: this passes an object from typedef Player_ship as reference of which the values shall be set.


bool got_hit_by_enemy(struct enemy_manager* EM);

This iterates through the map of enemies and checks if the distance of that enemy relative to the player is smaller or equal to the radians of the enemy.
@param EM: a reference of an enemy manager of type struct enemy_manager
@return TRUE if distance from enemy relative to player is smaller or equal to the radians of the enemy

Quicknav

Go back to wiki home

Code documentation:
doc_code

Architecture documentation:
doc_arch

Project license

Clone this wiki locally