Problem to make a Sokoban game.

0 favourites
  • 2 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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.

  • Try Construct 3

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

    Try 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)