fix: Поправил физику коллизий

This commit is contained in:
2026-08-28 20:39:05 +05:00
parent cdadd72635
commit 99cc4a4ff7
2 changed files with 45 additions and 60 deletions
+21 -26
View File
@@ -28,7 +28,7 @@ create_scene :: proc() -> Scene {
position = rl.Vector2{100, 100},
hp = 100,
walk_speed = 300,
run_speed = 500,
speed = 300,
col = 32,
},
camera = rl.Camera2D {
@@ -38,24 +38,24 @@ create_scene :: proc() -> Scene {
}
// _ = hm.add(
// &scene.enemies,
// Enemy {
// position = rl.Vector2{500, 500},
// hp = 100,
// speed = 100,
// col = 32,
// },
// )
// _ = hm.add(
// &scene.enemies,
// Enemy {
// position = rl.Vector2{600, 600},
// hp = 100,
// speed = 100,
// col = 32,
// },
// )
_ = hm.add(
&scene.enemies,
Enemy {
position = rl.Vector2{500, 500},
hp = 100,
speed = 100,
col = 32,
},
)
_ = hm.add(
&scene.enemies,
Enemy {
position = rl.Vector2{600, 600},
hp = 100,
speed = 100,
col = 32,
},
)
scene.atlas = load_atlas()
@@ -89,18 +89,12 @@ draw_scene :: proc(scene: ^Scene) {
rl.WHITE,
)
// for tile in scene.tiles {
// if tile.atlas == nil do continue
// draw_tile(tile)
// }
rl.DrawCircle(
cast(i32)scene.player.position.x,
cast(i32)scene.player.position.y,
32,
rl.GREEN,
)
rl.DrawRectangle(300, 300, 100, 100, rl.BLUE)
it := hm.iterator_make(&scene.enemies)
for i, _ in hm.iterate(&it) {
@@ -121,7 +115,8 @@ render_map :: proc(atlas: ^Atlas, map_data: Map) -> rl.RenderTexture2D {
rl.BeginTextureMode(tex)
for layer in map_data.layers {
for row_data, row in layer.data {
dest_y := f32(i32(map_data.height) - 1 - i32(row)) * atlas.tile_size.y
dest_y :=
f32(i32(map_data.height) - 1 - i32(row)) * atlas.tile_size.y
for tile_id, col in row_data {
offset, empty := get_offset(atlas, tile_id)
if empty do continue