-
-
Save Cric75/7cadd44e74d9247c80d9fd32322e9b9e to your computer and use it in GitHub Desktop.
Moving_Ball
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Gamebuino-Meta.h> | |
int positionX = 32; | |
int speedX = 1; | |
void setup() { | |
gb.begin(); | |
} | |
void loop() { | |
while (!gb.update()); | |
gb.display.clear(); | |
positionX = positionX + speedX; | |
if (positionX == gb.display.width()) { | |
positionX = 32; | |
} | |
if (gb.buttons.pressed(BUTTON_UP) && speedX <10) { | |
speedX += 1; | |
positionX = positionX + speedX; | |
gb.sound.playTick(); | |
} | |
if (gb.buttons.pressed(BUTTON_DOWN) && speedX >1) { | |
speedX -= 1; | |
positionX = positionX + speedX; | |
gb.sound.playTick(); | |
} | |
gb.display.print("PositionX : "); | |
gb.display.print(positionX); | |
gb.display.print("\nSpeedX : "); | |
gb.display.print(speedX); | |
gb.display.fillRect(positionX, 32, 4, 4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment