Jump to content
IGNORED

Randomly Change Colors Of A Multicolored Sprite


salzmafia.com

Recommended Posts

One example...

 

set kernel_options player1colors playercolors pfcolors

dim p0colorl=player0color
dim p0colorh=player0color+1

player0x=80
player0y=50

player0:
%11111111
%11000011
%10111101
%10111101
%10111101
%10111101
%11000011
%11111111
end

main
p0colorl=0
p0colorh=rand
drawscreen

 

...in a nutshell, it points player0color to the beginning of a random page of memory. As-is it flashes yellow a lot because there's a lot of unused rom in the kernel bank. As you use the rest of the space in the kernel bank the color will be more random appearing.

Link to comment
Share on other sites

One example...

 

set kernel_options player1colors playercolors pfcolors

dim p0colorl=player0color
dim p0colorh=player0color+1

player0x=80
player0y=50

player0:
%11111111
%11000011
%10111101
%10111101
%10111101
%10111101
%11000011
%11111111
end

main
p0colorl=0
p0colorh=rand
drawscreen

 

...in a nutshell, it points player0color to the beginning of a random page of memory. As-is it flashes yellow a lot because there's a lot of unused rom in the kernel bank. As you use the rest of the space in the kernel bank the color will be more random appearing.

How about pointing player0color to a section of RIOT or Superchip RAM and then changing that RAM to random color values?

Link to comment
Share on other sites

How about pointing player0color to a section of RIOT or Superchip RAM and then changing that RAM to random color values?

I found this old example I made of pointing player1's color table to RAM. It scrolls through all 128 colors, but it should be easy to change it to do random colors.

 

set kernel_options player1colors
dim p1color = a
dim p1color_row1 = a
dim p1color_row2 = b
dim p1color_row3 = c
dim p1color_row4 = d
dim p1color_row5 = e
dim p1color_row6 = f
dim p1color_row7 = g
rem * now set the player1color pointers
rem * to the address of variable a (or p1color)
asm
LDA #<p1color
STA player1color
LDA #>p1color
STA player1color+1
end
rem * define the player1 shape
player1:
%00111100
%01111110
%11111111
%11111111
%11111111
%01111110
%00111100
end
rem * set the initial color for each row
p1color_row1 = $00
p1color_row2 = $02
p1color_row3 = $04
p1color_row4 = $06
p1color_row5 = $08
p1color_row6 = $0A
p1color_row7 = $0C
rem * position the player
player1x = 76
player1y = 48
rem * now do the display loop
loop
drawscreen
rem * cycle the colors
p1color_row1 = p1color_row1 + 1
p1color_row2 = p1color_row2 + 1
p1color_row3 = p1color_row3 + 1
p1color_row4 = p1color_row4 + 1
p1color_row5 = p1color_row5 + 1
p1color_row6 = p1color_row6 + 1
p1color_row7 = p1color_row7 + 1
rem * adding 1 instead of 2 makes them cycle a little slower
goto loop

 

Edit: Pasting the code didn't work too well-- use the attached source instead.

test_player1colors_in_RAM.bas

test_player1colors_in_RAM.bas.bin

Edited by SeaGtGruff
Link to comment
Share on other sites

One example...

 

set kernel_options player1colors playercolors pfcolors

dim p0colorl=player0color
dim p0colorh=player0color+1

player0x=80
player0y=50

player0:
%11111111
%11000011
%10111101
%10111101
%10111101
%10111101
%11000011
%11111111
end

main
p0colorl=0
p0colorh=rand
drawscreen

 

...in a nutshell, it points player0color to the beginning of a random page of memory. As-is it flashes yellow a lot because there's a lot of unused rom in the kernel bank. As you use the rest of the space in the kernel bank the color will be more random appearing.

 

Worked perfect. Thanks!

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...