Use the lifetime limiters on Bullets & Asteroids
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m3s
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m3s
Closes #14 Despawn bullets to limit range. Despawn asteroids to limit random garbage floating around the scene.
This commit is contained in:
@@ -8,9 +8,9 @@ mod title_screen;
|
||||
|
||||
use crate::asteroids::{Asteroid, AsteroidSpawner};
|
||||
use crate::config::{
|
||||
ASTEROID_SMALL_COLOR, BACKGROUND_COLOR, BULLET_COLOR, BULLET_SPEED, PLAYER_SHIP_COLOR,
|
||||
SHIP_ROTATION, SHIP_THRUST, SHIP_THRUSTER_COLOR_ACTIVE, SHIP_THRUSTER_COLOR_INACTIVE,
|
||||
WINDOW_SIZE,
|
||||
ASTEROID_SMALL_COLOR, BACKGROUND_COLOR, BULLET_COLOR, BULLET_LIFETIME, BULLET_SPEED,
|
||||
PLAYER_SHIP_COLOR, SHIP_ROTATION, SHIP_THRUST, SHIP_THRUSTER_COLOR_ACTIVE,
|
||||
SHIP_THRUSTER_COLOR_INACTIVE, WINDOW_SIZE,
|
||||
};
|
||||
use crate::physics::AngularVelocity;
|
||||
use crate::ship::{Bullet, Ship};
|
||||
@@ -340,6 +340,7 @@ fn input_ship_shoot(
|
||||
Mesh2d(game_assets.bullet().0),
|
||||
MeshMaterial2d(game_assets.bullet().1),
|
||||
ship_pos.clone(), // clone ship transform
|
||||
Lifetime(Timer::from_seconds(BULLET_LIFETIME, TimerMode::Once)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user