Problem with collosion

Hi, I’m new here and I’d like to get some help (also english isn’t my native language so sorry for any grammer mistakes).

I’m trying to build a 2d shooter game and there’s some problem with my collosion, I’m building the map with tiles so that for every tile there is a 40X40 rectangle size in its place.
Here’s the code:

public tiles(int x, int y, char type1) {
		tileX = x * 40;
		tileY = y * 40;
		type = type1;
		if (type != '0') {
			r = new Rectangle(tileX, tileY, 40, 40);
			mapRects.add(r);
		} else {
			r = new Rectangle(0, 0, 0, 0);
			mapRects.add(r);
		}

(creating a rect for every tile except the background which is labled 0) (mapRects is an ArrayList).
I know creating a rect with 0’s values for the background is pointless but for some reason if i don’t do that is somehow messes everything badly.

Now for the collosion with the character:

	public void checkCollosion() {
		allowRight = true;
		allowLeft = true;
		for (int i = 0; i < tiles.mapRects.size(); i++) {
			if (bottom.intersects(tiles.mapRects.get(i))) {
				downToEarth = true;
				speedY = 0;
				falling = false;
				jumped = false;
			}
			if (head.intersects(tiles.mapRects.get(i))) {
				if (jumped)
					speedY = 5;
			}	
			if(leftSide.intersects(tiles.mapRects.get(i)))
				stop();
			if(rightSide.intersects(tiles.mapRects.get(i)))
				stop();
		}
		if (!downToEarth && !falling && !jumped) {
			speedY = 5;
			falling = true;
		}
	}

	public void jump() {
		speedY = -14;
		jumped = true;
	}
	
	public void moveRight() {
		if(allowRight){
			speedX = 5;
		}
	}
	
	public void moveLeft() {
		if(allowLeft){
			speedX = -5;
		}
	}
	public void stop() {
		if(speedX > 0)
			allowRight = false;
		else
			allowLeft = false;
		speedX = 0;
	}

basically i’m just checking for any tile if there’s a collosion, if there’s a collosion for leftSide or rightSide and the player was moving in these directions it’ll call stop() and won’t allow this movement any more. The thing is it works when there’s a collosion with leftSide but if its with rightSide the player is just stuck and can’t move in both directions.
Also i’m checking for bottom collosion to see if the player’s on the floor and it works, but it works weird, if i jump it’ll stop like the collosion is late.

http://up413.siz.co.il/up3/2wymmyqfxm2j.png

At first i thought the problem is with the efficiency but i tried to improve it and it didn’t work so i’m clueless…

sorry for the long post, if anyone can help or give any tips for this kind of project it’ll be great.
Also i don’t mind sending the whole project to someone if it’ll make it easier to tell me what im doing wrong.

I have a feeling that your problem is in the stop method. I don’t think allowRight = false; is ever achieved. Why don’t you try to do a print line statement after to check if you reach it. I can’t know for sure because i need to see the method you use to call move right and tour update method.