add bright version of the game sprites
[gbajam22] / src / gamescr.c
index 5b3a6d2..7d0e051 100644 (file)
@@ -109,8 +109,6 @@ static void setup_palette(void)
        int i;
        unsigned char *cmap = gba_colors ? color_gba_cmap : color_cmap;
 
-       emuprint("setting up %s palette", gba_colors ? "GBA" : "NDS/Emu");
-
        for(i=0; i<256; i++) {
                int r = cmap[i * 3];
                int g = cmap[i * 3 + 1];
@@ -145,7 +143,7 @@ static int gamescr_start(void)
        /* setup color image palette */
        setup_palette();
 
-       spr_setup(16, 16, spr_game_pixels, spr_game_cmap);
+       spr_setup(16, 16, spr_game_pixels, gba_colors ? spr_game_gba_cmap : spr_game_cmap);
        wait_vblank();
        spr_clear();
 
@@ -187,7 +185,7 @@ static int gamescr_start(void)
                                enemy->vobj.px = -1;
                                enemy->anm = 0xff;
                                enemy->hp = ENEMY_ENERGY;
-                               enemy->last_shot = timer_msec > E_RATE ? timer_msec - E_RATE : 0;
+                               enemy->last_shot = -1;
                                enemy->shot_frame = -1;
                                if(++total_enemies >= MAX_ENEMIES) {
                                        goto endspawn;
@@ -197,7 +195,6 @@ static int gamescr_start(void)
                }
        }
 endspawn:
-       total_enemies = 1;      /* XXX DBG */
        /* check continuity */
        for(i=0; i<total_enemies; i++) {
                if(enemies[i].anm <= 0) {
@@ -262,9 +259,10 @@ static void gamescr_frame(void)
        wait_vblank();
        present(backbuf);
 
+       /*
        if(!(nframes & 15)) {
                emuprint("vbl: %d", vblperf_count);
-       }
+       }*/
 #ifdef VBLBAR
        vblperf_begin();
 #else
@@ -383,8 +381,8 @@ static int update(void)
        /* enemy logic */
        enemy = enemies;
        for(i=0; i<total_enemies; i++) {
-               /* only consider visible enemies which are not dead */
-               if(enemy->hp <= 0 || enemy->vobj.px < 0) {
+               /* only consider enemies which are not dead */
+               if(enemy->hp <= 0) {
                        enemy++;
                        continue;
                }
@@ -392,7 +390,8 @@ static int update(void)
                if(enemy->shot_frame >= 0) {
                        /* in the process of charging a shot */
                        if(++enemy->shot_frame >= NUM_SHOT_FRAMES - 1) {
-                               if(!did_strafe) {
+                               /* only get hit if we can see the enemy and we didn't strafe */
+                               if(!did_strafe && enemy->vobj.px >= 0) {
                                        hit_frame = 1;
                                        if(--energy <= 0) {
                                                gameover = 1;
@@ -400,9 +399,11 @@ static int update(void)
                                }
                                enemy->shot_frame = -1;
                        }
-               } else {
+               } else if(enemy->vobj.px >= 0) {
                        /* check rate of fire and start a shot if necessary */
-                       if(timer_msec - enemy->last_shot >= E_RATE) {
+                       if(enemy->last_shot == -1) {
+                               enemy->last_shot = timer_msec;
+                       } else if(timer_msec - enemy->last_shot >= E_RATE) {
                                enemy->last_shot = timer_msec;
                                enemy->shot_frame = 0;
                        }