Collision Help 2D Tiles

Hello JGO, I’ve had this weird issue every time I try to program collision into a game lol.

I am trying to implement Collision for Rectangle Vs. Rectangle.
As we all know a rectangle has 4 sides, thus there’s 4 sides to check collision for ;D

My collision works perfect, I just cannot get it to work on ALL 4 SIDES >…<

At the moment I can basically ‘pick’ which 2 sides (top/bottom -or- left/right) of a tile will have active collision areas.

Here is the process of my game:


	public void process() {
		if (canMove) {
			if (up) { /* do stuff... */ }
			if (down) { /* do stuff... */ }
			if (left) { /* do stuff... */ }
			if (right) { /* do stuff... */ }
		}
	}

The above code will result in me being able to slide up / down while moving right / left.
(Collision is being applied properly to the tiles left / right side)

It is vice-verse, if I re-order the code like so:
(Please note the changes between the 2 code snippets)


	public void process() {
		if (canMove) {
			if (left) { /* do stuff... */ }
			if (right) { /* do stuff... */ }
			if (up) { /* do stuff... */ }
			if (down) { /* do stuff... */ }
		}
	}

The above code will result in me being able to slide left / right while moving up / down.
(Collision is being applied properly to the tiles top / bottom side)

Notes: It always favors the last 2 if statements 0_0

This is rather weird 0_0, I’ve tried implementing a Thread which starts prior to the if statements in hopes of running the other collision sides on a whole new ‘scene’ but that still didn’t work >.<

If anyone can help that would be great, if I left out anything needed or you require something more than what I provided :slight_smile: please feel free to ask me for it.

I need help :c
I’m motivated lets figure this out =D