|
@@ -105,78 +105,6 @@ static void enemy_start(Entity *self, GameManager *manager, void *context)
|
|
|
entity_collider_add_circle(self, enemy_context->radius);
|
|
entity_collider_add_circle(self, enemy_context->radius);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void draw_menu(GameManager *manager, Canvas *canvas)
|
|
|
|
|
-{
|
|
|
|
|
- GameContext *game_context = game_manager_game_context_get(manager);
|
|
|
|
|
-
|
|
|
|
|
- // draw background rectangle
|
|
|
|
|
- canvas_draw_icon(
|
|
|
|
|
- canvas,
|
|
|
|
|
- 0,
|
|
|
|
|
- 0,
|
|
|
|
|
- &I_icon_menu_128x64px);
|
|
|
|
|
-
|
|
|
|
|
- // draw menu options
|
|
|
|
|
- switch (game_context->menu_screen)
|
|
|
|
|
- {
|
|
|
|
|
- case GAME_MENU_INFO:
|
|
|
|
|
- // draw info
|
|
|
|
|
- // first option is highlighted
|
|
|
|
|
- char health[32];
|
|
|
|
|
- char xp[32];
|
|
|
|
|
- char level[32];
|
|
|
|
|
- char strength[32];
|
|
|
|
|
-
|
|
|
|
|
- snprintf(level, sizeof(level), "Level : %ld", game_context->player_context->level);
|
|
|
|
|
- snprintf(health, sizeof(health), "Health : %ld", game_context->player_context->health);
|
|
|
|
|
- snprintf(xp, sizeof(xp), "XP : %ld", game_context->player_context->xp);
|
|
|
|
|
- snprintf(strength, sizeof(strength), "Strength: %ld", game_context->player_context->strength);
|
|
|
|
|
- canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
- canvas_draw_str(canvas, 7, 16, game_context->player_context->username);
|
|
|
|
|
- canvas_set_font_custom(canvas, FONT_SIZE_SMALL);
|
|
|
|
|
- canvas_draw_str(canvas, 7, 30, level);
|
|
|
|
|
- canvas_draw_str(canvas, 7, 37, health);
|
|
|
|
|
- canvas_draw_str(canvas, 7, 44, xp);
|
|
|
|
|
- canvas_draw_str(canvas, 7, 51, strength);
|
|
|
|
|
-
|
|
|
|
|
- // draw a box around the selected option
|
|
|
|
|
- canvas_draw_frame(canvas, 80, 18, 36, 30);
|
|
|
|
|
- canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
- canvas_draw_str(canvas, 86, 30, "Info");
|
|
|
|
|
- canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
- canvas_draw_str(canvas, 86, 42, "More");
|
|
|
|
|
- break;
|
|
|
|
|
- case GAME_MENU_MORE:
|
|
|
|
|
- // draw settings
|
|
|
|
|
- switch (game_context->menu_selection)
|
|
|
|
|
- {
|
|
|
|
|
- case 0:
|
|
|
|
|
- // first option is highlighted
|
|
|
|
|
- break;
|
|
|
|
|
- case 1:
|
|
|
|
|
- // second option is highlighted
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
- canvas_draw_str(canvas, 7, 16, "FlipWorld v0.4");
|
|
|
|
|
- canvas_set_font_custom(canvas, FONT_SIZE_SMALL);
|
|
|
|
|
- canvas_draw_str_multi(canvas, 7, 25, "Developed by\nJBlanked and Derek \nJamison. Graphics\nfrom Pr3!\n\nwww.github.com/jblanked");
|
|
|
|
|
-
|
|
|
|
|
- // draw a box around the selected option
|
|
|
|
|
- canvas_draw_frame(canvas, 80, 18, 36, 30);
|
|
|
|
|
- canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
- canvas_draw_str(canvas, 86, 30, "Info");
|
|
|
|
|
- canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
- canvas_draw_str(canvas, 86, 42, "More");
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// Enemy render function
|
|
// Enemy render function
|
|
|
static void enemy_render(Entity *self, GameManager *manager, Canvas *canvas, void *context)
|
|
static void enemy_render(Entity *self, GameManager *manager, Canvas *canvas, void *context)
|
|
|
{
|
|
{
|
|
@@ -184,7 +112,6 @@ static void enemy_render(Entity *self, GameManager *manager, Canvas *canvas, voi
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
EnemyContext *enemy_context = (EnemyContext *)context;
|
|
EnemyContext *enemy_context = (EnemyContext *)context;
|
|
|
- GameContext *game_context = game_manager_game_context_get(manager);
|
|
|
|
|
|
|
|
|
|
// Get the position of the enemy
|
|
// Get the position of the enemy
|
|
|
Vector pos = entity_pos_get(self);
|
|
Vector pos = entity_pos_get(self);
|
|
@@ -207,33 +134,13 @@ static void enemy_render(Entity *self, GameManager *manager, Canvas *canvas, voi
|
|
|
pos.x - camera_x - (enemy_context->size.x / 2),
|
|
pos.x - camera_x - (enemy_context->size.x / 2),
|
|
|
pos.y - camera_y - (enemy_context->size.y / 2));
|
|
pos.y - camera_y - (enemy_context->size.y / 2));
|
|
|
|
|
|
|
|
- // instead of username, draw health
|
|
|
|
|
|
|
+ // draw health of enemy
|
|
|
char health_str[32];
|
|
char health_str[32];
|
|
|
snprintf(health_str, sizeof(health_str), "%.0f", (double)enemy_context->health);
|
|
snprintf(health_str, sizeof(health_str), "%.0f", (double)enemy_context->health);
|
|
|
draw_username(canvas, pos, health_str);
|
|
draw_username(canvas, pos, health_str);
|
|
|
|
|
|
|
|
// Draw user stats (this has to be done for all enemies)
|
|
// Draw user stats (this has to be done for all enemies)
|
|
|
draw_user_stats(canvas, (Vector){0, 50}, manager);
|
|
draw_user_stats(canvas, (Vector){0, 50}, manager);
|
|
|
-
|
|
|
|
|
- // draw player username from GameContext
|
|
|
|
|
- Vector posi = entity_pos_get(game_context->player);
|
|
|
|
|
- draw_username(canvas, posi, game_context->player_context->username);
|
|
|
|
|
-
|
|
|
|
|
- if (game_context->is_switching_level)
|
|
|
|
|
- {
|
|
|
|
|
- // draw switch world icon
|
|
|
|
|
- canvas_draw_icon(
|
|
|
|
|
- canvas,
|
|
|
|
|
- 0,
|
|
|
|
|
- 0,
|
|
|
|
|
- &I_icon_world_change_128x64px);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (game_context->is_menu_open)
|
|
|
|
|
- {
|
|
|
|
|
- // draw menu
|
|
|
|
|
- draw_menu(manager, canvas);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void atk_notify(GameContext *game_context, EnemyContext *enemy_context, bool player_attacked)
|
|
static void atk_notify(GameContext *game_context, EnemyContext *enemy_context, bool player_attacked)
|
|
@@ -353,6 +260,9 @@ static void enemy_collision(Entity *self, Entity *other, GameManager *manager, v
|
|
|
// Handle Player Attacking Enemy (Press OK, facing enemy, and enemy not facing player)
|
|
// Handle Player Attacking Enemy (Press OK, facing enemy, and enemy not facing player)
|
|
|
if (player_is_facing_enemy && game_context->last_button == GameKeyOk && !enemy_is_facing_player)
|
|
if (player_is_facing_enemy && game_context->last_button == GameKeyOk && !enemy_is_facing_player)
|
|
|
{
|
|
{
|
|
|
|
|
+ // Reset last button
|
|
|
|
|
+ game_context->last_button = -1;
|
|
|
|
|
+
|
|
|
if (game_context->player_context->elapsed_attack_timer >= game_context->player_context->attack_timer)
|
|
if (game_context->player_context->elapsed_attack_timer >= game_context->player_context->attack_timer)
|
|
|
{
|
|
{
|
|
|
atk_notify(game_context, enemy_context, true);
|
|
atk_notify(game_context, enemy_context, true);
|