diff --git a/res/bg/ceil1.png b/res/chrome/frame.png similarity index 70% rename from res/bg/ceil1.png rename to res/chrome/frame.png index cefbd20..25fb574 100644 Binary files a/res/bg/ceil1.png and b/res/chrome/frame.png differ diff --git a/res/bg/floor1.png b/res/fg/rock1.png similarity index 70% rename from res/bg/floor1.png rename to res/fg/rock1.png index ab49ba9..ceb0bac 100644 Binary files a/res/bg/floor1.png and b/res/fg/rock1.png differ diff --git a/res/fg/rock1t.png b/res/fg/rock1t.png new file mode 100644 index 0000000..f9039fa Binary files /dev/null and b/res/fg/rock1t.png differ diff --git a/res/font.png b/res/font.png index 5e3cb08..294553c 100644 Binary files a/res/font.png and b/res/font.png differ diff --git a/res/resources.res b/res/resources.res index 37eda00..0fdb583 100644 --- a/res/resources.res +++ b/res/resources.res @@ -1,8 +1,10 @@ IMAGE font "font.png" BEST NONE +IMAGE frame "chrome/frame.png" FAST -IMAGE bgWall1 "bg/wall1.png" FAST -IMAGE bgCeil1 "bg/ceil1.png" FAST -IMAGE bgFloor1 "bg/floor1.png" FAST +IMAGE wall1 "bg/wall1.png" FAST + +IMAGE rock1 "fg/rock1.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 4a0a765..9ece06a 100644 --- a/src/background.h +++ b/src/background.h @@ -1,4 +1,4 @@ -// bg +// background #define BG_I 512 @@ -11,16 +11,7 @@ static void drawBg(){ for(u16 x = 0; x < BG_W; x++) for(u16 y = 0; y < BG_H; y++){ if(x % 8 == 0 && y % 8 == 0){ - VDP_drawImageEx(BG_B, &bgWall1, TILE_ATTR_FULL(PAL2, 0, 0, 0, BG_I), x, y, 0, DMA); - } - } -} - -static void drawFg(){ - for(u16 x = 0; x < BG_W; x++){ - if(x % 4 == 0){ - VDP_drawImageEx(BG_A, &bgCeil1, TILE_ATTR_FULL(PAL2, 0, 0, 0, BG_I + 64), x, 0, 0, DMA); - VDP_drawImageEx(BG_A, &bgFloor1, TILE_ATTR_FULL(PAL2, 0, 0, 0, BG_I + 64 + 12), x, 21, 0, DMA); + VDP_drawImageEx(BG_A, &wall1, TILE_ATTR_FULL(PAL2, 0, 0, 0, BG_I), x, y, 0, DMA); } } } @@ -28,7 +19,6 @@ static void drawFg(){ // update - #define BG_SPEED FIX16(1) #define BG_SPEED_NORM FIX16(0.707) @@ -36,24 +26,27 @@ static void drawFg(){ #define BG_SIZE_F FIX16(BG_SIZE) +s16 bgPosX[WIN_H_T]; +fix16 bgPosXF[WIN_H_T]; Vect2D_f16 bgPos; static void scrollBg(){ - bgPos.x = fix16Sub(bgPos.x, BG_SPEED); - // bgPos.y = fix16Add(bgPos.y, BG_SPEED_NORM); - if(bgPos.x <= -BG_SIZE_F) bgPos.x = fix16Add(bgPos.x, BG_SIZE_F); - if(bgPos.y >= BG_SIZE_F) bgPos.y = fix16Sub(bgPos.y, BG_SIZE_F); + + 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); + bgPosX[y] = fix16ToInt(bgPosXF[y]); + } } // loop void loadBg(){ + VDP_setScrollingMode(HSCROLL_TILE, VSCROLL_PLANE); drawBg(); - drawFg(); } void updateBg(){ - VDP_setHorizontalScroll(BG_B, fix16ToInt(bgPos.x)); - VDP_setVerticalScroll(BG_B, fix16ToInt(bgPos.y)); + VDP_setHorizontalScrollTile(BG_A, 0, bgPosX, WIN_H_T, DMA); scrollBg(); } \ No newline at end of file diff --git a/src/chrome.h b/src/chrome.h index 99c9622..5a75965 100644 --- a/src/chrome.h +++ b/src/chrome.h @@ -1,5 +1,14 @@ // chrome +#define CHROME_I 64 + +// frame + +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); +} + // score #define SCORE_X 4 @@ -52,6 +61,7 @@ static void loadHeat(){ // loop void loadChrome(){ + loadFrame(); loadScore(); loadRound(); loadHeat(); diff --git a/src/foreground.h b/src/foreground.h new file mode 100644 index 0000000..90ce7e6 --- /dev/null +++ b/src/foreground.h @@ -0,0 +1,49 @@ +// foreground + +#define FG_I 576 + + +// draw + +#define CEIL_Y 3 +#define FLOOR_Y 24 + +static void drawFg(){ + for(u16 x = 0; x < BG_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); + } + } +} + + +// update + +#define FG_SPEED FIX16(2) +#define BG_SPEED_NORM FIX16(2 * 0.707) + +#define FG_SIZE 32 + +#define FG_SIZE_F FIX16(FG_SIZE) + +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); +} + + +// loop + +void loadFg(){ + drawFg(); +} + +void updateFg(){ + // VDP_setHorizontalScroll(BG_B, fix16ToInt(fgPos.x)); + // VDP_setVerticalScroll(BG_B, fix16ToInt(fgPos.y)); + scrollFg(); +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index f77ef09..036bf83 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ #include "global.h" #include "controls.h" #include "background.h" +#include "foreground.h" #include "player.h" #include "bullets.h" #include "chrome.h" @@ -17,14 +18,16 @@ static void loadInternals(){ JOY_setEventHandler(&updateControls); SPR_init(127, 0, 0); VDP_setScreenWidth256(); - VDP_setPalette(PAL1, font.palette -> data); - VDP_setPalette(PAL2, bgWall1.palette -> data); + VDP_setPalette(PAL1, nitori.palette -> data); + VDP_setPalette(PAL2, wall1.palette -> data); + VDP_setPalette(PAL3, font.palette -> data); VDP_loadFont(font.tileset, DMA); - VDP_setTextPalette(1); + VDP_setTextPalette(3); } static void loadGame(){ loadBg(); + loadFg(); loadPlayer(); loadChrome(); } @@ -33,6 +36,7 @@ static void updateGame(){ updatePlayer(); updateBullets(); updateBg(); + updateFg(); updateChrome(); clock++; if(clock >= CLOCK_LIMIT) clock -= CLOCK_LIMIT; diff --git a/src/player.h b/src/player.h index dffd0d6..09ac1b9 100644 --- a/src/player.h +++ b/src/player.h @@ -2,7 +2,7 @@ #define PLAYER_OFF FIX16(16) #define PLAYER_INIT_X FIX16(40) -#define PLAYER_INIT_Y FIX16(GAME_H / 2) +#define PLAYER_INIT_Y FIX16((GAME_H - 24) / 2 + 24) #define INVINCIBLE_LIMIT 60 * 4 #define SHOT_INTERVAL 15