
Lab1
graphics.h@7:45e908a56319, 2020-11-10 (annotated)
- Committer:
- kwstasfane1
- Date:
- Tue Nov 10 13:29:56 2020 +0000
- Revision:
- 7:45e908a56319
- Parent:
- 0:cb8d734a17f1
- Child:
- 11:aa8de6ff4003
Last Instance of the space invader code. It was also tested on the mbed hardware and worked as intended. Their moving hands issue was not fixed yet, however all of the rest required functionality was achieved!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kwstasfane1 | 0:cb8d734a17f1 | 1 | static char sprite1[] = |
kwstasfane1 | 0:cb8d734a17f1 | 2 | {0x20,0x80,0x11,0x00,0x3F,0x80,0x6E,0xC0,0xFF,0xE0,0xBF,0xA0,0xA0,0xA0,0x1B ,0x00} ; |
kwstasfane1 | 0:cb8d734a17f1 | 3 | static char sprite2[] = |
kwstasfane1 | 0:cb8d734a17f1 | 4 | {0x20,0x80,0x91,0x20,0xBF,0xA0,0xEE,0xE0,0xFF,0xE0,0x3F,0x80,0x20,0x80,0x1B ,0x00} ; |
kwstasfane1 | 0:cb8d734a17f1 | 5 | |
kwstasfane1 | 0:cb8d734a17f1 | 6 | static char shooter[] = |
kwstasfane1 | 0:cb8d734a17f1 | 7 | {0x04,0x00,0x0E,0x00,0x0E,0x00,0x7F,0xC0,0xFF,0xE0,0xFF,0xE0,0xFF,0xE0,0xFF ,0xE0} ; |
kwstasfane1 | 0:cb8d734a17f1 | 8 | |
kwstasfane1 | 0:cb8d734a17f1 | 9 | struct sprite{ |
kwstasfane1 | 0:cb8d734a17f1 | 10 | char snum; //sprite number |
kwstasfane1 | 0:cb8d734a17f1 | 11 | int xpos; // x position |
kwstasfane1 | 0:cb8d734a17f1 | 12 | int ypos; // y position |
kwstasfane1 | 0:cb8d734a17f1 | 13 | int oldy; // prvious y pos |
kwstasfane1 | 0:cb8d734a17f1 | 14 | char active; // 1 = sprite displayed 0 = sprite destroyed |
kwstasfane1 | 0:cb8d734a17f1 | 15 | char *type; //sprite1 or 2 |
kwstasfane1 | 0:cb8d734a17f1 | 16 | }; |
kwstasfane1 | 0:cb8d734a17f1 | 17 | |
kwstasfane1 | 0:cb8d734a17f1 | 18 | |
kwstasfane1 | 0:cb8d734a17f1 | 19 | sprite spritetab[] = { |
kwstasfane1 | 0:cb8d734a17f1 | 20 | {0,1,0,0,1,sprite1}, |
kwstasfane1 | 0:cb8d734a17f1 | 21 | {1,16,0,0,1,sprite2}, |
kwstasfane1 | 0:cb8d734a17f1 | 22 | {2,32,0,0,1,sprite1}, |
kwstasfane1 | 0:cb8d734a17f1 | 23 | {3,48,0,0,1,sprite2}, |
kwstasfane1 | 0:cb8d734a17f1 | 24 | {4,64,0,0,1,sprite1}, |
kwstasfane1 | 0:cb8d734a17f1 | 25 | {5,80,0,0,1,sprite2}, |
kwstasfane1 | 0:cb8d734a17f1 | 26 | {6,96,0,0,1,sprite1}, |
kwstasfane1 | 0:cb8d734a17f1 | 27 | {7,112,0,0,1,sprite2} |
kwstasfane1 | 0:cb8d734a17f1 | 28 | }; |
kwstasfane1 | 7:45e908a56319 | 29 | |
kwstasfane1 | 7:45e908a56319 | 30 | sprite reverse_spritetab[] = { |
kwstasfane1 | 7:45e908a56319 | 31 | {0,1,0,0,1,sprite2}, |
kwstasfane1 | 7:45e908a56319 | 32 | {1,16,0,0,1,sprite1}, |
kwstasfane1 | 7:45e908a56319 | 33 | {2,32,0,0,1,sprite2}, |
kwstasfane1 | 7:45e908a56319 | 34 | {3,48,0,0,1,sprite1}, |
kwstasfane1 | 7:45e908a56319 | 35 | {4,64,0,0,1,sprite2}, |
kwstasfane1 | 7:45e908a56319 | 36 | {5,80,0,0,1,sprite1}, |
kwstasfane1 | 7:45e908a56319 | 37 | {6,96,0,0,1,sprite2}, |
kwstasfane1 | 7:45e908a56319 | 38 | {7,112,0,0,1,sprite1} |
kwstasfane1 | 7:45e908a56319 | 39 | }; |
kwstasfane1 | 7:45e908a56319 | 40 | |
kwstasfane1 | 7:45e908a56319 | 41 | |
kwstasfane1 | 0:cb8d734a17f1 | 42 | // Some defines |
kwstasfane1 | 0:cb8d734a17f1 | 43 | #define WIN 1 |
kwstasfane1 | 0:cb8d734a17f1 | 44 | #define LOSE 0 |
kwstasfane1 | 0:cb8d734a17f1 | 45 | #define BASE 24 // the display baseline Y location for the shooter |
kwstasfane1 | 0:cb8d734a17f1 | 46 | //LCD display |
kwstasfane1 | 0:cb8d734a17f1 | 47 | C12832 lcd(p5, p7, p6, p8, p11); |
kwstasfane1 | 0:cb8d734a17f1 | 48 | // The 4 on board LEDs |
kwstasfane1 | 0:cb8d734a17f1 | 49 | DigitalOut myled(LED1); |
kwstasfane1 | 0:cb8d734a17f1 | 50 | DigitalOut myled2(LED2); |
kwstasfane1 | 0:cb8d734a17f1 | 51 | DigitalOut myled3(LED3); |
kwstasfane1 | 0:cb8d734a17f1 | 52 | DigitalOut myled4(LED4); |
kwstasfane1 | 0:cb8d734a17f1 | 53 | // RGB LED |
kwstasfane1 | 0:cb8d734a17f1 | 54 | PwmOut r (p23); |
kwstasfane1 | 0:cb8d734a17f1 | 55 | PwmOut g (p24); |
kwstasfane1 | 0:cb8d734a17f1 | 56 | //PwmOut b (p25); |
kwstasfane1 | 0:cb8d734a17f1 | 57 | //joystick |
kwstasfane1 | 0:cb8d734a17f1 | 58 | DigitalIn joyD(p12); |
kwstasfane1 | 0:cb8d734a17f1 | 59 | DigitalIn joyL(p13); |
kwstasfane1 | 0:cb8d734a17f1 | 60 | DigitalIn joyC(p14); |
kwstasfane1 | 0:cb8d734a17f1 | 61 | DigitalIn joyU(p15); |
kwstasfane1 | 0:cb8d734a17f1 | 62 | DigitalIn joyR(p16); |