Post Reply 
Sokoban game for HP Prime
01-04-2014, 10:58 AM (This post was last modified: 01-15-2014 01:40 PM by ArielPalazzesi.)
Post: #1
Sokoban game for HP Prime
Sokoban game for HP Prime

Hello!
I'm still learning a little bit about the commands and possibilities of this excellent machine.

I started working on developing a version of the game Sokoban. Using tiles of 16x16 bits and I'm using the touch screen to control the movements of "pusher".

[Image: Captura+de+pantalla+de+2014-01-03+12%253A18%253A53.png]

I've already finished programming the graphics and movement routines. I need to optimize the compression / decompression of maps and details of the game (score, help, etc).

I made one (the first one!) video of the game:





The video shows how the game works. It is not a particular level, but a sandbox created just to do some testing.

I try finish in a few days.

Regards

PD: Sorry for my bad English language management. My native language is Spanish, and it showsWink
----------------------------
EDIT 14/01/14: Download latest release: ([url=http://www.hpmuseum.org/forum/attachment.php?aid=170[/url])
Find all posts by this user
Quote this message in a reply
01-04-2014, 07:35 PM
Post: #2
RE: Sokoban game for HP Prime
Hello!
The "Beta 1" version is ready!.
Only has 10 levels, and keeps track of the number of moves made and the amount of pushes made.

They are the first ten levels of the DOS version about 30 years. ... They are difficult to solve, but not impossible. Enjoy! Wink

The pusher moves touching the edges of the screen. I did not use keys courses to preserve the "health" of the keyboard.

Soon more levels. Wink

T.I.A., Ariel.

[Image: level1.png]

[Image: Level3.png]

[Image: Level5.png]

PS: Remember.....is a "Beta", there are features that have not yet been implemented.


Attached File(s)
.zip  SokobanBeta1.hpprgm.zip (Size: 3.76 KB / Downloads: 61)
Find all posts by this user
Quote this message in a reply
01-04-2014, 09:11 PM
Post: #3
RE: Sokoban game for HP Prime
This will definitively go in the HP Prime Tribute video with the other games and programs Smile

I will also give this a try for sure.

-Dream of Omnimaga
https://dreamofomnimaga.page
Visit this user's website Find all posts by this user
Quote this message in a reply
01-04-2014, 10:39 PM
Post: #4
RE: Sokoban game for HP Prime
Going to try it now. Looks good! And, your english is VERY readable, much better than my spanish!

I'm a math teacher. Of course I have problems.
Find all posts by this user
Quote this message in a reply
01-05-2014, 09:11 AM (This post was last modified: 01-05-2014 09:20 AM by patrice.)
Post: #5
RE: Sokoban game for HP Prime
About compression, you can use a simple encoding as commonly used in the game of life
Here is a decoding routine
Code:
RLEMap (Rows, Cols,RLE)
BEGIN
LOCAL Row, Col, Ptr, Cnt, Tmp;
Row:= 1; Col:= 1; Cnt:= 0;
Tmp:= MAKEMAT(0,Rows,Cols);
FOR Ptr FROM 1 TO DIM(RLE) DO
  CASE
  IF INSTRING("0123456789", MID(RLE, Ptr, 1)) <> 0 THEN Cnt:= Cnt*10+EXPR(MID(RLE, Ptr, 1)); END;
  IF MID(RLE, Ptr, 1) == "$" THEN Row:= Row+MAX(1, Cnt); Col:= 1; Cnt:= 0; END;
  IF INSTRING("b.", MID(RLE, Ptr, 1)) <> 0 THEN Col:= Col+MAX(1, Cnt); Cnt:= 0; END;
  IF INSTRING("w", MID(RLE, Ptr, 1)) <> 0 THEN // Wall
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=1; END; Cnt:= 0; END;
  IF INSTRING("c", MID(RLE, Ptr, 1)) <> 0 THEN // Cube
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=2; END; Cnt:= 0; END;
  IF INSTRING("d", MID(RLE, Ptr, 1)) <> 0 THEN // Destination
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=3; END; Cnt:= 0; END;
  IF INSTRING("s", MID(RLE, Ptr, 1)) <> 0 THEN // Sokoban
    FOR Col FROM Col TO Col+MAX(1, Cnt)-1 DO Tmp(Row,Col):=4; END; Cnt:= 0; END;
   END;
END;
RETURN Tmp;
END;
and the encoding for the first level
Code:
"$$$5b5w$5bw3bw$5bwc2bw$3b3w2bc2w$3bw2bcbcbw$b3wbwb2wbw3b7w$bw3bwb2wb5w2b2dw$bwbc​6bs6b2dw$b5wb3wbwb2w2b2dw$6bw5b9w$5b7w!"
The coding is :
$ : new line
! : End (optional)
b : Background (your 0)
w : Wall (your1)
c : Cube (your 3)
s : Sokoban (your 4)
and numeric is the repeat factor for next letter

Routine and level untested, but you get the idea

By the way, are you sure there is a Cube missing in level 1 ?

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
01-05-2014, 11:01 AM
Post: #6
RE: Sokoban game for HP Prime
would be a nice idea to allow cursor keys instead of mouse.
Mouse have timeout that prevent quick moves. It is a pain.

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
01-05-2014, 12:05 PM
Post: #7
RE: Sokoban game for HP Prime
(01-05-2014 11:01 AM)patrice Wrote:  would be a nice idea to allow cursor keys instead of mouse.
Mouse have timeout that prevent quick moves. It is a pain.

Thanks Patrice!

I will analyze the compression routines, and provide an option to play with the keyboard or touch screen.
Revisiting the cube at level 1Wink
Find all posts by this user
Quote this message in a reply
01-05-2014, 12:36 PM (This post was last modified: 01-05-2014 03:08 PM by ArielPalazzesi.)
Post: #8
RE: Sokoban game for HP Prime
Yep....one cube was missing.

Fixed! (Beta 1.1 attached)

PS: Working in more levels/options

[Image: index.php?action=dlattach;topic=17833.0;...6641;image]


Attached File(s)
.zip  SokobanBeta1.01.zip (Size: 4.26 KB / Downloads: 29)
Find all posts by this user
Quote this message in a reply
01-05-2014, 03:29 PM
Post: #9
RE: Sokoban game for HP Prime
Here is a little rewrite of your code for Moves and Pushes in the 4 directions.
Code:
local DX, DY;
...
        IF xmouse<80 AND ymouse>60 AND ymouse<180 THEN DY:=0; DX:=-1; END;
        IF xmouse>240 AND ymouse>60 AND ymouse<180 THEN DY:=0; DX:=1; END;
        IF xmouse>80 AND xmouse<240 AND ymouse<60 THEN DY:=-1; DX:=0; END;
        IF xmouse>80 AND xmouse<240 AND ymouse>180 THEN DY:=1; DX:=0; END;

        CASE
          IF matriz [YYP+1+DY, XXP+1+DX] == 0 OR matriz [YYP+1+DY, XXP+1+DX] == 3 THEN
            IF matriz [YYP+1,XXP+1] == 0 THEN BLIT_P(G5,XXP*16,YYP*16); END;
            IF matriz [YYP+1,XXP+1] == 3 THEN BLIT_P(G3,XXP*16,YYP*16); END;
            YYP := YYP+DY; XXP := XXP+DX;
            BLIT_P(G4,XXP*16,YYP*16);
            MOVI := MOVI + 1;
          END; //-----------------------------------
          IF ((matriz [YYP+1+DY,XXP+1+DX]==2) OR (matriz [YYP+1+DY,XXP+1+DX]==5)) AND ((matriz [YYP+1+2*DY,XXP+1+2*DX]==0) OR (matriz [YYP+1+2*DY,XXP+1+2*DX]==3)) THEN
            IF matriz [YYP+1,XXP+1] == 0 THEN BLIT_P(G5,XXP*16,YYP*16); END;
            IF matriz [YYP+1,XXP+1] == 3 THEN BLIT_P(G3,XXP*16,YYP*16); END;
            YYP := YYP+DY; XXP := XXP+DX;
            BLIT_P(G4,XXP*16,YYP*16);
            BLIT_P(G2,(XXP+DX)*16,(YYP+DY)*16);
            IF (matriz [YYP+1,XXP+1]==2) THEN matriz [YYP+1,XXP+1] := 0; ELSE matriz [YYP+1,XXP+1] := 3; END;
            IF (matriz [YYP+1+DY,XXP+1+DX]==0) THEN matriz [YYP+1+DY,XXP+1+DX] := 2; ELSE matriz [YYP+1+DY,XXP+1+DX] := 5; END;
            MOVI := MOVI + 1;
            PUSH := PUSH + 1;
          END; //-----------------------------------
        END;
Since Moves and Pushes are the same in each directions, this code is doing the trick without duplicating the code. It save about 20K in source code.

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
01-05-2014, 03:31 PM
Post: #10
RE: Sokoban game for HP Prime
(01-05-2014 03:29 PM)patrice Wrote:  Here is a little rewrite of your code for Moves and Pushes in the 4 directions.

WOW!!! Thanks!
Find all posts by this user
Quote this message in a reply
01-07-2014, 11:11 AM (This post was last modified: 01-15-2014 01:41 PM by ArielPalazzesi.)
Post: #11
RE: Sokoban game for HP Prime
Versión Beta 1.03 ready.

* 40 levels
* Help screen
* Abort game
* Exit screen
* Etc.

Download Link: Sokoban for HP Prime (Beta 1.03) (some problems fixed, Beta 1.031)

Demo video:




Is the last release for 15 or 20 days (vacation time!)


PS: The "control with keys" opción don't work. When I return from my vacation will finish characteristic of this program, adding 60 more levels, and change in name to "version 1.0" Wink
Find all posts by this user
Quote this message in a reply
01-09-2014, 03:36 PM
Post: #12
Sokoban game for HP Prime
That's one of my favorite games, it makes you think a lot, thank you for sharing your game with us Ariel. can't wait to get my hands dirty with version 1.0![/size][/size]
Find all posts by this user
Quote this message in a reply
01-10-2014, 09:59 PM
Post: #13
RE: Sokoban game for HP Prime
I love Sokoban and it was a very good idea to port it on HPP and nice implementation.
Thanks.
Find all posts by this user
Quote this message in a reply
01-14-2014, 11:25 AM
Post: #14
RE: Sokoban game for HP Prime
Bug report.
You need to add a test for when you hit a wall.
Because if the wall is on first/last row/col, you can't test for pushing because second cell is outside of matrix.

go to Board 4 7 and hit the wall on top

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
01-14-2014, 01:36 PM
Post: #15
RE: Sokoban game for HP Prime
(01-14-2014 11:25 AM)patrice Wrote:  Bug report.
You need to add a test for when you hit a wall.
Because if the wall is on first/last row/col, you can't test for pushing because second cell is outside of matrix.

go to Board 4 7 and hit the wall on top

Thanks!!! Checking....
Find all posts by this user
Quote this message in a reply
01-14-2014, 02:14 PM
Post: #16
RE: Sokoban game for HP Prime
Solved. Thanks a lot! Wink

Working in final version 1.0. Release date: Feb/2014, after vacation time Wink


Attached File(s)
.zip  SokobanBeta1.03 fixed.zip (Size: 8.59 KB / Downloads: 16)
Find all posts by this user
Quote this message in a reply
01-14-2014, 05:42 PM
Post: #17
RE: Sokoban game for HP Prime
Another problem.

When the program is running, the calc never slow down while waiting for an event (key or tap)

Something should be changed in the WAIT function. a WAIT(0) may do the trick

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
01-15-2014, 08:37 AM
Post: #18
RE: Sokoban game for HP Prime
Board 1-2 is impossible

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
01-15-2014, 01:40 PM (This post was last modified: 01-15-2014 01:52 PM by ArielPalazzesi.)
Post: #19
RE: Sokoban game for HP Prime
Fixed! Thanks a lot Wink

PS: Attach the original level, from Sinclair ZX Spectrum Sokoban:

[Image: attachment.php?aid=171]


Attached File(s) Thumbnail(s)
   

.zip  SokobanBeta1.03 fixed.zip (Size: 8.59 KB / Downloads: 84)
Find all posts by this user
Quote this message in a reply
01-27-2014, 11:21 PM
Post: #20
RE: Sokoban game for HP Prime
Hi Ariel,
Have a look at the library entry "1 Utility for Games", you should be interested.

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 10 Guest(s)