Merge branch 'main' into profiling
commit
8a731637f7
|
@ -54,6 +54,7 @@ typedef struct _CTransform_t {
|
||||||
Vector2 shape_factor;
|
Vector2 shape_factor;
|
||||||
float grav_delay;
|
float grav_delay;
|
||||||
float grav_timer;
|
float grav_timer;
|
||||||
|
float bounce_coeff;
|
||||||
MovementMode_t movement_mode;
|
MovementMode_t movement_mode;
|
||||||
bool active;
|
bool active;
|
||||||
} CTransform_t;
|
} CTransform_t;
|
||||||
|
|
|
@ -1130,6 +1130,7 @@ static void at_level_dead(Scene_t* scene)
|
||||||
{
|
{
|
||||||
p_pstate->locked = true;
|
p_pstate->locked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
change_level_state(data, LEVEL_STATE_STARTING);
|
change_level_state(data, LEVEL_STATE_STARTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,6 +1217,11 @@ void init_sandbox_scene(LevelScene_t* scene)
|
||||||
scene->data.player_spawn = p_player->position;
|
scene->data.player_spawn = p_player->position;
|
||||||
scene->data.camera.target_pos = p_player->position;
|
scene->data.camera.target_pos = p_player->position;
|
||||||
scene->data.camera.cam.target = p_player->position;
|
scene->data.camera.cam.target = p_player->position;
|
||||||
|
|
||||||
|
Entity_t* p_urchin = create_urchin(&scene->scene.ent_manager);
|
||||||
|
p_urchin->position = p_player->position;
|
||||||
|
p_urchin->position.x += 64;
|
||||||
|
p_urchin->position.y -= 240;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_entity_manager(&scene->scene.ent_manager);
|
update_entity_manager(&scene->scene.ent_manager);
|
||||||
|
|
|
@ -16,6 +16,7 @@ Entity_t* create_boulder(EntityManager_t* ent_manager);
|
||||||
Entity_t* create_arrow(EntityManager_t* ent_manager, uint8_t dir);
|
Entity_t* create_arrow(EntityManager_t* ent_manager, uint8_t dir);
|
||||||
Entity_t* create_bomb(EntityManager_t* ent_manager, Vector2 launch_dir);
|
Entity_t* create_bomb(EntityManager_t* ent_manager, Vector2 launch_dir);
|
||||||
Entity_t* create_explosion(EntityManager_t* ent_manager);
|
Entity_t* create_explosion(EntityManager_t* ent_manager);
|
||||||
|
Entity_t* create_urchin(EntityManager_t* ent_manager);
|
||||||
Entity_t* create_chest(EntityManager_t* ent_manager);
|
Entity_t* create_chest(EntityManager_t* ent_manager);
|
||||||
Entity_t* create_level_end(EntityManager_t* ent_manager);
|
Entity_t* create_level_end(EntityManager_t* ent_manager);
|
||||||
|
|
||||||
|
|
|
@ -827,21 +827,20 @@ void tile_collision_system(Scene_t* scene)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collide_side & (1<<3))
|
if (
|
||||||
|
((collide_side & (1<<3)) && (p_ctransform->velocity.x < 0))
|
||||||
|
|| ((collide_side & (1<<2)) && (p_ctransform->velocity.x > 0))
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (p_ctransform->velocity.x < 0) p_ctransform->velocity.x = 0;
|
p_ctransform->velocity.x *= -p_ctransform->bounce_coeff;
|
||||||
}
|
}
|
||||||
if (collide_side & (1<<2))
|
|
||||||
|
if (
|
||||||
|
((collide_side & (1<<1)) && (p_ctransform->velocity.y < 0))
|
||||||
|
|| ((collide_side & (1)) && (p_ctransform->velocity.y > 0))
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (p_ctransform->velocity.x > 0) p_ctransform->velocity.x = 0;
|
p_ctransform->velocity.y *= -p_ctransform->bounce_coeff;
|
||||||
}
|
|
||||||
if (collide_side & (1<<1))
|
|
||||||
{
|
|
||||||
if (p_ctransform->velocity.y < 0) p_ctransform->velocity.y = 0;
|
|
||||||
}
|
|
||||||
if (collide_side & (1))
|
|
||||||
{
|
|
||||||
if (p_ctransform->velocity.y > 0) p_ctransform->velocity.y = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float decimal;
|
float decimal;
|
||||||
|
@ -1314,7 +1313,7 @@ void movement_update_system(Scene_t* scene)
|
||||||
{
|
{
|
||||||
p_ent->position.x = p_ent->position.x;
|
p_ent->position.x = p_ent->position.x;
|
||||||
}
|
}
|
||||||
p_ctransform->velocity.x = 0;
|
p_ctransform->velocity.x *= -p_ctransform->bounce_coeff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p_ent->position.y < 0 || p_ent->position.y + p_bbox->size.y > level_height)
|
if(p_ent->position.y < 0 || p_ent->position.y + p_bbox->size.y > level_height)
|
||||||
|
@ -1328,7 +1327,7 @@ void movement_update_system(Scene_t* scene)
|
||||||
{
|
{
|
||||||
p_ent->position.y = p_ent->position.y;
|
p_ent->position.y = p_ent->position.y;
|
||||||
}
|
}
|
||||||
p_ctransform->velocity.y = 0;
|
p_ctransform->velocity.y *= -p_ctransform->bounce_coeff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "EC.h"
|
||||||
|
#include "assets_tag.h"
|
||||||
#include "ent_impl.h"
|
#include "ent_impl.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
|
@ -242,6 +244,39 @@ Entity_t* create_explosion(EntityManager_t* ent_manager)
|
||||||
return p_explosion;
|
return p_explosion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entity_t* create_urchin(EntityManager_t* ent_manager)
|
||||||
|
{
|
||||||
|
Entity_t* p_urchin = add_entity(ent_manager, NO_ENT_TAG);
|
||||||
|
if (p_urchin == NULL) return NULL;
|
||||||
|
|
||||||
|
CBBox_t* p_bbox = add_component(p_urchin, CBBOX_COMP_T);
|
||||||
|
set_bbox(p_bbox, TILE_SIZE, TILE_SIZE);
|
||||||
|
|
||||||
|
CTransform_t* p_ctransform = add_component(p_urchin, CTRANSFORM_COMP_T);
|
||||||
|
p_ctransform->movement_mode = KINEMATIC_MOVEMENT;
|
||||||
|
p_ctransform->bounce_coeff = 1.0f;
|
||||||
|
p_ctransform->velocity.x = -100;
|
||||||
|
p_ctransform->active = true;
|
||||||
|
|
||||||
|
add_component(p_urchin, CTILECOORD_COMP_T);
|
||||||
|
CHurtbox_t* p_hurtbox = add_component(p_urchin, CHURTBOX_T);
|
||||||
|
p_hurtbox->size = p_bbox->size;
|
||||||
|
p_hurtbox->def = 2;
|
||||||
|
p_hurtbox->damage_src = -1;
|
||||||
|
|
||||||
|
CHitBoxes_t* p_hitbox = add_component(p_urchin, CHITBOXES_T);
|
||||||
|
p_hitbox->n_boxes = 1;
|
||||||
|
p_hitbox->boxes[0] = (Rectangle){3, 3, 26, 26};
|
||||||
|
p_hitbox->atk = 3;
|
||||||
|
|
||||||
|
CSprite_t* p_cspr = add_component(p_urchin, CSPRITE_T);
|
||||||
|
p_cspr->sprites = item_sprite_map;
|
||||||
|
p_cspr->current_idx = 0;
|
||||||
|
|
||||||
|
|
||||||
|
return p_urchin;
|
||||||
|
}
|
||||||
|
|
||||||
Entity_t* create_chest(EntityManager_t* ent_manager)
|
Entity_t* create_chest(EntityManager_t* ent_manager)
|
||||||
{
|
{
|
||||||
Entity_t* p_chest = add_entity(ent_manager, CHEST_ENT_TAG);
|
Entity_t* p_chest = add_entity(ent_manager, CHEST_ENT_TAG);
|
||||||
|
|
Loading…
Reference in New Issue