Java Game Collision Slick2D

I am using Slick and Tiled2D to make a top-down RPG style game. I am trying to do collision, but the player seems to be able to go through blocks that are on the left side of a building, or the left half of a block. The full project is here: Here is my code for the player movement and collision detection:

public void update(GameContainer gc, int delta) throws SlickException {
    input = gc.getInput();
            if(!isBlocked(x, y - delta * 0.1f)){
                y-=0.1 * delta;
        }else if(input.isKeyDown(Input.KEY_S) && y < screenBottomEdge){
            if (!isBlocked(x, y + playerHeight + delta * 0.1f)){
                y+=0.1 * delta;
        }else if(input.isKeyDown(Input.KEY_A) && x > screenLeftEdge){
            if (!isBlocked(x - delta * 0.1f, y)){
                x-=0.1 * delta;
        }else if(input.isKeyDown(Input.KEY_D) && x < screenRightEdge){
            if (!isBlocked(x + playerWidth + delta * 0.1f, y)){
                x+=0.1 * delta;


private boolean isBlocked(float x, float y) {
    int xBlock = (int)x / 30;
    int yBlock = (int)y / 30;
    return blocked[xBlock][yBlock];


I guess the x and y in isBlocked are the player's pixel-accurate x and y-positions, while xBlock and yBlock are the tile-accurate positions.

When you say they go through half of the block this seems to me like a rounding-problem at

int xBlock = (int)x / 30;
int yBlock = (int)y / 30;

Try something along the lines of

(int) Math.round(x/30.0);

Need Your Help

Cannot find my data folder when I export my project as jar

java eclipse jar

I tried to export my eclipse java project as a runnable jar file. In my main function I have to read data file from the data folder in my project as following:

Get list of windows in taskbar on Windows 7?

c++ c windows-7 windows

how can I get a list of windows shown on the taskbar on Windows 7? I have tried EnumWindows, but I'm getting way more windows than those shown on the taskbar (800 vs 15).