How should I handle collision detection for a Zelda clone?

Alright, so I’m working on Phantasy Blade again, and I need a new way to do collision detection because the way I’m doing it isn’t working too well.

This is how I’m doing it:


public boolean mapCheck(Map m, float x, float y, float xmod, float ymod)
	{
		if( (int) ((x/m.tileWidth) + xmod) >= 0 && 
			(int) ((y/m.tileHeight) + ymod) >= 0 &&
			(int) ((x/m.tileWidth) + xmod) < m.width && 
			(int) ((y/m.tileHeight) + ymod) < m.height)
		{
			if(m.tileInfo[m.tiles[(int) ((x/m.tileWidth) + xmod)][(int) ((y/m.tileHeight) + ymod)]] == 0){
				return false;
			}
			
			else
				return true;
		}

		return false;
	}

And this is how I move:


public float moveUp(Map m, float worldY){
		if(!mapCheck(m, (float) x, (float) y, (float) 0, (float) -0.1)){
			y -= speed;
			worldY -= speed;
		}
		
		else{
			dashing = false;
			dashDelay = 30;
		}
		
		state = 0;
		walking = true;
		return worldY;
	}
	
	public float moveDown(Map m,float worldY){
		if(!mapCheck(m, (float) x, (float) y, (float) 0, (float) 0.5)){
			y += speed;
			worldY += speed;
		}
		
		else{
			dashing = false;
			dashDelay = 30;
		}
		
		state = 2;
		walking = true;
		return worldY;
	}
	
	public float moveLeft(Map m,float worldX){
		if(!mapCheck(m, (float) x, (float) y, (float) -0.1, (float) 0)){
			x -= speed;
			worldX -= speed;
		}
		
		else{
			dashing = false;
			dashDelay = 30;
		}
		
		state = 3;
		walking = true;
		return worldX;
	}
	
	public float moveRight(Map m,float worldX){
		if(!mapCheck(m, (float) x, (float) y, (float) 0.5, (float) 0)){
			x += speed;
			worldX += speed;
		}
		
		else{
			dashing = false;
			dashDelay = 30;
		}
		
		state = 1;
		walking = true;
		return worldX;
	}

So what are some better ways I could handle collision detection?

A simple way that works quite well is to do 4 checks per entity, one at each vertex of their bounding box. Either way, even if your

Collision response is a bit more difficult, but still not hard. Just move the square back to the point of collision. You have hopefullyassume that this won’t move it back on top of something else and cause a totally different collision.