Skip to content

Commit

Permalink
Pango - 2nd PR (#306)
Browse files Browse the repository at this point in the history
Lots of Pango improvements
  • Loading branch information
JVeg199X authored Oct 27, 2024
1 parent 5cc5615 commit 70143d9
Show file tree
Hide file tree
Showing 36 changed files with 895 additions and 1,041 deletions.
Binary file added assets/fonts/tiny_numbers.font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/sounds/bgmGameOver.mid
Binary file not shown.
Binary file modified assets/pango/sounds/snd1up.mid
Binary file not shown.
Binary file added assets/pango/sounds/sndBlockCombo.mid
Binary file not shown.
Binary file added assets/pango/sounds/sndTally.mid
Binary file not shown.
Binary file modified assets/pango/sprites/kr-007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/sprites/kr-008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/sprites/kr-009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/sprites/kr-010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/sprites/kr-011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/sprites/kr-012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pango/sprites/pa-115.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pango/sprites/po-015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pango/sprites/px-015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/tiles/pa-tile-010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/tiles/pa-tile-011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/tiles/pa-tile-012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/tiles/pa-tile-013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/tiles/pa-tile-014.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pango/tiles/pa-tile-015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
383 changes: 248 additions & 135 deletions main/modes/games/pango/paEntity.c

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions main/modes/games/pango/paEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ typedef enum
PA_ENTITY_BREAK_BLOCK,
PA_ENTITY_BLOCK_FRAGMENT,
ENTITY_HIT_BLOCK,
ENTITY_DEAD
ENTITY_DEAD,
PA_ENTITY_SCORE_DISPLAY
} paEntityIndex_t;

typedef enum
Expand Down Expand Up @@ -64,10 +65,11 @@ 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_TILE_CollisionHandler_t)(struct paEntity_t* self, uint8_t tileId, uint8_t tx, uint8_t ty,
uint8_t direction);
typedef bool (*pa_tileCollisionHandler_t)(struct paEntity_t* self, uint8_t tileId, uint8_t tx, uint8_t ty,
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);

struct paEntity_t
{
Expand Down Expand Up @@ -107,11 +109,7 @@ struct paEntity_t
uint8_t homeTileX;
uint8_t homeTileY;

int16_t jumpPower;

bool visible;
uint8_t hp;
int8_t invincibilityFrames;
uint16_t scoreValue;

uint8_t targetTileX;
Expand All @@ -126,9 +124,9 @@ struct paEntity_t
paEntityManager_t* entityManager;

pa_collisionHandler_t collisionHandler;
PA_TILE_CollisionHandler_t tileCollisionHandler;
pa_fallOffTileHandler_t fallOffTileHandler;
pa_tileCollisionHandler_t tileCollisionHandler;
pa_overlapTileHandler_t overlapTileHandler;
pa_drawHandler_t drawHandler;
};

//==============================================================================
Expand Down Expand Up @@ -185,7 +183,13 @@ void killPlayer(paEntity_t* self);
void drawEntityTargetTile(paEntity_t* self);

bool pa_hitBlockTileCollisionHandler(paEntity_t* self, uint8_t tileId, uint8_t tx, uint8_t ty, uint8_t direction);
void pa_executeSpawnBlockCombo(paEntity_t* self, uint8_t tx, uint8_t ty, uint16_t scoreIndex);
void pa_updateBreakBlock(paEntity_t* self);
void pa_updateBlockFragment(paEntity_t* self);
void pa_updateScoreDisplay(paEntity_t* self);
void pa_defaultEntityDrawHandler(paEntity_t* self);
void pa_scoreDisplayDrawHandler(paEntity_t* self);
int16_t pa_enemySetAggroStateTimer(paEntity_t* self);
uint16_t pa_correctPlayerFacingDirection(int16_t btnState, uint16_t currentFacingDirection);

#endif
78 changes: 52 additions & 26 deletions main/modes/games/pango/paEntityManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,17 @@ void pa_deactivateAllEntities(paEntityManager_t* entityManager, bool excludePlay
for (uint8_t i = 0; i < MAX_ENTITIES; i++)
{
paEntity_t* currentEntity = &(entityManager->entities[i]);
currentEntity->active = false;

// clear out invisible block tiles that are placed for every Break Block object
// if(currentEntity->type == PA_ENTITY_BREAK_BLOCK){
// pa_setTile(currentEntity->tilemap, PA_TO_TILECOORDS(currentEntity->x >> SUBPIXEL_RESOLUTION),
// PA_TO_TILECOORDS(currentEntity->y >> SUBPIXEL_RESOLUTION), PA_TILE_EMPTY);
// }

if (currentEntity->type == ENTITY_HIT_BLOCK && currentEntity->jumpPower == PA_TILE_SPAWN_BLOCK_0)
if (currentEntity->active == false || (excludePlayer && currentEntity == entityManager->playerEntity))
{
entityManager->gameData->remainingEnemies--;
continue;
}

if (excludePlayer && currentEntity == entityManager->playerEntity)
currentEntity->active = false;

if (currentEntity->type == ENTITY_HIT_BLOCK && currentEntity->state == PA_TILE_SPAWN_BLOCK_0)
{
currentEntity->active = true;
entityManager->gameData->remainingEnemies--;
}
}

Expand All @@ -99,13 +94,7 @@ void pa_drawEntities(paEntityManager_t* entityManager)

if (currentEntity.active && currentEntity.visible)
{
drawWsg(entityManager->wsgManager->sprites[currentEntity.spriteIndex].wsg,
(currentEntity.x >> SUBPIXEL_RESOLUTION)
- entityManager->wsgManager->sprites[currentEntity.spriteIndex].originX
- entityManager->tilemap->mapOffsetX,
(currentEntity.y >> SUBPIXEL_RESOLUTION) - entityManager->tilemap->mapOffsetY
- entityManager->wsgManager->sprites[currentEntity.spriteIndex].originY,
currentEntity.spriteFlipHorizontal, currentEntity.spriteFlipVertical, 0);
currentEntity.drawHandler(&currentEntity);
}
}
}
Expand Down Expand Up @@ -207,9 +196,7 @@ paEntity_t* pa_createPlayer(paEntityManager_t* entityManager, uint16_t x, uint16
entity->gravityEnabled = false;
entity->gravity = 4;
entity->falling = false;
entity->jumpPower = 0;
entity->spriteFlipVertical = false;
entity->hp = 1;
entity->animationTimer = 0; // Used as a cooldown for shooting square wave balls
entity->state = PA_PL_ST_NORMAL;
entity->stateTimer = -1;
Expand All @@ -219,8 +206,8 @@ paEntity_t* pa_createPlayer(paEntityManager_t* entityManager, uint16_t x, uint16
entity->updateFunction = &pa_updatePlayer;
entity->collisionHandler = &pa_playerCollisionHandler;
entity->tileCollisionHandler = &pa_playerTileCollisionHandler;
entity->fallOffTileHandler = &defaultFallOffTileHandler;
entity->overlapTileHandler = &pa_playerOverlapTileHandler;
entity->drawHandler = &pa_defaultEntityDrawHandler;
return entity;
}

Expand Down Expand Up @@ -260,8 +247,8 @@ paEntity_t* createCrabdozer(paEntityManager_t* entityManager, uint16_t x, uint16
entity->updateFunction = &updateCrabdozer;
entity->collisionHandler = &pa_enemyCollisionHandler;
entity->tileCollisionHandler = &pa_enemyTileCollisionHandler;
entity->fallOffTileHandler = &defaultFallOffTileHandler;
entity->overlapTileHandler = &pa_defaultOverlapTileHandler;
entity->drawHandler = &pa_defaultEntityDrawHandler;

return entity;
}
Expand All @@ -288,16 +275,17 @@ paEntity_t* pa_createBreakBlock(paEntityManager_t* entityManager, uint16_t x, ui
entity->gravity = 0;
entity->spriteFlipHorizontal = false;
entity->spriteFlipVertical = false;
entity->scoreValue = 100;
entity->scoreValue = 0;
entity->animationTimer = 0;
entity->type = PA_ENTITY_BREAK_BLOCK;
entity->spriteIndex = PA_SP_BREAK_BLOCK;
entity->facingDirection = PA_DIRECTION_NONE;
entity->updateFunction = &pa_updateBreakBlock;
entity->collisionHandler = &pa_dummyCollisionHandler;
entity->tileCollisionHandler = &pa_dummyTileCollisionHandler;
entity->fallOffTileHandler = &defaultFallOffTileHandler;
entity->overlapTileHandler = &pa_defaultOverlapTileHandler;
entity->drawHandler = &pa_defaultEntityDrawHandler;
entity->state = 0;

pa_setTile(entityManager->tilemap, PA_TO_TILECOORDS(x), PA_TO_TILECOORDS(y), PA_TILE_EMPTY);

Expand All @@ -323,7 +311,7 @@ paEntity_t* pa_createBlockFragment(paEntityManager_t* entityManager, uint16_t x,
entity->xMaxSpeed = 132;
entity->yMaxSpeed = 132;
entity->gravityEnabled = true;
entity->gravity = 0;
entity->gravity = 4;
entity->spriteFlipHorizontal = false;
entity->spriteFlipVertical = false;
entity->scoreValue = 100;
Expand All @@ -334,8 +322,8 @@ paEntity_t* pa_createBlockFragment(paEntityManager_t* entityManager, uint16_t x,
entity->updateFunction = &pa_updateBlockFragment;
entity->collisionHandler = &pa_dummyCollisionHandler;
entity->tileCollisionHandler = &pa_dummyTileCollisionHandler;
entity->fallOffTileHandler = &defaultFallOffTileHandler;
entity->overlapTileHandler = &pa_defaultOverlapTileHandler;
entity->drawHandler = &pa_defaultEntityDrawHandler;

return entity;
}
Expand Down Expand Up @@ -370,10 +358,48 @@ paEntity_t* createHitBlock(paEntityManager_t* entityManager, uint16_t x, uint16_
entity->type = ENTITY_HIT_BLOCK;
entity->spriteIndex = PA_SP_BLOCK;
entity->animationTimer = 0;
entity->scoreValue = 0;
entity->updateFunction = &updateHitBlock;
entity->collisionHandler = &pa_dummyCollisionHandler;
entity->tileCollisionHandler = &pa_hitBlockTileCollisionHandler;
entity->overlapTileHandler = &pa_defaultOverlapTileHandler;
entity->drawHandler = &pa_defaultEntityDrawHandler;

return entity;
}

paEntity_t* pa_createScoreDisplay(paEntityManager_t* entityManager, uint16_t x, uint16_t y)
{
paEntity_t* entity = pa_findInactiveEntity(entityManager);

if (entity == NULL)
{
return NULL;
}

entity->active = true;
entity->visible = true;
entity->x = x << SUBPIXEL_RESOLUTION;
entity->y = y << SUBPIXEL_RESOLUTION;

entity->xspeed = 0;
entity->yspeed = 0;
entity->gravityEnabled = false;
entity->gravity = 0;

entity->spriteFlipHorizontal = false;
entity->spriteFlipVertical = false;

entity->type = PA_ENTITY_SCORE_DISPLAY;
entity->spriteIndex = 0;
entity->animationTimer = 0;
entity->scoreValue = 0;
entity->stateTimer = 0;
entity->updateFunction = &pa_updateScoreDisplay;
entity->collisionHandler = &pa_dummyCollisionHandler;
entity->tileCollisionHandler = &pa_hitBlockTileCollisionHandler;
entity->overlapTileHandler = &pa_defaultOverlapTileHandler;
entity->drawHandler = &pa_scoreDisplayDrawHandler;

return entity;
}
Expand Down
1 change: 1 addition & 0 deletions main/modes/games/pango/paEntityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ void pa_freeEntityManager(paEntityManager_t* entityManager);
paEntity_t* pa_spawnEnemyFromSpawnBlock(paEntityManager_t* entityManager);
paEntity_t* pa_createBreakBlock(paEntityManager_t* entityManager, uint16_t x, uint16_t y);
paEntity_t* pa_createBlockFragment(paEntityManager_t* entityManager, uint16_t x, uint16_t y);
paEntity_t* pa_createScoreDisplay(paEntityManager_t* entityManager, uint16_t x, uint16_t y);

#endif
Loading

0 comments on commit 70143d9

Please sign in to comment.