|
|
@@ -1,101 +1,46 @@
|
|
|
#include <furi.h>
|
|
|
#include "scene.h"
|
|
|
-#include "assets/emotes.h"
|
|
|
#include "assets/items.h"
|
|
|
+#include "assets/meta.h"
|
|
|
#include <gui/elements.h>
|
|
|
|
|
|
-const char* action_str[] = {"Sleep", "Idle", "Walk", "Emote", "Use", "MC"};
|
|
|
-
|
|
|
-static void scene_draw_hint(SceneState* state, Canvas* canvas, bool glitching) {
|
|
|
- furi_assert(state);
|
|
|
- furi_assert(canvas);
|
|
|
- char buf[32];
|
|
|
-
|
|
|
- const Item* near = is_nearby(state);
|
|
|
- if(near) {
|
|
|
- int32_t hint_pos_x = (near->x - state->player_global.x) * PARALLAX(near->layer) + 25;
|
|
|
- int8_t hint_pos_y = near->y < 15 ? near->y + 4 : near->y - 16;
|
|
|
-
|
|
|
- strcpy(buf, near->action_name);
|
|
|
- if(glitching) {
|
|
|
- for(size_t g = 0; g != state->action_timeout; g++) {
|
|
|
- buf[(g * 23) % strlen(buf)] = ' ' + (random() % g * 17) % ('z' - ' ');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- canvas_draw_str(canvas, hint_pos_x, hint_pos_y, buf);
|
|
|
+void dolphin_scene_transition_handler(SceneState* state) {
|
|
|
+ uint8_t speed_mod = (state->player_v.x || state->player_v.y || state->transition) ? 6 : 10;
|
|
|
+
|
|
|
+ if(state->player_v.x < 0) {
|
|
|
+ state->frame_pending = DirLeft;
|
|
|
+ } else if(state->player_v.x > 0) {
|
|
|
+ state->frame_pending = DirRight;
|
|
|
+ } else if(state->player_v.y < 0) {
|
|
|
+ state->frame_pending = DirUp;
|
|
|
+ } else if(state->player_v.y > 0) {
|
|
|
+ state->frame_pending = DirDown;
|
|
|
}
|
|
|
-}
|
|
|
+ state->transition_pending = state->frame_group != state->frame_pending;
|
|
|
|
|
|
-static void scene_draw_current_emote(SceneState* state, Canvas* canvas) {
|
|
|
- furi_assert(state);
|
|
|
- furi_assert(canvas);
|
|
|
- elements_multiline_text_framed(canvas, 80, 20, (char*)emotes_list[state->emote_id]);
|
|
|
-}
|
|
|
-
|
|
|
-static void scene_draw_sleep_emote(SceneState* state, Canvas* canvas) {
|
|
|
- furi_assert(state);
|
|
|
- furi_assert(canvas);
|
|
|
-
|
|
|
- char dialog_str[] = "zZzZ..";
|
|
|
- // 2do - sofa x pos getter
|
|
|
- if(state->player_global.x == 154 && state->action_timeout % 100 < 50) {
|
|
|
- if(state->dialog_progress < strlen(dialog_str)) {
|
|
|
- if(state->action_timeout % 10 == 0) state->dialog_progress++;
|
|
|
-
|
|
|
- dialog_str[state->dialog_progress + 1] = '\0';
|
|
|
- canvas_draw_str(canvas, 80, 20, dialog_str);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- state->dialog_progress = 0;
|
|
|
+ if(*&frames[state->frame_group][state->frame_type]->frames[state->frame_idx].f) {
|
|
|
+ state->current_frame = *&frames[state->frame_group][state->frame_type];
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-static void scene_draw_dialog(SceneState* state, Canvas* canvas) {
|
|
|
- furi_assert(state);
|
|
|
- furi_assert(canvas);
|
|
|
+ uint8_t total = state->current_frame->frames[2].f == NULL ? 2 : 3;
|
|
|
|
|
|
- char dialog_str[64];
|
|
|
- char buf[64];
|
|
|
-
|
|
|
- strcpy(dialog_str, (char*)dialogues_list[state->dialogue_id]);
|
|
|
-
|
|
|
- if(state->dialog_progress <= strlen(dialog_str)) {
|
|
|
- if(state->action_timeout % 2 == 0) state->dialog_progress++;
|
|
|
- dialog_str[state->dialog_progress] = '\0';
|
|
|
- snprintf(buf, state->dialog_progress, dialog_str);
|
|
|
- } else {
|
|
|
- snprintf(buf, 64, dialog_str);
|
|
|
+ if(state->transition_pending && !state->frame_idx) {
|
|
|
+ state->transition_pending = false;
|
|
|
+ state->transition = true;
|
|
|
}
|
|
|
|
|
|
- elements_multiline_text_framed(canvas, 68, 16, buf);
|
|
|
-}
|
|
|
-
|
|
|
-/*
|
|
|
-static void draw_idle_emote(SceneState* state, Canvas* canvas){
|
|
|
- if(state->action_timeout % 50 < 40 && state->prev_action == MINDCONTROL){
|
|
|
- elements_multiline_text_framed(canvas, 68, 16, "WUT?!");
|
|
|
+ if(state->transition) {
|
|
|
+ state->frame_type = state->frame_pending;
|
|
|
+ state->frame_group = state->last_group;
|
|
|
+ state->transition = !(state->frame_idx == total - 1);
|
|
|
+ } else {
|
|
|
+ state->frame_group = state->frame_type;
|
|
|
}
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
-static void draw_idle_emote(SceneState* state, Canvas* canvas) {
|
|
|
- furi_assert(state);
|
|
|
- furi_assert(canvas);
|
|
|
|
|
|
- char dialog_str[] = "...";
|
|
|
+ state->player_anim++;
|
|
|
|
|
|
- if(state->action_timeout % 100 < 50) {
|
|
|
- if(state->dialog_progress < strlen(dialog_str)) {
|
|
|
- if(state->action_timeout % 10 == 0) state->dialog_progress++;
|
|
|
-
|
|
|
- dialog_str[state->dialog_progress + 1] = '\0';
|
|
|
- canvas_draw_str(canvas, 70, 15, dialog_str);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- state->dialog_progress = 0;
|
|
|
+ if(!(state->player_anim % speed_mod)) {
|
|
|
+ state->frame_idx = (state->frame_idx + 1) % total;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -103,44 +48,24 @@ void dolphin_scene_render_dolphin(SceneState* state, Canvas* canvas) {
|
|
|
furi_assert(state);
|
|
|
furi_assert(canvas);
|
|
|
|
|
|
- if(state->scene_zoom == SCENE_ZOOM) {
|
|
|
- state->dolphin_gfx = &I_DolphinExcited_64x63;
|
|
|
- } else if(state->action == SLEEP && state->player_global.x == 154) { // 2do - sofa x pos getter
|
|
|
- state->dolphin_gfx = &A_FX_Sitting_40x27;
|
|
|
- state->dolphin_gfx_b = &I_FX_SittingB_40x27;
|
|
|
- } else if(state->action != INTERACT) {
|
|
|
- if(state->player_v.x < 0 || state->player_flipped) {
|
|
|
- if(state->player_anim == 0) {
|
|
|
- state->dolphin_gfx = &I_WalkL1_32x32;
|
|
|
- state->dolphin_gfx_b = &I_WalkLB1_32x32;
|
|
|
-
|
|
|
- } else {
|
|
|
- state->dolphin_gfx = &I_WalkL2_32x32;
|
|
|
- state->dolphin_gfx_b = &I_WalkLB2_32x32;
|
|
|
- }
|
|
|
- } else if(state->player_v.x > 0 || !state->player_flipped) {
|
|
|
- if(state->player_anim == 0) {
|
|
|
- state->dolphin_gfx = &I_WalkR1_32x32;
|
|
|
- state->dolphin_gfx_b = &I_WalkRB1_32x32;
|
|
|
-
|
|
|
- } else {
|
|
|
- state->dolphin_gfx = &I_WalkR2_32x32;
|
|
|
- state->dolphin_gfx_b = &I_WalkRB2_32x32;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ dolphin_scene_transition_handler(state);
|
|
|
|
|
|
canvas_set_bitmap_mode(canvas, true);
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
- canvas_draw_icon(canvas, state->player.x, state->player.y, state->dolphin_gfx_b);
|
|
|
+ canvas_draw_icon(
|
|
|
+ canvas, state->player.x, state->player.y, state->current_frame->frames[state->frame_idx].b);
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
- canvas_draw_icon(canvas, state->player.x, state->player.y, state->dolphin_gfx);
|
|
|
+ canvas_draw_icon(
|
|
|
+ canvas, state->player.x, state->player.y, state->current_frame->frames[state->frame_idx].f);
|
|
|
canvas_set_bitmap_mode(canvas, false);
|
|
|
}
|
|
|
|
|
|
-static bool item_screen_bounds(int32_t pos) {
|
|
|
+static bool item_screen_bounds_x(int32_t pos) {
|
|
|
return pos > -SCREEN_WIDTH && pos < (SCREEN_WIDTH * 2);
|
|
|
}
|
|
|
+static bool item_screen_bounds_y(int32_t pos) {
|
|
|
+ return pos > -SCREEN_HEIGHT * 2 && pos < (SCREEN_HEIGHT * 2);
|
|
|
+}
|
|
|
|
|
|
void dolphin_scene_render(SceneState* state, Canvas* canvas, uint32_t t) {
|
|
|
furi_assert(state);
|
|
|
@@ -151,24 +76,17 @@ void dolphin_scene_render(SceneState* state, Canvas* canvas, uint32_t t) {
|
|
|
const Item** current_scene = get_scene(state);
|
|
|
|
|
|
for(uint8_t l = 0; l < LAYERS; l++) {
|
|
|
- if(state->scene_zoom < SCENE_ZOOM) {
|
|
|
- for(uint8_t i = 0; i < ITEMS_NUM; i++) {
|
|
|
- int32_t item_pos = (current_scene[i]->x - state->player_global.x);
|
|
|
- if(item_screen_bounds(item_pos)) {
|
|
|
- if(current_scene[i]->draw) current_scene[i]->draw(canvas, state);
|
|
|
-
|
|
|
- if(l == current_scene[i]->layer) {
|
|
|
- canvas_draw_icon(
|
|
|
- canvas,
|
|
|
- item_pos * PARALLAX(l),
|
|
|
- current_scene[i]->y,
|
|
|
- current_scene[i]->icon);
|
|
|
- canvas_set_bitmap_mode(canvas, false);
|
|
|
+ for(uint8_t i = 0; i < ItemsEnumTotal; i++) {
|
|
|
+ int32_t item_pos_X = (current_scene[i]->pos.x - state->player_global.x);
|
|
|
+ int32_t item_pos_Y = (current_scene[i]->pos.y - state->player_global.y);
|
|
|
+
|
|
|
+ if(item_screen_bounds_x(item_pos_X) && item_screen_bounds_y(item_pos_Y)) {
|
|
|
+ if(l == current_scene[i]->layer) {
|
|
|
+ if(current_scene[i]->draw) {
|
|
|
+ current_scene[i]->draw(canvas, state);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if(l == 0) canvas_draw_line(canvas, 0, 42, 128, 42);
|
|
|
}
|
|
|
|
|
|
if(l == DOLPHIN_LAYER) dolphin_scene_render_dolphin(state, canvas);
|
|
|
@@ -188,24 +106,16 @@ void dolphin_scene_render_state(SceneState* state, Canvas* canvas) {
|
|
|
if(state->debug) {
|
|
|
sprintf(
|
|
|
buf,
|
|
|
- "x:%ld>%d %ld %s",
|
|
|
- state->player_global.x,
|
|
|
- state->poi,
|
|
|
- state->action_timeout,
|
|
|
- action_str[state->action]);
|
|
|
+ "%d:%d %d/%dP%dL%d T%d-%d",
|
|
|
+ state->frame_idx,
|
|
|
+ state->current_frame->frames[2].f == NULL ? 2 : 3,
|
|
|
+ state->frame_group,
|
|
|
+ state->frame_type,
|
|
|
+ state->frame_pending,
|
|
|
+ state->last_group,
|
|
|
+ state->transition_pending,
|
|
|
+ state->transition);
|
|
|
canvas_draw_str(canvas, 0, 13, buf);
|
|
|
}
|
|
|
-
|
|
|
- if(state->scene_zoom == SCENE_ZOOM)
|
|
|
- scene_draw_dialog(state, canvas);
|
|
|
- else if(state->action == EMOTE)
|
|
|
- scene_draw_current_emote(state, canvas);
|
|
|
- else if(state->action == MINDCONTROL)
|
|
|
- scene_draw_hint(state, canvas, state->action_timeout > 45);
|
|
|
- else if(state->action == INTERACT)
|
|
|
- scene_activate_item_callback(state, canvas);
|
|
|
- else if(state->action == SLEEP)
|
|
|
- scene_draw_sleep_emote(state, canvas);
|
|
|
- else if(state->action == IDLE)
|
|
|
- draw_idle_emote(state, canvas);
|
|
|
+ if(state->action == INTERACT) scene_activate_item_callback(state, canvas);
|
|
|
}
|