152 lines
5.0 KiB
C++
152 lines
5.0 KiB
C++
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include "engine.h"
|
|
|
|
#define BGWIDTH 1280
|
|
#define BGHEIGHT 800
|
|
|
|
extern const char _binary_sprite_lobby_raw_start[];
|
|
extern const char _binary_sprite_managers_office_raw_start[];
|
|
extern const char _binary_sprite_managers_office_safe_raw_start[];
|
|
extern const char _binary_sprite_basement_raw_start[];
|
|
|
|
extern const char _binary_sprite_stickman_raw_start[];
|
|
|
|
extern struct navmesh navmesh_lobby;
|
|
extern struct navmesh navmesh_managers_office;
|
|
extern struct navmesh navmesh_basement;
|
|
|
|
#define OBJID_BACKGROUND 1
|
|
#define OBJID_DOOR_TO_MANAGERS_OFFICE_FROM_LOBBY 2
|
|
#define OBJID_DOOR_TO_LOBBY_FROM_MANAGERS_OFFICE 3
|
|
// #define OBJID_PLAYER 4
|
|
// #define SCRIPTID_PLAYER_WALK 5
|
|
#define OBJID_PLAYER_WALK_TO_DOOR_SCRIPT 6
|
|
#define OBJID_MANAGERS_OFFICE_SAFE 7
|
|
#define OBJID_MANAGERS_OFFICE_TRAPDOOR 8
|
|
#define OBJID_BASEMENT_POPCORN 9
|
|
#define OBJID_BASEMENT_ELECTRICAL_BOX 10
|
|
#define OBJID_BASEMENT_LADDER 11
|
|
#define OBJID_CLOSE_MODAL 12
|
|
|
|
void scene_setup(int scene, int fromscene) {
|
|
top_scene.render_fn = standard_scene_render;
|
|
switch(scene) {
|
|
case SCENE_LOBBY:
|
|
scene_add_object(OBJID_BACKGROUND, 0, 0, BGWIDTH, BGHEIGHT, _binary_sprite_lobby_raw_start);
|
|
scene_add_object(OBJID_DOOR_TO_MANAGERS_OFFICE_FROM_LOBBY, 273, 313, 76, 128, nullptr);
|
|
switch(fromscene) {
|
|
case SCENE_MANAGERS_OFFICE:
|
|
scene_add_object(OBJID_PLAYER, 308-51/2, 445-111, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
default:
|
|
scene_add_object(OBJID_PLAYER, 424, 575, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
}
|
|
top_scene.navmesh = &navmesh_lobby;
|
|
break;
|
|
case SCENE_MANAGERS_OFFICE:
|
|
scene_add_object(OBJID_BACKGROUND, 0, 0, BGWIDTH, BGHEIGHT, _binary_sprite_managers_office_raw_start);
|
|
scene_add_object(OBJID_DOOR_TO_LOBBY_FROM_MANAGERS_OFFICE, 740, 440, 151, 276, nullptr);
|
|
scene_add_object(OBJID_MANAGERS_OFFICE_TRAPDOOR, 332, 565, 139, 87, nullptr);
|
|
scene_add_object(OBJID_MANAGERS_OFFICE_SAFE, 784, 297, 191, 188, nullptr);
|
|
switch(fromscene) {
|
|
case SCENE_LOBBY:
|
|
scene_add_object(OBJID_PLAYER, 804-51/2, 708-111, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
case SCENE_BASEMENT:
|
|
scene_add_object(OBJID_PLAYER, 408-51/2, 559-111, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
case SCENE_MANAGERS_OFFICE_SAFE:
|
|
scene_add_object(OBJID_PLAYER, 895-51/2, 497-111, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
default:
|
|
scene_add_object(OBJID_PLAYER, 424, 575, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
}
|
|
top_scene.navmesh = &navmesh_managers_office;
|
|
break;
|
|
case SCENE_MANAGERS_OFFICE_SAFE:
|
|
scene_add_object(OBJID_BACKGROUND, 248, 0, 787, BGHEIGHT, _binary_sprite_managers_office_safe_raw_start);
|
|
scene_add_object(OBJID_CLOSE_MODAL, 0, 0, 248, 800, nullptr);
|
|
scene_add_object(OBJID_CLOSE_MODAL, 1035, 0, 1280-1035, 800, nullptr);
|
|
break;
|
|
case SCENE_BASEMENT:
|
|
scene_add_object(OBJID_BACKGROUND, 0, 0, BGWIDTH, BGHEIGHT, _binary_sprite_basement_raw_start);
|
|
scene_add_object(OBJID_BASEMENT_LADDER, 396, 86, 85, 312, nullptr);
|
|
switch(fromscene) {
|
|
case SCENE_MANAGERS_OFFICE:
|
|
scene_add_object(OBJID_PLAYER, 435-51/2, 404-111, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
default:
|
|
scene_add_object(OBJID_PLAYER, 424, 575, 51, 111, _binary_sprite_stickman_raw_start);
|
|
break;
|
|
}
|
|
top_scene.navmesh = &navmesh_basement;
|
|
break;
|
|
}
|
|
}
|
|
|
|
static void transition_scene_on_walk_finish(struct script *scr, int wakeupMode, int arg1, int arg2, int arg3, int arg4) {
|
|
scr->id = 0;
|
|
if(wakeupMode == SCRIPT_WAKEUP_OTHER_SCRIPT) {
|
|
if(scr->vars[0] == SCENE_MANAGERS_OFFICE_SAFE) {
|
|
push_scene(scr->vars[0]);
|
|
} else {
|
|
replace_scene(scr->vars[0]);
|
|
}
|
|
}
|
|
else
|
|
assert(wakeupMode == SCRIPT_WAKEUP_OTHER_SCRIPT_INTERRUPTED);
|
|
}
|
|
|
|
static void start_player_walk_to_point_then_transition_scene(int x, int y, int scene) {
|
|
start_player_walk_to_point(x, y);
|
|
|
|
struct script *scr = scene_add_script(OBJID_PLAYER_WALK_TO_DOOR_SCRIPT, true);
|
|
scr->wakeupMode = SCRIPT_WAKEUP_OTHER_SCRIPT;
|
|
scr->wakeupArg1 = OBJID_PLAYER_WALK_SCRIPT;
|
|
scr->wakeupFn = transition_scene_on_walk_finish;
|
|
scr->vars[0] = scene;
|
|
}
|
|
|
|
void onclick(int curscene, int objid) {
|
|
switch(curscene) {
|
|
case SCENE_LOBBY:
|
|
switch(objid) {
|
|
case OBJID_DOOR_TO_MANAGERS_OFFICE_FROM_LOBBY:
|
|
start_player_walk_to_point_then_transition_scene(312, 441, SCENE_MANAGERS_OFFICE);
|
|
return;
|
|
}
|
|
break;
|
|
case SCENE_MANAGERS_OFFICE:
|
|
switch(objid) {
|
|
case OBJID_DOOR_TO_LOBBY_FROM_MANAGERS_OFFICE:
|
|
start_player_walk_to_point_then_transition_scene(815, 713, SCENE_LOBBY);
|
|
return;
|
|
case OBJID_MANAGERS_OFFICE_SAFE:
|
|
start_player_walk_to_point_then_transition_scene(895, 497, SCENE_MANAGERS_OFFICE_SAFE);
|
|
return;
|
|
case OBJID_MANAGERS_OFFICE_TRAPDOOR:
|
|
start_player_walk_to_point_then_transition_scene(408, 559, SCENE_BASEMENT);
|
|
return;
|
|
}
|
|
break;
|
|
case SCENE_BASEMENT:
|
|
switch(objid) {
|
|
case OBJID_BASEMENT_LADDER:
|
|
start_player_walk_to_point_then_transition_scene(438, 402, SCENE_MANAGERS_OFFICE);
|
|
return;
|
|
}
|
|
break;
|
|
case SCENE_MANAGERS_OFFICE_SAFE:
|
|
switch(objid) {
|
|
case OBJID_CLOSE_MODAL:
|
|
pop_scene();
|
|
return;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|