Allegro.cc - Online Community

Allegro.cc Forums » The Depot » Simple Sokoban Clone

This thread is locked; no one can reply to it. rss feed Print
Simple Sokoban Clone
Eric Johnson
Member #14,841
January 2013
avatar

Do you guys like Sokoban (the box-pushing game)? I sure do. :D I just found out about Sokoban a few days ago and decided to write my own simple box/block-pushing game. So here it is, my very own generic block-pushing Sokoban clone:

Screenshots
{"name":"download_1.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/1\/e14f1168e59e7f66fe2d108daea1e376.png","w":800,"h":400,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/1\/e14f1168e59e7f66fe2d108daea1e376"}download_1.png
{"name":"download.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/9\/19a0dbac11f56095a57cb801fcb67dec.png","w":800,"h":400,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/9\/19a0dbac11f56095a57cb801fcb67dec"}download.png

You can play it in your browser at https://thardus.xyz/blox/. It is VERY crude, but you can create new levels, save them, and play previously saved levels. I created the first 9 levels. I'm curious to know how difficult / easy people find them to be (they ramp up in difficulty, but only slightly).

Controls
Move with the arrow keys (repeatedly press the key to move each time), and press "R" to restart a level if you get stuck. When creating a level, toggle between edit and play mode with the "E" key. Use the left and right arrow keys, the "A" and "D" keys, or keys 1 - 6 to switch between objects in editor mode.

This was created over two days' time. So think of this is a proof of concept. If it's well-received, I will spruce it up into something nicer. ;D

Update 1
I have updated the game with a new name and address, among other changes. The game can now be played at https://thardus.xyz/blox/, and its source code is freely available on GitHub.

Changes:

  • Completed refactored codebase with less spaghetti code

  • Added new spaghetti code

  • Fixed some bugs (like an out of bounds bug that stalls everything)

  • Blocks that are placed on top of goals are set to blue in the editor

  • Level resolution increased from 20x10 tiles to 24x14 tiles

  • Results screen no longer includes decimals in time spent "puzzling"

  • Results screen drops "s" from "seconds" and "moves" when appropriate

  • Keys can be held down to move the player instead of having to repeatedly tap them

  • Player now "slides" to the next space instead of instantly appearing there

  • Blocks now "slide" along as if being kicked by the player

  • Added annoying sound effects

  • Added a few more levels of varying degrees of difficulty

  • Dropped the ability to create new levels, as no one used it

Update 2
As per Audric's request, I have added the ability to undo moves with the "Z" key. Here's the commit: 42fa6d8. The game can still be played at https://thardus.xyz/blox/; you might need to clear your cache though. ;D

jmasterx
Member #11,410
October 2009

Beat hardest level on my first try woo!

Eric Johnson
Member #14,841
January 2013
avatar

jmasterx said:

Beat hardest level on my first try woo!

Nicely done! ;D

Edit
I updated the game to cycle through all of the levels. So now when you complete a level, it will let you continue on to the next one. It then loops back to the first level after the last one. All user-created levels are automatically added to the list of levels, and can be played and shared immediately.

amarillion
Member #940
January 2001
avatar

Yep, I finished all levels. I remember the original Sokoban as being much more difficult! But admittedly I was very young back then, so maybe that has more to do with it.

It would be cool to see ranking of speed and number of moves.

--
Martijn van Iersel | My Blog | Sin & Cos | Tegel tilemap editor | TINS 2017

Eric Johnson
Member #14,841
January 2013
avatar

The original is indeed much more difficult. Did you try the level editor? You can create and save your own levels for others to play. Maybe you could create some really challenging ones.

SilverTES
Member #16,572
October 2016

Good job, simple but very efficient, I completed all levels. ^^

Eric Johnson
Member #14,841
January 2013
avatar

Thanks for playing, SilverTES. :)

By the way, how's that Tower Defense platformer of yours coming along?

SilverTES
Member #16,572
October 2016

I'm working hard for make an first alpha version, working on the menu, controllers configuration, selection stage and in-game message system.

Wow at first, it was just a little game I want to make for testing my engine, but it's very hard to stop adding new features.

PS: my post thread was deleted, I need to make another for my game.

Eric Johnson
Member #14,841
January 2013
avatar

This thread? It wasn't deleted; threads just get locked after being inactive for a time (2 weeks, I think). Feel free to make a new thread. It looks like fun. I'd love to play it someday.

Edit
I updated the original post with an updated version of the game.

GullRaDriel
Member #3,861
September 2003
avatar

Wonderful job Eric :-D

I played with it a bit and it was very cool, fluid and responsive. Thanks for sharing the source BTW.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Audric
Member #907
January 2001

Undo would be nice, even a single-step Undo would be a welcome when you press the wrong key (or one step too many).

I wonder if people who create sokoban puzzles can use a reverse engine, where you start with a finalized state, and have the option to drag crates behind you ?

Eric Johnson
Member #14,841
January 2013
avatar

Wonderful job Eric :-D

I played with it a bit and it was very cool, fluid and responsive. Thanks for sharing the source BTW.

Thanks for playing and thanks for the nice comments! :D You're welcome for the source. I always get a kick out of reading source code from TINS games and the like, so I figured others would feel the same about my source. You never know what hidden gems may await in source code, so reading it is always fun, I think. :)

Audric said:

Undo would be nice, even a single-step Undo would be a welcome when you press the wrong key (or one step too many).

I wonder if people who create sokoban puzzles can use a reverse engine, where you start with a finalized state, and have the option to drag crates behind you ?

That's a good idea. I'll see if I can implement an undo feature over the weekend. And that's an interesting concept--a reverse puzzle! :o

Edit
I implemented your suggestion, Audric. :) You can now undo moves using the "Z" key. It saves your last 999 moves. Let me know if you encounter any issues with it. ;D

Audric
Member #907
January 2001

It works quite well.
I see you've also changed to a control scheme where you hold a direction key to move, and the character smoothly animates.
I'm not completely sure the crate movement is best (it jerks forward, rather than smoothly follow the player). Maybe it's helpful for stopping precisely, I haven't played enough to make up my mind.

Eric Johnson
Member #14,841
January 2013
avatar

Audric said:

I'm not completely sure the crate movement is best (it jerks forward, rather than smoothly follow the player). Maybe it's helpful for stopping precisely, I haven't played enough to make up my mind.

Pushing a block smoothly just wasn't as visually appealing as jerking it forward (as if it's being kicked abruptly or something), especially when I added sound effects. I might change it though if others feel differently about it.

Go to: