Skip to content

Commit

Permalink
replace ghost with yappyghost!
Browse files Browse the repository at this point in the history
  • Loading branch information
jaylikesbunda authored Nov 7, 2024
1 parent 7e7c044 commit 112f7fa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
Binary file added flappy_bird/assets/yappyghost_01.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 flappy_bird/assets/yappyghost_02.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 flappy_bird/assets/yappyghost_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 19 additions & 18 deletions flappy_bird/flappy_bird.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#define FLAPPY_GAB_HEIGHT 24
#define YAPPER_GAB_HEIGHT 32
#define GHOSTESP_GAB_HEIGHT 28
#define YAPPYGHOST_GAB_HEIGHT 29

#define FLAPPY_GAB_WIDTH 10

#define YAPPER_HEIGHT 22
Expand All @@ -42,7 +43,7 @@ typedef enum {
typedef enum {
BirdTypeDefault = 0,
BirdTypeYapper,
BirdTypeGhostESP,
BirdTypeYappyGhost,
BirdTypeMAX
} BirdType;

Expand All @@ -68,18 +69,18 @@ static const CharacterDimensions character_dimensions[] = {
4,
YAPPER_WIDTH - 8,
YAPPER_HEIGHT - 8}, // Yapper with larger offset
{YAPPER_WIDTH,
YAPPER_HEIGHT,
5,
5,
YAPPER_WIDTH - 10,
YAPPER_HEIGHT - 10} // GhostESP with smaller hitbox
{18,
19,
4,
4,
10,
11} // YappyGhost with custom hitbox
};

const Icon* bird_sets[BirdTypeMAX][BirdStateMAX] = {
{&I_bird_01, &I_bird_02, &I_bird_03},
{&I_yapper_01, &I_yapper_02, &I_yapper_03},
{&I_ghostesp_01, &I_ghostesp_02, &I_ghostesp_03}};
{&I_yappyghost_01, &I_yappyghost_02, &I_yappyghost_03}};

typedef enum {
EventTypeTick,
Expand Down Expand Up @@ -165,13 +166,12 @@ static inline int get_gap_height(BirdType bird_type) {
switch(bird_type) {
case BirdTypeYapper:
return YAPPER_GAB_HEIGHT;
case BirdTypeGhostESP:
return GHOSTESP_GAB_HEIGHT;
case BirdTypeYappyGhost:
return YAPPYGHOST_GAB_HEIGHT; // Now uses its own gap height
default:
return FLAPPY_GAB_HEIGHT;
}
}

static void flappy_game_random_pilar(GameState* const game_state) {
PILAR pilar;
int gap_height = get_gap_height(game_state->selected_bird);
Expand Down Expand Up @@ -238,9 +238,9 @@ static bool check_collision(
return false;
}

// Extra forgiving collision for Yapper/GhostESP
// Extra forgiving collision for Yapper/YappyGhost
if(game_state->selected_bird == BirdTypeYapper ||
game_state->selected_bird == BirdTypeGhostESP) {
game_state->selected_bird == BirdTypeYappyGhost) {
// Add small grace area for top and bottom pipes
top_pipe_bottom += 2;
bottom_pipe_top -= 2;
Expand All @@ -259,6 +259,7 @@ static bool check_collision(
return false;
}


static void flappy_game_tick(GameState* const game_state) {
if(game_state->collision_frame > 0) {
game_state->collision_frame--;
Expand Down Expand Up @@ -352,8 +353,8 @@ static void flappy_game_render_callback(Canvas* const canvas, void* ctx) {
// Change title based on selected character
if(game_state->selected_bird == BirdTypeYapper) {
canvas_draw_str_aligned(canvas, 64, 20, AlignCenter, AlignBottom, "Yappy Bird");
} else if(game_state->selected_bird == BirdTypeGhostESP) {
canvas_draw_str_aligned(canvas, 64, 20, AlignCenter, AlignBottom, "Flappy Ghost");
} else if(game_state->selected_bird == BirdTypeYappyGhost) {
canvas_draw_str_aligned(canvas, 64, 20, AlignCenter, AlignBottom, "Yappy Ghost");
} else {
canvas_draw_str_aligned(canvas, 64, 20, AlignCenter, AlignBottom, "Flappy Bird");
}
Expand Down Expand Up @@ -457,8 +458,8 @@ static void flappy_game_render_callback(Canvas* const canvas, void* ctx) {
// Adjust Y position to keep character in bounds
int adjusted_y = game_state->bird.point.y;
if(adjusted_y < 0) adjusted_y = 0;
if(adjusted_y > FLIPPER_LCD_HEIGHT - dims.width) {
adjusted_y = FLIPPER_LCD_HEIGHT - dims.width;
if(adjusted_y > FLIPPER_LCD_HEIGHT - dims.height) {
adjusted_y = FLIPPER_LCD_HEIGHT - dims.height;
}

// Draw the character with adjusted position
Expand Down

0 comments on commit 112f7fa

Please sign in to comment.