0 Favourites

Problem to make a Sokoban game.

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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 ;)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
763 305,634
asikanddestroy's avatar
asikanddestroy
Unread hot topic
232 177,671
Tetriser's avatar
Tetriser
Unread hot topic
167 14,489
DMT2005's avatar
DMT2005