Skip to content

Code_controller

lemmiix edited this page Nov 5, 2025 · 2 revisions

Controller documentation

controller

extern struct map_uint_bool key_state[];

This creates a map of SDLK_x keys and their active status if the corresponsing key is pressed at the moment.


extern float Center_x;

Center-X of the player object.


extern float Center_y;

Center-Y of the player object.


void turn_the_thing(float* x, float* y);

This calculates the angle the player is supposed to be turned to, by using the mouse position as the target.
@param x: the x-position of the mouse
@param y: the y-position of the mouse


void move_ship_up();

This calculates the new position of the player object for moving up.


void move_ship_left();

This calculates the new position of the player object for moving left.


void move_ship_down();

This calculates the new position of the player object for moving down.


void move_ship_right();

This calculates the new position of the player object for moving right.


void set_key_active(unsigned int key);

This sets a key of the key_state[] as active.
@param key: the SDLK_x key


void set_key_inactive(unsigned int key);

This sets a key of the key_state[] as inactive.
@param key: the SDLK_x key


bool is_key_active(unsigned int key);

This checks if a specific key is currently set as active.
@param key: the SDLK_x key
@return TRUE if key is active


void flush_keystate();

This sets all keys in key_state[] as inactive.


void flush_mousepos();

This sets the variable that holds the mouse position to the starting position (does NOT affect the actual position of the mouse).


void flush_playerpos();

This sets the variable that holds the player position to the starting position.

Quicknav

Go back to wiki home

Code documentation:
doc_code

Architecture documentation:
doc_arch

Project license

Clone this wiki locally