Jump to content
IGNORED

How do we cycle colors from low to high and back down again (twice)?


Random Terrain

Recommended Posts

I need to cycle from $40 to $46, then from $46 to $40, but I need to do it twice in a row.

 

The only thing I can think of uses bloated code, a whole variable as a counter and too many bits. Is there a simpler, easier way to ping pong though a range of colors for a certain number of times?

 

 

Thanks.

Link to comment
Share on other sites

I need to cycle from $40 to $46, then from $46 to $40, but I need to do it twice in a row.

 

The only thing I can think of uses bloated code, a whole variable as a counter and too many bits. Is there a simpler, easier way to ping pong though a range of colors for a certain number of times?

 

 

Thanks.

 

 

Since the color array is static, how about just use a pointer and a data table.

 

 


data colorflash 
$40,$42,$44,$46,$44,$42,$40,$42,$44,$46,$44,$42,$40
end


Loop

COLUBK = 0

if a < colorflash_length-1 then a = a + 1 :  COLUBK = colorflash[a]

if joy0fire then a = 0

drawscreen

goto Loop

Edited by jrok
  • Like 2
Link to comment
Share on other sites

Since the color array is static, how about just use a pointer and a data table.

 

 


data colorflash 
$40,$42,$44,$46,$44,$42,$40,$42,$44,$46,$44,$42,$40
end


Loop

COLUBK = 0

if a < colorflash_length-1 then a = a + 1 :  COLUBK = colorflash[a]

if joy0fire then a = 0

drawscreen

goto Loop

That's a heck of a lot easier than the stupid, bloated crap I was trying to do.

 

 

Thanks.

Link to comment
Share on other sites

I would just do this instead:

 

dim color = a
dim FrameNum = b

rem set starting color
color = $40

Loop
drawscreen
FrameNum = FrameNum + 1

rem cycle color from 40 and 46 every other frame
if FrameNum{0} then color = color ^ 6

COLUBK = color
goto Loop

 

I was working under the assumption that he wanted to limit RAM usage, and have an effect that was simple to restart and stop after two iterations. My version uses 22 more bytes of ROM, but it only uses 1 byte of RAM and resets to defaults after two flashes.

 

And - maybe I was wrong in assuming this - but I figured that the "flash" effect itself was something that would start when a certain condition was triggered, like a ship being smacked with a missile, and stop after a certain duration.

 

In that spirit, I put together a little demo showing how 9 bits can be used to trigger a color & sound event. This could be optimized in a bunch of ways (including storing both the color and sound effect in a single data table), but I get the feeling that this is somewhat along the lines of what RT was looking for.

Hit_Effect.bas

Hit_Effect.bas.bin

Edited by jrok
Link to comment
Share on other sites

. . . but I get the feeling that this is somewhat along the lines of what RT was looking for.

I needed to change the color of the score background after shooting 100 bits of seaweed. Data worked great for what I ended up doing.

 

I hoped to upload the latest unfinished version of Seaweed Assault today, but it's taking longer than I planned.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...