diff --git a/main/modes/games/pango/paEntity.c b/main/modes/games/pango/paEntity.c index 10ef0bc9a..5b4082b98 100644 --- a/main/modes/games/pango/paEntity.c +++ b/main/modes/games/pango/paEntity.c @@ -94,13 +94,13 @@ void pa_updatePlayer(paEntity_t* self) self->xspeed = -16; } - //Make the player face in the most recent direction pressed + // Make the player face in the most recent direction pressed if (!(self->gameData->prevBtnState & PB_LEFT)) { self->facingDirection = PA_DIRECTION_WEST; } } - + if (self->gameData->btnState & PB_RIGHT) { self->xspeed += 4; @@ -110,7 +110,7 @@ void pa_updatePlayer(paEntity_t* self) self->xspeed = 16; } - //Make the player face in the most recent direction pressed + // Make the player face in the most recent direction pressed if (!(self->gameData->prevBtnState & PB_RIGHT)) { self->facingDirection = PA_DIRECTION_EAST; @@ -126,13 +126,13 @@ void pa_updatePlayer(paEntity_t* self) self->yspeed = -16; } - //Make the player face in the most recent direction pressed + // Make the player face in the most recent direction pressed if (!(self->gameData->prevBtnState & PB_UP)) { self->facingDirection = PA_DIRECTION_NORTH; } } - + if (self->gameData->btnState & PB_DOWN) { self->yspeed += 4; @@ -142,14 +142,14 @@ void pa_updatePlayer(paEntity_t* self) self->yspeed = 16; } - //Make the player face in the most recent direction pressed + // Make the player face in the most recent direction pressed if (!(self->gameData->prevBtnState & PB_DOWN)) { self->facingDirection = PA_DIRECTION_SOUTH; } } - //Fix the player's facing direction if: + // Fix the player's facing direction if: //- the player has let go of the most recent direction held //- the player is pressing opposite directions self->facingDirection = pa_correctPlayerFacingDirection(self->gameData->btnState, self->facingDirection); @@ -163,7 +163,7 @@ void pa_updatePlayer(paEntity_t* self) { self->gameData->changeState = PA_ST_PAUSE; } - + switch (self->facingDirection) { case PA_DIRECTION_WEST: @@ -269,10 +269,10 @@ void pa_updatePlayer(paEntity_t* self) uint16_t pa_correctPlayerFacingDirection(int16_t btnState, uint16_t currentFacingDirection) { - //Mask out button bits that do not correspond to directional buttons + // Mask out button bits that do not correspond to directional buttons int16_t directionBtnState = btnState & 0b1111; - - switch(directionBtnState) + + switch (directionBtnState) { case PA_DIRECTION_NORTH: case PA_DIRECTION_SOUTH: @@ -753,8 +753,10 @@ void updateCrabdozer(paEntity_t* self) } } -int16_t pa_enemySetAggroStateTimer(paEntity_t* self){ - return (self->gameData->minAggroTime + esp_random() % (self->gameData->maxAggroTime - self->gameData->minAggroTime)); +int16_t pa_enemySetAggroStateTimer(paEntity_t* self) +{ + return (self->gameData->minAggroTime + + esp_random() % (self->gameData->maxAggroTime - self->gameData->minAggroTime)); } void pa_enemyChangeDirection(paEntity_t* self, uint16_t newDirection, int16_t speed) @@ -974,7 +976,6 @@ void pa_moveEntityWithTileCollisions(paEntity_t* self) << SUBPIXEL_RESOLUTION; } } - } } } @@ -1079,7 +1080,8 @@ void pa_destroyEntity(paEntity_t* self, bool respawn) void animatePlayer(paEntity_t* self) { - switch(self->facingDirection){ + switch (self->facingDirection) + { case PA_DIRECTION_NORTH: if ((self->gameData->btnState & PB_UP) && self->yspeed < 0) { @@ -1165,8 +1167,8 @@ void pa_playerCollisionHandler(paEntity_t* self, paEntity_t* other) } else { - self->xspeed = 0; - self->yspeed = 0; + self->xspeed = 0; + self->yspeed = 0; soundPlaySfx(&(self->soundManager->sndHurt), BZR_LEFT); } } @@ -1229,8 +1231,10 @@ void pa_enemyCollisionHandler(paEntity_t* self, paEntity_t* other) pa_scorePoints(self->gameData, pointsScored); other->scoreValue++; - paEntity_t* createdEntity = pa_createScoreDisplay(self->entityManager, (self->x >> SUBPIXEL_RESOLUTION) - 4, (self->y >> SUBPIXEL_RESOLUTION) - 4); - if(createdEntity != NULL){ + paEntity_t* createdEntity = pa_createScoreDisplay(self->entityManager, (self->x >> SUBPIXEL_RESOLUTION) - 4, + (self->y >> SUBPIXEL_RESOLUTION) - 4); + if (createdEntity != NULL) + { createdEntity->scoreValue = pointsScored; } @@ -1385,18 +1389,22 @@ bool pa_hitBlockTileCollisionHandler(paEntity_t* self, uint8_t tileId, uint8_t t if (pa_isSolid(tileId)) { soundPlaySfx(&(self->soundManager->sndHit), 1); - + self->tilemap->map[PA_TO_TILECOORDS(self->y >> SUBPIXEL_RESOLUTION) * self->tilemap->mapWidth - + PA_TO_TILECOORDS(self->x >> SUBPIXEL_RESOLUTION)] - = self->state; - + + PA_TO_TILECOORDS(self->x >> SUBPIXEL_RESOLUTION)] + = self->state; + if (PA_TO_TILECOORDS(self->x >> SUBPIXEL_RESOLUTION) == self->homeTileX && PA_TO_TILECOORDS(self->y >> SUBPIXEL_RESOLUTION) == self->homeTileY) { - if(self->state == PA_TILE_SPAWN_BLOCK_0){ + if (self->state == PA_TILE_SPAWN_BLOCK_0) + { pa_executeSpawnBlockCombo(self, self->homeTileX, self->homeTileY, 0); - } else { - pa_createBreakBlock(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); + } + else + { + pa_createBreakBlock(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, + self->y >> SUBPIXEL_RESOLUTION); pa_scorePoints(self->gameData, 10); } } @@ -1408,26 +1416,32 @@ bool pa_hitBlockTileCollisionHandler(paEntity_t* self, uint8_t tileId, uint8_t t return false; } -void pa_executeSpawnBlockCombo(paEntity_t* self, uint8_t tx, uint8_t ty, uint16_t scoreIndex){ +void pa_executeSpawnBlockCombo(paEntity_t* self, uint8_t tx, uint8_t ty, uint16_t scoreIndex) +{ uint8_t t = pa_getTile(self->tilemap, tx, ty); paEntity_t* newEntity; - switch(t){ + switch (t) + { case PA_TILE_SPAWN_BLOCK_0: - newEntity = pa_createBreakBlock(self->entityManager, (tx << PA_TILE_SIZE_IN_POWERS_OF_2) + PA_HALF_TILE_SIZE, (ty << PA_TILE_SIZE_IN_POWERS_OF_2) + PA_HALF_TILE_SIZE); - if(newEntity == NULL) { + newEntity + = pa_createBreakBlock(self->entityManager, (tx << PA_TILE_SIZE_IN_POWERS_OF_2) + PA_HALF_TILE_SIZE, + (ty << PA_TILE_SIZE_IN_POWERS_OF_2) + PA_HALF_TILE_SIZE); + if (newEntity == NULL) + { pa_setTile(self->tilemap, tx, ty, PA_TILE_EMPTY); pa_scorePoints(self->gameData, spawnBlockComboScores[self->scoreValue]); self->entityManager->gameData->remainingEnemies--; - } else { - newEntity->state = PA_TILE_SPAWN_BLOCK_0; + } + else + { + newEntity->state = PA_TILE_SPAWN_BLOCK_0; newEntity->scoreValue = scoreIndex; } break; default: break; } - } void dieWhenFallingOffScreen(paEntity_t* self) @@ -1458,34 +1472,41 @@ void pa_updateBreakBlock(paEntity_t* self) uint8_t ty = (self->y >> SUBPIXEL_RESOLUTION >> PA_TILE_SIZE_IN_POWERS_OF_2); uint16_t pointsScored; - switch(self->state){ + switch (self->state) + { case PA_TILE_SPAWN_BLOCK_0: pointsScored = spawnBlockComboScores[self->scoreValue]; pa_scorePoints(self->gameData, pointsScored); soundPlaySfx(&(self->soundManager->sndCoin), BZR_STEREO); self->entityManager->gameData->remainingEnemies--; - - pa_executeSpawnBlockCombo(self, tx+1, ty, self->scoreValue+1); - pa_executeSpawnBlockCombo(self, tx-1, ty, self->scoreValue+1); - pa_executeSpawnBlockCombo(self, tx, ty+1, self->scoreValue+1); - pa_executeSpawnBlockCombo(self, tx, ty-1, self->scoreValue+1); - - paEntity_t* createdEntity = pa_createScoreDisplay(self->entityManager, (self->x >> SUBPIXEL_RESOLUTION) - 4, (self->y >> SUBPIXEL_RESOLUTION) - 4); - if(createdEntity != NULL){ + + pa_executeSpawnBlockCombo(self, tx + 1, ty, self->scoreValue + 1); + pa_executeSpawnBlockCombo(self, tx - 1, ty, self->scoreValue + 1); + pa_executeSpawnBlockCombo(self, tx, ty + 1, self->scoreValue + 1); + pa_executeSpawnBlockCombo(self, tx, ty - 1, self->scoreValue + 1); + + paEntity_t* createdEntity + = pa_createScoreDisplay(self->entityManager, (self->x >> SUBPIXEL_RESOLUTION) - 4, + (self->y >> SUBPIXEL_RESOLUTION) - 4); + if (createdEntity != NULL) + { createdEntity->scoreValue = pointsScored; } break; default: - pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); - pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); - pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); - pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); + pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, + self->y >> SUBPIXEL_RESOLUTION); + pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, + self->y >> SUBPIXEL_RESOLUTION); + pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, + self->y >> SUBPIXEL_RESOLUTION); + pa_createBlockFragment(self->entityManager, self->x >> SUBPIXEL_RESOLUTION, + self->y >> SUBPIXEL_RESOLUTION); break; } - - + pa_destroyEntity(self, false); } } @@ -1493,7 +1514,8 @@ void pa_updateBreakBlock(paEntity_t* self) /*if(self->scoreValue > 0){ char scoreStr[32]; snprintf(scoreStr, sizeof(scoreStr) - 1, "+%" PRIu32, self->scoreValue); - drawText(&(self->gameData->scoreFont), c050, scoreStr, self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); + drawText(&(self->gameData->scoreFont), c050, scoreStr, self->x >> SUBPIXEL_RESOLUTION, self->y >> + SUBPIXEL_RESOLUTION); }*/ } @@ -1506,10 +1528,12 @@ void updateEntityDead(paEntity_t* self) despawnWhenOffscreen(self); } -void pa_updateScoreDisplay(paEntity_t* self){ +void pa_updateScoreDisplay(paEntity_t* self) +{ self->stateTimer++; - if(self->stateTimer > 120){ + if (self->stateTimer > 120) + { pa_destroyEntity(self, false); } } @@ -1615,18 +1639,20 @@ void drawEntityTargetTile(paEntity_t* self) (self->targetTileY << PA_TILE_SIZE_IN_POWERS_OF_2) + PA_TILE_SIZE, esp_random() % 216); } -void pa_defaultEntityDrawHandler(paEntity_t* self){ +void pa_defaultEntityDrawHandler(paEntity_t* self) +{ drawWsg(self->entityManager->wsgManager->sprites[self->spriteIndex].wsg, - (self->x >> SUBPIXEL_RESOLUTION) - - self->entityManager->wsgManager->sprites[self->spriteIndex].originX - - self->entityManager->tilemap->mapOffsetX, - (self->y >> SUBPIXEL_RESOLUTION) - self->entityManager->tilemap->mapOffsetY - - self->entityManager->wsgManager->sprites[self->spriteIndex].originY, - self->spriteFlipHorizontal, self->spriteFlipVertical, 0); + (self->x >> SUBPIXEL_RESOLUTION) - self->entityManager->wsgManager->sprites[self->spriteIndex].originX + - self->entityManager->tilemap->mapOffsetX, + (self->y >> SUBPIXEL_RESOLUTION) - self->entityManager->tilemap->mapOffsetY + - self->entityManager->wsgManager->sprites[self->spriteIndex].originY, + self->spriteFlipHorizontal, self->spriteFlipVertical, 0); } -void pa_scoreDisplayDrawHandler(paEntity_t* self){ +void pa_scoreDisplayDrawHandler(paEntity_t* self) +{ char scoreStr[32]; snprintf(scoreStr, sizeof(scoreStr) - 1, "+%" PRIu16, self->scoreValue); - drawText(&(self->gameData->scoreFont), greenColors[(self->stateTimer >> 3) % 4], scoreStr, self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); + drawText(&(self->gameData->scoreFont), greenColors[(self->stateTimer >> 3) % 4], scoreStr, + self->x >> SUBPIXEL_RESOLUTION, self->y >> SUBPIXEL_RESOLUTION); } \ No newline at end of file diff --git a/main/modes/games/pango/paEntity.h b/main/modes/games/pango/paEntity.h index c197cc794..f797886bf 100644 --- a/main/modes/games/pango/paEntity.h +++ b/main/modes/games/pango/paEntity.h @@ -66,7 +66,7 @@ typedef enum typedef void (*pa_updateFunction_t)(struct paEntity_t* self); typedef void (*pa_collisionHandler_t)(struct paEntity_t* self, struct paEntity_t* other); typedef bool (*pa_tileCollisionHandler_t)(struct paEntity_t* self, uint8_t tileId, uint8_t tx, uint8_t ty, - uint8_t direction); + uint8_t direction); typedef void (*pa_fallOffTileHandler_t)(struct paEntity_t* self); typedef void (*pa_overlapTileHandler_t)(struct paEntity_t* self, uint8_t tileId, uint8_t tx, uint8_t ty); typedef void (*pa_drawHandler_t)(struct paEntity_t* self); diff --git a/main/modes/games/pango/paEntityManager.c b/main/modes/games/pango/paEntityManager.c index 05e4d7206..924013946 100644 --- a/main/modes/games/pango/paEntityManager.c +++ b/main/modes/games/pango/paEntityManager.c @@ -74,7 +74,7 @@ void pa_deactivateAllEntities(paEntityManager_t* entityManager, bool excludePlay continue; } - currentEntity->active = false; + currentEntity->active = false; if (currentEntity->type == ENTITY_HIT_BLOCK && currentEntity->state == PA_TILE_SPAWN_BLOCK_0) { @@ -368,7 +368,8 @@ paEntity_t* createHitBlock(paEntityManager_t* entityManager, uint16_t x, uint16_ return entity; } -paEntity_t* pa_createScoreDisplay(paEntityManager_t* entityManager, uint16_t x, uint16_t y){ +paEntity_t* pa_createScoreDisplay(paEntityManager_t* entityManager, uint16_t x, uint16_t y) +{ paEntity_t* entity = pa_findInactiveEntity(entityManager); if (entity == NULL) @@ -376,10 +377,10 @@ paEntity_t* pa_createScoreDisplay(paEntityManager_t* entityManager, uint16_t x, return NULL; } - entity->active = true; - entity->visible = true; - entity->x = x << SUBPIXEL_RESOLUTION; - entity->y = y << SUBPIXEL_RESOLUTION; + entity->active = true; + entity->visible = true; + entity->x = x << SUBPIXEL_RESOLUTION; + entity->y = y << SUBPIXEL_RESOLUTION; entity->xspeed = 0; entity->yspeed = 0; diff --git a/main/modes/games/pango/paGameData.c b/main/modes/games/pango/paGameData.c index a9fb10820..2ceef223a 100644 --- a/main/modes/games/pango/paGameData.c +++ b/main/modes/games/pango/paGameData.c @@ -15,40 +15,40 @@ //============================================================================== void pa_initializeGameData(paGameData_t* gameData, paSoundManager_t* soundManager) { - gameData->gameState = 0; - gameData->btnState = 0; - gameData->score = 0; - gameData->extraLifeScore = 10000; - gameData->lives = 3; - gameData->levelTime = 000; - gameData->level = 1; - gameData->frameCount = 0; - gameData->bgColor = c000; - gameData->initials[0] = 'A'; - gameData->initials[1] = 'A'; - gameData->initials[2] = 'A'; - gameData->rank = 5; - gameData->debugMode = false; - gameData->continuesUsed = false; - gameData->inGameTimer = 0; - gameData->soundManager = soundManager; - gameData->playerCharacter = PA_PLAYER_CHARACTER_PANGO; + gameData->gameState = 0; + gameData->btnState = 0; + gameData->score = 0; + gameData->extraLifeScore = 10000; + gameData->lives = 3; + gameData->levelTime = 000; + gameData->level = 1; + gameData->frameCount = 0; + gameData->bgColor = c000; + gameData->initials[0] = 'A'; + gameData->initials[1] = 'A'; + gameData->initials[2] = 'A'; + gameData->rank = 5; + gameData->debugMode = false; + gameData->continuesUsed = false; + gameData->inGameTimer = 0; + gameData->soundManager = soundManager; + gameData->playerCharacter = PA_PLAYER_CHARACTER_PANGO; } void pa_initializeGameDataFromTitleScreen(paGameData_t* gameData, uint16_t levelIndex) { - gameData->gameState = 0; - gameData->btnState = 0; - gameData->score = 0; - gameData->extraLifeScore = 10000; - gameData->lives = 3; - gameData->levelTime = 000; - gameData->frameCount = 0; - gameData->bgColor = c000; - gameData->currentBgm = 0; - gameData->changeBgm = 0; - gameData->continuesUsed = (gameData->level == 1) ? false : true; - gameData->inGameTimer = 0; + gameData->gameState = 0; + gameData->btnState = 0; + gameData->score = 0; + gameData->extraLifeScore = 10000; + gameData->lives = 3; + gameData->levelTime = 000; + gameData->frameCount = 0; + gameData->bgColor = c000; + gameData->currentBgm = 0; + gameData->changeBgm = 0; + gameData->continuesUsed = (gameData->level == 1) ? false : true; + gameData->inGameTimer = 0; pa_resetGameDataLeds(gameData); } diff --git a/main/modes/games/pango/paGameData.h b/main/modes/games/pango/paGameData.h index 30da2a647..2e2a26d18 100644 --- a/main/modes/games/pango/paGameData.h +++ b/main/modes/games/pango/paGameData.h @@ -77,5 +77,4 @@ void pa_updateLedsLevelClear(paGameData_t* gameData); void pa_updateLedsGameClear(paGameData_t* gameData); void pa_updateLedsGameOver(paGameData_t* gameData); - #endif \ No newline at end of file diff --git a/main/modes/games/pango/paTilemap.c b/main/modes/games/pango/paTilemap.c index 2a112ceaa..7667c22d6 100644 --- a/main/modes/games/pango/paTilemap.c +++ b/main/modes/games/pango/paTilemap.c @@ -238,10 +238,10 @@ void pa_unlockScrolling(paTilemap_t* tilemap) bool pa_needsTransparency(uint8_t tileId) { - //TODO - //Currently, all tiles need transparency. - //So get rid of this then? - + // TODO + // Currently, all tiles need transparency. + // So get rid of this then? + switch (tileId) { /*case PA_TILE_BOUNCE_BLOCK: diff --git a/main/modes/games/pango/paWsgManager.c b/main/modes/games/pango/paWsgManager.c index 3ba9cf702..f6a98fa5a 100644 --- a/main/modes/games/pango/paWsgManager.c +++ b/main/modes/games/pango/paWsgManager.c @@ -300,7 +300,7 @@ void pa_animateTiles(paWsgManager_t* self) self->globalTileAnimationTimer--; if (self->globalTileAnimationTimer < 0) { - //Assumption: all animated tiles have 6 frames of animation + // Assumption: all animated tiles have 6 frames of animation self->globalTileAnimationFrame = ((self->globalTileAnimationFrame + 1) % 6); pa_remapWsgToTile(self, 9, PA_WSG_BLOCK_BLUE + self->globalTileAnimationFrame); @@ -309,7 +309,8 @@ void pa_animateTiles(paWsgManager_t* self) } } -void pa_remapBlockTile(paWsgManager_t *self, uint16_t newBlockWsgIndex){ +void pa_remapBlockTile(paWsgManager_t* self, uint16_t newBlockWsgIndex) +{ pa_remapWsgToTile(self, 8, newBlockWsgIndex); pa_remapWsgToSprite(self, PA_SP_BLOCK, newBlockWsgIndex); } \ No newline at end of file diff --git a/main/modes/games/pango/paWsgManager.h b/main/modes/games/pango/paWsgManager.h index c8272d94b..45d3fc638 100644 --- a/main/modes/games/pango/paWsgManager.h +++ b/main/modes/games/pango/paWsgManager.h @@ -21,7 +21,6 @@ // Enums //============================================================================== - //============================================================================== // Structs //============================================================================== @@ -50,6 +49,6 @@ void pa_remapWsgToTile(paWsgManager_t* self, uint16_t tileIndex, uint16_t wsgInd void pa_remapPlayerCharacter(paWsgManager_t* self, uint16_t newBaseIndex); void pa_animateTiles(paWsgManager_t* self); -void pa_remapBlockTile(paWsgManager_t *self, uint16_t newBlockWsgIndex); +void pa_remapBlockTile(paWsgManager_t* self, uint16_t newBlockWsgIndex); #endif \ No newline at end of file diff --git a/main/modes/games/pango/pango.c b/main/modes/games/pango/pango.c index 6d359664b..10f9c4f15 100644 --- a/main/modes/games/pango/pango.c +++ b/main/modes/games/pango/pango.c @@ -47,18 +47,19 @@ const char pangoName[] = "Pango"; static const paletteColor_t highScoreNewEntryColors[4] = {c050, c055, c005, c055}; static const paletteColor_t redColors[4] = {c501, c540, c550, c540}; -static const paletteColor_t tsRedColors[4] = {c535, c534, c514, c534}; +static const paletteColor_t tsRedColors[4] = {c535, c534, c514, c534}; static const paletteColor_t yellowColors[4] = {c550, c331, c550, c555}; static const paletteColor_t cyanColors[4] = {c055, c455, c055, c033}; static const paletteColor_t purpleColors[4] = {c213, c535, c555, c535}; -//static const paletteColor_t rgbColors[4] = {c500, c050, c005, c050}; +// static const paletteColor_t rgbColors[4] = {c500, c050, c005, c050}; static const int16_t cheatCode[11] = {PB_UP, PB_UP, PB_DOWN, PB_DOWN, PB_LEFT, PB_RIGHT, PB_LEFT, PB_RIGHT, PB_B, PB_A, PB_START}; -const char* characterSelectOptions[] = {"Pango", "Po", "Pixel", "Polly"}; -const int32_t characterSelectOptionValues[] = {PA_PLAYER_CHARACTER_PANGO, PA_PLAYER_CHARACTER_PO, PA_PLAYER_CHARACTER_PIXEL, PA_PLAYER_CHARACTER_GIRL}; +const char* characterSelectOptions[] = {"Pango", "Po", "Pixel", "Polly"}; +const int32_t characterSelectOptionValues[] + = {PA_PLAYER_CHARACTER_PANGO, PA_PLAYER_CHARACTER_PO, PA_PLAYER_CHARACTER_PIXEL, PA_PLAYER_CHARACTER_GIRL}; #define NUM_CHARACTERS 4 //============================================================================== @@ -138,7 +139,8 @@ void loadPangoUnlockables(pango_t* self); void pangoSaveUnlockables(pango_t* self); void drawPangoHighScores(font_t* font, pangoHighScores_t* highScores, paGameData_t* gameData); uint8_t getHighScoreRank(pangoHighScores_t* highScores, uint32_t newScore); -void insertScoreIntoHighScores(pangoHighScores_t* highScores, uint32_t newScore, char newInitials[], uint8_t newCharacter, uint8_t rank); +void insertScoreIntoHighScores(pangoHighScores_t* highScores, uint32_t newScore, char newInitials[], + uint8_t newCharacter, uint8_t rank); void changeStateNameEntry(pango_t* self); void updateNameEntry(pango_t* self, int64_t elapsedUs); void drawNameEntry(font_t* font, paGameData_t* gameData, uint8_t currentInitial); @@ -231,12 +233,12 @@ void pangoEnterMode(void) loadFont("pango-fw.font", &pango->font, false); pango->menuRenderer = initMenuManiaRenderer(&pango->font, &pango->font, &pango->font); - led_t ledColor = {.r = 0xf0, .g = 0xf0, .b = 0x00}; - recolorMenuManiaRenderer(pango->menuRenderer, // - c200, c555, c555, // Title colors (bg, text, outline) - c000, // Background - c110, c100, // Rings - c003, c555, // Rows + led_t ledColor = {.r = 0xf0, .g = 0xf0, .b = 0x00}; + recolorMenuManiaRenderer(pango->menuRenderer, // + c200, c555, c555, // Title colors (bg, text, outline) + c000, // Background + c110, c100, // Rings + c003, c555, // Rows highScoreNewEntryColors, ARRAY_SIZE(highScoreNewEntryColors), ledColor); setManiaLedsOn(pango->menuRenderer, true); @@ -359,7 +361,8 @@ static void pangoMenuCb(const char* label, bool selected, uint32_t settingVal) } else { - if (label == pangoMenuCharacter){ + if (label == pangoMenuCharacter) + { pango->gameData.playerCharacter = settingVal; pa_remapPlayerCharacter(&(pango->wsgManager), 16 * settingVal); } @@ -434,7 +437,8 @@ void pangoBuildMainMenu(pango_t* self) .max = 3, .key = NULL, }; - addSettingsOptionsItemToMenu(pango->menu, pangoMenuCharacter, characterSelectOptions, characterSelectOptionValues, NUM_CHARACTERS, &characterSettingBounds, pango->gameData.playerCharacter); + addSettingsOptionsItemToMenu(pango->menu, pangoMenuCharacter, characterSelectOptions, characterSelectOptionValues, + NUM_CHARACTERS, &characterSettingBounds, pango->gameData.playerCharacter); addSingleItemToMenu(pango->menu, pangoMenuHighScores); @@ -493,7 +497,6 @@ void updateGame(pango_t* self, int64_t elapsedUs) pa_spawnEnemyFromSpawnBlock(&(self->entityManager)); } - } void drawPangoHud(font_t* font, paGameData_t* gameData) @@ -519,12 +522,13 @@ void drawPangoHud(font_t* font, paGameData_t* gameData) snprintf(scoreStr, sizeof(scoreStr) - 1, "HI%7.6" PRIu32, pango->highScores.scores[0]); drawText(font, c553, scoreStr, 157, 2); - for(uint8_t i=0; i < gameData->lives; i++){ + for (uint8_t i = 0; i < gameData->lives; i++) + { drawWsgSimple(pango->wsgManager.sprites[PA_SP_PLAYER_ICON].wsg, 32 + i * 16, 224); } drawText(font, c553, levelStr, 145, 226); - drawText(font, c553, timeStr, 200, 226); + drawText(font, c553, timeStr, 200, 226); } void updateTitleScreen(pango_t* self, int64_t elapsedUs) @@ -579,8 +583,10 @@ void updateTitleScreen(pango_t* self, int64_t elapsedUs) { for (int32_t i = 0; i < CONFIG_NUM_LEDS; i++) { - if( !(esp_random() % 8) ) { - switch(esp_random() % 3){ + if (!(esp_random() % 8)) + { + switch (esp_random() % 3) + { case 0: default: paLeds[i].r = 255; @@ -600,13 +606,16 @@ void updateTitleScreen(pango_t* self, int64_t elapsedUs) } } - if(paLeds[i].r >= 16){ + if (paLeds[i].r >= 16) + { paLeds[i].r -= 16; } - if(paLeds[i].g >= 16){ + if (paLeds[i].g >= 16) + { paLeds[i].g -= 16; } - if(paLeds[i].b >= 16) { + if (paLeds[i].b >= 16) + { paLeds[i].b -= 16; } } @@ -638,14 +647,15 @@ void drawPangoTitleScreen(font_t* font, paGameData_t* gameData) { drawText(font, c555, "- Press START button -", 20, 208); } - } -void drawPangoLogo(font_t* font, int16_t x, int16_t y){ - drawTriangleOutlined(x, y+23, x+63, y, x+71, y+47, c003, cyanColors[(pango->gameData.frameCount >> 2) % 4]); - drawTriangleOutlined(x, y, x+79, y+15, x+23, y+47, c220, yellowColors[(pango->gameData.frameCount >> 3) % 4]); - drawText(font, c500, "PANGO", x+12, y+16); - drawText(font, tsRedColors[(pango->gameData.frameCount >> 4) % 4], "PANGO", x+11, y+15); +void drawPangoLogo(font_t* font, int16_t x, int16_t y) +{ + drawTriangleOutlined(x, y + 23, x + 63, y, x + 71, y + 47, c003, cyanColors[(pango->gameData.frameCount >> 2) % 4]); + drawTriangleOutlined(x, y, x + 79, y + 15, x + 23, y + 47, c220, + yellowColors[(pango->gameData.frameCount >> 3) % 4]); + drawText(font, c500, "PANGO", x + 12, y + 16); + drawText(font, tsRedColors[(pango->gameData.frameCount >> 4) % 4], "PANGO", x + 11, y + 15); } void changeStateReadyScreen(pango_t* self) @@ -935,12 +945,12 @@ void changeStateTitleScreen(pango_t* self) self->gameData.frameCount = 0; self->gameData.gameState = PA_ST_TITLE_SCREEN; pa_remapBlockTile(&(pango->wsgManager), PA_WSG_BLOCK_TITLESCREEN); - self->update = &updateTitleScreen; + self->update = &updateTitleScreen; } void changeStateLevelClear(pango_t* self) { - self->gameData.frameCount = 0; + self->gameData.frameCount = 0; pa_resetGameDataLeds(&(self->gameData)); self->gameData.bonusScore = pa_getLevelClearBonus(self->gameData.levelTime); @@ -954,7 +964,8 @@ void updateLevelClear(pango_t* self, int64_t elapsedUs) if (self->gameData.frameCount > 100) { - if(self->gameData.bonusScore > 0){ + if (self->gameData.bonusScore > 0) + { pa_scorePoints(&(pango->gameData), 100); self->gameData.bonusScore -= 100; soundPlaySfx(&(self->soundManager.sndTally), 0); @@ -962,7 +973,7 @@ void updateLevelClear(pango_t* self, int64_t elapsedUs) else if (self->gameData.frameCount % 120 == 0) { // Hey look, it's a frame rule! - self->gameData.levelTime = 0; + self->gameData.levelTime = 0; if (self->gameData.level >= MASTER_DIFFICULTY_TABLE_LENGTH) { @@ -1031,7 +1042,7 @@ void updateLevelClear(pango_t* self, int64_t elapsedUs) } pa_updateEntities(&(self->entityManager)); - //pa_drawTileMap(&(self->tilemap)); + // pa_drawTileMap(&(self->tilemap)); pa_drawEntities(&(self->entityManager)); drawPangoHud(&(self->font), &(self->gameData)); drawLevelClear(&(self->font), &(self->gameData)); @@ -1044,13 +1055,31 @@ void drawLevelClear(font_t* font, paGameData_t* gameData) drawText(font, c000, str_well_done, (TFT_WIDTH - textWidth(font, str_well_done) + 1) >> 1, 48); drawText(font, c553, str_well_done, (TFT_WIDTH - textWidth(font, str_well_done)) >> 1, 48); - if(gameData->frameCount > 30) { + if (gameData->frameCount > 30) + { drawText(font, c555, "Time Bonus", 80, 80); - drawText(font, (gameData->levelTime < 20) ? yellowColors[(pango->gameData.frameCount >> 3) % 4] : c555, "00 - 19s ... 5000", 44, 100); - drawText(font, (gameData->levelTime >=20 && gameData->levelTime < 30) ? greenColors[(pango->gameData.frameCount >> 3) % 4] : c555, "20 - 29s ... 2000", 44, 112); - drawText(font, (gameData->levelTime >=30 && gameData->levelTime < 40) ? cyanColors[(pango->gameData.frameCount >> 3) % 4] : c555, "30 - 39s ... 1000", 44, 124); - drawText(font, (gameData->levelTime >=40 && gameData->levelTime < 50) ? purpleColors[(pango->gameData.frameCount >> 3) % 4] : c555, "40 - 49s ... 500", 44, 136); - drawText(font, (gameData->levelTime >=50 && gameData->levelTime < 60) ? redColors[(pango->gameData.frameCount >> 3) % 4] : c555, "50 - 59s ... 100", 44, 148); + drawText(font, (gameData->levelTime < 20) ? yellowColors[(pango->gameData.frameCount >> 3) % 4] : c555, + "00 - 19s ... 5000", 44, 100); + drawText(font, + (gameData->levelTime >= 20 && gameData->levelTime < 30) + ? greenColors[(pango->gameData.frameCount >> 3) % 4] + : c555, + "20 - 29s ... 2000", 44, 112); + drawText(font, + (gameData->levelTime >= 30 && gameData->levelTime < 40) + ? cyanColors[(pango->gameData.frameCount >> 3) % 4] + : c555, + "30 - 39s ... 1000", 44, 124); + drawText(font, + (gameData->levelTime >= 40 && gameData->levelTime < 50) + ? purpleColors[(pango->gameData.frameCount >> 3) % 4] + : c555, + "40 - 49s ... 500", 44, 136); + drawText(font, + (gameData->levelTime >= 50 && gameData->levelTime < 60) + ? redColors[(pango->gameData.frameCount >> 3) % 4] + : c555, + "50 - 59s ... 100", 44, 148); drawText(font, (gameData->levelTime > 59) ? c500 : c555, ">59s ....... None", 44, 160); } } @@ -1225,7 +1254,8 @@ uint8_t getHighScoreRank(pangoHighScores_t* highScores, uint32_t newScore) return i; } -void insertScoreIntoHighScores(pangoHighScores_t* highScores, uint32_t newScore, char newInitials[], uint8_t newCharacter, uint8_t rank) +void insertScoreIntoHighScores(pangoHighScores_t* highScores, uint32_t newScore, char newInitials[], + uint8_t newCharacter, uint8_t rank) { if (rank >= NUM_PLATFORMER_HIGH_SCORES) { @@ -1245,7 +1275,7 @@ void insertScoreIntoHighScores(pangoHighScores_t* highScores, uint32_t newScore, highScores->initials[rank][0] = newInitials[0]; highScores->initials[rank][1] = newInitials[1]; highScores->initials[rank][2] = newInitials[2]; - highScores->character[rank] = newCharacter; + highScores->character[rank] = newCharacter; } void changeStateNameEntry(pango_t* self) @@ -1317,8 +1347,8 @@ void updateNameEntry(pango_t* self, int64_t elapsedUs) if (self->menuState > 2) { - insertScoreIntoHighScores(&(self->highScores), self->gameData.score, self->gameData.initials, self->gameData.playerCharacter, - self->gameData.rank); + insertScoreIntoHighScores(&(self->highScores), self->gameData.score, self->gameData.initials, + self->gameData.playerCharacter, self->gameData.rank); pangoSaveHighScores(self); pangoChangeStateShowHighScores(self); soundPlaySfx(&(self->soundManager.sndPowerUp), BZR_STEREO); @@ -1426,7 +1456,8 @@ void drawPause(font_t* font) uint16_t pa_getLevelClearBonus(int16_t elapsedTime) { - switch(elapsedTime){ + switch (elapsedTime) + { case 0 ... 19: return 5000; case 20 ... 29: @@ -1445,19 +1476,21 @@ uint16_t pa_getLevelClearBonus(int16_t elapsedTime) void pa_setDifficultyLevel(paWsgManager_t* wsgManager, paGameData_t* gameData, uint16_t levelIndex) { gameData->remainingEnemies - = masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + TOTAL_ENEMIES_LOOKUP_OFFSET]; + = masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + TOTAL_ENEMIES_LOOKUP_OFFSET]; gameData->maxActiveEnemies - = masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + MAX_ACTIVE_ENEMIES_LOOKUP_OFFSET]; + = masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + MAX_ACTIVE_ENEMIES_LOOKUP_OFFSET]; gameData->enemyInitialSpeed - = masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + ENEMY_INITIAL_SPEED_LOOKUP_OFFSET]; - gameData->minAggroTime - = masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + ENEMY_MINIMUM_AGGRESSIVE_TIME_LOOKUP_OFFSET]; - gameData->maxAggroTime - = masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + ENEMY_MAXIMUM_AGGRESSIVE_TIME_LOOKUP_OFFSET]; - gameData->minAggroEnemies - = masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + ENEMY_MINIMUM_AGGRESSIVE_COUNT_LOOKUP_OFFSET]; - gameData->maxAggroEnemies - = masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + ENEMY_MAXIMUM_AGGRESSIVE_COUNT_LOOKUP_OFFSET]; - - pa_remapBlockTile(wsgManager, masterDifficulty[((levelIndex-1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + BLOCK_WSG_LOOKUP_OFFSET]); + = masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + ENEMY_INITIAL_SPEED_LOOKUP_OFFSET]; + gameData->minAggroTime = masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + + ENEMY_MINIMUM_AGGRESSIVE_TIME_LOOKUP_OFFSET]; + gameData->maxAggroTime = masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + + ENEMY_MAXIMUM_AGGRESSIVE_TIME_LOOKUP_OFFSET]; + gameData->minAggroEnemies = masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + + ENEMY_MINIMUM_AGGRESSIVE_COUNT_LOOKUP_OFFSET]; + gameData->maxAggroEnemies = masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + + ENEMY_MAXIMUM_AGGRESSIVE_COUNT_LOOKUP_OFFSET]; + + pa_remapBlockTile( + wsgManager, + masterDifficulty[((levelIndex - 1) * MASTER_DIFFICULTY_TABLE_ROW_LENGTH) + BLOCK_WSG_LOOKUP_OFFSET]); } \ No newline at end of file