Better naming. opponent > enemy

This commit is contained in:
2026-09-11 07:51:18 +02:00
parent 75ce3e04a4
commit 115b42f00d
3 changed files with 50 additions and 18 deletions
+4 -7
View File
@@ -1,8 +1,8 @@
package game
import "core:math/rand"
import "core:log"
import rl "vendor:raylib"
import "core:log"
init_ball :: proc() -> Entity {
return Entity{
@@ -29,18 +29,15 @@ reset_ball :: proc(ball: ^Entity) {
}
update_ball :: proc(ball: ^Entity, level: ^Level, dt: f32) {
// first check the level timer are we waiting to serve?
// first check the level timer are we waiting to serve?
if level.serve_timer > 0 {
level.serve_timer -= dt
if level.serve_timer <= 0 {
serve_ball(ball)
}
// return early if timer still ticking
return
}
// serve_ball(ball)
ball.pos += ball.vel * dt
radius := ball.size.x
field_bounds := level.field_bounds
@@ -50,9 +47,9 @@ update_ball :: proc(ball: ^Entity, level: ^Level, dt: f32) {
ball.vel.x = abs(ball.vel.x)
// stp stickiness
ball.pos.x = level.player.pos.x + level.player.size.x + radius
} else if check_ball_paddle_collision(ball^, level.enemy) {
} else if check_ball_paddle_collision(ball^, level.opponent) {
ball.vel.x = -abs(ball.vel.x)
ball.pos.x = level.enemy.pos.x - radius
ball.pos.x = level.opponent.pos.x - radius
}
// bounds collision detection