Rework urchin collision with crates
Changelog: - Fix error in urchin spawning in main game - Reduce urchin's collision box - Adjust crate destruction: - Delay with arrows and bombs, instant with anything elsemain
parent
613d5642cc
commit
6509b33c5a
|
@ -1730,21 +1730,14 @@ void hitbox_update_system(Scene_t* scene)
|
||||||
{
|
{
|
||||||
remove_component(p_other_ent, CHURTBOX_T);
|
remove_component(p_other_ent, CHURTBOX_T);
|
||||||
CLifeTimer_t* p_clifetimer = add_component(p_other_ent, CLIFETIMER_T);
|
CLifeTimer_t* p_clifetimer = add_component(p_other_ent, CLIFETIMER_T);
|
||||||
if (p_other_ent->m_tag == CRATES_ENT_TAG)
|
if (p_other_ent->m_tag == CRATES_ENT_TAG
|
||||||
|
&& (p_ent->m_tag == ARROW_ENT_TAG || p_ent->m_tag == DESTRUCTABLE_ENT_TAG))
|
||||||
{
|
{
|
||||||
CContainer_t* p_container = get_component(p_other_ent, CCONTAINER_T);
|
p_clifetimer->life_time = 0.1f;
|
||||||
if (p_container->item == CONTAINER_BOMB)
|
|
||||||
{
|
|
||||||
p_clifetimer->life_time = 0.1f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_clifetimer->life_time = 0.1f;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p_clifetimer->life_time = 0.05f;
|
p_clifetimer->life_time = 0.01f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
|
|
||||||
static SpriteRenderInfo_t item_sprite_map[22] = {0};
|
static SpriteRenderInfo_t item_sprite_map[22] = {0};
|
||||||
|
#define URCHIN_OFFSET 6
|
||||||
bool init_item_creation(Assets_t* assets)
|
bool init_item_creation(Assets_t* assets)
|
||||||
{
|
{
|
||||||
item_sprite_map[0].sprite = get_sprite(assets, "w_crate");
|
item_sprite_map[0].sprite = get_sprite(assets, "w_crate");
|
||||||
|
@ -46,6 +46,7 @@ bool init_item_creation(Assets_t* assets)
|
||||||
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};
|
item_sprite_map[20].offset = (Vector2){0, TILE_SIZE >> 1};
|
||||||
item_sprite_map[21].sprite = get_sprite(assets, "urchin");
|
item_sprite_map[21].sprite = get_sprite(assets, "urchin");
|
||||||
|
item_sprite_map[21].offset = (Vector2){-URCHIN_OFFSET, -URCHIN_OFFSET};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ Entity_t* create_urchin(EntityManager_t* ent_manager)
|
||||||
if (p_urchin == NULL) return NULL;
|
if (p_urchin == NULL) return NULL;
|
||||||
|
|
||||||
CBBox_t* p_bbox = add_component(p_urchin, CBBOX_COMP_T);
|
CBBox_t* p_bbox = add_component(p_urchin, CBBOX_COMP_T);
|
||||||
set_bbox(p_bbox, TILE_SIZE-2, TILE_SIZE-2);
|
set_bbox(p_bbox, TILE_SIZE-(URCHIN_OFFSET<<1), TILE_SIZE-(URCHIN_OFFSET<<1));
|
||||||
|
|
||||||
CTransform_t* p_ctransform = add_component(p_urchin, CTRANSFORM_COMP_T);
|
CTransform_t* p_ctransform = add_component(p_urchin, CTRANSFORM_COMP_T);
|
||||||
p_ctransform->movement_mode = KINEMATIC_MOVEMENT;
|
p_ctransform->movement_mode = KINEMATIC_MOVEMENT;
|
||||||
|
@ -272,7 +273,7 @@ Entity_t* create_urchin(EntityManager_t* ent_manager)
|
||||||
|
|
||||||
CHitBoxes_t* p_hitbox = add_component(p_urchin, CHITBOXES_T);
|
CHitBoxes_t* p_hitbox = add_component(p_urchin, CHITBOXES_T);
|
||||||
p_hitbox->n_boxes = 1;
|
p_hitbox->n_boxes = 1;
|
||||||
p_hitbox->boxes[0] = (Rectangle) {-1,-1,TILE_SIZE,TILE_SIZE};
|
p_hitbox->boxes[0] = (Rectangle) {-(URCHIN_OFFSET>>1),-(URCHIN_OFFSET>>1),TILE_SIZE-URCHIN_OFFSET,TILE_SIZE-URCHIN_OFFSET};
|
||||||
p_hitbox->atk = 2;
|
p_hitbox->atk = 2;
|
||||||
|
|
||||||
CSprite_t* p_cspr = add_component(p_urchin, CSPRITE_T);
|
CSprite_t* p_cspr = add_component(p_urchin, CSPRITE_T);
|
||||||
|
|
|
@ -228,7 +228,7 @@ bool load_level_tilemap(LevelScene_t* scene, unsigned int level_num)
|
||||||
CBBox_t* p_bbox = get_component(ent, CBBOX_COMP_T);
|
CBBox_t* p_bbox = get_component(ent, CBBOX_COMP_T);
|
||||||
ent->position.x = (i % scene->data.tilemap.width) * scene->data.tilemap.tile_size + (scene->data.tilemap.tile_size >> 1) - p_bbox->half_size.x;
|
ent->position.x = (i % scene->data.tilemap.width) * scene->data.tilemap.tile_size + (scene->data.tilemap.tile_size >> 1) - p_bbox->half_size.x;
|
||||||
|
|
||||||
ent->position.y = (i / scene->data.tilemap.width) * scene->data.tilemap.tile_size + (scene->data.tilemap.tile_size >> 1) + (scene->data.tilemap.tile_size >> 1) - p_bbox->half_size.y;
|
ent->position.y = (int)(i / scene->data.tilemap.width) * scene->data.tilemap.tile_size + (scene->data.tilemap.tile_size >> 1) - p_bbox->half_size.y;
|
||||||
|
|
||||||
uint8_t spd_encoding = lvl_map.tiles[i].tile_type - 25;
|
uint8_t spd_encoding = lvl_map.tiles[i].tile_type - 25;
|
||||||
float angle = 45.0f / 180.0f * PI * ((spd_encoding >> 2) & 7);
|
float angle = 45.0f / 180.0f * PI * ((spd_encoding >> 2) & 7);
|
||||||
|
|
Loading…
Reference in New Issue