Explorar o código

Update to match engine changes

Tankernn %!s(int64=8) %!d(string=hai) anos
pai
achega
5179245369

+ 6 - 6
src/eu/tankernn/pong/Ball.java

@@ -13,7 +13,7 @@ public class Ball extends Entity2D {
 	private Pad winner = null;
 
 	public Ball(Texture texture, Pad p1, Pad p2) {
-		super(texture, new Vector2f(0, 0), new Vector2f(0.03f, 0.03f));
+		super(texture, new Vector2f(0, 0), 0.03f);
 		this.p1 = p1;
 		this.p2 = p2;
 
@@ -23,10 +23,10 @@ public class Ball extends Entity2D {
 
 	@Override
 	public void update() {
-		if (position.y - scale.y < -1 || position.y + scale.y > 1) {
+		if (position.y - getSize().y < -1 || position.y + getSize().y > 1) {
 			velocity.y *= -1;
-			position.y = Math.max(position.y, -1 + scale.y);
-			position.y = Math.min(position.y, 1 - scale.y);
+			position.y = Math.max(position.y, -1 + getSize().y);
+			position.y = Math.min(position.y, 1 - getSize().y);
 		}
 
 		Vector2f padPos = null;
@@ -49,9 +49,9 @@ public class Ball extends Entity2D {
 			this.setAngle(angle);
 		}
 
-		if (position.x - scale.x < -1) {
+		if (position.x - getSize().x < -1) {
 			winner = p2;
-		} else if (position.x + scale.x > 1) {
+		} else if (position.x + getSize().x > 1) {
 			winner = p1;
 		}
 

+ 4 - 3
src/eu/tankernn/pong/Pad.java

@@ -13,7 +13,8 @@ public class Pad extends Entity2D {
 	private int upKey, downKey;
 
 	public Pad(Texture texture, Vector2f position, int upKey, int downKey) {
-		super(texture, position, new Vector2f(0.02f, 0.3f));
+		// TODO Fix size of this thing, render single-color textures
+		super(texture, position, 0.3f);
 		this.upKey = upKey;
 		this.downKey = downKey;
 		this.position = position;
@@ -21,9 +22,9 @@ public class Pad extends Entity2D {
 
 	@Override
 	public void update() {
-		if (Keyboard.isKeyDown(upKey) && position.y + scale.y < 1) {
+		if (Keyboard.isKeyDown(upKey) && position.y + getSize().y < 1) {
 			this.setVelocity(new Vector2f(0, SPEED));
-		} else if (Keyboard.isKeyDown(downKey) && position.y - scale.y > -1) {
+		} else if (Keyboard.isKeyDown(downKey) && position.y - getSize().y > -1) {
 			this.setVelocity(new Vector2f(0, -SPEED));
 		} else {
 			this.setVelocity(new Vector2f(0, 0));

+ 1 - 1
src/eu/tankernn/pong/Pong.java

@@ -49,7 +49,7 @@ public class Pong extends TankernnGame {
 		for (Entity2D e : entities)
 			guiMaster.loadGui(e);
 
-		guiMaster.loadGui(new GuiTexture(white, new Vector2f(0.0f, 0.0f), new Vector2f(0.005f, 1.0f)));
+		guiMaster.loadGui(new GuiTexture(white, new Vector2f(0.0f, 0.0f), 0.005f));
 
 		textMaster.loadText(scoreText);
 	}