Chris Dick
/
Gameduino_Invaders_game
Invaders game for the Gameduino
Revision 4:e82f4a87df9e, committed 2013-10-26
- Comitter:
- TheChrisyd
- Date:
- Sat Oct 26 22:32:18 2013 +0000
- Parent:
- 3:9b01f67c7e15
- Commit message:
- Shields are now destroyed when hit, corrected score displays
Changed in this revision
diff -r 9b01f67c7e15 -r e82f4a87df9e game.cpp --- a/game.cpp Fri Dec 21 13:53:46 2012 +0000 +++ b/game.cpp Sat Oct 26 22:32:18 2013 +0000 @@ -134,6 +134,7 @@ unsigned int addr = (y*64)+x; GD.__wstart(addr); char c = *m; + c = *m++; while (c != 0) { spigame.write(c); c = *m++; @@ -403,11 +404,11 @@ BlastInfo bulletBlast, bombBlast[3]; void blastShield(BlastInfo& n, bool asBullet) { if (n.hasBlast()) { - byte s = (n.sprite-SP_FIRST_SHIELD)>>1; - int8 x = int8(n.xpos-(shieldXpos+(s*shieldXstep))); - //int8 y = zapShield(s,x,asBullet); + int8_t s = (n.sprite-SP_FIRST_SHIELD)>>1; + int8_t x = int8(n.xpos-(shieldXpos+(s*shieldXstep))); + int8_t y = zapShield(s,x,asBullet); if (asBullet) { - //bullet.setY(shieldYpos+y); + bullet.setY(shieldYpos+y); } n.reset(); } @@ -1092,4 +1093,3 @@ highScore = 0; resetGame(); } -
diff -r 9b01f67c7e15 -r e82f4a87df9e graphics.cpp --- a/graphics.cpp Fri Dec 21 13:53:46 2012 +0000 +++ b/graphics.cpp Sat Oct 26 22:32:18 2013 +0000 @@ -311,7 +311,7 @@ } } -int8 zapShield(int n, int8 x, bool withBullet) +int8_t zapShield(int8_t n, int8_t x, bool withBullet) { int y = 0; if ((n >= 0) and (n <= 3)) { @@ -330,7 +330,7 @@ const sprite_data *blastMap = bullet_blast; if (withBullet) { // Go from the top, find lowest pixel - for (int8 r=0; r<16; ++r) { + for (int8_t r=0; r<16; ++r) { if ((GD.rd(s)&pixelMask)!=0) { y = r; } @@ -343,8 +343,8 @@ // Go from the bottom, find highest pixel y = 16; s += 256; - int8 offset = 3; - for (int8 r=0; r<16; ++r) { + int8_t offset = 3; + for (int8_t r=0; r<16; ++r) { s -= 16; // Bombs are wider...we check three columns if ((GD.rd(s)&pixelMask)!=0) { @@ -365,12 +365,12 @@ blastMap = bomb_blast; } // Blast a hole in it - for (int8 j=0; j<8; ++j) { // 8 lines tall + for (int8_t j=0; j<8; ++j) { // 8 lines tall const int py = y+j; if ((py>=0) and (py<=15)) { unsigned int blastMask = 0x1000; unsigned int blastGraphic = pgm_read_word_near(blastMap); - for (int8 i=0; i<8; ++i) { // 8 pixels wide... + for (int8_t i=0; i<8; ++i) { // 8 pixels wide... if ((blastGraphic&blastMask)!=0) { // Set shield pixel to 0 where there's a 1 in the source graphic int px = x+i;
diff -r 9b01f67c7e15 -r e82f4a87df9e graphics.h --- a/graphics.h Fri Dec 21 13:53:46 2012 +0000 +++ b/graphics.h Sat Oct 26 22:32:18 2013 +0000 @@ -59,7 +59,8 @@ // Damage the shield with either a bomb or a bullet (ie. above/below) // n=shield number [0..4], x is relative to the shield's top-left corner -int8 zapShield(byte n, int8 x, bool withBullet); // Return Y coordinate of blast +int8_t zapShield(int8_t n, int8_t x, bool withBullet); // Return Y coordinate of blast + #endif
diff -r 9b01f67c7e15 -r e82f4a87df9e joystick.cpp --- a/joystick.cpp Fri Dec 21 13:53:46 2012 +0000 +++ b/joystick.cpp Sat Oct 26 22:32:18 2013 +0000 @@ -98,12 +98,7 @@ There are no user-servicable parts below this line ------------------------------------------------------*/ -#define STICK_LEFT_BIT 0x01 -#define STICK_RIGHT_BIT 0x02 -#define STICK_UP_BIT 0x04 -#define STICK_DOWN_BIT 0x08 -#define ANALOG_STICK_BIT 0x80 -#define STICK_INFO_MASK (ANALOG_STICK_BIT) + /*--------------------------------------------- Joystick reader
diff -r 9b01f67c7e15 -r e82f4a87df9e joystick.h --- a/joystick.h Fri Dec 21 13:53:46 2012 +0000 +++ b/joystick.h Sat Oct 26 22:32:18 2013 +0000 @@ -13,6 +13,14 @@ //#include "WProgram.h" #include "arduino.h" + +#define STICK_LEFT_BIT 0x01 +#define STICK_RIGHT_BIT 0x02 +#define STICK_UP_BIT 0x04 +#define STICK_DOWN_BIT 0x08 +#define ANALOG_STICK_BIT 0x80 +#define STICK_INFO_MASK (ANALOG_STICK_BIT) + class Joystick { byte buttons; // State of buttons, packed into a byte byte prev; // State of the buttons on previous read
diff -r 9b01f67c7e15 -r e82f4a87df9e main.cpp --- a/main.cpp Fri Dec 21 13:53:46 2012 +0000 +++ b/main.cpp Sat Oct 26 22:32:18 2013 +0000 @@ -21,7 +21,7 @@ GD.begin(); makeGraphics(); Coprocessor::reset(samplePlaybackBuffer); - //randomSeed(GD.rd(FRAME)); + randomSeed(GD.rd(FRAME)); resetGameSounds(); initGame(); }