Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:46 19 Nov 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 : Sprite question or bug?

Author Message
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 114
Posted: 02:39am 13 May 2021
Copy link to clipboard 
Print this post

I'm in the middle of testing a few tests for animating sprites for a project and have come across 1 problem in coding. I am animating a sprite and the sprite animation is dependent on what direction it is moving - so we have 3 sprites each on 4 frames. Animation frame displayed is controlled by an interrupt routine and this seems to work fine. The issue I have found is in this little bit of code....

if x=oldx and (spr<5 or spr>8) then
sprite hide spr
spr=5
sprstart=5
sprmax=8
sprite show spr,x,y,1
endif

This causes a syntax error, but if I call the same code as a subroutine it works without an error.

if x=oldx and (spr<5 or spr>8) then front
.
.
.
sub front
sprite hide spr:spr=5:sprstart=5:sprmax=8:sprite show spr,x,y,1
end sub

Is there an issue in my code or just a quirk of using sprite commands in if/then statements?
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4147
Posted: 05:46am 13 May 2021
Copy link to clipboard 
Print this post

If you make the smallest (non-runnable but valid otherwise) program (or pair of programs) along those lines does it still cause a syntax error?

If it does, let Peter have it so he can debug MMBasic.

I suspect it will not cause the error...

John
 
Goksteroo
Senior Member

Joined: 15/03/2021
Location: Australia
Posts: 114
Posted: 06:59am 13 May 2021
Copy link to clipboard 
Print this post

Those pieces of code are taken from a working test program where the animation and sprites work.... as long as the second version using subs is used. BUT, I've just changed the code back to the original, non-sub version and now it works without any syntax errors. I've been trying to trouble shoot it for 2 hours this am 'til I turned the CMM2 off and posted here. Go figure - the joys of programming.
 
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