Chris Dick
/
Gameduino_Invaders_game
Invaders game for the Gameduino
graphics.h@4:e82f4a87df9e, 2013-10-26 (annotated)
- Committer:
- TheChrisyd
- Date:
- Sat Oct 26 22:32:18 2013 +0000
- Revision:
- 4:e82f4a87df9e
- Parent:
- 2:20a89dc286d5
Shields are now destroyed when hit, corrected score displays
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TheChrisyd | 2:20a89dc286d5 | 1 | /*--------------------------------------------- |
TheChrisyd | 2:20a89dc286d5 | 2 | Send all graphics to the Gameduino |
TheChrisyd | 2:20a89dc286d5 | 3 | ---------------------------------------------*/ |
TheChrisyd | 2:20a89dc286d5 | 4 | #ifndef INVADER_GRAPHICS |
TheChrisyd | 2:20a89dc286d5 | 5 | #define INVADER_GRAPHICS |
TheChrisyd | 2:20a89dc286d5 | 6 | #include "shield.h" |
TheChrisyd | 2:20a89dc286d5 | 7 | #include "mbed.h" |
TheChrisyd | 2:20a89dc286d5 | 8 | #include "arduino.h" |
TheChrisyd | 2:20a89dc286d5 | 9 | void makeGraphics(); |
TheChrisyd | 2:20a89dc286d5 | 10 | |
TheChrisyd | 2:20a89dc286d5 | 11 | /*--------------------------------------------- |
TheChrisyd | 2:20a89dc286d5 | 12 | Identifiers for custom chars |
TheChrisyd | 2:20a89dc286d5 | 13 | ---------------------------------------------*/ |
TheChrisyd | 2:20a89dc286d5 | 14 | enum char_id { |
TheChrisyd | 2:20a89dc286d5 | 15 | CH_FLOOR=128, |
TheChrisyd | 2:20a89dc286d5 | 16 | CH_PLAYERL, |
TheChrisyd | 2:20a89dc286d5 | 17 | CH_PLAYERR |
TheChrisyd | 2:20a89dc286d5 | 18 | }; |
TheChrisyd | 2:20a89dc286d5 | 19 | /*--------------------------------------------- |
TheChrisyd | 2:20a89dc286d5 | 20 | Identifiers for each sprite graphic |
TheChrisyd | 2:20a89dc286d5 | 21 | |
TheChrisyd | 2:20a89dc286d5 | 22 | Sprites are made in four color mode so |
TheChrisyd | 2:20a89dc286d5 | 23 | each 'sprite' can have four images inside |
TheChrisyd | 2:20a89dc286d5 | 24 | it. |
TheChrisyd | 2:20a89dc286d5 | 25 | |
TheChrisyd | 2:20a89dc286d5 | 26 | The first image is usually the 'normal' |
TheChrisyd | 2:20a89dc286d5 | 27 | (eg. player/saucer) one and the third is |
TheChrisyd | 2:20a89dc286d5 | 28 | usually blank (so you can hide the sprite). |
TheChrisyd | 2:20a89dc286d5 | 29 | |
TheChrisyd | 2:20a89dc286d5 | 30 | The other two are used for animations |
TheChrisyd | 2:20a89dc286d5 | 31 | (eg. invaders) and explosions (eg. player) |
TheChrisyd | 2:20a89dc286d5 | 32 | ---------------------------------------------*/ |
TheChrisyd | 2:20a89dc286d5 | 33 | enum graphic_id { |
TheChrisyd | 2:20a89dc286d5 | 34 | // Invader sprites - Top, Middle, Bottom, two animation frames each... |
TheChrisyd | 2:20a89dc286d5 | 35 | GR_INVADER_T, |
TheChrisyd | 2:20a89dc286d5 | 36 | GR_INVADER_M, |
TheChrisyd | 2:20a89dc286d5 | 37 | GR_INVADER_B, |
TheChrisyd | 2:20a89dc286d5 | 38 | GR_BOMB_ZIGZAG, // Zigzag bomb |
TheChrisyd | 2:20a89dc286d5 | 39 | GR_BOMB_BARS, // The bomb with rolling horizontal bars across it |
TheChrisyd | 2:20a89dc286d5 | 40 | GR_BOMB_DIAG, // The bomb with diagonal bars across it |
TheChrisyd | 2:20a89dc286d5 | 41 | GR_BOMB_OTHER, // Other bomb graphics (explosion and blank) |
TheChrisyd | 2:20a89dc286d5 | 42 | // The player (with bullet) |
TheChrisyd | 2:20a89dc286d5 | 43 | GR_PLAYER, |
TheChrisyd | 2:20a89dc286d5 | 44 | GR_BULLET, // nb. Has a '0' in frame 2 (for the saucer...) |
TheChrisyd | 2:20a89dc286d5 | 45 | // The saucer at the top |
TheChrisyd | 2:20a89dc286d5 | 46 | GR_SAUCER, |
TheChrisyd | 2:20a89dc286d5 | 47 | GR_SAUCER_SCORE, |
TheChrisyd | 2:20a89dc286d5 | 48 | // Shields |
TheChrisyd | 2:20a89dc286d5 | 49 | GR_SHIELD1, |
TheChrisyd | 2:20a89dc286d5 | 50 | GR_SHIELD2, |
TheChrisyd | 2:20a89dc286d5 | 51 | GR_SHIELD3, |
TheChrisyd | 2:20a89dc286d5 | 52 | GR_SHIELD4 |
TheChrisyd | 2:20a89dc286d5 | 53 | }; |
TheChrisyd | 2:20a89dc286d5 | 54 | |
TheChrisyd | 2:20a89dc286d5 | 55 | /*--------------------------------------------- |
TheChrisyd | 2:20a89dc286d5 | 56 | Functions for wrecking/rebuilding shields |
TheChrisyd | 2:20a89dc286d5 | 57 | ---------------------------------------------*/ |
TheChrisyd | 2:20a89dc286d5 | 58 | void remakeShields(); |
TheChrisyd | 2:20a89dc286d5 | 59 | |
TheChrisyd | 2:20a89dc286d5 | 60 | // Damage the shield with either a bomb or a bullet (ie. above/below) |
TheChrisyd | 2:20a89dc286d5 | 61 | // n=shield number [0..4], x is relative to the shield's top-left corner |
TheChrisyd | 4:e82f4a87df9e | 62 | int8_t zapShield(int8_t n, int8_t x, bool withBullet); // Return Y coordinate of blast |
TheChrisyd | 4:e82f4a87df9e | 63 | |
TheChrisyd | 2:20a89dc286d5 | 64 | |
TheChrisyd | 2:20a89dc286d5 | 65 | #endif |
TheChrisyd | 2:20a89dc286d5 | 66 |