key pressed problem
in
Programming Questions
•
9 months ago
hello,
for school i have to make a game but i'm having difficulties with the keyPressed function.
i'm trying to move an object to the left with te left button on the keyboard.
below shows what i have so far ( i left out the part that draws the monster)
thanks in advance for you help
class Monster {
int x;
int y;
int speed;
Monster(int tempX, int tempY, int tempSpeed) {
x = tempX;
y = tempY;
speed = tempSpeed;
}
void beweegMonster() {
if keyPressed () {
if (key == 'left') {
x = x + speed;
}
}
}
}
1