Problem to make a Sokoban game.

Get help using Construct 2

Post » Tue Apr 23, 2013 8:46 pm

Hello (2nd language english here).

I want to make a "Sokoban" prototype. But I have a problem with moving the crates, I don't seem to get the collision between the crates and the wall to work, and the crates and the player too.
I can move the player just fine, but not the crates, they cross the wall and they cross between themselves and when the player want them to move, it don't always work.

For you to better understand the different problems of collision, I put the .capx file. I want to point out that the source code for the player displacement is not from me, but from an example I found on this forum (I don't really like to reuse in an identical way the source code of someone else, but since I'm not used to program that kind of game, and I didn't know how to do a grid movement...)
I thought reusing the code for the player movement would work for the crates.

Thanks in advance for anyone who can help.
Posts: 1
Reputation: 177

Post » Tue Apr 23, 2013 10:41 pm

On first glance at the code, you have overlapping at offset (1,0) on both the X movements and Y. This would only check 1 to the right all the time.

checking to the right
if overlapping(1,0)
if player.angle = 0

checking to the left
if overlapping(1,0) <- should be (-1,0) - checking to the left

if overlapping(1,0)
if player.angle = 270
^ you're still checking the X coord.. needs to be overlapping(0,-1) to check above the crate

same with down - overlapping(0,1) to check 1 below the crate

Don't have time to go through all your code, but I'm sure you'll see a difference if you fix those ;)
Posts: 877
Reputation: 5,650

Return to How do I....?

Who is online

Users browsing this forum: yurinkab and 23 guests