diff --git a/src/background.h b/src/background.h index 3284af2..e9c7988 100644 --- a/src/background.h +++ b/src/background.h @@ -3,7 +3,7 @@ #define BG_I 512 #define BG_W GAME_W_T + 8 -#define BG_H WIN_H_T +#define BG_H GAME_H_T // draw @@ -26,12 +26,12 @@ static void drawBg(){ #define BG_SIZE_F FIX16(BG_SIZE) -s16 bgPosX[WIN_H_T]; -fix16 bgPosXF[WIN_H_T]; +s16 bgPosX[GAME_H_T]; +fix16 bgPosXF[GAME_H_T]; Vect2D_f16 bgPos; static void scrollBg(){ - for(u8 y = 0; y < WIN_H_T; y++){ + for(u8 y = 0; y < GAME_H_T; y++){ if(y > 3) bgPosXF[y] = fix16Sub(bgPosXF[y], BG_SPEED); if(bgPosXF[y] <= -BG_SIZE_F) bgPosXF[y] = fix16Add(bgPosXF[y], BG_SIZE_F); bgPosX[y] = fix16ToInt(bgPosXF[y]); @@ -46,6 +46,6 @@ void loadBg(){ } void updateBg(){ - VDP_setHorizontalScrollTile(BG_A, 0, bgPosX, WIN_H_T, DMA); + VDP_setHorizontalScrollTile(BG_A, 0, bgPosX, GAME_H_T, DMA); scrollBg(); } \ No newline at end of file diff --git a/src/chrome.h b/src/chrome.h index 8d8674e..f436817 100644 --- a/src/chrome.h +++ b/src/chrome.h @@ -6,7 +6,7 @@ static void loadFrame(){ VDP_loadTileSet(frame.tileset, CHROME_I, DMA); - VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL2, 1, 0, 0, CHROME_I), 0, 0, WIN_W_T, 3); + VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL2, 1, 0, 0, CHROME_I), 0, 0, GAME_W_T, 3); } // score @@ -40,9 +40,10 @@ static void updateScore(){ #define ZONE_X 28 #define ZONE_Y 1 +#define ZONE_LABEL_X 23 static void loadZone(){ - VDP_drawText("ZONE", ZONE_X - 5, ZONE_Y); + VDP_drawText("ZONE", ZONE_LABEL_X, ZONE_Y); VDP_drawText("001", ZONE_X, ZONE_Y); } @@ -51,9 +52,10 @@ static void loadZone(){ #define HEAT_X 28 #define HEAT_Y 2 +#define HEAT_LABEL_X 23 static void loadHeat(){ - VDP_drawText("heat", HEAT_X - 5, HEAT_Y); + VDP_drawText("heat", HEAT_LABEL_X, HEAT_Y); VDP_drawText("100", HEAT_X, HEAT_Y); } diff --git a/src/foreground.h b/src/foreground.h index f274653..b6bc5bc 100644 --- a/src/foreground.h +++ b/src/foreground.h @@ -7,7 +7,7 @@ struct obstacle { bool active; Vect2D_f16 pos; -} +}; struct obstacle obstacles[OBSTACLE_COUNT]; @@ -34,28 +34,28 @@ s16 obsX; static void spawnObstacle(){ obsX = 32; VDP_drawImageEx(BG_B, &rock1l, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 32), obsX, OBS_FLOOR_Y, 0, DMA); - VDP_drawImageEx(BG_B, &rock1, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 32 + 16), obsX + 2, OBS_FLOOR_Y, 0, DMA); - VDP_drawImageEx(BG_B, &rock1r, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 32 + 16 + 16), obsX + 2 + 4, OBS_FLOOR_Y, 0, DMA); - VDP_drawImageEx(BG_B, &rock1b, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 32 + 16 + 16 + 16), obsX + 2, OBS_FLOOR_Y + 4, 0, DMA); + VDP_drawImageEx(BG_B, &rock1, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 48), obsX + 2, OBS_FLOOR_Y, 0, DMA); + VDP_drawImageEx(BG_B, &rock1r, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 64), obsX + 2 + 4, OBS_FLOOR_Y, 0, DMA); + VDP_drawImageEx(BG_B, &rock1b, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 80), obsX + 2, OBS_FLOOR_Y + 4, 0, DMA); } // update #define FG_SPEED FIX16(2) -#define FG_SPEED_NORM FIX16(2 * 0.707) +#define FG_SPEED_NORM FIX16(1.414) #define FG_SIZE 32 -#define FG_LIMIT FIX16(-40 * 8) +#define FG_LIMIT FIX16(-320) #define FG_SIZE_F 40 -s16 fgPosX[WIN_H_T]; -fix16 fgPosXF[WIN_H_T]; +s16 fgPosX[GAME_H_T]; +fix16 fgPosXF[GAME_H_T]; static void scrollFg(){ - for(u8 y = 0; y < WIN_H_T; y++){ + for(u8 y = 0; y < GAME_H_T; y++){ if(y > 2){ fgPosXF[y] = fix16Sub(fgPosXF[y], FG_SPEED); if(fgPosXF[y] <= FG_LIMIT) fgPosXF[y] = 0; @@ -74,6 +74,6 @@ void loadFg(){ } void updateFg(){ - VDP_setHorizontalScrollTile(BG_B, 0, fgPosX, WIN_H_T, DMA); + VDP_setHorizontalScrollTile(BG_B, 0, fgPosX, GAME_H_T, DMA); scrollFg(); } \ No newline at end of file diff --git a/src/global.h b/src/global.h index 2ec5d97..d914ae2 100644 --- a/src/global.h +++ b/src/global.h @@ -1,16 +1,10 @@ // globals -#define WIN_W_T 32 -#define WIN_H_T 28 +#define GAME_W_T 32 +#define GAME_H_T 28 -#define WIN_W WIN_W_T * 8 -#define WIN_H WIN_H_T * 8 - -#define GAME_W_T WIN_W_T -#define GAME_H_T WIN_H_T - -#define GAME_W GAME_W_T * 8 -#define GAME_H GAME_H_T * 8 +#define GAME_W 256 +#define GAME_H 224 #define GAME_X_T 0 #define GAME_Y_T 0 diff --git a/src/player.h b/src/player.h index 943baa0..08a7de4 100644 --- a/src/player.h +++ b/src/player.h @@ -1,8 +1,8 @@ // player #define PLAYER_OFF FIX16(16) -#define PLAYER_INIT_X FIX16(40) -#define PLAYER_INIT_Y FIX16((GAME_H - 24) / 2 + 24) +#define PLAYER_INIT_X FIX16(32) +#define PLAYER_INIT_Y FIX16(124) #define INVINCIBLE_LIMIT 60 * 4 #define SHOT_INTERVAL 15 @@ -31,12 +31,12 @@ static void spawnPlayer(){ // collision #define PLAYER_LIMIT_X FIX16(16) -#define PLAYER_LIMIT_W FIX16(GAME_W - 16) +#define PLAYER_LIMIT_W FIX16(240) #define PLAYER_LIMIT_Y FIX16(16) -#define PLAYER_LIMIT_H FIX16(GAME_H - 16) +#define PLAYER_LIMIT_H FIX16(208) #define PLAYER_LIMIT_Y_HORI FIX16(72) -#define PLAYER_LIMIT_H_HORI FIX16(GAME_H - 32 - 16) +#define PLAYER_LIMIT_H_HORI FIX16(176) static void checkPlayerBounds(){ if(player.pos.x < PLAYER_LIMIT_X) player.pos.x = PLAYER_LIMIT_X; @@ -48,7 +48,7 @@ static void checkPlayerBounds(){ // movement #define PLAYER_SPEED FIX16(2.5) -#define PLAYER_SPEED_NORM FIX16(2.5 * 0.707) +#define PLAYER_SPEED_NORM FIX16(1.768) s16 playerFrame; diff --git a/src/tiles.h b/src/tiles.h deleted file mode 100644 index a1515dc..0000000 --- a/src/tiles.h +++ /dev/null @@ -1,84 +0,0 @@ -// tiles - -#define TILE_I 128 -#define TILE_W 128 - -#define TILE_COUNT 3072 -u16 tileMap[TILE_COUNT]; - -u16 tileC; - -static void loadTilesI(){ - VDP_loadTileSet(tile1_1.tileset, TILE_I, DMA); -} - - -static void spawnTileRows(s16 y1, s16 y2, bool trig){ - tileC = 0; - for(u16 y = 0; y < GAME_H_T; y++) for(u16 x = 0; x < TILE_W; x++){ - if((y == y1 && tileMap[tileC - TILE_W] > 0 && random() % 4 < 3) || (y == y2 && tileMap[tileC + TILE_W] > 0 && trig)) tileMap[tileC] = 1; - tileC++; - } -} - -static void spawnTiles(){ - - // initial ceiling and floor - tileC = 0; - for(u16 y = 0; y < GAME_H_T; y++) for(u16 x = 0; x < TILE_W; x++){ - tileMap[tileC] = 0; - if(y == 0 || y == 23) tileMap[tileC] = 1; - tileC++; - } - - // first go around - spawnTileRows(1, 22, random() % 4 < 3); - - // second go around - spawnTileRows(2, 21, random() % 4 < 2); - - // third go around - spawnTileRows(3, 20, random() % 4 < 1); - - // draw small - tileC = 0; - for(u16 y = 0; y < GAME_H_T; y++) for(u16 x = 0; x < TILE_W; x++){ - if(tileMap[tileC] > 0) - VDP_setTileMapXY(BG_A, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE_I), x, y + 4); - tileC++; - } - - - // if(tileMap[tileC] > 0 && x % 2 == 0 && y % 2 == 0) VDP_drawImageEx(BG_A, &tile1_2, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE_I + 1), x, y + 4, 0, DMA); - // if(x % 2 == 0 && tileC % 256 < 128 && tileMap[tileC] > 0){ - // VDP_drawImageEx(BG_A, &tile1_2, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE_I + 1), x, 4, 0, DMA); - // } - // tileC++; - // } - // } - -} - -#define TILE_SPEED -1 -#define TILE_LIMIT -TILE_W * 8 -s16 tilePos[GAME_H_T]; -static void scrollTiles(){ - for(u16 y = 0; y < GAME_H_T; y++){ - tilePos[y] += TILE_SPEED; - if(tilePos[y] <= TILE_LIMIT) tilePos[y] = 0; - } - VDP_setHorizontalScrollTile(BG_A, 4, tilePos, GAME_H_T, DMA); -} - - -// loop - -void loadTiles(){ - // loadTilesI(); - // VDP_setScrollingMode(HSCROLL_TILE, VSCROLL_PLANE); - // spawnTiles(); -} - -void updateTiles(){ - // scrollTiles(); -} \ No newline at end of file