Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:21 27 Nov 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 : COBO - New Puzzle Game

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 12:32pm 04 Apr 2013
Copy link to clipboard 
Print this post

Greetings fellow Maximiters (or perhaps Mighty Maxxers?)

I've been writing a new game for the colour Maximite. This
game is a shameless copy of an un-named game available for
smart phones and play-able online.

2013-04-04_222918_COBO.zip

Instructions are in the included help file, which I have
copied below. Basically, you must knock all but one ball
from the playing field by launching the balls into each
other. The puzzle is determining which balls to hit others
with in which order.

Included are 52 levels, all of which are solve-able. The
first few are simple, but the challenge increases. In due
course, I'll make more levels. And accept level submissions
from others. ;-)

I've written this for the colour Maximite. I have no idea
how (or even if) it works on a regular Maximite.

Have fun and, as always, feedback, bug reports, etc are appreciated.
Pete.

ps:
Also, in the process of writing this game, I may have
stumbled upon a bug lurking in the handling of FOR-NEXT loops.
I say may have because I can't isolate the bug and my coding
may be asking too much of the interpreter. The seeming bug
is that program flow changes depending on whether the loop
variable is specifically called out in the NEXT statement at
the end of a FOR-NEXT loop. Line 290 of COBO03.BAS is the
statement in question. If the 'n' is not included, the
program doesn't work correctly - the FOR-NEXT loop doesn't
actually happen. (This appeared in earlier development versions.
I haven't actually checked if COBO03.BAS still requires the
'n'.) If you feel like experimenting, comment out the 'n' and
see if you can detect a change in program operation. (Under
certain conditions, balls can pass right through other balls
instead of hitting them.)

===================================
COBO - Can Only Be One
Written by VegiPete for the Colour Maximite computer.

Knock the balls off the playing field until only one remains.

The balls can only travel horizontally or vertically. Once
moving, they will continue until they leave the field or hit
another ball. The struck ball will continue moving in the
same direction.

A ball needs at least one space in the desired direction of
travel to start moving.

Balls cannot be launched directly from the playing field.
They must hit another ball, or chain of balls.

A level is solved when only one ball remains.

Keys:
z/Z - undo one move for each press
r/R - restart level
0-9 - select ball
arrow keys - launch selected ball in desired direction
ESC - quit game
l/L - enter level code

When each level is solved, a level code is displayed. Use
this code to jump directly to the next level.

Have fun!

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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6099
Posted: 12:57pm 04 Apr 2013
Copy link to clipboard 
Print this post

Not tested yet but I don't think it's a good idea to 'exit function' from within a for next loop.
Better to 'exit for'

Function notempty(x,y)
Local n
notempty = 0
If x<0 Or x>xsize-1 Or y<0 Or y>ysize-1 Then notempty = -1 : Exit Function
For n = 1 To maxballs
If curlevel(stepnum,n) = x + y/100 Then
notempty = n : Exit For 'there's a ball in this spot
EndIf
Next n 'MUST SPECIFY VARIABLE HERE. WHY? BUG?

End Function


(I usually put the variable in the next line anyway)

Jim
VK7JH
MMedit   MMBasic Help
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 05:03pm 04 Apr 2013
Copy link to clipboard 
Print this post

I just did some testing and the 'bug' can be seen in COBO03.BAS also. If you change line 290 to
Next 'n 'MUST SPECIFY VARIABLE HERE. WHY? BUG?
(add an apostrophe in front of the n variable so it becomes a comment) then the peculiar behaviour can be seen on level 19.
(Use level code 11411611 to go straight to level 19)
Without the 'n' after the NEXT, move 5 left, then 5 down. Now move 9 left and watch what happens. If you move 9 left again, everything works again. If you make an illegal move before 9 left, it works correctly.

Thanks for your thoughts, Jim.
Your suggestion works. In fact, the early loop exit isn't even needed, although it allows the subroutine to finish faster.
But there is still some sort of weird FOR-NEXT behaviour, perhaps related to 'unfriendly' use of the EXIT command.

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


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

© JAQ Software 2024