1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include "character.h"
Character::Character(DrawEngine *de, int s_index, float x, float y, int lives,
char u, char d, char l, char r)
: Sprite(de, s_index, x, y, lives)
{
up_key = u;
down_key = d;
left_key = l;
right_key = r;
classID = CHARACTER_CLASSID;
}
bool Character::keyPress(char c)
{
if (c == up_key)
{
return move(0, -1);
}
else if (c == down_key)
{
return move(0, 1);
}
else if ( c == right_key)
{
return move(1, 0);
}
else if (c == left_key)
{
return move(-1, 0);
}
}
| |