hope this doesn't lag

This commit is contained in:
kdx 2023-03-21 21:29:20 +01:00
parent 4beddb454c
commit a262d35146
3 changed files with 16 additions and 2 deletions

View File

@ -1 +1 @@
{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,5,0,0,0,1,1,1,1,5,0,0,0,0,0,0,0,0,2,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,5,0,0,0,0,0,4,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,5,0,0,1,1,1,1,1,1,1,5,0,0,0,0,0,5,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,0,5,1,1,5,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,0,0,5,0,0,1,1,0,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}
{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,5,0,0,0,1,1,1,1,5,0,0,0,0,0,0,0,2,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,5,0,0,0,0,0,4,1,1,1,1,1,1,0,0,5,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,5,0,0,1,1,1,1,1,1,1,5,0,0,0,0,0,5,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,0,5,1,1,5,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,0,0,5,0,0,1,1,0,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}

View File

@ -10,6 +10,7 @@ void
game_init(Game *this)
{
memset(this, 0, sizeof(*this));
this->player_dir = 1;
game_restart_scene(this);
}
@ -28,6 +29,7 @@ game_update(Game *this)
}
if (this->queue_next_scene) {
this->queue_next_scene = false;
this->player_dir = game_get_entity(this, ET_exit)->exit.dir;
map_next();
game_restart_scene(this);
return;
@ -61,7 +63,8 @@ game_restart_scene(Game *this)
Entity *e;
switch (map_get(x, y)) {
case 2:
player_init(game_create_entity(this), dx, dy);
e = player_init(game_create_entity(this), dx, dy);
e->player.dirx = this->player_dir;
break;
case 3:
case 4:
@ -100,3 +103,12 @@ game_entity_count(Game *this, unsigned int type)
count += (this->entities[i].type == type);
return count;
}
Entity *
game_get_entity(Game *this, unsigned int type)
{
for (int i = 0; i < MAX_ENTITIES; i++)
if (this->entities[i].type == type)
return &this->entities[i];
return NULL;
}

View File

@ -7,6 +7,7 @@ typedef struct Game {
unsigned int uuid;
bool queue_next_scene;
int queue_restart_scene;
int player_dir;
Entity entities[MAX_ENTITIES];
} Game;
@ -17,3 +18,4 @@ void game_draw(Game *this);
void game_restart_scene(Game *this);
Entity *game_create_entity(Game *this);
int game_entity_count(Game *this, unsigned int type);
Entity *game_get_entity(Game *this, unsigned int type);