Created
April 26, 2016 13:27
-
-
Save egonelbre/bfd63496bff6bcfe116134b35f4d5655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/examples/breakout.k b/examples/breakout.k | |
index 47a3732..c867ce5 100644 | |
--- a/examples/breakout.k | |
+++ b/examples/breakout.k | |
@@ -142,8 +142,12 @@ class Ball implements Entity { | |
body_.shape = 0; | |
body_.static = false; | |
body_.halfsize.setxy(10.0, 10.0); | |
+ | |
+ color = new Color(144, 195, 212); | |
} | |
+ public Color color; | |
+ | |
private Body body_; | |
public Body body(){ return body_; } | |
@@ -236,10 +240,11 @@ context State { | |
all_.add(paddle_); | |
} | |
- public void spawn_ball(Vector center, Vector velocity){ | |
+ public void spawn_ball(Vector center, Vector velocity, Color color){ | |
Ball ball = new Ball(); | |
ball.body.center = center; | |
ball.body.velocity = velocity; | |
+ ball.color = color; | |
balls_.add(ball); | |
all_.add(ball); | |
} | |
@@ -500,7 +505,7 @@ context Render { | |
role Canvas { | |
public void ball(Ball ball){ | |
- body(new Color(144, 195, 212), ball.body); | |
+ body(ball.color, ball.body); | |
} | |
public void block(Block block){ | |
@@ -593,8 +598,8 @@ context World implements CollisionHandler { | |
double cx = state_.paddle.body.center.x.clone; | |
double cy = state_.paddle.body.center.y - 20.0; | |
- state_.spawn_ball(new Vector(cx+10.0,cy), new Vector(100.0, -100.0)); | |
- state_.spawn_ball(new Vector(cx-10.0,cy), new Vector(-90.0, -100.0)); | |
+ state_.spawn_ball(new Vector(cx+10.0,cy), new Vector(100.0, -100.0), new Color(0, 255, 0)); | |
+ state_.spawn_ball(new Vector(cx-10.0,cy), new Vector(-90.0, -100.0), new Color(0, 0, 255)); | |
// spawn walls | |
state_.spawn_wall( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment