Topic:   GM Sokoban clone: Winterban   (Read 14239 times)


0 Members and 1 Guest are viewing this topic.

Charlo


  • GMG-er

  • **


  • Posts: 451
GM Sokoban clone: Winterban
« on: September 24, 2010, 06:45:09 PM »
I'm sure some of you are familiar with the concept of Sokoban, but if you're not, it's quite simple: push all the boxes onto the goals.  Winterban is my attempt at recreating this basic gameplay in GameMaker.  Download link:

http://www.mediafire.com/file/31d8wsbhcslb6sm/Winterban.zip

Here are some screenshots:

 http://www.mediafire.com/imgbnc.php/6ff6a1cfdedaa21f7195bebf7dc3437f6g.jpg
http://www.mediafire.com/imgbnc.php/41894746dc93fbbc2f9f4b127275e0406g.jpg

The original plan was to have 25 or so levels, but I stopped at 16.  Why?  Because the process of designing the levels, using a tiling program to create the images, and then inputting all the data into GM (wall positions, goal positions, rock positions) was a bit tedious.  I think I proved my point, and I was never going to finish if I tried to do that many levels.

The coding was a bit hairy as well; the lack of real arrays made checking for blocks more complicated than it needed to be.  The game is a little laggy due to the amount of code, but it's not too bad.  Many thanks to Silverwind for the inspiration behind the movement/wall system.

The music, once again, is composed by me in Garageband.  Not to toot my own horn (music pun, get it?), but I think I did a pretty good job at creating a piece of music that really evokes some atmosphere.  And if you're wondering about the theme, well, I started this project early this year and intended it to be released while it was still winter.  That part didn't work out, but if you really care, you can just wait until November to download it.  ;)

Tell me what you think!

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: GM Sokoban clone: Winterban
« Reply #1 on: September 25, 2010, 01:18:00 PM »
Nice! I'd love to see the source sometime.
I survived the spammage of 2007

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: GM Sokoban clone: Winterban
« Reply #2 on: September 25, 2010, 01:33:54 PM »
its pretty good, it has alot of levels, i wasnt able to beat it though. it should say what level im on in the screen

Charlo


  • GMG-er

  • **


  • Posts: 451
Re: GM Sokoban clone: Winterban
« Reply #3 on: September 25, 2010, 06:10:38 PM »
Quote
it should say what level im on in the screen
Good idea.  There probably won't be any updates for this game however... :P

GabrielCA


  • GMG-er

  • **

  • no avatar

  • Posts: 224
Re: GM Sokoban clone: Winterban
« Reply #4 on: September 26, 2010, 03:05:13 PM »
Great game !
Reminds me of "Gridz".

Quote
Nice! I'd love to see the source sometime.
Well, since Charlo doesn't think he'll ever update the game:

Quick reverse engineering reveals that a string is used to store the wall collisions in the map (values for a given index are obtained through "WORD$") and specific variables are used to manage the goals and stones.

The system for the wall collisions is somewhat similar to the one used in V6 Grid Navigation.

Snippet (part of the stone moving code):
Code: [Select]
   IF gridposition = stone1gridposition THEN
       stone1beyondposition = stone1gridposition + positionchange
« Last Edit: September 26, 2010, 03:08:27 PM by GabrielCA »
Creator of the deprecated plugin KeyDetect (2005)

Charlo


  • GMG-er

  • **


  • Posts: 451
Re: GM Sokoban clone: Winterban
« Reply #5 on: September 27, 2010, 09:18:04 PM »
Quote
Snippet (part of the stone moving code):
Code: [Select]
   IF gridposition = stone1gridposition THEN
 Â      stone1beyondposition = stone1gridposition + positionchange
Yeah, the tedious part was checking the potential stone destination for both walls and all of the other stones.  Arrays would have been useful for holding all the stones in a variable similar to the one used to hold the walls (I know there is a way to mimic arrays in GM, but it's convoluted and would have made the code WAY worse).

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: GM Sokoban clone: Winterban
« Reply #6 on: September 28, 2010, 03:08:42 AM »
Oh? I use phoney baloney arrays a lot now, and I love them to bits! ;D Here's an easy way of extracting values and whatnot: http://www.gamemakersgarage.com/cgi-bin/yabb/YaBB.cgi?board=CX;action=display;num=1266455701
I survived the spammage of 2007

GabrielCA


  • GMG-er

  • **

  • no avatar

  • Posts: 224
Re: GM Sokoban clone: Winterban
« Reply #7 on: September 28, 2010, 03:44:58 PM »
Challenge : making that array handling code support multi-dimensional arrays (this would make coding games like Sokoban much, much easier)
Creator of the deprecated plugin KeyDetect (2005)

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: GM Sokoban clone: Winterban
« Reply #8 on: September 28, 2010, 06:25:11 PM »
In SC, I would make an array with (width of matrix*height of matrix) as the length, and then use the following method of accessing fields:

Code: [Select]
GETGRIDLOCATION:
Parameters: x,y

IF y = 1 THEN
 Â  RETURN x
END IF

RETURN ((y * WIDTH)-WIDTH) + x

Where WIDTH is the width of the matrix. Then I would just do

Code: [Select]
matrix(GETGRIDLOCATION(x,y)) = whatever

EDIT - hell, I'm inspired. I'm going to rewrite this in SC this weekend.
« Last Edit: September 28, 2010, 06:26:30 PM by WarHampster »

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: GM Sokoban clone: Winterban
« Reply #9 on: September 28, 2010, 06:38:39 PM »
My goodness, you guys are lightyears ahead of me now. That code is beyond me!
I survived the spammage of 2007

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: GM Sokoban clone: Winterban
« Reply #10 on: September 28, 2010, 06:57:06 PM »
Heh, it's really pretty simple. I'm just making an array with the number of fields of a matrix with dimensions WIDTH and HEIGHT and then using that GETGRIDLOCATION method to look up the field of the array that would correspond with the x,y coordinates in the matrix.

GabrielCA


  • GMG-er

  • **

  • no avatar

  • Posts: 224
Re: GM Sokoban clone: Winterban
« Reply #11 on: September 28, 2010, 08:45:32 PM »
This can be simplified to :
Code: [Select]
GETGRIDLOCATION:
Parameters: x,y
RETURN y*WIDTH+x
If the first cell's number is zero and its coordinates are (0,0).

Example :
Code: [Select]
Width : 4 units
Height : 3 units

     0   1   2   3
   -----------------
 0 | 0 | 1 | 2 | 3 |
   -----------------
 1 | 4 | 5 | 6 | 7 |
   -----------------
 2 | 8 | 9 | 10| 11|
   -----------------

Coordinates (3,2) --> 2*4+3 --> Cell 11
(Formatted in "code" mode to prevent proportional spacing !)

Programmers should always count starting from zero !
« Last Edit: September 28, 2010, 08:51:14 PM by GabrielCA »
Creator of the deprecated plugin KeyDetect (2005)

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: GM Sokoban clone: Winterban
« Reply #12 on: September 28, 2010, 08:56:04 PM »
SC's arrays start from 1  ;)

GabrielCA


  • GMG-er

  • **

  • no avatar

  • Posts: 224
Re: GM Sokoban clone: Winterban
« Reply #13 on: September 28, 2010, 08:59:22 PM »
Code: [Select]
RETURN ((y * WIDTH)-WIDTH) + x
You could remove the parentheses (unless SC doesn't support the order of operations)
Multiplications evaluate before additions and subtractions...
Code: [Select]
RETURN y*WIDTH-WIDTH+x
Creator of the deprecated plugin KeyDetect (2005)

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: GM Sokoban clone: Winterban
« Reply #14 on: September 28, 2010, 09:40:34 PM »
You're nitpicking. Unless you're programming for something ridiculously underpowered, readability is more important than being concise. I find that using lots of parentheses makes ugly math seem simpler. In this case things are so simple that it doesn't really matter, but containing parts of equations in parentheses helps me visualize what's going on.
« Last Edit: September 28, 2010, 09:42:22 PM by WarHampster »