Add sprites for player finishing the stage
Also add cave exit sprite They are all placeholder for now.main
parent
bf655daf8d
commit
2be80ea6bf
|
@ -7,6 +7,7 @@ bool init_player_creation(const char* info_file, Assets_t* assets);
|
|||
bool init_player_creation_rres(const char* rres_file, const char* file, Assets_t* assets);
|
||||
Entity_t* create_player(EntityManager_t* ent_manager);
|
||||
Entity_t* create_dead_player(EntityManager_t* ent_manager);
|
||||
Entity_t* create_player_finish(EntityManager_t* ent_manager);
|
||||
|
||||
|
||||
bool init_item_creation(Assets_t* assets);
|
||||
|
|
|
@ -2017,6 +2017,16 @@ void level_end_detection_system(Scene_t* scene)
|
|||
)
|
||||
)
|
||||
{
|
||||
Entity_t* ent = create_player_finish(&scene->ent_manager);
|
||||
if (ent != NULL)
|
||||
{
|
||||
ent->position = p_flag->position;
|
||||
ent->position.y += tilemap.tile_size >> 1;
|
||||
CSprite_t* p_cspr = get_component(p_other_ent, CSPRITE_T);
|
||||
CSprite_t* new_cspr = get_component(ent, CSPRITE_T);
|
||||
new_cspr->flip_x = p_cspr->flip_x;
|
||||
|
||||
}
|
||||
destroy_entity(scene, &lvl_scene->data.tilemap, p_other_ent);
|
||||
change_level_state(&lvl_scene->data, LEVEL_STATE_COMPLETE);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "constants.h"
|
||||
#include "raymath.h"
|
||||
|
||||
static SpriteRenderInfo_t item_sprite_map[20] = {0};
|
||||
static SpriteRenderInfo_t item_sprite_map[21] = {0};
|
||||
|
||||
bool init_item_creation(Assets_t* assets)
|
||||
{
|
||||
|
@ -29,6 +29,10 @@ bool init_item_creation(Assets_t* assets)
|
|||
item_sprite_map[17].offset = (Vector2){-12, -12};
|
||||
item_sprite_map[18].sprite = get_sprite(assets, "chest");
|
||||
item_sprite_map[19].sprite = get_sprite(assets, "boulder");
|
||||
item_sprite_map[20].sprite = get_sprite(assets, "exit");
|
||||
item_sprite_map[20].src_anchor = AP_BOT_CENTER;
|
||||
item_sprite_map[20].src_anchor = AP_BOT_CENTER;
|
||||
item_sprite_map[20].offset = (Vector2){0, TILE_SIZE >> 1};
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -256,6 +260,10 @@ Entity_t* create_level_end(EntityManager_t* ent_manager)
|
|||
Entity_t* p_flag = add_entity(ent_manager, LEVEL_END_TAG);
|
||||
if (p_flag == NULL) return NULL;
|
||||
|
||||
CSprite_t* p_cspr = add_component(p_flag, CSPRITE_T);
|
||||
p_cspr->sprites = item_sprite_map;
|
||||
p_cspr->current_idx = 20;
|
||||
|
||||
add_component(p_flag, CTILECOORD_COMP_T);
|
||||
return p_flag;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <string.h>
|
||||
#include "raymath.h"
|
||||
|
||||
#define N_PLAYER_SPRITES 11
|
||||
#define N_PLAYER_SPRITES 12
|
||||
enum PlayerSpriteEnum
|
||||
{
|
||||
SPR_PLAYER_STAND = 0,
|
||||
|
@ -18,6 +18,7 @@ enum PlayerSpriteEnum
|
|||
SPR_PLAYER_USWIM,
|
||||
SPR_PLAYER_DSWIM,
|
||||
SPR_PLAYER_DEAD,
|
||||
SPR_PLAYER_ENTER,
|
||||
};
|
||||
|
||||
static SpriteRenderInfo_t player_sprite_map[N_PLAYER_SPRITES] = {0};
|
||||
|
@ -136,6 +137,32 @@ Entity_t* create_dead_player(EntityManager_t* ent_manager)
|
|||
return p_ent;
|
||||
}
|
||||
|
||||
static unsigned int player_finish_transition_func(Entity_t* ent)
|
||||
{
|
||||
CSprite_t* p_spr = get_component(ent, CSPRITE_T);
|
||||
// Due to index-from-0
|
||||
if (p_spr->current_frame == p_spr->sprites[p_spr->current_idx].sprite->frame_count - 1)
|
||||
{
|
||||
p_spr->pause = true;
|
||||
}
|
||||
return p_spr->current_idx;
|
||||
}
|
||||
|
||||
Entity_t* create_player_finish(EntityManager_t* ent_manager)
|
||||
{
|
||||
Entity_t* p_ent = add_entity(ent_manager, NO_ENT_TAG);
|
||||
if (p_ent == NULL) return NULL;
|
||||
|
||||
CSprite_t* p_cspr = add_component(p_ent, CSPRITE_T);
|
||||
p_cspr->sprites = player_sprite_map;
|
||||
p_cspr->current_idx = SPR_PLAYER_ENTER;
|
||||
p_cspr->transition_func = &player_finish_transition_func;
|
||||
|
||||
add_component(p_ent, CTILECOORD_COMP_T);
|
||||
|
||||
return p_ent;
|
||||
}
|
||||
|
||||
static AnchorPoint_t parse_anchor_symbol(const char symbol[2])
|
||||
{
|
||||
if (symbol[0] == 't')
|
||||
|
|
Loading…
Reference in New Issue