multi-ball
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -64,13 +64,28 @@ fn main() {
|
||||
Tuple::vector(2.2, 0.0, 21.0),
|
||||
);
|
||||
|
||||
let mut ball2 = Projectile::new(
|
||||
Tuple::point(195.0, 0.0, 0.0),
|
||||
Tuple::vector(-2.2, 0.0, 21.0),
|
||||
);
|
||||
|
||||
let mut ball3 = Projectile::new(
|
||||
Tuple::point(299.0, 0.0, 0.0),
|
||||
Tuple::vector(-2.2, 0.0, 21.0),
|
||||
);
|
||||
|
||||
let mut canvas = Canvas::new(300, 300);
|
||||
let color = Color::new(1.0, 1.0, 0.0);
|
||||
let color = Color::new(1.0, 0.0, 0.0);
|
||||
let color2 = Color::new(0.0, 1.0, 0.0);
|
||||
let color3 = Color::new(0.0, 0.0, 1.0);
|
||||
loop {
|
||||
canvas.write_pixel(ball.position.x() as usize, canvas.height() - (ball.position.z() as usize) - 1, color);
|
||||
canvas.write_pixel(ball2.position.x() as usize, canvas.height() - (ball2.position.z() as usize) - 1, color2);
|
||||
canvas.write_pixel(ball3.position.x() as usize, canvas.height() - (ball3.position.z() as usize) - 1, color3);
|
||||
|
||||
ball.tick(&env);
|
||||
println!("ball {}", ball);
|
||||
ball2.tick(&env);
|
||||
ball3.tick(&env);
|
||||
if ball.position.z() >= (canvas.height() - 1) as f32
|
||||
|| ball.position.z() < 0.0
|
||||
|| ball.position.x() >= (canvas.width() - 1) as f32
|
||||
|
||||
Reference in New Issue
Block a user