diff options
author | Michael Giacomelli <giac2000@hotmail.com> | 2009-05-24 23:42:32 +0000 |
---|---|---|
committer | Michael Giacomelli <giac2000@hotmail.com> | 2009-05-24 23:42:32 +0000 |
commit | 62bf9f40fc71ab7697edc97eae3384986daa349e (patch) | |
tree | 10c022c9104d7739e3cf6050d86373da0b14d2ae | |
parent | 526b5580dabbfed7cfe5439dc3a90ec727f563c2 (diff) | |
download | rockbox-62bf9f40fc71ab7697edc97eae3384986daa349e.tar.gz rockbox-62bf9f40fc71ab7697edc97eae3384986daa349e.zip |
Commit FS#10234 - Spacerocks respawn invulnerability by Eric Clayton. Gives you a couple seconds of invulnerability after respawn.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21071 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/spacerocks.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index d41abf9a3a..6879ab6ee9 100644 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c | |||
@@ -325,6 +325,8 @@ PLUGIN_HEADER | |||
325 | #define MISSILE_SURVIVAL_LENGTH 40 | 325 | #define MISSILE_SURVIVAL_LENGTH 40 |
326 | 326 | ||
327 | #define EXTRA_LIFE 250 | 327 | #define EXTRA_LIFE 250 |
328 | #define SPAWN_TIME 30 | ||
329 | #define BLINK_TIME 10 | ||
328 | #define SCALE 5000 | 330 | #define SCALE 5000 |
329 | #define MISSILE_SCALE 5000 | 331 | #define MISSILE_SCALE 5000 |
330 | #define WRAP_GAP 12 | 332 | #define WRAP_GAP 12 |
@@ -412,6 +414,7 @@ PLUGIN_HEADER | |||
412 | #ifdef HAVE_LCD_COLOR | 414 | #ifdef HAVE_LCD_COLOR |
413 | #define COL_MISSILE LCD_RGBPACK(200,0,0) | 415 | #define COL_MISSILE LCD_RGBPACK(200,0,0) |
414 | #define COL_PLAYER LCD_RGBPACK(200,200,200) | 416 | #define COL_PLAYER LCD_RGBPACK(200,200,200) |
417 | #define COL_INVULN LCD_RGBPACK(100,100,200) | ||
415 | #define COL_STARS LCD_WHITE | 418 | #define COL_STARS LCD_WHITE |
416 | #define COL_ASTEROID LCD_RGBPACK(ASTEROID_R,ASTEROID_G,ASTEROID_B) | 419 | #define COL_ASTEROID LCD_RGBPACK(ASTEROID_R,ASTEROID_G,ASTEROID_B) |
417 | #define COL_TEXT LCD_RGBPACK(200,200,255) | 420 | #define COL_TEXT LCD_RGBPACK(200,200,255) |
@@ -564,6 +567,8 @@ struct Ship | |||
564 | struct Point vertices[NUM_SHIP_VERTICES]; | 567 | struct Point vertices[NUM_SHIP_VERTICES]; |
565 | struct Point position; | 568 | struct Point position; |
566 | bool waiting_for_space; | 569 | bool waiting_for_space; |
570 | bool invulnerable; | ||
571 | int spawn_time; | ||
567 | int explode_countdown; | 572 | int explode_countdown; |
568 | }; | 573 | }; |
569 | 574 | ||
@@ -1252,10 +1257,13 @@ void check_collisions(void) | |||
1252 | { | 1257 | { |
1253 | if(is_ship_within_asteroid(asteroid)) | 1258 | if(is_ship_within_asteroid(asteroid)) |
1254 | { | 1259 | { |
1255 | /*blow up ship*/ | 1260 | if (!ship.invulnerable) |
1256 | ship.explode_countdown = EXPLOSION_LENGTH; | 1261 | { |
1257 | /* initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); */ | 1262 | /*if not invulnerable, blow up ship*/ |
1258 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | 1263 | ship.explode_countdown = EXPLOSION_LENGTH; |
1264 | /* initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); */ | ||
1265 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | ||
1266 | } | ||
1259 | } | 1267 | } |
1260 | 1268 | ||
1261 | /*has the enemy missile blown something up?*/ | 1269 | /*has the enemy missile blown something up?*/ |
@@ -1291,9 +1299,12 @@ void check_collisions(void) | |||
1291 | /*has the enemy collided with the ship?*/ | 1299 | /*has the enemy collided with the ship?*/ |
1292 | if(is_point_within_enemy(&ship.position)) | 1300 | if(is_point_within_enemy(&ship.position)) |
1293 | { | 1301 | { |
1294 | ship.explode_countdown = EXPLOSION_LENGTH; | 1302 | if (!ship.invulnerable) |
1295 | /* initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); */ | 1303 | { |
1296 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | 1304 | ship.explode_countdown = EXPLOSION_LENGTH; |
1305 | /* initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); */ | ||
1306 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | ||
1307 | } | ||
1297 | create_trail_blaze(ENEMY_EXPLOSION_COLOUR, &enemy.position); | 1308 | create_trail_blaze(ENEMY_EXPLOSION_COLOUR, &enemy.position); |
1298 | } | 1309 | } |
1299 | 1310 | ||
@@ -1318,10 +1329,13 @@ void check_collisions(void) | |||
1318 | enemy_missile.position.x - ship.position.x, | 1329 | enemy_missile.position.x - ship.position.x, |
1319 | enemy_missile.position.y - ship.position.y)) | 1330 | enemy_missile.position.y - ship.position.y)) |
1320 | { | 1331 | { |
1321 | ship.explode_countdown = EXPLOSION_LENGTH; | 1332 | if (!ship.invulnerable) |
1322 | /* initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); */ | 1333 | { |
1323 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | 1334 | ship.explode_countdown = EXPLOSION_LENGTH; |
1324 | enemy_missile.survived = 0; | 1335 | /* initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); */ |
1336 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | ||
1337 | } | ||
1338 | enemy_missile.survived = 0; | ||
1325 | enemy_missile.position.x = enemy_missile.position.y = 0; | 1339 | enemy_missile.position.x = enemy_missile.position.y = 0; |
1326 | } | 1340 | } |
1327 | 1341 | ||
@@ -1617,6 +1631,8 @@ void initialise_ship(void) | |||
1617 | ship.position.x *= SCALE; | 1631 | ship.position.x *= SCALE; |
1618 | ship.position.y *= SCALE; | 1632 | ship.position.y *= SCALE; |
1619 | ship.position.dx = ship.position.dy = 0; | 1633 | ship.position.dx = ship.position.dy = 0; |
1634 | ship.spawn_time = SPAWN_TIME; | ||
1635 | ship.invulnerable = 1; | ||
1620 | 1636 | ||
1621 | point = ship.vertices; | 1637 | point = ship.vertices; |
1622 | lives_point = lives_points; | 1638 | lives_point = lives_points; |
@@ -1672,9 +1688,25 @@ void draw_and_move_ship(void) | |||
1672 | { | 1688 | { |
1673 | int nxoffset = ship.position.x/SCALE; | 1689 | int nxoffset = ship.position.x/SCALE; |
1674 | int nyoffset = ship.position.y/SCALE; | 1690 | int nyoffset = ship.position.y/SCALE; |
1675 | SET_FG(COL_PLAYER); | 1691 | if (ship.invulnerable && (ship.spawn_time > BLINK_TIME || ship.spawn_time % 2 == 0)) |
1692 | { | ||
1693 | SET_FG(COL_INVULN); | ||
1694 | } | ||
1695 | else | ||
1696 | { | ||
1697 | SET_FG(COL_PLAYER); | ||
1698 | } | ||
1676 | if(!ship.explode_countdown) | 1699 | if(!ship.explode_countdown) |
1677 | { | 1700 | { |
1701 | /* make sure ship is invulnerable until spawn time over */ | ||
1702 | if (ship.spawn_time) | ||
1703 | { | ||
1704 | ship.spawn_time--; | ||
1705 | if (ship.spawn_time <= 0) | ||
1706 | { | ||
1707 | ship.invulnerable = 0; | ||
1708 | } | ||
1709 | } | ||
1678 | if(!ship.waiting_for_space) | 1710 | if(!ship.waiting_for_space) |
1679 | { | 1711 | { |
1680 | draw_polygon(ship.vertices, nxoffset, nyoffset, NUM_SHIP_VERTICES); | 1712 | draw_polygon(ship.vertices, nxoffset, nyoffset, NUM_SHIP_VERTICES); |