Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:54 01 Aug 2025 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: ChemiChaos - Fix the Mix, Save the Lab!

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 02:56am 22 Dec 2020
Copy link to clipboard 
Print this post

More foolishness from the desk of vegipete.

Chemical Chaos

Apparently, some nefarious actor has infiltrated the lab and randomly mixed chemicals. Sort them and save the day!

Use the arrow keys and the space bar to transfer chemical balls one by one from tube to tube until they are sorted. But watch out! You cannot place a ball on a differently coloured one!

35 levels, generally fairly easy. Some levels are fixed, some are randomly generated. (Usually levels with 2 empty test tubes at the start are random ones. I've never yet found a random level that wasn't solvable but maybe you'll get lucky.)

' ChemiChaos
' by vegipete, December 2020
'
' Sort the Chemical Balls in the Test Tubes
' Move with the arrow keys
' Pick and place with the space bar
' Restart level with R
' Quit with Esc
'
'   version 1.0   Original release, graphics tweaks, more levels + counter, intro text

Visit Vegipete's *Mite Library for cool programs.
 
PilotPirx

Regular Member

Joined: 03/11/2020
Location: Germany
Posts: 99
Posted: 08:31am 22 Dec 2020
Copy link to clipboard 
Print this post

Congratulations vegipete, great game.
Nice look, fun to play.
Great work!

Just a small suggestion for improvement:
Display of
- number of current moves
- Highscore (best solution so far)
- minimum possible number of moves
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 03:17am 27 Dec 2020
Copy link to clipboard 
Print this post

I've tried to avoid CMM2 games so far, but this one looked interesting so I thought I would give it a go.

Fired up my second CMM2 to try it out. (Been dormant for a while)
Great game & a bit addictive.  

I added a small pause before the SAFE splash notice came up so I could savour the moment .

An "OOPS" key would be also good (Undo last move) in case one accidently hits the space bar. Would save starting the level again.

There are a few programming concepts there which I hadn't come across before from my brief look at the program.

Now to try out some other games that have been posted over the past few months or so.

Thanks.
Brian
ChopperP
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 09:36pm 28 Dec 2020
Copy link to clipboard 
Print this post

Yes, it's potentially addicting. Fortunately there are only 35 levels so you can't keep going and going...

I thought about a move counter. A counter would be easy enough, but the minimum number of moves is harder. Fine for the pre-defined levels, much harder for the randomly generated levels. I took the lazy route.  

During development, there was the equivalent of an "OOPS" key. I deliberately took it out for release. If you really want it back, change lines 210-212 with the following: (although I don't guarantee it works.)
     case  27    ' [ESC]
       DrawBall(0,src,0)   ' erase coloured ball above source vial
       for j = 1 to 4
         if vials(src,j) = 0 then     ' find top spot
           vials(src,j) = movingball  ' put the ball back
           DrawBall(movingball,src,j+1) ' re-draw coloured ball in vial
           exit do
         endif
       next j
       gameover = 1
       exit do

Visit Vegipete's *Mite Library for cool programs.
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 02:55am 30 Dec 2020
Copy link to clipboard 
Print this post

  vegipete said  During development, there was the equivalent of an "OOPS" key. I deliberately took it out for release. If you really want it back, change lines 210-212 with the following: (although I don't guarantee it works.)


Sorry vegipete,

Hitting ESC only puts half a ball on the LHS of the white background, not back in the original tube. No changes to the other test tubes.

Also, the ESC counter doesn't reset at the end of the level.

Just have to be more careful as to which key I press & when.

Thanks
 
Brian
ChopperP
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 03:45am 30 Dec 2020
Copy link to clipboard 
Print this post

That's what I get for not checking my work.  

This one should work properly: ChemiChaos10b.zip

"z" is your undocumented friend.
Visit Vegipete's *Mite Library for cool programs.
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 12:38pm 30 Dec 2020
Copy link to clipboard 
Print this post

Thanks,

Works well.
ChopperP
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 504
Posted: 04:50am 31 Dec 2020
Copy link to clipboard 
Print this post

Vegipete

I loved your game, it's so fun.

Thank you
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 11:52pm 31 Dec 2020
Copy link to clipboard 
Print this post

@ vegipete

Sent you a PM

Brian
ChopperP
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 01:57am 30 Jan 2021
Copy link to clipboard 
Print this post

Here is an update to ChemiChaos.

A mouse should work fine if present.
As per Brian's suggestion and example, I've added key stroke and mouse click counters, so you can see just how much time you've wasted playing this game. Press 'c' to toggle counts on and off.
There are more levels now and level numbering is a bit different. For level sets 3 to 7, there are 10 levels each.

On my 400 MHz WaveShare, I'm getting some gnarly sync problems from the time to time - the whole image rips sideways for a frame or two every so often, even with no mouse. Could others report if they see this too?

Thanks, enjoy, and have fun.

ChemiChaos12.zip
Visit Vegipete's *Mite Library for cool programs.
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 10:27pm 30 Jan 2021
Copy link to clipboard 
Print this post

Thanks vegipete

The first thing I had to do was to add ON ERROR SKIP to blank line 50 as I don't have a mouse & am not using the latest version. It protested at line 51.

No sign of tearing yet. Only on level 4.6.
The counters font size is a bit small my eyes as well.

Will continue.

Brian
ChopperP
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 11:58pm 30 Jan 2021
Copy link to clipboard 
Print this post

Ah, older firmware version.
You could change line 51 to
mport = 0 ' mm.info(option mouse) + 1

and comment lines 52 to 69 inclusive.

I'll make the game more tolerant of older versions and eyes.

I suspect the tearing is version related. What firmware version are you using?
Visit Vegipete's *Mite Library for cool programs.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 02:10am 31 Jan 2021
Copy link to clipboard 
Print this post

Running this program highlighted an interesting problem.

If I run it normally from the commandline, no problems.
I normally will run programs by clicking on the file name in my file manager (or the files command).
When I start it with a mouse left click, the LeftClick SUB gets called before the cursor has been setup.
This causes an error.

My 'fix' was to put
newclick = -1

immediately before searching for the mouse.
and then added a test in the LeftClick SUB

sub LeftClick
 if newclick = 0 then
   newclick = 1
   handx = mouse(x,mport-1)
   handy = mouse(y,mport-1)
   if mport then gui cursor handx,handy
 endif
end sub


Your code has newclick = 0 later, after all the setup, so the test inhibits the first LeftClick.


I expect that any program that uses the interrupt is likely to have the same problem.

Perhaps Peter can clear the mouse buttons on RUN.

Jim
VK7JH
MMedit
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 06:19am 31 Jan 2021
Copy link to clipboard 
Print this post

Hi vegipete

There is tearing evident. Wasn't noticeable early on.

Got through a couple of times. Really stumped a couple of times.

A "Save Game" feature would be handy.  

Running 5.06.00. One of Bigmik's units. Single board.
ChopperP
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 09:10am 31 Jan 2021
Copy link to clipboard 
Print this post

  Quote  Running this program highlighted an interesting problem.


If I understand correctly this is a simple programming bug which others have encountered.

It is essential that all resources used in an interrupt routine are set up and ready before the interrupt is enabled. Enabling interrupts should be the last thing before the main program loop starts.

For example an interrupt routine could use a global variable that hasn't yet been DIMmed. This isn't something the firmware can cater for. All interrupts are disable when a program is run but if an interrupt condition exists then it will fire as soon as the interrupt is enabled
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:25am 01 Feb 2021
Copy link to clipboard 
Print this post

  matherp said  
If I understand correctly this is a simple programming bug which others have encountered.


I agree that there are a number of programming bugs here but the problem I see is:
If a program is started from 'files' by using the mouse, an initial interrupt is triggered. If the same program is started from 'files' by using only the keyboard, the initial interrupt is NOT triggered.

This program will demonstrate the issue.
 'mouse button initial test
   dim integer mp
 CLS
 MODE 1,8
 
 mp = mm.info(option mouse)
 if mp = -1 then ' no mouse set
   mp = 0 ' assume PS/2 mouse - change to suit
 endif
 print "Mouse port ";mp
 
 PAUSE 5000
 GUI CURSOR ON
 
 CONTROLLER MOUSE OPEN mp, leftclick, rightclick
 
 PRINT "Mouse found is type ",MOUSE(t,mp)
 
 DO : LOOP UNTIL inkey$<>""
 
 CONTROLLER MOUSE CLOSE mp
 pause 20
 GUI CURSOR OFF
END
 
 
 '
SUB leftclick
 STATIC INTEGER n
 n=n+1
 PRINT @(100,100)"left",n
END SUB
 '
SUB rightclick
 STATIC INTEGER m
 m=m+1
 PRINT @(200,100)"Right",m
END SUB


Try running it with and without using the mouse.
There is a 5 second delay to make sure that it is not my fingers doing the click.

If I use the right mouse button to scroll pages in 'files' before double-left-click to run the program, both interrupts are triggered.

I have only tried this with a PS/2 mouse. The HobbyTronics might be different.

Jim
VK7JH
MMedit
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 03:00pm 16 Jan 2022
Copy link to clipboard 
Print this post

Really good Vegipete !!!

What a fun game is this.

Spend the evening finishing all levels.
Honestly, at level 7.4 I hit the escape key per accident, and decided to hack the game and change the restore to where I was. Did not want to start from the beginning again.

Thanks for making it...

Volhout

P.S. also enjoyed your "Crate Away".... Much nicer than my own.
PicomiteVGA PETSCII ROBOTS
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025