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/Ossigeno.java

-package ggj.bloodrace.entities;
-
-import ggj.bloodrace.entities.obstacles.Obstacle;
-import ggj.bloodrace.utils.Constants;
-
-import org.newdawn.slick.Animation;
-import org.newdawn.slick.Image;
-import org.newdawn.slick.SlickException;
-import org.newdawn.slick.geom.Rectangle;
-
-public class Ossigeno extends Entity {
-
-	public Ossigeno(){
-		super();
-		Animation animation;
-		try {
-			animation = new Animation(new Image[] {new Image("resources/images/ball_yellow.png") }, 250);
-		this.setAnimation("basic", animation);
-		this.setCurrentAnimation(this.getAnimation("basic"));
-
-		} catch (SlickException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	this.shape = new Rectangle(this.getXPosition(),this.getYPosition(),this.getCurrentAnimation().getCurrentFrame().getWidth(),this.getCurrentAnimation().getCurrentFrame().getHeight());
-	this.setPosition(Constants.OBSTACLE_X_OFFSET, Constants.OBSTACLE_Y_OFFSET);
-	
-	}
-}

src/ggj/bloodrace/entities/Player.java

 import ggj.bloodrace.entities.obstacles.BlockLeft;
 import ggj.bloodrace.entities.obstacles.BlockRight;
 import ggj.bloodrace.entities.obstacles.BlockTop;
+import ggj.bloodrace.entities.obstacles.BlockOxygen;
 import ggj.bloodrace.handlers.ActionCollision;
 import ggj.bloodrace.handlers.CollisionHandler;
 import ggj.bloodrace.utils.Constants;
 	protected PlayerCollider left;
 	protected PlayerCollider right;
 	protected List<Entity> entities;
-	
+
+	private int score = 0;
+
 	private ActionCollision topCollision;
 	private ActionCollision bottomCollision;
 	private ActionCollision rightCollision;
 	private ActionCollision leftCollision;
+	private ActionCollision grabOxygen;
 	
 	public Player(CollisionHandler c, GameContainer container, List<Entity> entities) {
 		super(c);
 			}
 		};
 
-		ActionCollision rightCollision = new ActionCollision() {
+		rightCollision = new ActionCollision() {
 			public void execute(Entity me, Entity target) {
 
 				setXPosition((int) (target.getXPosition() - shape.getWidth()));
 			}
 		};
 
-		ActionCollision leftCollision = new ActionCollision() {
+		leftCollision = new ActionCollision() {
 			public void execute(Entity me, Entity target) {
-				setXPosition((int) (target.getXPosition() + target.getShape()
-						.getWidth()));
+				setXPosition((int) (target.getXPosition() + target.getShape().getWidth()));
+			}
+		};
+		
+		grabOxygen = new ActionCollision() {
+			public void execute(Entity me, Entity target) {
+				BlockOxygen ox = (BlockOxygen) target;
+				Player p = (Player) me;
+				if (ox.isVisible()){
+					p.setScore(p.getScore()+10);
+				}
+				ox.setVisible(false);
 			}
 		};
 	}
 		collisionHandler.registerAction(top, BlockFull.class, topCollision);
 		collisionHandler.registerAction(top, BlockLeft.class, topCollision);
 		collisionHandler.registerAction(top, BlockRight.class, topCollision);
-		collisionHandler.registerAction(top, BlockTop.class, topCollision);
+		collisionHandler.registerAction(top, BlockTop.class, topCollision);
+
+		//score
+		collisionHandler.registerAction(this, BlockOxygen.class, grabOxygen);
 	}
 
 	private void instantiateCollider() {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.