foreground work

This commit is contained in:
t. boddy 2022-08-21 13:44:00 -04:00
parent dbd635fa26
commit 4211296f3b
2 changed files with 19 additions and 15 deletions

View File

@ -30,7 +30,7 @@ fix16 bgPosXF[GAME_H_T];
static void scrollBg(){ static void scrollBg(){
for(u8 y = 0; y < GAME_H_T; y++){ for(u8 y = 0; y < GAME_H_T; y++){
if(y > 3) bgPosXF[y] = fix16Sub(bgPosXF[y], BG_SPEED); if(y > 2) bgPosXF[y] = fix16Sub(bgPosXF[y], BG_SPEED);
if(bgPosXF[y] <= -BG_SIZE_F) bgPosXF[y] = fix16Add(bgPosXF[y], BG_SIZE_F); if(bgPosXF[y] <= -BG_SIZE_F) bgPosXF[y] = fix16Add(bgPosXF[y], BG_SIZE_F);
bgPosX[y] = fix16ToInt(bgPosXF[y]); bgPosX[y] = fix16ToInt(bgPosXF[y]);
} }

View File

@ -26,18 +26,24 @@ SpriteDefinition* currentBottomImage;
static void drawFg(){ static void drawFg(){
switch(currentFg){ switch(currentFg){
case 0: case 0:
currentTopImage = &rock1Top; VDP_loadTileSet(rock1Top.tileset, FG_I, DMA);
currentBottomImage = &rock1Bottom; VDP_loadTileSet(rock1Bottom.tileset, FG_I + 16, DMA);
break; break;
case 1: case 1:
currentTopImage = &rock2Top; VDP_loadTileSet(rock2Top.tileset, FG_I, DMA);
currentBottomImage = &rock2Bottom; VDP_loadTileSet(rock2Bottom.tileset, FG_I + 16, DMA);
break; break;
} }
for(u16 x = 0; x < FG_W; x++){ for(u16 x = 0; x < FG_W; x++){
if(x % 4 == 0){ if(x % 4 == 0){
VDP_drawImageEx(BG_B, currentTopImage, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I), x, CEIL_Y, 0, DMA); for(s16 i = 0; i < 4; i++){
VDP_drawImageEx(BG_B, currentBottomImage, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 16), x, FLOOR_Y, 0, DMA); for(s16 j = 0; j < 4; j++){
VDP_setTileMapXY(BG_B, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + i + 4 * j), x + i, CEIL_Y + j);
VDP_setTileMapXY(BG_B, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 16 + i + 4 * j), x + i, FLOOR_Y + j);
}
}
} }
} }
} }
@ -91,17 +97,15 @@ static void spawnObstacle(bool top, s16 offset, u8 type){
#define OBSTACLE_MOD FIX16(8) #define OBSTACLE_MOD FIX16(8)
#define OBSTACLE_LIMIT_X FIX16(-64) #define OBSTACLE_LIMIT_X FIX16(-64)
SpriteDefinition* obstacleImage;
static void killObstacle(s16 i){ static void killObstacle(s16 i){
obstacles[i].active = FALSE; obstacles[i].active = FALSE;
VDP_clearTileMapRect(BG_B, obstacles[i].startX, obstacles[i].top ? OBS_CEIL_Y + 4 : OBS_FLOOR_Y, 4, 4); VDP_clearTileMapRect(BG_B, obstacles[i].startX, obstacles[i].top ? OBS_CEIL_Y + 4 : OBS_FLOOR_Y, 4, 4);
VDP_drawImageEx(BG_B, for(s16 h = 0; h < 4; h++){
obstacles[i].top ? currentTopImage : currentBottomImage, for(s16 j = 0; j < 4; j++){
TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + (obstacles[i].top ? 0 : 16)), if(obstacles[i].top) VDP_setTileMapXY(BG_B, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + h + 4 * j), obstacles[i].startX + h, CEIL_Y + j);
obstacles[i].startX, else VDP_setTileMapXY(BG_B, TILE_ATTR_FULL(PAL2, 1, 0, 0, FG_I + 16 + h + 4 * j), obstacles[i].startX + h, FLOOR_Y + j);
obstacles[i].top ? CEIL_Y : FLOOR_Y, }
0, DMA_QUEUE); }
} }
static void collideObstacle(s16 i){ static void collideObstacle(s16 i){