renamed entities.

This commit is contained in:
2026-09-09 07:17:57 +02:00
parent 7341bbe927
commit d453a2cb33
-41
View File
@@ -1,41 +0,0 @@
package game
import "core:math"
import rl "vendor:raylib"
init_player :: proc() -> Entity {
return Entity{
type = .Player,
active = true,
pos = rl.Vector2{0,0},
speed = 900,
shape = .Rectangle,
shape_size = rl.Vector2{50, 250}
}
}
update_player :: proc(dt: f32, player: ^Entity, level: ^Level) {
bounds : rl.Rectangle = level.field_bounds
// 1. Gather Directional Input
move_dir: f32 = 0
if rl.IsKeyDown(.W) || rl.IsKeyDown(.UP) {
move_dir -= 1.0
}
if rl.IsKeyDown(.S) || rl.IsKeyDown(.DOWN) {
move_dir += 1.0
}
// 2. Apply Movement (Frame-rate independent)
player.pos.y += move_dir * player.speed * dt
// 3. Clamp Position within Field Bounds
min_y := bounds.y + 3 // Padding offset inside border
max_y := bounds.y + bounds.height - player.shape_size.y - 3
player.pos.y = math.clamp(player.pos.y, min_y, max_y)
}
render_player :: proc(player: Entity, field_bounds: rl.Rectangle) {
rl.DrawRectangleV(player.pos, player.shape_size, rl.BLACK)
}