Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE LSM9DS1_Library SDFileSystem mbed-rtos mbed wave_player
main.cpp@2:623f29bad35c, 2016-03-10 (annotated)
- Committer:
- Dogstopper
- Date:
- Thu Mar 10 22:51:12 2016 +0000
- Revision:
- 2:623f29bad35c
- Parent:
- 0:6a49493943be
- Child:
- 3:27889fffc2f7
Working Part1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Dogstopper | 0:6a49493943be | 1 | #include "mbed.h" |
Dogstopper | 0:6a49493943be | 2 | #include "InputHandler.h" |
Dogstopper | 2:623f29bad35c | 3 | #include "Invader.h" |
Dogstopper | 2:623f29bad35c | 4 | #include "Player.h" |
Dogstopper | 0:6a49493943be | 5 | |
Dogstopper | 0:6a49493943be | 6 | #define WIDTH 128 |
Dogstopper | 0:6a49493943be | 7 | #define HEIGHT 128 |
Dogstopper | 0:6a49493943be | 8 | |
Dogstopper | 0:6a49493943be | 9 | //DigitalOut led(LED1); |
Dogstopper | 0:6a49493943be | 10 | |
Dogstopper | 0:6a49493943be | 11 | InputHandler input(p9, p10, 0xD6, 0x3C, p15); |
Dogstopper | 2:623f29bad35c | 12 | |
Dogstopper | 2:623f29bad35c | 13 | uLCD_4DGL uLCD(p28,p27,p30); // serial tx, serial rx, reset pin; |
Dogstopper | 0:6a49493943be | 14 | |
Dogstopper | 0:6a49493943be | 15 | //Player player(&uLCD, &input, WIDTH/2, HEIGHT/2); |
Dogstopper | 2:623f29bad35c | 16 | Invader invader(&uLCD, WIDTH/2, HEIGHT/2, 0, 2); |
Dogstopper | 0:6a49493943be | 17 | |
Dogstopper | 0:6a49493943be | 18 | void gameLoop(void const *p) |
Dogstopper | 0:6a49493943be | 19 | { |
Dogstopper | 0:6a49493943be | 20 | // bool alive = true; |
Dogstopper | 0:6a49493943be | 21 | // while(alive) { |
Dogstopper | 0:6a49493943be | 22 | //// player.update(); |
Dogstopper | 0:6a49493943be | 23 | // invader.update(); |
Dogstopper | 0:6a49493943be | 24 | // |
Dogstopper | 0:6a49493943be | 25 | // invader.draw(); |
Dogstopper | 0:6a49493943be | 26 | //// player.draw(); |
Dogstopper | 0:6a49493943be | 27 | // |
Dogstopper | 0:6a49493943be | 28 | // // If there is a collision, we are done |
Dogstopper | 0:6a49493943be | 29 | //// if (invader.intersects(player.getX(), player.getY(), player.getWidth(), player.getHeight())) { |
Dogstopper | 0:6a49493943be | 30 | //// led = 1; |
Dogstopper | 0:6a49493943be | 31 | //// alive = false; |
Dogstopper | 0:6a49493943be | 32 | //// } |
Dogstopper | 0:6a49493943be | 33 | // |
Dogstopper | 0:6a49493943be | 34 | // Thread::wait(32); // 30 FPS |
Dogstopper | 0:6a49493943be | 35 | // } |
Dogstopper | 0:6a49493943be | 36 | |
Dogstopper | 0:6a49493943be | 37 | } |
Dogstopper | 0:6a49493943be | 38 | |
Dogstopper | 0:6a49493943be | 39 | int main() { |
Dogstopper | 2:623f29bad35c | 40 | Thread* gameThread = new Thread(gameLoop); |
Dogstopper | 2:623f29bad35c | 41 | Thread* inputThread = input.start(); |
Dogstopper | 2:623f29bad35c | 42 | uLCD.background_color(BLACK); |
Dogstopper | 2:623f29bad35c | 43 | invader.draw(); |
Dogstopper | 0:6a49493943be | 44 | while(1) { |
Dogstopper | 0:6a49493943be | 45 | printf("xAccel: %.6f\n\ryAccel: %.6f\n\rbutton: %s\n\r", input.getXAccel(), input.getYAccel(), input.getPushed() ? "true" : "false"); |
Dogstopper | 0:6a49493943be | 46 | |
Dogstopper | 0:6a49493943be | 47 | wait(0.5); |
Dogstopper | 0:6a49493943be | 48 | } |
Dogstopper | 0:6a49493943be | 49 | } |