mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-26 19:43:41 +01:00
Added portal support
This commit is contained in:
parent
48f1f44b5b
commit
a3d0ca40c1
4 changed files with 46 additions and 10 deletions
|
@ -327,6 +327,7 @@ def convert_map(input: str, output: str, params: dict, target):
|
|||
portal_struct += fxconv.u32(rect[3])
|
||||
# Add a reference to the destination portal
|
||||
portal_struct += fxconv.ref(f"{dest_file_name}_{dest_portal}")
|
||||
portal_struct += fxconv.ref(f"{dest_file_name}")
|
||||
map_struct += fxconv.ptr(portal_struct)
|
||||
map_struct += fxconv.u32(dialog_num)
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
86,93,94,1,1,1,1,1,9,10,1,92,
|
||||
110,117,118,1,1,1,1,1,33,34,1,116,
|
||||
86,1,1,1,1,1,1,1,1,1,1,92,
|
||||
110,1,1,1,1,1,1,1,1,1,1,116,
|
||||
110,1,1,1,1,133,2,1,1,1,1,92,
|
||||
110,1,1,1,1,2,2,1,1,1,1,116
|
||||
110,1,1,1,1,133,2,1,1,1,1,116,
|
||||
110,1,1,1,1,2,2,1,1,1,1,92,
|
||||
110,114,114,114,114,114,114,114,114,114,114,116
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Foreground" width="12" height="8">
|
||||
|
@ -40,11 +40,11 @@
|
|||
410,0,0,0,0,0,0,0,0,0,0,410,
|
||||
410,0,0,0,0,0,0,0,0,0,0,410,
|
||||
410,0,0,0,0,0,0,0,0,0,0,410,
|
||||
410,0,0,0,0,0,0,0,0,0,0,410
|
||||
410,410,410,410,410,410,410,410,410,410,410,410
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="4" name="ExtraData">
|
||||
<object id="2" name="porte" type="PORTAL" x="39.9918" y="56.0098" width="15.8058" height="7.84986">
|
||||
<object id="2" name="porte" type="PORTAL" x="39.6736" y="40.0979" width="15.8058" height="15.9119">
|
||||
<properties>
|
||||
<property name="dest" type="file" value="level0.tmx"/>
|
||||
<property name="destPortal" value="taverne"/>
|
||||
|
|
43
src/game.c
43
src/game.c
|
@ -82,11 +82,20 @@ void game_logic(Game *game) {
|
|||
|
||||
void game_render_indicator(Game *game) {
|
||||
/* nothing to do for the player so we quit */
|
||||
if(game->player.canDoSomething == false)
|
||||
return;
|
||||
|
||||
/* else we draw a small indicator on the screen */
|
||||
dimage(5, 5, &SignAction_img);
|
||||
if(game->player.canDoSomething)
|
||||
dimage(5, 5, &SignAction_img);
|
||||
int i;
|
||||
Player *player = &game->player;
|
||||
for(i=0;i<game->map_level->nbPortal;i++){
|
||||
Portal *portal = &game->map_level->portals[i];
|
||||
if(player->x >= portal->collider.x1*PXSIZE &&
|
||||
player->x < portal->collider.x2*PXSIZE &&
|
||||
player->y >= portal->collider.y1*PXSIZE &&
|
||||
player->y < portal->collider.y2*PXSIZE){
|
||||
dimage(5, 5, &SignAction_img);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void game_draw(Game *game) {
|
||||
|
@ -100,6 +109,7 @@ void game_draw(Game *game) {
|
|||
/*DEBUG*/
|
||||
dprint(8, 8, C_BLACK, "Lifes: %d", game->player.life);
|
||||
dprint(8, 16, C_BLACK, "Mana: %d", game->mana);
|
||||
dprint(8, 24, C_BLACK, "X: %d Y: %d", game->player.x, game->player.y);
|
||||
}
|
||||
|
||||
/* Key management */
|
||||
|
@ -133,6 +143,29 @@ void game_get_inputs(Game *game) {
|
|||
sleep();
|
||||
}
|
||||
}
|
||||
Player *player = &game->player;
|
||||
if(keydown(KEY_SHIFT)){
|
||||
int i;
|
||||
for(i=0;i<game->map_level->nbPortal;i++){
|
||||
Portal *portal = &game->map_level->portals[i];
|
||||
if(player->x >= portal->collider.x1*PXSIZE &&
|
||||
player->x < portal->collider.x2*PXSIZE &&
|
||||
player->y >= portal->collider.y1*PXSIZE &&
|
||||
player->y < portal->collider.y2*PXSIZE){
|
||||
Portal *dest_portal = (Portal*)portal->portal;
|
||||
Collider dest_collider = dest_portal->collider;
|
||||
Map *dest_map = (Map*)portal->map;
|
||||
player->x = (dest_collider.x1+dest_collider.x2)/2*PXSIZE;
|
||||
player->y = (dest_collider.y1+dest_collider.y2)/2*PXSIZE;
|
||||
game->map_level = dest_map;
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_SHIFT)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display Debug Information on screen */
|
||||
#if DEBUGMODE
|
||||
|
|
|
@ -111,6 +111,8 @@ typedef struct {
|
|||
Collider collider;
|
||||
/* The destination portal */
|
||||
void *portal;
|
||||
/* The destination map */
|
||||
void *map;
|
||||
} Portal;
|
||||
|
||||
typedef struct {
|
||||
|
|
Loading…
Reference in a new issue