Armageddon - a missile commad clone by Wuuff, originally for Gamebuino. Conversion by Jonne
Dependencies: PokittoLib
Fork of Asterocks by
Diff: ageddon.cpp
- Revision:
- 13:b133c46dbda7
- Parent:
- 6:22d706e5dd6e
- Child:
- 14:41173f26c0ef
--- a/ageddon.cpp Sun Oct 22 19:05:06 2017 +0000 +++ b/ageddon.cpp Mon Oct 30 02:45:32 2017 +0000 @@ -37,6 +37,7 @@ int main() { setup(); + gb.display.setDefaultPalette(); while (gb.isRunning()) { loop(); } @@ -169,7 +170,7 @@ uint8_t stage = 0; //Maximum of 255 stages uint32_t score = 0; //Score needs more space than other vars -uint8_t lullMissiles = 0; +uint32_t lullMissiles = 0; uint8_t lullCities[8] = {0,0,0,0,0,0,0,0}; uint8_t cities[8] = {1,1,1,1,1,1,1,1}; //Whether the cities or launchers are alive @@ -252,7 +253,7 @@ void drawTargets(){ gb.display.drawFastHLine(targetX-1,targetY,3); - gb.display.drawFastVLine(targetX,targetY-1,3); + gb.display.drawFastVLine(targetX,targetY-1,2); for(uint8_t i = 0; i < MAX_PMISSILES; i++){ //Check for a valid destination without a current detonation @@ -263,6 +264,7 @@ } void drawCities(){ + gb.display.setColor(4); //uint8_t alldead = 1; for(uint8_t i = 0; i < 8; i++){ if( i == 2 || i == 5 ){ @@ -281,6 +283,7 @@ } } + gb.display.setColor(1); /* if( alldead ){ gb.display.cursorX = 84/2 - 5*3; @@ -291,7 +294,7 @@ } void drawAmmo(){ - gb.display.setColor(2); + gb.display.setColor(3); for( uint8_t i = 0; i < 2; i++ ){ uint8_t xcoord = i == 0 ? 25 : 55; uint8_t ycoord = 47; @@ -312,7 +315,7 @@ void drawMissiles(){ //Player Missiles - gb.display.setColor(2); + gb.display.setColor(3); for(uint8_t i = 0; i < MAX_PMISSILES; i++){ //Check for a valid destination without a current detonation if( pDests[i][0] <= 84 && pDetonations[i][0] > 84 ){ @@ -325,7 +328,7 @@ } //Enemy Missiles - gb.display.setColor(3); + gb.display.setColor(7); for(uint8_t i = 0; i < MAX_EMISSILES; i++){ //Check for a valid destination if( eDests[i] <= 84 ){ @@ -335,12 +338,19 @@ gb.display.setColor(1); } +uint8_t explosionColor = 0; void drawDetonations(){ + gb.display.setColor(explosionColor+1); + if(counter%2 == 0){ + explosionColor++; + explosionColor%=7; + } for(uint8_t i = 0; i < MAX_PMISSILES; i++){ if( pDetonations[i][0] <= 84 ){ - gb.display.drawCircle(pDetonations[i][0],pDetonations[i][1],pDetonations[i][2]); + gb.display.fillCircle(pDetonations[i][0],pDetonations[i][1],pDetonations[i][2]); } } + gb.display.setColor(1); } void launchMissile(uint8_t launcher){ @@ -388,7 +398,7 @@ for(uint8_t i = 0; i < MAX_EMISSILES; i++){ if( eDests[i] > 84 ){ etotal--; - eDests[i] = random(8); //Target one of the 6 cities or 2 launch sites + eDests[i] = random(7); //Target one of the 6 cities or 2 launch sites TODO: Come back later if random's behavior changes eMissiles[i][0] = random(84); //Screen width eMissiles[i][1] = 0; //Top of screen eMissiles[i][2] = eMissiles[i][0]; //Start and end are same @@ -569,7 +579,7 @@ } void drawLull(){ - uint8_t cityCount = 0; + uint32_t cityCount = 0; gb.display.cursorX = 84/2 - 4*6; gb.display.cursorY = 48/2 - 5*3; gb.display.print(("BONUS POINTS")); @@ -578,21 +588,25 @@ gb.display.cursorY += 5*2; gb.display.print(lullMissiles); + gb.display.setColor(3); for(uint8_t i = 0; i < lullMissiles; i++){ gb.display.drawPixel(84/2 - 4*6 + i*2,48/2 - 3); } + gb.display.setColor(1); gb.display.cursorX = 84/2 - 4*8; gb.display.cursorY += 5*2; - for( uint8_t i; i < 8; i++ ){ + for( uint8_t i = 0; i < 8; i++ ){ if( lullCities[i] ) cityCount++; } gb.display.print(cityCount); + gb.display.setColor(4); for(uint8_t i = 0; i < cityCount; i++){ gb.display.drawBitmap(84/2 - 4*6 + i*9,48/2+2, city); } + gb.display.setColor(1); drawScore(); drawCities(); drawAmmo();