Files
pong_raylib/src/entity.odin
T

50 lines
1.0 KiB
Odin

package game
import rl "vendor:raylib"
// ------------------------------------------------------------------------------
// Generic base structure shared by all world objects.
// Fields are populated selectively based on entity type.
// ------------------------------------------------------------------------------
MAX_TRAILS :: 8
Entity_Type :: enum {
Player,
Opponent,
Ball,
}
Shape_Type :: enum {
Rectangle,
Circle,
}
Entity :: struct {
type: Entity_Type,
active: bool,
pos: rl.Vector2,
shape: Shape_Type,
color: rl.Color,
// width / height or diameter / diameter
size: rl.Vector2,
// Fixed input speed (paddles)
speed: f32,
max_speed: f32,
// 2D momentum & direction (ball / physics)
vel: rl.Vector2,
target_y: f32,
reaction_timer: f32,
// animation options
tween_duration: f32,
tween_elapsed: f32,
// trail effect
trail_positions: [MAX_TRAILS]rl.Vector2,
trail_count: int,
trail_timer: f32,
}