Commits

Valerio Riva committed dc86da8

cleaning code + collisione destra

Comments (0)

Files changed (10)

src/ggj/keyspong/game/OurGame.java

 package ggj.keyspong.game;
 
 import ggj.keyspong.entities.Entity;
-import ggj.keyspong.game.levels.ElementsType;
 import ggj.keyspong.game.levels.Level;
 import ggj.keyspong.handlers.CollisionHandler;
-import ggj.keyspong.utils.Constants;
-import ggj.keysrace.entities.obstacles.Obstacle;
-
 import java.util.ArrayList;
 import java.util.List;
 

src/ggj/keyspong/game/PongMain.java

 package ggj.keyspong.game;
 
-import ggj.keyspong.game.levels.Level;
-
 import org.newdawn.slick.AppGameContainer;
 import org.newdawn.slick.SlickException;
 

src/ggj/keyspong/game/levels/Level.java

 package ggj.keyspong.game.levels;
 
-import java.io.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.List;

src/ggj/keyspong/utils/Pair.java

 		
 		if (getClass() != obj.getClass()) return false;
 		
-		Pair other = (Pair) obj;
+		Pair<E, A> other = (Pair<E, A>) obj;
 		if (first == null) {
 			if (other.first != null) 
 				return false;

src/ggj/keysrace/RaceGame.java

 			Obstacle o = ElementsType.getObstacle(et);
 			o.setXPosition(x);
 			this.entities.add(o);
-			System.out.println("ciao: "+x);
 			x += o.getCurrentAnimation().getCurrentFrame().getWidth();
 		}
 		

src/ggj/keysrace/entities/Player.java

 	protected int points = 0; 
 	protected int jumping = 0;
 	protected boolean collidesBackground = false;
-	
 	private int jumpAcc = 0;
 	private int velocity = 0;
+	
 	private ActionCollision bottomCollision = new ActionCollision() {
 		public void execute(Entity me, Entity target) {
 			collidesBackground = true;
 			setYPosition((int) (target.getYPosition()-shape.getHeight()));
 		}
 	};
+
+	private ActionCollision rightCollision = new ActionCollision() {
+		public void execute(Entity me, Entity target) {
+			int rightSide = (int) (getXPosition()+shape.getWidth());
+			int bottomSide = (int) (getYPosition()+shape.getHeight());
+			if (rightSide > target.getXPosition() && bottomSide > target.getYPosition()) {
+				setXPosition(getXPosition()-Constants.OBSTACLE_SPEED);
+			}
+		}
+	};
 	
 	public Player(CollisionHandler c, GameContainer container) {
 		super(c);
 		this.loadAnimation();
 		this.assignInput();
 		
+		/*
 		collisionHandler.registerAction(this, Square.class, new ActionCollision() {
 			public void execute(Entity me, Entity target) {
 				life--;
 			}
-		});		
+		});
+		*/
 		
-		collisionHandler.registerAction(this, HorizontalBottom.class,bottomCollision);
-		collisionHandler.registerAction(this, Dosso.class,bottomCollision);
-		collisionHandler.registerAction(this, Blocco.class,bottomCollision);
+		collisionHandler.registerAction(this, HorizontalBottom.class, bottomCollision);
+		collisionHandler.registerAction(this, Dosso.class, bottomCollision);
+		collisionHandler.registerAction(this, Blocco.class, bottomCollision);
+		collisionHandler.registerAction(this, Dosso.class, rightCollision);
+		collisionHandler.registerAction(this, Blocco.class, rightCollision);
+		
 		
 		collisionHandler.registerAction(this, HorizontalTop.class, new ActionCollision() {
 			public void execute(Entity me, Entity target) {

src/ggj/keysrace/entities/obstacles/Blocco.java

 
 import org.newdawn.slick.Animation;
 import org.newdawn.slick.Image;
-import org.newdawn.slick.SlickException;
 import org.newdawn.slick.geom.Rectangle;
 
 public class Blocco extends Obstacle {

src/ggj/keysrace/entities/obstacles/Dosso.java

 
 import org.newdawn.slick.Animation;
 import org.newdawn.slick.Image;
-import org.newdawn.slick.SlickException;
 import org.newdawn.slick.geom.Rectangle;
 
 public class Dosso extends Obstacle {

src/ggj/keysrace/entities/obstacles/Fosso.java

 
 import org.newdawn.slick.Animation;
 import org.newdawn.slick.Image;
-import org.newdawn.slick.SlickException;
 import org.newdawn.slick.geom.Rectangle;
 
 public class Fosso extends Obstacle {

src/ggj/keysrace/entities/obstacles/Obstacle.java

 package ggj.keysrace.entities.obstacles;
 
-import java.io.File;
-
-import org.lwjgl.util.Rectangle;
 import org.newdawn.slick.BasicGame;
 import org.newdawn.slick.Image;
 import org.newdawn.slick.SlickException;
-import org.newdawn.slick.particles.ConfigurableEmitter;
-import org.newdawn.slick.particles.ParticleIO;
-import org.newdawn.slick.particles.ParticleSystem;
-
 import ggj.keyspong.entities.Entity;
 import ggj.keyspong.utils.Constants;
-import ggj.keysrace.entities.HorizontalBottom;
 
 public class Obstacle extends Entity {
 	public static Image dossoImage;