shit lmao

This commit is contained in:
t. boddy 2026-02-18 22:05:46 -05:00
parent 06e8e735fb
commit 6adbe1882d
40 changed files with 608 additions and 361 deletions

View file

@ -1,8 +1,8 @@
#define MAP_I 512
#define MAP_TILE TILE_ATTR_FULL(PAL1, 1, 0, 0, MAP_I)
#define MAP_TILE TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I)
#define MAP_PLAYER_TILE TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 1)
#define MAP_ENEMY_TILE TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 2)
#define MAP_HUMAN_TILE TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 3)
#define MAP_TREASURE_TILE TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 3)
#define MAP_BORDER_X_TILE TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 4)
#define FONT_BIG_I 256
@ -37,7 +37,7 @@ static void drawLives(){
// previous map positions: -1 means not drawn
s16 mapEnemyCol[ENEMY_COUNT], mapEnemyRow[ENEMY_COUNT];
s16 mapHumanCol[HUMAN_COUNT], mapHumanRow[HUMAN_COUNT];
s16 mapTreasureCol[TREASURE_COUNT], mapTreasureRow[TREASURE_COUNT];
s16 mapPlayerRow;
static void drawScore(){
@ -57,33 +57,40 @@ static void drawScore(){
void loadMap(){
VDP_fillTileMapRect(BG_A, MAP_TILE, MAP_X, MAP_Y, MAP_W, MAP_H);
// VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 3), MAP_X, MAP_Y - 1, MAP_W, 1);
// VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 1, 0, MAP_I + 3), MAP_X, MAP_Y + MAP_H, MAP_W, 1);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 4), MAP_X, MAP_Y - 1, MAP_W, 1);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 5), MAP_X, MAP_Y + MAP_H, MAP_W, 1);
// VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 4), MAP_X - 1, MAP_Y, 1, MAP_H);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 6), MAP_X - 1, MAP_Y, 1, MAP_H);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 1, MAP_I + 6), MAP_X + MAP_W, MAP_Y, 1, MAP_H);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 7), MAP_X - 1, MAP_Y + MAP_H, 1, 1);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 1, MAP_I + 7), MAP_X + MAP_W, MAP_Y + MAP_H, 1, 1);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 0, MAP_I + 8), MAP_X - 1, MAP_Y - 1, 1, 1);
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL0, 1, 0, 1, MAP_I + 8), MAP_X + MAP_W, MAP_Y - 1, 1, 1);
for(s16 i = 0; i < ENEMY_COUNT; i++){
mapEnemyCol[i] = -1;
mapEnemyRow[i] = -1;
}
for(s16 i = 0; i < HUMAN_COUNT; i++){
mapHumanCol[i] = -1;
mapHumanRow[i] = -1;
for(s16 i = 0; i < TREASURE_COUNT; i++){
mapTreasureCol[i] = -1;
mapTreasureRow[i] = -1;
}
mapPlayerRow = -1;
}
// temp arrays for new positions
s16 mapNewCol[ENEMY_COUNT], mapNewRow[ENEMY_COUNT];
s16 mapNewHumanCol[HUMAN_COUNT], mapNewHumanRow[HUMAN_COUNT];
s16 mapNewTreasureCol[TREASURE_COUNT], mapNewTreasureRow[TREASURE_COUNT];
static bool mapTileOccupied(s16 col, s16 row, s16 pRow){
// player always at center column
if(col == MAP_W / 2 && row == pRow) return TRUE;
for(s16 i = 0; i < ENEMY_COUNT; i++)
if(mapNewCol[i] == col && mapNewRow[i] == row) return TRUE;
for(s16 i = 0; i < HUMAN_COUNT; i++)
if(mapNewHumanCol[i] == col && mapNewHumanRow[i] == row) return TRUE;
for(s16 i = 0; i < TREASURE_COUNT; i++)
if(mapNewTreasureCol[i] == col && mapNewTreasureRow[i] == row) return TRUE;
return FALSE;
}
@ -112,22 +119,22 @@ static void updateMap(){
mapNewRow[i] = row;
}
// compute new human positions
for(s16 i = 0; i < HUMAN_COUNT; i++){
if(!humans[i].active || humans[i].image == NULL || humans[i].state == HUMAN_COLLECTED){
mapNewHumanCol[i] = -1;
mapNewHumanRow[i] = -1;
// compute new treasure positions
for(s16 i = 0; i < TREASURE_COUNT; i++){
if(!treasures[i].active || treasures[i].image == NULL || treasures[i].state == TREASURE_COLLECTED){
mapNewTreasureCol[i] = -1;
mapNewTreasureRow[i] = -1;
continue;
}
fix32 dx = getWrappedDelta(humans[i].pos.x, player.pos.x);
fix32 dx = getWrappedDelta(treasures[i].pos.x, player.pos.x);
s16 col = fix32ToInt(dx) / 54 + MAP_W / 2;
if(col < 0) col = 0;
if(col >= MAP_W) col = MAP_W - 1;
s16 row = fix32ToInt(humans[i].pos.y) / 75;
s16 row = fix32ToInt(treasures[i].pos.y) / 75;
if(row < 0) row = 0;
if(row >= MAP_H) row = MAP_H - 1;
mapNewHumanCol[i] = col;
mapNewHumanRow[i] = row;
mapNewTreasureCol[i] = col;
mapNewTreasureRow[i] = row;
}
// clear old player tile if it moved and nothing new occupies it
@ -143,21 +150,21 @@ static void updateMap(){
VDP_setTileMapXY(BG_A, MAP_TILE, MAP_X + mapEnemyCol[i], MAP_Y + mapEnemyRow[i]);
}
// clear old human tiles that moved or disappeared
for(s16 i = 0; i < HUMAN_COUNT; i++){
if(mapHumanCol[i] < 0) continue;
if(mapHumanCol[i] == mapNewHumanCol[i] && mapHumanRow[i] == mapNewHumanRow[i]) continue;
if(!mapTileOccupied(mapHumanCol[i], mapHumanRow[i], pRow))
VDP_setTileMapXY(BG_A, MAP_TILE, MAP_X + mapHumanCol[i], MAP_Y + mapHumanRow[i]);
// clear old treasure tiles that moved or disappeared
for(s16 i = 0; i < TREASURE_COUNT; i++){
if(mapTreasureCol[i] < 0) continue;
if(mapTreasureCol[i] == mapNewTreasureCol[i] && mapTreasureRow[i] == mapNewTreasureRow[i]) continue;
if(!mapTileOccupied(mapTreasureCol[i], mapTreasureRow[i], pRow))
VDP_setTileMapXY(BG_A, MAP_TILE, MAP_X + mapTreasureCol[i], MAP_Y + mapTreasureRow[i]);
}
// draw human dots (skip if player occupies same tile)
for(s16 i = 0; i < HUMAN_COUNT; i++){
mapHumanCol[i] = mapNewHumanCol[i];
mapHumanRow[i] = mapNewHumanRow[i];
if(mapNewHumanCol[i] < 0) continue;
if(mapNewHumanCol[i] == MAP_W / 2 && mapNewHumanRow[i] == pRow) continue;
VDP_setTileMapXY(BG_A, MAP_HUMAN_TILE, MAP_X + mapNewHumanCol[i], MAP_Y + mapNewHumanRow[i]);
// draw treasure dots (skip if player occupies same tile)
for(s16 i = 0; i < TREASURE_COUNT; i++){
mapTreasureCol[i] = mapNewTreasureCol[i];
mapTreasureRow[i] = mapNewTreasureRow[i];
if(mapNewTreasureCol[i] < 0) continue;
if(mapNewTreasureCol[i] == MAP_W / 2 && mapNewTreasureRow[i] == pRow) continue;
VDP_setTileMapXY(BG_A, MAP_TREASURE_TILE, MAP_X + mapNewTreasureCol[i], MAP_Y + mapNewTreasureRow[i]);
}
// draw enemy dots (skip if player occupies same tile)
@ -174,12 +181,14 @@ static void updateMap(){
VDP_setTileMapXY(BG_A, MAP_PLAYER_TILE, MAP_X + MAP_W / 2, MAP_Y + pRow);
}
u8 phraseIndex[4];
s16 lastLevel;
static void drawLevel(){
char lvlStr[4];
uintToStr(level + 1, lvlStr, 1);
VDP_drawText("L", 1, 26);
VDP_drawText(lvlStr, 2, 26);
VDP_drawText("LVL", 1, 8);
VDP_drawText(lvlStr, 4, 8);
lastLevel = level;
}
@ -201,34 +210,36 @@ static void doGameOver(){
didGameOver = TRUE;
for(s16 i = 0; i < BULLET_COUNT; i++) if(bullets[i].active) SPR_setPalette(bullets[i].image, PAL1);
for(s16 i = 0; i < ENEMY_COUNT; i++) if(enemies[i].active) SPR_setPalette(enemies[i].image, PAL1);
for(s16 i = 0; i < HUMAN_COUNT; i++) if(humans[i].active){
if(humans[i].state == HUMAN_COLLECTED){
// spawn player bullet explosion at carried human position
for(s16 i = 0; i < TREASURE_COUNT; i++) if(treasures[i].active){
if(treasures[i].state == TREASURE_COLLECTED){
// spawn player bullet explosion at carried treasure position
struct bulletSpawner spawner = {
.x = humans[i].pos.x, .y = humans[i].pos.y,
.x = treasures[i].pos.x, .y = treasures[i].pos.y,
.anim = 0, .speed = 0, .angle = 0, .player = TRUE
};
void noop(s16 j){ (void)j; }
spawnBullet(spawner, noop);
for(s16 j = BULLET_COUNT - 1; j >= 0; j--){
if(bullets[j].active && !bullets[j].explosion
&& bullets[j].pos.x == humans[i].pos.x && bullets[j].pos.y == humans[i].pos.y){
&& bullets[j].pos.x == treasures[i].pos.x && bullets[j].pos.y == treasures[i].pos.y){
killBullet(j, TRUE);
break;
}
}
}
killHuman(i);
killTreasure(i);
}
SPR_releaseSprite(player.image);
// clear minimap
VDP_clearTileMapRect(BG_A, MAP_X, MAP_Y, MAP_W, MAP_H);
// clear score
VDP_clearTileMapRect(BG_A, SCORE_X, SCORE_Y, SCORE_LENGTH, 2);
// clear lives
VDP_clearTileMapRect(BG_A, LIVES_X, LIVES_Y, 1, 16);
// clear messages
treasureCollectedClock = 0;
allTreasureCollected = FALSE;
hitMessageClock = 0;
VDP_clearText(9, 5, 22);
VDP_drawText("GAME OVER", 15, 13);
VDP_drawText("PRESS ANY BUTTON", 12, 14);
}
@ -236,7 +247,7 @@ static void doGameOver(){
static void showPause(){
for(s16 i = 0; i < BULLET_COUNT; i++) if(bullets[i].active) SPR_setPalette(bullets[i].image, PAL1);
for(s16 i = 0; i < ENEMY_COUNT; i++) if(enemies[i].active) SPR_setPalette(enemies[i].image, PAL1);
for(s16 i = 0; i < HUMAN_COUNT; i++) if(humans[i].active) SPR_setPalette(humans[i].image, PAL1);
for(s16 i = 0; i < TREASURE_COUNT; i++) if(treasures[i].active) SPR_setPalette(treasures[i].image, PAL1);
SPR_setPalette(player.image, PAL1);
XGM2_pause();
VDP_drawText("PAUSE", 17, 13);
@ -245,7 +256,7 @@ static void showPause(){
static void clearPause(){
for(s16 i = 0; i < BULLET_COUNT; i++) if(bullets[i].active) SPR_setPalette(bullets[i].image, PAL0);
for(s16 i = 0; i < ENEMY_COUNT; i++) if(enemies[i].active) SPR_setPalette(enemies[i].image, PAL0);
for(s16 i = 0; i < HUMAN_COUNT; i++) if(humans[i].active) SPR_setPalette(humans[i].image, PAL0);
for(s16 i = 0; i < TREASURE_COUNT; i++) if(treasures[i].active) SPR_setPalette(treasures[i].image, PAL0);
SPR_setPalette(player.image, PAL0);
XGM2_resume();
VDP_clearText(17, 13, 5);
@ -307,5 +318,52 @@ void updateChrome(){
}
if(lastLives != player.lives) drawLives();
if(lastLevel != level) drawLevel();
if(treasureCollectedClock > 0 && levelWaitClock == 0){
if(treasureCollectedClock == 120){
VDP_clearText(10, 5, 22);
const char* mirrorPhrases[] = {"REFLECT THE DEPTHS", "DIG DEEPER WITHIN", "SEE WHAT SHINES BELOW", "MIRROR OF THE MINE", "LOOK BACK STRIKE BACK"};
const char* lampPhrases[] = {"STRIKE LIGHT", "LET THERE BE LODE", "BRIGHT IDEA DEEP DOWN", "ILLUMINATE THE VEIN", "GLOW FROM BELOW"};
const char* scarfPhrases[] = {"COZY IN THE CAVES", "WRAP THE UNDERWORLD", "SNUG AS BEDROCK", "STYLE FROM THE STRATA", "WARM THE DEPTHS"};
const char* swordPhrases[] = {"ORE YOU READY", "MINED YOUR STEP", "CUTTING EDGE GEOLOGY", "STRIKE THE VEIN", "SPIRIT STEEL"};
const char** sets[] = {mirrorPhrases, lampPhrases, scarfPhrases, swordPhrases};
const char* phrase = sets[treasureCollectedType][phraseIndex[treasureCollectedType]];
phraseIndex[treasureCollectedType] = (phraseIndex[treasureCollectedType] + 1) % 5;
u8 len = strlen(phrase);
VDP_drawText(phrase, 20 - len / 2, 5);
}
treasureCollectedClock--;
if(treasureCollectedClock == 0){
VDP_clearText(10, 5, 22);
// check if all treasures are collected or gone
bool allDone = TRUE;
for(s16 j = 0; j < TREASURE_COUNT; j++){
if(treasures[j].active && treasures[j].state != TREASURE_COLLECTED){
allDone = FALSE;
break;
}
}
if(allDone && collectedCount > 0){
allTreasureCollected = TRUE;
VDP_drawText("ALL TREASURE COLLECTED", 9, 5);
}
}
}
if(hitMessageClock > 0){
if(hitMessageClock == 120){
VDP_clearText(9, 5, 22);
treasureCollectedClock = 0;
allTreasureCollected = FALSE;
VDP_drawText(hitMessageBullet ? "BLASTED" : "SMASHED", hitMessageBullet ? 16 : 16, 5);
}
hitMessageClock--;
if(hitMessageClock == 0)
VDP_clearText(9, 5, 22);
}
if(levelWaitClock == 240){
VDP_clearText(9, 5, 22);
treasureCollectedClock = 0;
allTreasureCollected = FALSE;
VDP_drawText("ALL ENEMIES DESTROYED", 9, 5);
}
if(clock % 4 == 0) updateMap();
}