
Lab1
graphics.h@11:aa8de6ff4003, 2020-11-25 (annotated)
- Committer:
- kwstasfane1
- Date:
- Wed Nov 25 08:54:44 2020 +0000
- Revision:
- 11:aa8de6ff4003
- Parent:
- 7:45e908a56319
code to be submitted
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 | 0:cb8d734a17f1 | 30 | // Some defines |
kwstasfane1 | 0:cb8d734a17f1 | 31 | #define WIN 1 |
kwstasfane1 | 0:cb8d734a17f1 | 32 | #define LOSE 0 |
kwstasfane1 | 0:cb8d734a17f1 | 33 | #define BASE 24 // the display baseline Y location for the shooter |
kwstasfane1 | 0:cb8d734a17f1 | 34 | //LCD display |
kwstasfane1 | 0:cb8d734a17f1 | 35 | C12832 lcd(p5, p7, p6, p8, p11); |
kwstasfane1 | 0:cb8d734a17f1 | 36 | // The 4 on board LEDs |
kwstasfane1 | 0:cb8d734a17f1 | 37 | DigitalOut myled(LED1); |
kwstasfane1 | 0:cb8d734a17f1 | 38 | DigitalOut myled2(LED2); |
kwstasfane1 | 0:cb8d734a17f1 | 39 | DigitalOut myled3(LED3); |
kwstasfane1 | 0:cb8d734a17f1 | 40 | DigitalOut myled4(LED4); |
kwstasfane1 | 0:cb8d734a17f1 | 41 | // RGB LED |
kwstasfane1 | 0:cb8d734a17f1 | 42 | PwmOut r (p23); |
kwstasfane1 | 0:cb8d734a17f1 | 43 | PwmOut g (p24); |
kwstasfane1 | 0:cb8d734a17f1 | 44 | //PwmOut b (p25); |
kwstasfane1 | 0:cb8d734a17f1 | 45 | //joystick |
kwstasfane1 | 0:cb8d734a17f1 | 46 | DigitalIn joyD(p12); |
kwstasfane1 | 0:cb8d734a17f1 | 47 | DigitalIn joyL(p13); |
kwstasfane1 | 0:cb8d734a17f1 | 48 | DigitalIn joyC(p14); |
kwstasfane1 | 0:cb8d734a17f1 | 49 | DigitalIn joyU(p15); |
kwstasfane1 | 0:cb8d734a17f1 | 50 | DigitalIn joyR(p16); |