add the basement scene
parent
4c62c864ea
commit
9a40409ebb
|
@ -37,10 +37,8 @@ for polygon in tree.findall("objectgroup[@name='navmesh']/object/polygon"):
|
|||
poly_id = len(polys)
|
||||
polys.append(points)
|
||||
|
||||
print(points)
|
||||
for edge in points_to_edges(points):
|
||||
edge_id = tuple(sorted(edge))
|
||||
print(edge, edge_id)
|
||||
if edge_id not in edge2poly: edge2poly[edge_id] = []
|
||||
edge2poly[edge_id].append(poly_id)
|
||||
assert len(edge2poly[edge_id]) <= 2, "more than 2 polygons share edge "+str(edge_id)
|
||||
|
|
4
engine.h
4
engine.h
|
@ -49,11 +49,13 @@ void start_player_walk_to_point(int x, int y); // x and y are not corrected to l
|
|||
// game-specific constants
|
||||
#define SCENE_LOBBY 1
|
||||
#define SCENE_MANAGERS_OFFICE 2
|
||||
#define SCENE_MANAGERS_OFFICE_SAFE 3
|
||||
#define SCENE_BASEMENT 4
|
||||
|
||||
// The player ID and walk script are globally relevant
|
||||
#define OBJID_PLAYER 4
|
||||
#define OBJID_PLAYER_WALK_SCRIPT 5
|
||||
|
||||
// game.cpp
|
||||
void scene_setup(int scene);
|
||||
void scene_setup(int scene, int fromscene);
|
||||
void onclick(int curscene, int objid);
|
||||
|
|
70
game.cpp
70
game.cpp
|
@ -7,10 +7,13 @@
|
|||
|
||||
extern const char _binary_sprite_lobby_raw_start[];
|
||||
extern const char _binary_sprite_managers_office_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
|
||||
|
@ -18,19 +21,61 @@ extern struct navmesh navmesh_lobby;
|
|||
// #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
|
||||
|
||||
void scene_setup(int scene) {
|
||||
void scene_setup(int scene, int fromscene) {
|
||||
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);
|
||||
scene_add_object(OBJID_PLAYER, 424, 575, 51, 111, _binary_sprite_stickman_raw_start);
|
||||
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;
|
||||
}
|
||||
scene_set_navmesh(&navmesh_lobby);
|
||||
break;
|
||||
case SCENE_MANAGERS_OFFICE:
|
||||
case SCENE_MANAGERS_OFFICE_SAFE:
|
||||
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, 273, 313, 76, 128, nullptr);
|
||||
scene_add_object(OBJID_PLAYER, 424, 575, 51, 111, _binary_sprite_stickman_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;
|
||||
}
|
||||
scene_set_navmesh(&navmesh_managers_office);
|
||||
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;
|
||||
}
|
||||
scene_set_navmesh(&navmesh_basement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +109,24 @@ void onclick(int curscene, int objid) {
|
|||
}
|
||||
break;
|
||||
case SCENE_MANAGERS_OFFICE:
|
||||
case SCENE_MANAGERS_OFFICE_SAFE:
|
||||
switch(objid) {
|
||||
case OBJID_DOOR_TO_LOBBY_FROM_MANAGERS_OFFICE:
|
||||
transition_scene(SCENE_LOBBY);
|
||||
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);
|
||||
start_player_walk_to_point(895, 497);
|
||||
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;
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.9" tiledversion="1.9.2" orientation="orthogonal" renderorder="right-down" width="40" height="25" tilewidth="32" tileheight="32" infinite="0" nextlayerid="5" nextobjectid="4">
|
||||
<layer id="1" name="Tile Layer 1" width="40" height="25">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
</data>
|
||||
</layer>
|
||||
<imagelayer id="2" name="Image Layer 1">
|
||||
<image source="../build/default/basement.png" width="1280" height="800"/>
|
||||
</imagelayer>
|
||||
<objectgroup id="3" name="navmesh">
|
||||
<object id="1" x="348" y="398">
|
||||
<polygon points="0,0 181,0 180,41 -68,117"/>
|
||||
</object>
|
||||
<object id="2" x="280" y="515">
|
||||
<polygon points="0,0 -101,174 821,174 679,-74 248,-76"/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="4" name="Object Layer 2">
|
||||
<object id="3" x="396" y="86" width="85" height="312"/>
|
||||
</objectgroup>
|
||||
</map>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.9" tiledversion="1.9.2" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="32" tileheight="32" infinite="0" nextlayerid="4" nextobjectid="19">
|
||||
<map version="1.9" tiledversion="1.9.2" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="32" tileheight="32" infinite="0" nextlayerid="5" nextobjectid="22">
|
||||
<layer id="1" name="Tile Layer 1" width="30" height="20">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
@ -29,58 +29,42 @@
|
|||
</imagelayer>
|
||||
<objectgroup id="3" name="navmesh">
|
||||
<object id="1" x="305" y="491">
|
||||
<polygon points="0,0 42,73 -93,163"/>
|
||||
<polygon points="0,0 68,0 42,72 -40,73"/>
|
||||
</object>
|
||||
<object id="2" x="177" y="715">
|
||||
<polygon points="35,-61 170,-151 133,-61"/>
|
||||
</object>
|
||||
<object id="3" x="312" y="654">
|
||||
<polygon points="-2,0 -27,60 148,0"/>
|
||||
<polygon points="35,-61 88,-151 170,-152 133,-61"/>
|
||||
</object>
|
||||
<object id="4" x="212" y="654">
|
||||
<polygon points="0,0 -33,60 73,60"/>
|
||||
</object>
|
||||
<object id="5" x="212" y="654">
|
||||
<polygon points="0,0 98,0 73,60"/>
|
||||
<polygon points="0,0 -33,60 73,60 98,0"/>
|
||||
</object>
|
||||
<object id="6" x="285" y="714">
|
||||
<polygon points="0,0 175,0 175,-60"/>
|
||||
<polygon points="0,0 175,0 175,-60 25,-60"/>
|
||||
</object>
|
||||
<object id="7" x="305" y="491">
|
||||
<polygon points="0,0 187,1 169,71"/>
|
||||
</object>
|
||||
<object id="8" x="305" y="491">
|
||||
<polygon points="0,0 42,73 169,71"/>
|
||||
<polygon points="68,0 187,1 169,71 42,72"/>
|
||||
</object>
|
||||
<object id="9" x="595" y="417">
|
||||
<polygon points="0,0 0,75 189,0"/>
|
||||
</object>
|
||||
<object id="10" x="595" y="492">
|
||||
<polygon points="0,0 229,0 189,-75"/>
|
||||
<polygon points="0,0 0,75 229,75 189,0"/>
|
||||
</object>
|
||||
<object id="11" x="824" y="492">
|
||||
<polygon points="0,0 105,222 278,222"/>
|
||||
<polygon points="203,92 105,222 278,222"/>
|
||||
</object>
|
||||
<object id="12" x="825" y="493">
|
||||
<polygon points="-1,-1 149,-1 277,221"/>
|
||||
</object>
|
||||
<object id="13" x="595" y="492">
|
||||
<polygon points="0,0 334,222 229,0"/>
|
||||
<polygon points="-1,-1 149,-1 202,91"/>
|
||||
</object>
|
||||
<object id="14" x="595" y="492">
|
||||
<polygon points="0,0 0,222 334,222"/>
|
||||
<polygon points="0,0 -121,70 -135,162 0,222 334,222 432,92 229,0"/>
|
||||
</object>
|
||||
<object id="15" x="474" y="562">
|
||||
<polygon points="0,0 18,-70 121,-70"/>
|
||||
</object>
|
||||
<object id="16" x="474" y="562">
|
||||
<polygon points="0,0 121,-70 121,152"/>
|
||||
</object>
|
||||
<object id="17" x="474" y="562">
|
||||
<polygon points="0,0 -14,92 121,152"/>
|
||||
</object>
|
||||
<object id="18" x="460" y="654">
|
||||
<polygon points="0,0 0,60 135,60"/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="4" name="Object Layer 2">
|
||||
<object id="19" x="740" y="440" width="151" height="276"/>
|
||||
<object id="20" x="332" y="565" width="139" height="87"/>
|
||||
<object id="21" x="784" y="297" width="191" height="188"/>
|
||||
</objectgroup>
|
||||
</map>
|
||||
|
|
|
@ -167,14 +167,15 @@ void scene_set_navmesh(struct navmesh *navmesh) {
|
|||
}
|
||||
|
||||
static uint32_t scene_generation_count = 0;
|
||||
static int curscene;
|
||||
static int curscene = -1;
|
||||
void transition_scene(int scene) {
|
||||
int prevscene = curscene;
|
||||
scene_generation_count++;
|
||||
curscene = scene;
|
||||
memset(objects, 0, sizeof objects);
|
||||
memset(scripts, 0, sizeof scripts); // script state is local to scene, so no cancel notification
|
||||
cur_navmesh = &null_navmesh;
|
||||
scene_setup(scene);
|
||||
scene_setup(scene, prevscene);
|
||||
}
|
||||
|
||||
void scene_add_object(int id, int x, int y, int width, int height, const char *pixels) {
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue