File: Space.ino - Tab length: 1 2 4 8 - Lines: on off - No wrap: on off

01: #include <SPI.h>
02: #include <Gamebuino.h>
03: 
04: Gamebuino gb;
05: 
06: void setup() {
07:   gb.begin();
08: }
09: 
10: void loop() {
11:   float x = 20, y = 20, angle = 0;
12:   while (1) {
13:     if (gb.update()) {
14:       if (gb.buttons.repeat(BTN_RIGHT, 1)) {
15:         angle += 0.31415 / 2;
16:       }
17:       if (gb.buttons.repeat(BTN_LEFT, 1)) {
18:         angle -= 0.31415 / 2;
19:       }
20:       if (gb.buttons.repeat(BTN_A, 1)) {
21:         x += cos(angle) * 0.5;
22:         y += sin(angle) * 0.5;
23:       }
24:       gb.display.cursorX = 0;
25:       gb.display.cursorY = 0;
26:       gb.display.print(angle);
27:       gb.display.cursorX = 0;
28:       gb.display.cursorY = 6;
29:       gb.display.print(x);
30:       gb.display.cursorX = 0;
31:       gb.display.cursorY = 12;
32:       gb.display.print(y);
33:       gb.display.fillTriangle(x, y, x - cos(angle) * 8, y - sin(angle) * 8, x - cos(angle - 0.8) * 8, y - sin(angle - 0.8) * 8);
34:       gb.display.setColor(WHITE);
35:       gb.display.drawPixel(x - cos(angle - 0.25) * 3, y - sin(angle - 0.25) * 3);
36:       gb.display.setColor(BLACK);
37:     }
38:   }
39: }
40: