News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Yet Another Sokoban Game

Started by kevin, May 30, 2015, 03:56:21 PM

Previous topic - Next topic

kevin


   Yet Another Sokoban Game

        Was having a look through another example and was inspired to put together a little sokoban remake. Will post the sourcecode later on today.   The art and maps are ripped.   There's an open Sokoban level format, which looks dead simple to implement a loader for, so might as well stick that in too.



kevin


    Yet Another Sokoban Game - Adding a crusty Level Format

           First day of winter and it's cold, very cold tonight (well this morning) but none the less been putting together a level format based loosely on the text formats that can be found online.    The actual game isn't any different than it was the other day, only the setup code has changed.   The format this version loads in another square bracket markup which contains an info chunk with some global fields (SetName,Auther,Email,Website,Copyright etc)  followed by the levels blocks.   Levels can have various fields also but don't actually need them.  So you'd only the levels author for example if that level wasn't written by the set creator.   

          Here's an example set that only contains a single level.. 



;---------------------------------------------------------
;---------------------------------------------------------
;   -----> YET ANOTHER SOBOKAN LEVEL FORMAT <------
;---------------------------------------------------------
;---------------------------------------------------------

  This file is stored in a [] bracket markup, with a header
information section [SETINFO] followed by a series of levels.

Level maps are RLE compressed, runs of same characters will
  have an 1 or 2 digit integer in front of them, followed by the repeated
  character.  Rows end with a the pipe character | and empty unused
  are presented as the - character.

        The info section is expect to appear before the levels. 

[SetInfo]
      Set: Sokaban Mixed levels
   Author: unknown
Copyright: unknown
    Email: unknown
  Website: unknown
[/SetInfo]


       Level share many of the same fields as the set info, so you can leave
the Author/Email/Website/Copyright out of these if that information is the
same as for every level within the set, or set each one of them manually


  Level ascii format is defined here,

    http://www.sokobano.de/wiki/index.php?title=Level_format#Level_file_format

Wall # 0x23
Player @ 0x40
Player on goal square + 0x2b
Box $ 0x24
Box on goal square * 0x2a
Goal square . 0x2e
Floor (Space) 0x20
         


[level=1]
Author: unknown
Email: unknown
       WebSite: unknown
     Copyright: unknown
Level: 32-|32-|32-|32-|32-|32-|32-|7-4#19-|7-#2 #19-|7-#$  #19-|5-2#  $##18-|5-#  $ $ #18-|3-2# # ## #2-5#9-|3-#2 # ## 4#  ..#9-|3-# $ 

$9 ..#9-|3-4# 2# #@##  ..#9-|7-#4 8#9-|7-6#17-|32-|32-|32-|32-|32-|32-|32-|
   
[/level]



        The level data is stored on a RLE format, so runs of characters have a leading integer character.   Runs can be up to 99 characters long, the depacker doesn't support 3 digit run lengths (you can add that!).   So when a level is loaded, it's depacked and remapped to a PB map/level.   

        Anyway the game can now  load/parse and play a level from the set.   It's just missing the pretty stuff like transitions and some information dialogs about what level your playing/move counts etc. 


kevin


  Yet Another Sokoban Game - Released

       You'll find the project attached to this post.  have fun




bmorris

Good old Sokoban  :)

Incidentally, I have an alternative representation of levels that I deem superior to the standard one. It is as follows:

Floor tile = space, wall = #, box = O, player = C
Drop zone = —, box on zone = 8, player on zone = E

The rationale is clear, i.e. O + — = 8, C + — = E, with O resembling an actual box and, as a bonus, C resembling pac-man!

kevin

 not too fond the notations myself,  would probably have gone for more obvious notation like P=player, B=box, G=Goal etc, but  there's no particular benefit. 
 
while looking around some level sites the idea of a DTAB SCRIPT styled downloader/parser app did come to mind.. so the user would give it url and it parsers that sites format into the program common through external scripts.