#include "debug.h"
#include "voxscape.h"
#include "data.h"
+#include "scoredb.h"
#define FOV 30
#define NEAR 2
#define E_RATE 250
#define SHOT_TIME 50
+#define ENEMY_VIS_RANGE (2 * FAR / 3)
+
static int gamescr_start(void);
static void gamescr_stop(void);
static void gamescr_frame(void);
#define COLOR_HORIZON 192
#define COLOR_ZENITH 255
-#define MAX_SPR 32
+#define MAX_SPR 40
static uint16_t oam[4 * MAX_SPR];
static int dynspr_base, dynspr_count;
static int score;
static unsigned long total_time, start_time;
+static int running;
#define XFORM_PIXEL_X(x, y) (xform_ca * (x) - xform_sa * (y) + (120 << 8))
#define XFORM_PIXEL_Y(x, y) (xform_sa * (x) + xform_ca * (y) + (80 << 8))
}
}
endspawn:
+ total_enemies = 1; /* XXX DBG */
/* check continuity */
for(i=0; i<total_enemies; i++) {
if(enemies[i].anm <= 0) {
total_time = 0;
start_time = timer_msec;
+ hitfrm = 0;
+
vblcount = 0;
nframes = 0;
+
+ running = 1;
return 0;
}
static void gamescr_stop(void)
{
+ running = 0;
+
iwram_brk(prev_iwram_top);
wait_vblank();
vox_view(pos[0], pos[1], -40, angle);
}
+ /* enemy logic */
+ enemy = enemies;
+ for(i=0; i<total_enemies; i++) {
+ int32_t dx, dy;
+
+ if(enemy->hp <= 0 || timer_msec - enemy->last_shot < E_RATE) {
+ enemy++;
+ continue;
+ }
+
+ dx = enemy->vobj.x - pos[0];
+ dy = enemy->vobj.y - pos[1];
+ if(abs(dx >> 16) < ENEMY_VIS_RANGE && abs(dy >> 16) < ENEMY_VIS_RANGE) {
+ if(vox_check_vis(enemy->vobj.x, enemy->vobj.y, pos[0], pos[1])) {
+ enemy->last_shot = timer_msec;
+ /* TODO shoot */
+ }
+ }
+ enemy++;
+ }
+
snum = 0;
/* turrets number */
spr_oam(oam, dynspr_base + snum++, numspr[num_kills][0], 200, 144, SPR_VRECT | SPR_256COL);
vox_render();
//vox_sky_grad(COLOR_HORIZON, COLOR_ZENITH);
//vox_sky_solid(COLOR_ZENITH);
+
+ if(score >= 0) {
+ int sec = total_time / 1000;
+
+ fillblock_16byte(framebuf + 8 * 240 / 2, 199 | (199 << 8) | (199 << 16) | (199 << 24), 40 * 240 / 16);
+
+ glyphfb = framebuf;
+ glyphbg = 199;
+ glyphcolor = 197;
+ dbg_drawstr(80, 10, "Victory!");
+ glyphcolor = 200;
+ dbg_drawstr(30, 20, " Score: %d", score);
+ dbg_drawstr(30, 28, "Completed in: %lum.%lus", sec / 60, sec % 60);
+ glyphcolor = 198;
+ dbg_drawstr(85, 40, "Press start to exit");
+ }
}
static void victory(void)
{
total_time = timer_msec - start_time;
score = 42;
+
+ /* TODO enter name */
+ save_score("???", score, total_time, 0);
+ save_scores();
}
static inline void xform_pixel(int *xp, int *yp)
static int bank, bankdir, theta;
int32_t sa, ca;
+ if(!running) return;
+
vblcount++;
/* TODO: pre-arrange sprite tiles in gba-native format, so that I can just