Moved and renamed entities.

This commit is contained in:
2026-09-09 07:17:28 +02:00
parent 6b6725b8bb
commit c6ab8705d1
4 changed files with 119 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package game
import rl "vendor:raylib"
init_ball :: proc() -> Entity {
ball_radius: f32 = 25
return Entity{
type = .Ball,
active = true,
pos = rl.Vector2{(VIEWPORT_WIDTH / 2), (VIEWPORT_HEIGHT / 2) - (ball_radius / 2)},
vel = rl.Vector2{400,0},
shape = .Circle,
size = rl.Vector2{15, 15}
}
}
update_ball :: proc(ball: ^Entity, field_bounds: rl.Rectangle, dt: f32) {
ball.pos += ball.vel * dt
if ball.pos.x >= (field_bounds.x + field_bounds.width) - ball.size.x {
ball.vel.x = -ball.vel.x
}
if ball.pos.x <= field_bounds.x + ball.size.x {
ball.vel.x = -ball.vel.x
}
}
render_ball :: proc(ball: Entity, field_bounds: rl.Rectangle) {
rl.DrawCircleV(ball.pos, ball.size.x, rl.MAROON)
}