Code:
package com.src.impostor;
import java.awt.Font;
import java.io.InputStream;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
import org.newdawn.slick.util.ResourceLoader;
public class StateGame extends BasicGameState {
private java.awt.Font awtFont;
TrueTypeFont font;
TrueTypeFont font2;
SpriteSheet mario;
Music background;
public static int world = 1;
public static int level = 2;
private boolean isJumping = Player.isJumping;
float playerX = Player.playerX;
float playerY = Player.playerY;
private Animation animPlayer;
int frame = 0;
private float playerSpeed = Player.moveSpeed;
private float fallSpeed = Player.fallSpeed;
private int jumpTimer;
private BlockMap map;
private boolean[][] blocked;
private static final int SIZE = 16;
public StateGame(int state) {
jumpTimer = 0;
}
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
awtFont = new java.awt.Font("Verdana", Font.PLAIN, 16);
font = new TrueTypeFont(awtFont, false);
try {
InputStream inputStream = ResourceLoader.getResourceAsStream("res/font/ArcadeClassic.ttf");
Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
awtFont2 = awtFont2.deriveFont(15f);
font2 = new TrueTypeFont(awtFont2, false);
} catch (Exception e) {
e.printStackTrace();
}
mario = new SpriteSheet("res/char/mario.png", 16, 16);
animPlayer = new Animation();
animPlayer.setAutoUpdate(false);
for(int frame=0; frame <4;frame++) {
animPlayer.addFrame(mario.getSprite(frame, 0), 150);
if(animPlayer.getFrame() <= 2) {
animPlayer.setCurrentFrame(0);
}
}
map = new BlockMap("res/world/world" + StateGame.world + "-" + StateGame.level + ".tmx");
blocked = new boolean[map.tmap.getWidth()][map.tmap.getHeight()];
for(int xAxis=0;xAxis<map.tmap.getWidth();xAxis++) {
for(int yAxis=0;yAxis<map.tmap.getHeight(); yAxis++) {
int tileID = map.tmap.getTileId(xAxis, yAxis, 0);
String value = map.tmap.getTileProperty(tileID, "blocked", "false");
if("true".equals(value)) {
blocked[xAxis][yAxis] = true;
}
}
}
background = new Music("res/sound/music/overworld.ogg");
}
public void enter(GameContainer gc, StateBasedGame sbg) {
background.play();
background.loop();
}
public void leave(GameContainer gc, StateBasedGame sbg) {
background.stop();
}
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
jumpTimer = 0;
if (gc.getInput().isKeyDown(Input.KEY_LEFT)) {
if(!isBlocked(playerX - delta * 0.1f, playerY)&& playerX > 0) {
playerX -= delta * playerSpeed;
}
}
if (gc.getInput().isKeyDown(Input.KEY_RIGHT)) {
if (!isBlocked(playerX + SIZE + delta * 0.1f, playerY)) {
animPlayer.update(delta);
playerX += delta * playerSpeed;
}
}
if (gc.getInput().isKeyDown(Input.KEY_UP)) {
if (!isBlocked(playerX, playerY - delta * 0.1f) && playerY >= 0) {
isJumping = false;
jumpTimer += delta;
animPlayer.setCurrentFrame(3);
playerY -= delta * fallSpeed;
if(jumpTimer > 2000) {
isJumping = true;
}
}
}
if (isJumping) {
Player.fallSpeed = 2.4f;
}
if (isJumping && playerY < 255) {
playerY += delta * fallSpeed;
}
isJumping = true;
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
g.scale(2, 2);
map.tmap.render(-60, 0);
g.drawAnimation(animPlayer, playerX, playerY);
g.resetTransform();
font2.drawString(20, 30, "Mario");
font2.drawString(650, 10, "World " + world + " Map " + level);
}
private boolean isBlocked(float playerX, float playerY) {
int xBlock = (int) playerX / SIZE;
int yBlock = (int) playerY / SIZE;
return blocked[xBlock][yBlock];
}
public int getID() {
return 2;
}
}
Here is my code. I can't get collisions to work. . .I think one of my variables might be wrong

Anyways the time isn't working out very well, it is setting it constantly at 0 so it won't stop. Also I was wondering how I could use rows for different animations like if(input.left) {animPlayer.row++}