Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:38 19 Jun 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Game: CrateAway - Feeling pushy? Push some crates!

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1085
Posted: 08:00pm 10 Dec 2020
Copy link to clipboard 
Print this post

Here's my latest diversion:




Many should recognize this as a clone of a particular pushing game with a Japanese name. However, everything in my version is my own creation and should be copyright safe.

The game has 12 levels built in to get you started. Many more levels can be found on the internet by searching for "Sokoban levels". Make sure you use txt formatted levels.

CrateAway15-vp.zip

' Use the arrow keys to move
' Z - undo
' R - restart level
' Q - quit
' B - play built-in levels
' L - load levels file
' N - 'undocumented' skip to next level
Visit Vegipete's *Mite Library for cool programs.
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 431
Posted: 08:12pm 10 Dec 2020
Copy link to clipboard 
Print this post

Nice.  Thanks.  Any firmware version info considering the flux we are in with the marvelous enhancements being added.  I am going to look into the levels online but could you indicate how to add them, or will that become clear from the files? Wait I looked at the main program and you have them in data lines.  Can you just append level layouts at the end of the list or do you need to alter the code to gain access to them?
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1085
Posted: 08:39pm 10 Dec 2020
Copy link to clipboard 
Print this post

Should be no firmware requirements.

You could just add more data lines. No program change required.

But better would be to put them in a separate text file. Then they are easily shared.

Save this as a text file and it can be played. (Not much challenge though.)
#########################
#           +           #
#  $$$ $   $ $   $  $$  #
# $    $$ $$ $$ $$ $  $ #
# $    $ $ $ $ $ $    $ #
# $    $   $ $   $   $  #
# $    $   $ $   $  $   #
#  $$$ $   $ $   $ $$$$ #
#                       #
#                       #
#  ...  ....  ... ..... #
#  .  . .    .      .   #
#  ...  ...   ..    .   #
#  .  . .       .   .   #
#  .  . .       .   .   #
#  ...  .... ...    .   #
#                       #
#########################
;A sample level
;By vegipete, Dec 10,2020

I have seen some level text files out there that put the ";name" before the level itself. These will work too, although I expect the first level to be blank and then each name will get assigned to the previous level. And the last level won't appear.
Edited 2020-12-11 06:40 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 317
Posted: 09:29pm 10 Dec 2020
Copy link to clipboard 
Print this post

Fantastic! I look forward to playing this at the weekend. I do love a good puzzle game!
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3701
Posted: 08:19am 11 Dec 2020
Copy link to clipboard 
Print this post

@ Vegipete,

I love this, this brings back good memories. To bad I don't have a CMM2 yet. Maybe this is a good reason to finally buy one.

Volhout
PicomiteVGA PETSCII ROBOTS
 
PilotPirx

Regular Member

Joined: 03/11/2020
Location: Germany
Posts: 66
Posted: 12:33pm 11 Dec 2020
Copy link to clipboard 
Print this post

Great Game Vegipete,

but i get an error pressing B to start the game.
"Error in line 386: Syntax"
Which Firmware Version do we need?
 
fuse
Newbie

Joined: 26/07/2020
Location: United States
Posts: 2
Posted: 01:57pm 11 Dec 2020
Copy link to clipboard 
Print this post

Fixed line 386 issue and notblack issue

CrateAway15a.zip
 
PilotPirx

Regular Member

Joined: 03/11/2020
Location: Germany
Posts: 66
Posted: 02:58pm 11 Dec 2020
Copy link to clipboard 
Print this post

Game starts now with button B,
only Button "R" for restarting level gives "Error in line 168: Syntax", all other buttons work well.

Very good work and nice graphics!!!
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 454
Posted: 03:02pm 11 Dec 2020
Copy link to clipboard 
Print this post

Amazing Vegipete.
Unfortunately this EOY I'm stuck with some personal problems and only next year I will be back to my CMM2 projects
 
fuse
Newbie

Joined: 26/07/2020
Location: United States
Posts: 2
Posted: 03:43pm 11 Dec 2020
Copy link to clipboard 
Print this post

This fixes R (Restart) in v5.05.05

CrateAway15b.zip
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1085
Posted: 07:06pm 11 Dec 2020
Copy link to clipboard 
Print this post

I guess I did use a command or 2 only found in recent firmware. Oops, sorry.

math add boardstart(),0,board()
appears on line 168 and the reverse
math add board(),0,boardstart()
appears on line 386.

Fuse's solution does the trick. Good work.

An alternative to try is
math scale boardstart(),1,board()
which has been available in the firmware much longer, since 5.05.04

I also used the colour "NOTBLACK" (in line 470) which is quite new. Fuse solved that by using BLUE instead. That actually looks quite good. Darker is better due to the anti-aliasing so I would suggest changing "rgb(notblack)" to "&h000040"

Why, you ask? I wanted the "Solved" message to scroll into view, so I turned it into a sprite. But ordinary black and sprites don't play well together. Black is treated as transparent, which would make a mess of the solved message. That's why "notblack" was created.
Visit Vegipete's *Mite Library for cool programs.
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 431
Posted: 07:31pm 11 Dec 2020
Copy link to clipboard 
Print this post

There are so many Levels out there.  Here is a good site. Looks like they are in the proper format. https://www.sourcecode.se/sokoban/levels

I was surprised by how many there are out in the wild.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3038
Posted: 03:44pm 25 Apr 2021
Copy link to clipboard 
Print this post

A version that also runs on the Armmite F4 with IPS/OTM8009A 800.480 LCD

To add to another one of VegiPete's gems, I've tested this on 5 hardware configurations:

1) CMM2 with VGA and keyboard
2) CMM2 with VGA and PC console
3) CMM2 with VGA->HDMI->USB3 and PC console
4) F4 with PC console
5) F4 with hat  and keyboard

To handle the varying input (particularly arrow keys when using the PC console or F4 or CMM2), I replaced all INKEY$ with _INKEY$() and provided this FUNCTION _INKEY$

Function _inkey$()
 local ky$
 ky$=inkey$
 if asc(ky$)=27 then ' escape sequence
   ky$=inkey$: ky$=inkey$: ky$=ucase$(ky$)
   If ky$="A" Then: ky$=chr$(128) ' up arrow
   ElseIf ky$="B" Then: ky$=chr$(129) ' down arrow
   ElseIf ky$="C" Then: ky$=chr$(131) ' right arrow
   ElseIf ky$="D" Then: ky$=chr$(130) ' left arrow
   ElseIf ky$="5" Then: ky$=chr$(136) ' pgdn
   ElseIf ky$="6" Then: ky$=chr$(137) ' pgup
   ' Function keys are ???
   EndIf
 endif
 _inkey$=ky$
end function


Otherwise I had to replace blits of the sprite graphics page on a separate CMM2 page with F4 sprites created with BLIT READ and BLIT WRITE.

The F4 looked to have generous memory compared to most other micromites, but compared to the CMM2, it's miserly--114K compared to 5M+. I could not build all the necessary sprites without running out of memory. I wanted to keep the walking/pushing man on the instruction page--that took 29 sprites and left 4K of RAM remaining (other program RAM included).

(Note--VegiPete used the CMM2s mirroring parameter to flip the walking man and pushing man--I had to reverse the pixels on the bmp image screen and save walking left and pushing left and right.  It would be useful to save memory on the F4 by providing that mirroring parameter to BLIT WRITE.)

I squeezed some array sizes to gain more memory.

Then to get the sprites to play the game, I had to BLIT CLOSE all 29, reload the sprite image .bmp file and set another 7 game tile sprites.

Other than the blits, there was not much that had to be changed. The CMM2 game plays with 500x500 pixels, so I had to squeeze the vertical down to 480. That changed sprite depth by a pixel.

MATH ADD is also not available on the F4. It's used to make a copy of the game board. I used enclosed FOR loops to copy the double-dimensioned array.





F4 MMBasic doesn't have include files, so I didn't try to provide that way to add more games. The text file games found on the internet can be pasted into this program.

Zipped MMBasic file with .bmp sprite file:
CrateAwayF4.zip


F4 on Fruit of the Shed

~
Edited 2021-04-26 01:51 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1085
Posted: 05:13pm 25 Apr 2021
Copy link to clipboard 
Print this post

Cool. Vegipete approved!
Visit Vegipete's *Mite Library for cool programs.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024