User manual
002
if(engine.joypad.isPressed(UP)){
003
ballY = ballY - 1;
004
}
005
if(engine.joypad.isPressed(DOWN)){
006
ballY = ballY - 1;
007
}
008
}
With the controlBall() function you are now able to control the ball. The joypad
buttons are queried in a simple way. The engine.joypad.isPressed(UP) function
returns TRUE as soon as the key is pressed. Next the ball’s y-position is reduced
by one pixel, which results in the ball approaching the upper display edge. Analo-
gously there is the engine.joypad.isPressed(DOWN) function. This means that you
can manipulate the height of the ball by moving the directional buttons up and
down while the ball on the display is moving to the right. After the ball has reached
one end of the display, it will reappear at the other end. In order for these three
functions to interact well, they must be called up within the loop routine at the ap-
propriate position.
001
void loop(){
002
if(engine.update()){
003
controlBall();
004
if(engine.isFrameCount(20)){
005
moveBall();
006
}
007
drawBall();
008
}
009
}
Arduino has the loop function, which runs continuously. The engine.update() func-
tion ensures that all engine functions, such as drawing the ball and evaluating the
buttons, were accomplished before the next run starts. The moveBall() function
has yet another restriction, however - it is only called up every 20 frames. This
means that the content of the display is updated 20 times before the position of the
ball can change. The reason behind is that the ball would otherwise move much










