Commits

Valerio Riva committed 929813c Merge

Merge

Comments (0)

Files changed (4)

src/ggj/keysrace/RaceGame.java

 import ggj.keyspong.game.levels.ElementsType;
 import ggj.keyspong.game.levels.Level;
 import ggj.keyspong.utils.Constants;
+import ggj.keysrace.entities.Follower;
 import ggj.keysrace.entities.HorizontalBottom;
 import ggj.keysrace.entities.HorizontalTop;
 import ggj.keysrace.entities.Player;
 		player2.setPosition(Constants.PLAYER_START_X+1*Constants.PLAYER_START_SPACE_X, Constants.PLAYER_START_Y);
 		player3.setPosition(Constants.PLAYER_START_X+2*Constants.PLAYER_START_SPACE_X, Constants.PLAYER_START_Y);
 		player4.setPosition(Constants.PLAYER_START_X+3*Constants.PLAYER_START_SPACE_X, Constants.PLAYER_START_Y);
+		
+		
+		Follower frecciaP1 = new Follower(player1,"resources/images/a_blue.png",0,-40);
+		Follower frecciaP2 = new Follower(player2,"resources/images/a_green.png",0,-40);
+		Follower frecciaP3 = new Follower(player3,"resources/images/a_orange.png",0,-40);
+		Follower frecciaP4 = new Follower(player4,"resources/images/a_purple.png",0,-40);
+		
+		entities.add(frecciaP1);
+		entities.add(frecciaP2);
+		entities.add(frecciaP3);
+		entities.add(frecciaP4);
+		
+		//musica
+		Sound fx = new Sound("resources/music/bloodway.ogg");
+		fx.play();
 	}
 }

src/ggj/keysrace/entities/Follower.java

+package ggj.keysrace.entities;
+
+import org.newdawn.slick.Animation;
+import org.newdawn.slick.BasicGame;
+import org.newdawn.slick.Image;
+import org.newdawn.slick.SlickException;
+import org.newdawn.slick.geom.Rectangle;
+import org.newdawn.slick.geom.Shape;
+
+import ggj.keyspong.entities.Entity;
+import ggj.keysrace.entities.obstacles.Obstacle;
+
+public class Follower extends Entity {
+
+	private Entity followed;
+	private int x_off;
+	private int y_off;
+	
+	private final static int MAX_SLIDING = 5;
+	private int sliding = 2;
+	private int slidingDirection = 1;
+
+	public Follower(Entity followed, String image, int x_off, int y_off) {
+		super();
+		Animation animation;
+		try {
+			animation = new Animation(new Image[] { new Image(image) }, 250);
+			this.setAnimation("basic", animation);
+			this.setCurrentAnimation(this.getAnimation("basic"));
+			
+			this.followed = followed;
+			this.x_off = x_off;
+			this.y_off = y_off;
+			
+			this.shape =  new Rectangle(this.getXPosition(),this.getYPosition(),this.getCurrentAnimation().getCurrentFrame().getWidth(),this.getCurrentAnimation().getCurrentFrame().getHeight());
+		} catch (SlickException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	@Override
+	public void update(BasicGame game,int delta) {
+		super.update(game, delta);
+		
+		if (sliding == MAX_SLIDING*slidingDirection) slidingDirection*=-1;
+		sliding = sliding+slidingDirection;
+		
+		this.setPosition(followed.getXPosition()+x_off, followed.getYPosition()+y_off+sliding);
+	}
+}
Add a comment to this file

src/resources/images/fosso.png

Old
Old image
New
New image
Add a comment to this file

src/resources/music/bloodway.ogg

Binary file added.

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.