Untitled
unknown
rust
7 months ago
1.1 kB
2
Indexable
Never
fn collide_below(cs: &SpatialHash, player: &mut Entity) { let below_pos_1 = vec2(player.pos.x - player.size.x / 2., player.pos.y - player.size.y / 2.0); let below_pos_2 = vec2(player.pos.x + player.size.x / 2., player.pos.y - player.size.y / 2.0); for (_hit, data) in cs.raycast(player.pos, below_pos_1) { if data.entity_type == 1 { player.grounded = true; player.grav = 5.; } else { player.grounded = false; if player.timer < 0.0 { player.grav += 10.0 * delta(); player.pos.y -= player.grav * delta(); } } } for (_hit, data)in cs.raycast(player.pos, below_pos_2) { if data.entity_type == 1 { player.grounded = true; player.grav = 5.; } else { player.grounded = false; if player.timer < 0.0 { player.grav += 10.0 * delta(); player.pos.y -= player.grav * delta(); } } } }
Leave a Comment