Add 2D endless runner game with pickups and coyote time
- Platformer endless runner: fixed player x, world scrolls left - Logarithmic speed curve: initial + factor * ln(1 + t / time_scale) - Enemies stomped from above; side/bottom contact kills player - Procedural level generation with StdRng seeded from SystemTime - Object pooling via Vec::retain + frontier-based generator - Coyote time: grace window after leaving platform edge - Data-driven pickup system with trait-based effects (ActiveEffect) - Invulnerability, JumpBoost, ScoreMultiplier — extend via config - Score accumulates with per-effect multiplier; stomp bonuses scaled - Game over screen with score, best score, restart prompt - HUD: score, speed bar, active effect timer bars Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
src/enemy.rs
Normal file
34
src/enemy.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
#[derive(Clone)]
|
||||
pub struct Enemy {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub width: f32,
|
||||
pub height: f32,
|
||||
pub alive: bool,
|
||||
}
|
||||
|
||||
impl Enemy {
|
||||
pub fn new(x: f32, y: f32, width: f32, height: f32) -> Self {
|
||||
Self { x, y, width, height, alive: true }
|
||||
}
|
||||
|
||||
pub fn scroll(&mut self, speed: f32, dt: f32) {
|
||||
self.x -= speed * dt;
|
||||
}
|
||||
|
||||
pub fn is_off_screen(&self) -> bool {
|
||||
self.x + self.width < 0.0
|
||||
}
|
||||
|
||||
pub fn top(&self) -> f32 {
|
||||
self.y
|
||||
}
|
||||
|
||||
pub fn bottom(&self) -> f32 {
|
||||
self.y + self.height
|
||||
}
|
||||
|
||||
pub fn right(&self) -> f32 {
|
||||
self.x + self.width
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user