work on environment obstacles. break time

This commit is contained in:
t. boddy 2022-08-16 19:16:38 -04:00
parent a95f6f043e
commit 98416384b9
10 changed files with 56 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
res/fg/rock1b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
res/fg/rock1l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
res/fg/rock1r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -4,6 +4,10 @@ IMAGE frame "chrome/frame.png" FAST
IMAGE wall1 "bg/wall1.png" FAST IMAGE wall1 "bg/wall1.png" FAST
IMAGE rock1 "fg/rock1.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 IMAGE rock1t "fg/rock1t.png" FAST
SPRITE nitori "player/nitori.png" 4 4 FAST SPRITE nitori "player/nitori.png" 4 4 FAST

View File

@ -31,7 +31,6 @@ fix16 bgPosXF[WIN_H_T];
Vect2D_f16 bgPos; Vect2D_f16 bgPos;
static void scrollBg(){ static void scrollBg(){
for(u8 y = 0; y < WIN_H_T; y++){ for(u8 y = 0; y < WIN_H_T; y++){
if(y > 3) bgPosXF[y] = fix16Sub(bgPosXF[y], BG_SPEED); if(y > 3) 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);

View File

@ -19,7 +19,7 @@ u32 lastScore;
char scoreStr[SCORE_LENGTH]; char scoreStr[SCORE_LENGTH];
static void loadScore(){ static void loadScore(){
VDP_drawText("hi", 1, 1); VDP_drawText("HI", 1, 1);
VDP_drawText("00000000", SCORE_X, 1); VDP_drawText("00000000", SCORE_X, 1);
VDP_drawText("sc", 1, 2); VDP_drawText("sc", 1, 2);
intToStr(score, scoreStr, SCORE_LENGTH); intToStr(score, scoreStr, SCORE_LENGTH);
@ -36,14 +36,14 @@ static void updateScore(){
} }
// round // zone
#define ROUND_X 29 #define ZONE_X 28
#define ROUND_Y 1 #define ZONE_Y 1
static void loadRound(){ static void loadZone(){
VDP_drawText("round", ROUND_X - 6, ROUND_Y); VDP_drawText("ZONE", ZONE_X - 5, ZONE_Y);
VDP_drawText("01", ROUND_X, ROUND_Y); VDP_drawText("001", ZONE_X, ZONE_Y);
} }
@ -63,7 +63,7 @@ static void loadHeat(){
void loadChrome(){ void loadChrome(){
loadFrame(); loadFrame();
loadScore(); loadScore();
loadRound(); loadZone();
loadHeat(); loadHeat();
} }

View File

@ -1,6 +1,14 @@
// foreground // foreground
#define FG_I 576 #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 // draw
@ -9,7 +17,7 @@
#define FLOOR_Y 24 #define FLOOR_Y 24
static void drawFg(){ static void drawFg(){
for(u16 x = 0; x < BG_W; x++){ for(u16 x = 0; x < FG_W; x++){
if(x % 4 == 0){ 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, &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); 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 // update
#define FG_SPEED FIX16(2) #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_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(){ static void scrollFg(){
fgPos.x = fix16Sub(fgPos.x, FG_SPEED); for(u8 y = 0; y < WIN_H_T; y++){
if(fgPos.x <= -FG_SIZE_F) fgPos.x = fix16Add(fgPos.x, FG_SIZE_F); if(y > 2){
if(fgPos.y >= FG_SIZE_F) fgPos.y = fix16Sub(fgPos.y, FG_SIZE_F); 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(){ void loadFg(){
drawFg(); drawFg();
spawnObstacle();
} }
void updateFg(){ void updateFg(){
// VDP_setHorizontalScroll(BG_B, fix16ToInt(fgPos.x)); VDP_setHorizontalScrollTile(BG_B, 0, fgPosX, WIN_H_T, DMA);
// VDP_setVerticalScroll(BG_B, fix16ToInt(fgPos.y));
scrollFg(); scrollFg();
} }

View File

@ -35,11 +35,14 @@ static void spawnPlayer(){
#define PLAYER_LIMIT_Y FIX16(16) #define PLAYER_LIMIT_Y FIX16(16)
#define PLAYER_LIMIT_H FIX16(GAME_H - 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(){ static void checkPlayerBounds(){
if(player.pos.x < PLAYER_LIMIT_X) player.pos.x = PLAYER_LIMIT_X; 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; 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; if(player.pos.y < PLAYER_LIMIT_Y_HORI) player.pos.y = PLAYER_LIMIT_Y_HORI;
else if(player.pos.y > PLAYER_LIMIT_H) player.pos.y = PLAYER_LIMIT_H; else if(player.pos.y > PLAYER_LIMIT_H_HORI) player.pos.y = PLAYER_LIMIT_H_HORI;
} }
// movement // movement