diff --git a/res/fg/rock1.png b/res/fg/rock1.png index ceb0bac..e9bc810 100644 Binary files a/res/fg/rock1.png and b/res/fg/rock1.png differ diff --git a/res/fg/rock1b.png b/res/fg/rock1b.png new file mode 100644 index 0000000..2be8156 Binary files /dev/null and b/res/fg/rock1b.png differ diff --git a/res/fg/rock1l.png b/res/fg/rock1l.png new file mode 100644 index 0000000..e9a9d63 Binary files /dev/null and b/res/fg/rock1l.png differ diff --git a/res/fg/rock1r.png b/res/fg/rock1r.png new file mode 100644 index 0000000..31e93bc Binary files /dev/null and b/res/fg/rock1r.png differ diff --git a/res/fg/rock1t.png b/res/fg/rock1t.png index f9039fa..4273738 100644 Binary files a/res/fg/rock1t.png and b/res/fg/rock1t.png differ diff --git a/res/resources.res b/res/resources.res index 0fdb583..da127e1 100644 --- a/res/resources.res +++ b/res/resources.res @@ -4,6 +4,10 @@ IMAGE frame "chrome/frame.png" FAST IMAGE wall1 "bg/wall1.png" FAST IMAGE rock1 "fg/rock1.png" FAST +IMAGE rock1l "fg/rock1l.png" FAST +IMAGE rock1r "fg/rock1r.png" FAST +IMAGE rock1b "fg/rock1b.png" FAST + IMAGE rock1t "fg/rock1t.png" FAST SPRITE nitori "player/nitori.png" 4 4 FAST diff --git a/src/background.h b/src/background.h index 9ece06a..3284af2 100644 --- a/src/background.h +++ b/src/background.h @@ -31,7 +31,6 @@ fix16 bgPosXF[WIN_H_T]; Vect2D_f16 bgPos; static void scrollBg(){ - for(u8 y = 0; y < WIN_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); diff --git a/src/chrome.h b/src/chrome.h index 5a75965..8d8674e 100644 --- a/src/chrome.h +++ b/src/chrome.h @@ -19,7 +19,7 @@ u32 lastScore; char scoreStr[SCORE_LENGTH]; static void loadScore(){ - VDP_drawText("hi", 1, 1); + VDP_drawText("HI", 1, 1); VDP_drawText("00000000", SCORE_X, 1); VDP_drawText("sc", 1, 2); intToStr(score, scoreStr, SCORE_LENGTH); @@ -36,14 +36,14 @@ static void updateScore(){ } -// round +// zone -#define ROUND_X 29 -#define ROUND_Y 1 +#define ZONE_X 28 +#define ZONE_Y 1 -static void loadRound(){ - VDP_drawText("round", ROUND_X - 6, ROUND_Y); - VDP_drawText("01", ROUND_X, ROUND_Y); +static void loadZone(){ + VDP_drawText("ZONE", ZONE_X - 5, ZONE_Y); + VDP_drawText("001", ZONE_X, ZONE_Y); } @@ -63,7 +63,7 @@ static void loadHeat(){ void loadChrome(){ loadFrame(); loadScore(); - loadRound(); + loadZone(); loadHeat(); } diff --git a/src/foreground.h b/src/foreground.h index 90ce7e6..f274653 100644 --- a/src/foreground.h +++ b/src/foreground.h @@ -1,6 +1,14 @@ // foreground #define FG_I 576 +#define FG_W GAME_W_T + 30 +#define OBSTACLE_COUNT 8 + +struct obstacle { + bool active; + Vect2D_f16 pos; +} +struct obstacle obstacles[OBSTACLE_COUNT]; // draw @@ -9,7 +17,7 @@ #define FLOOR_Y 24 static void drawFg(){ - for(u16 x = 0; x < BG_W; x++){ + for(u16 x = 0; x < FG_W; x++){ if(x % 4 == 0){ VDP_drawImageEx(BG_B, &rock1t, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I), x, CEIL_Y, 0, DMA); VDP_drawImageEx(BG_B, &rock1, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 16), x, FLOOR_Y, 0, DMA); @@ -17,22 +25,44 @@ static void drawFg(){ } } +// obstacle + +#define OBS_FLOOR_Y FLOOR_Y - 4 +s16 fgPos; +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); +} + // update #define FG_SPEED FIX16(2) -#define BG_SPEED_NORM FIX16(2 * 0.707) +#define FG_SPEED_NORM FIX16(2 * 0.707) #define FG_SIZE 32 +#define FG_LIMIT FIX16(-40 * 8) -#define FG_SIZE_F FIX16(FG_SIZE) +#define FG_SIZE_F 40 + +s16 fgPosX[WIN_H_T]; +fix16 fgPosXF[WIN_H_T]; -Vect2D_f16 fgPos; static void scrollFg(){ - fgPos.x = fix16Sub(fgPos.x, FG_SPEED); - if(fgPos.x <= -FG_SIZE_F) fgPos.x = fix16Add(fgPos.x, FG_SIZE_F); - if(fgPos.y >= FG_SIZE_F) fgPos.y = fix16Sub(fgPos.y, FG_SIZE_F); + for(u8 y = 0; y < WIN_H_T; y++){ + if(y > 2){ + fgPosXF[y] = fix16Sub(fgPosXF[y], FG_SPEED); + if(fgPosXF[y] <= FG_LIMIT) fgPosXF[y] = 0; + fgPosX[y] = fix16ToInt(fgPosXF[y]); + if(y == 3) fgPos = fgPosX[y]; + } + } } @@ -40,10 +70,10 @@ static void scrollFg(){ void loadFg(){ drawFg(); + spawnObstacle(); } void updateFg(){ - // VDP_setHorizontalScroll(BG_B, fix16ToInt(fgPos.x)); - // VDP_setVerticalScroll(BG_B, fix16ToInt(fgPos.y)); + VDP_setHorizontalScrollTile(BG_B, 0, fgPosX, WIN_H_T, DMA); scrollFg(); } \ No newline at end of file diff --git a/src/player.h b/src/player.h index 09ac1b9..943baa0 100644 --- a/src/player.h +++ b/src/player.h @@ -35,11 +35,14 @@ static void spawnPlayer(){ #define PLAYER_LIMIT_Y FIX16(16) #define PLAYER_LIMIT_H FIX16(GAME_H - 16) +#define PLAYER_LIMIT_Y_HORI FIX16(72) +#define PLAYER_LIMIT_H_HORI FIX16(GAME_H - 32 - 16) + static void checkPlayerBounds(){ if(player.pos.x < PLAYER_LIMIT_X) player.pos.x = PLAYER_LIMIT_X; else if(player.pos.x > PLAYER_LIMIT_W) player.pos.x = PLAYER_LIMIT_W; - if(player.pos.y < PLAYER_LIMIT_Y) player.pos.y = PLAYER_LIMIT_Y; - else if(player.pos.y > PLAYER_LIMIT_H) player.pos.y = PLAYER_LIMIT_H; + if(player.pos.y < PLAYER_LIMIT_Y_HORI) player.pos.y = PLAYER_LIMIT_Y_HORI; + else if(player.pos.y > PLAYER_LIMIT_H_HORI) player.pos.y = PLAYER_LIMIT_H_HORI; } // movement