Jump to content

CONTROLS_STATE_AUX_0~CONTROLS_STATE_AUX_F function question


photo

Recommended Posts

These are 16 empty states you can map to whatever controls you need for your game.

For example, besides the already defined CONTROLS_STATE_FIRE for firing or CONTROLS_STATE_USE for using the item, you might want to open the item inventory when "i" key is pressed on the keyboard. For that, you will need to use CONTROLS_STATE_AUX_0.

 

/*
*/
void init_controls() {

   // Check if the key is pressed and update the state of the specified control.
   // You can use both 'i' or ASCII code (105).
   engine.controls.setStateKey(CONTROLS_STATE_AUX_0,'i');
}

int inventory_toggled = false;

/*
*/
// Implement your game logic for showing or hiding item inventory.
void update_game_logic() {

   // If the control state is positive (the key has been pressed), toggle item
   // inventory on and off.
   if(engine.controls.getState(CONTROLS_STATE_AUX_0)) {

   inventory_toggled = !inventory_toggled;

   }
}

/*
*/
int init() {
  init_controls();
}

/*
*/
// Update controls each frame according to the user input.
int update() {
   update_game_logic();
}

Link to comment
×
×
  • Create New...