I have never used functions I built so I decided to try and build some I could use later. I tried to make one that would check if the arrow keys were pressed and if they were move the man. Can that be done with a function? I tried making it and putting it in an include file. Here is my attempt:
Source file:
#include "movement.h" // it being included
(...) void check_keys();// its declaration
(...) check_keys(); // it being called
Header
int man_x = 0;
int man_y = 0;
void check_keys();
void check_keys()
{
if(key[KEY_RIGHT])
{
man_x ++;
}
if(key[KEY_LEFT])
{
man_x --;
}
if(key[KEY_UP])
{
man_y --;
}
if(key[KEY_DOWN])
{
man_y ++;
}
}END_OF_FUNCTION(check_keys);
It compiles fine but does nothing when I try pressing the arrow keys. Do you notice what might me wrong?