Compare commits
No commits in common. "26eeec5638cd275e874419f407f1a65c7f4e1c0e" and "1fa48b21767ee48fc5e284ef3793b3b5be5dcd5a" have entirely different histories.
26eeec5638
...
1fa48b2176
|
@ -177,20 +177,21 @@ uint8_t check_collision_offset(Entity_t* p_ent, Vector2 pos, Vector2 bbox_sz, Ti
|
|||
|
||||
bool check_on_ground(Entity_t* p_ent, Vector2 pos, Vector2 prev_pos, Vector2 bbox_sz, TileGrid_t* grid)
|
||||
{
|
||||
//return check_collision_at(ent_idx, pos, bbox_sz, grid, (Vector2){0, 1}, p_manager);
|
||||
Vector2 new_pos = Vector2Add(pos, (Vector2){0, 1});
|
||||
CollideEntity_t ent = {
|
||||
.p_ent = p_ent,
|
||||
.bbox = (Rectangle){new_pos.x, new_pos.y + bbox_sz.y, bbox_sz.x, 1},
|
||||
.bbox = (Rectangle){new_pos.x, new_pos.y + bbox_sz.y - 1, bbox_sz.x, 1},
|
||||
.prev_bbox = (Rectangle){prev_pos.x, prev_pos.y, bbox_sz.x, bbox_sz.y},
|
||||
.area = (TileArea_t){
|
||||
.tile_x1 = (new_pos.x) / grid->tile_size,
|
||||
.tile_y1 = (new_pos.y + bbox_sz.y) / grid->tile_size,
|
||||
.tile_x2 = (new_pos.x + bbox_sz.x) / grid->tile_size,
|
||||
.tile_y2 = (new_pos.y + bbox_sz.y) / grid->tile_size
|
||||
.tile_y1 = (new_pos.y + bbox_sz.y - 1) / grid->tile_size,
|
||||
.tile_x2 = (new_pos.x + bbox_sz.x - 1) / grid->tile_size,
|
||||
.tile_y2 = (new_pos.y + bbox_sz.y - 1) / grid->tile_size
|
||||
}
|
||||
};
|
||||
|
||||
return check_collision_line(&ent, grid, true) == 1;
|
||||
return check_collision(&ent, grid, true);
|
||||
}
|
||||
|
||||
uint8_t check_bbox_edges(
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
#include <unistd.h>
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
EM_BOOL keyDownCallback(int eventType, const EmscriptenKeyboardEvent *event, void* userData) {
|
||||
return true; // Just preventDefault everything lol
|
||||
}
|
||||
#endif
|
||||
|
||||
Scene_t* scenes[1];
|
||||
|
@ -76,8 +72,6 @@ int main(void)
|
|||
|
||||
#if defined(PLATFORM_WEB)
|
||||
puts("Setting emscripten main loop");
|
||||
emscripten_set_keypress_callback("#canvas", NULL, 1, keyDownCallback);
|
||||
emscripten_set_keydown_callback("#canvas", NULL, 1, keyDownCallback);
|
||||
emscripten_set_main_loop(update_loop, 0, 1);
|
||||
#else
|
||||
puts("Regular main loop");
|
||||
|
|
|
@ -581,8 +581,9 @@ void player_bbox_update_system(Scene_t* scene)
|
|||
}
|
||||
|
||||
CHitBoxes_t* p_hitbox = get_component(p_player, CHITBOXES_T);
|
||||
p_hitbox->boxes[0].height = p_bbox->size.y + 4;
|
||||
p_hitbox->boxes[1].height = p_bbox->size.y;
|
||||
p_hitbox->boxes[0].height = p_bbox->size.y + 2;
|
||||
//p_hitbox->boxes[1].y = p_bbox->size.y / 4;
|
||||
p_hitbox->boxes[1].height = p_bbox->size.y - 1;
|
||||
CHurtbox_t* p_hurtbox = get_component(p_player, CHURTBOX_T);
|
||||
p_hurtbox->size = p_bbox->size;
|
||||
}
|
||||
|
@ -1472,7 +1473,7 @@ void state_transition_update_system(Scene_t* scene)
|
|||
{
|
||||
play_sfx(scene->engine, BOULDER_LAND_SFX);
|
||||
}
|
||||
else if (p_ent->m_tag == CRATES_ENT_TAG || p_ent->m_tag == CHEST_ENT_TAG)
|
||||
else if (p_ent->m_tag == CRATES_ENT_TAG)
|
||||
{
|
||||
play_sfx(scene->engine, WOOD_LAND_SFX);
|
||||
}
|
||||
|
@ -1493,6 +1494,33 @@ void state_transition_update_system(Scene_t* scene)
|
|||
|
||||
}
|
||||
|
||||
if (p_mstate->water_state & 1)
|
||||
{
|
||||
CEmitter_t* p_emitter = get_component(p_ent, CEMITTER_T);
|
||||
if (p_emitter != NULL)
|
||||
{
|
||||
if (!is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
|
||||
{
|
||||
Vector2 new_pos = p_ctransform->position;
|
||||
new_pos.y += p_bbox->half_size.y;
|
||||
|
||||
ParticleEmitter_t emitter = {
|
||||
.spr = get_sprite(&scene->engine->assets, "p_water"),
|
||||
.config = get_emitter_conf(&scene->engine->assets, "pe_bubbling"),
|
||||
.position = new_pos,
|
||||
.n_particles = 5,
|
||||
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||
.update_func = &floating_particle_system_update,
|
||||
.emitter_update_func = &check_in_water,
|
||||
};
|
||||
p_emitter->handle = play_particle_emitter(&scene->part_sys, &emitter);
|
||||
}
|
||||
else
|
||||
{
|
||||
play_emitter_handle(&scene->part_sys, p_emitter->handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1591,8 +1619,8 @@ void hitbox_update_system(Scene_t* scene)
|
|||
|
||||
unsigned int tile_x1 = (hitbox_pos.x) / TILE_SIZE;
|
||||
unsigned int tile_y1 = (hitbox_pos.y) / TILE_SIZE;
|
||||
unsigned int tile_x2 = (hitbox_pos.x + p_hitbox->boxes[i].width) / TILE_SIZE;
|
||||
unsigned int tile_y2 = (hitbox_pos.y + p_hitbox->boxes[i].height) / TILE_SIZE;
|
||||
unsigned int tile_x2 = (hitbox_pos.x + p_hitbox->boxes[i].width - 1) / TILE_SIZE;
|
||||
unsigned int tile_y2 = (hitbox_pos.y + p_hitbox->boxes[i].height - 1) / TILE_SIZE;
|
||||
tile_x2 = (tile_x2 >= tilemap.width) ? tilemap.width - 1 : tile_x2;
|
||||
tile_y2 = (tile_y2 >= tilemap.height) ? tilemap.width - 1 : tile_y2;
|
||||
|
||||
|
@ -1674,10 +1702,6 @@ void hitbox_update_system(Scene_t* scene)
|
|||
p_cjump->short_hop = false;
|
||||
p_cjump->jumped = true;
|
||||
}
|
||||
if (p_ent->m_tag == PLAYER_ENT_TAG)
|
||||
{
|
||||
data->camera.base_y = p_ctransform->position.y;
|
||||
}
|
||||
}
|
||||
else if (p_ctransform->position.y >= p_other_ct->position.y + p_other_bbox->size.y)
|
||||
{
|
||||
|
@ -1904,7 +1928,7 @@ void airtimer_update_system(Scene_t* scene)
|
|||
if (p_ctransform == NULL || p_bbox == NULL || p_movement == NULL) continue;
|
||||
|
||||
Vector2 point_to_check = {
|
||||
p_ctransform->position.x + p_bbox->half_size.x,
|
||||
(p_movement->x_dir == 0) ? p_ctransform->position.x : p_ctransform->position.x + p_bbox->size.x,
|
||||
p_ctransform->position.y + p_bbox->half_size.y / 2,
|
||||
};
|
||||
|
||||
|
@ -1929,33 +1953,9 @@ void airtimer_update_system(Scene_t* scene)
|
|||
p_air->curr_count = p_air->max_count;
|
||||
p_air->curr_ftimer = p_air->max_ftimer * 2; // Lengthen the first
|
||||
}
|
||||
else
|
||||
{
|
||||
CEmitter_t* p_emitter = get_component(p_ent, CEMITTER_T);
|
||||
if (p_emitter != NULL)
|
||||
{
|
||||
if (!is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
|
||||
{
|
||||
Vector2 new_pos = p_ctransform->position;
|
||||
new_pos.y += p_bbox->half_size.y;
|
||||
|
||||
ParticleEmitter_t emitter = {
|
||||
.spr = get_sprite(&scene->engine->assets, "p_water"),
|
||||
.config = get_emitter_conf(&scene->engine->assets, "pe_bubbling"),
|
||||
.position = new_pos,
|
||||
.n_particles = 5,
|
||||
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||
.update_func = &floating_particle_system_update,
|
||||
.emitter_update_func = &check_in_water,
|
||||
};
|
||||
p_emitter->handle = play_particle_emitter(&scene->part_sys, &emitter);
|
||||
}
|
||||
else
|
||||
if (p_movement->water_state & 1)
|
||||
{
|
||||
play_emitter_handle(&scene->part_sys, p_emitter->handle);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_air->curr_ftimer > p_air->decay_rate)
|
||||
{
|
||||
p_air->curr_ftimer -= p_air->decay_rate;
|
||||
|
@ -1989,6 +1989,7 @@ void airtimer_update_system(Scene_t* scene)
|
|||
destroy_entity(scene, &tilemap, get_entity(&scene->ent_manager, ent_idx));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,15 +81,15 @@ Entity_t* create_player(EntityManager_t* ent_manager)
|
|||
p_hitbox->n_boxes = 2;
|
||||
p_hitbox->boxes[0] = (Rectangle) {
|
||||
.x = 0,
|
||||
.y = -2,
|
||||
.width = p_bbox->size.x,
|
||||
.height = p_bbox->size.y + 4,
|
||||
.y = -1,
|
||||
.width = p_bbox->size.x - 1,
|
||||
.height = p_bbox->size.y + 2,
|
||||
};
|
||||
p_hitbox->boxes[1] = (Rectangle) {
|
||||
.x = -2,
|
||||
.x = -1,
|
||||
.y = 0,
|
||||
.width = p_bbox->size.x + 4,
|
||||
.height = p_bbox->size.y,
|
||||
.width = p_bbox->size.x + 2,
|
||||
.height = p_bbox->size.y - 1,
|
||||
};
|
||||
p_hitbox->atk = 2;
|
||||
CHurtbox_t* p_hurtbox = add_component(p_ent, CHURTBOX_T);
|
||||
|
|
Loading…
Reference in New Issue