Newer
Older
#include "input_manager.h"
void activate_switch(int y, int x) {
map * m = current_map();
int i = coord_idx(y, x);
if (!m->entities[i] || m->entities[i]->category != SWI) {
printf("There is no switch to touch in front of you.\n");
return;
} else if (m->entities[i]->stats[0] == ACTIVATED) {
printf("This switch is already activated.\n");
return;
}
m->entities[i]->stats[0] = ACTIVATED;
printf("You activate the %dth switch.\n", m->entities[i]->id);
char buffer[2];
sprintf(buffer, "%d", m->entities[i]->id);
strcat(played_order, buffer);
}
void touch(void) {
int y, x;
player_in_dir_n(&y, &x, 1);
#ifdef inverse_xy
// @AGDB this bug is just an inversion of x and y, but the result is funny
activate_switch(x, y);
#else
activate_switch(y, x);
#endif
}
void c_apply_input(command * c) {
if (!strcmp(c->command_buffer, "TOUCH")) {
touch();
} else {