Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: bikemadness on April 24, 2018

Title: Another Colour Select/Randomizer
Post by: bikemadness on April 24, 2018
D-Pad to select, Page Up to Randomize.

Instead of a 1+1/1-1 count, data has been used for chosen numbers.
In this program, there is 32, 16 and 8 counts, changed by the line - restore value*. * is 1, 2 or 3.

Code: [Select]
restore RGB
read sets
dim Rset$(sets)
dim Rnos(sets)
for a=1 to sets
read Rset$(a)
read Rnos(a)
next a

restore values3
read cols
dim Rv(cols)
dim R(cols)
for a=1 to cols
read Rv(a)
next a


for a=1 to sel
next a

open window 640,512
setdispbuf vm
setdrawbuf vm
clear window

if and(c,128)<>0 left=1
if left=1 L=L+1
if L>2 L=2
if L=2 left=0
if and(c,128)=0 L=0

if and(c,32)<>0 right=1
if right=1 R=R+1
if R>2 R=2
if R=2 right=0
if and(c,32)=0 R=0

if left=1 sel=sel-1
if right=1 sel=sel+1
if sel<1 sel=1
if sel>sets sel=sets

if and(c,16)<>0 up=1
if up=1 U=U+1
if U>2 U=2
if U=2 up=0
if and(c,16)=0 U=0

if and(c,64)<>0 down=1
if down=1 D=D+1
if D>2 D=2
if D=2 down=0
if and(c,64)=0 D=0

if and(c,1)<>0 slide=1
if slide=1 S=S+1
if S>2 S=2
if S=2 slide=0
if and(c,1)=0 S=0

for a=1 to sets

if sel=a then
setrgb 1,256,128,0
fill rectangle 75*a+150,138 to 75*a+(len(Rset$(a))*10)+150,156

if sel=a then
setrgb 1,0,128,0
setrgb 1,256,256,256
text 75*a+150,150,Rset$(a)
next a

for a=1 to sets rem sel
if sel=a and up=1 R(a)=R(a)+1
if sel=a and down=1 R(a)=R(a)-1
if R(a)<1 R(a)=1
if R(a)>cols R(a)=cols

for b=1 to cols
if R(a)=b Rnos(a)=Rv(b)
next b

setrgb 1,256,256,256
text 75*a+150,165,str$(Rnos(a))
next a

if slide=1 then
for a=1 to sel
next a

for a=1 to sel
setrgb 1,Rnos(1),Rnos(2),Rnos(3)
fill rectangle 200,200 to 450,450
next a

until (1=0)

label RGB
data 3
data "RED",0
data "GREEN",0
data "BLUE",0

label values1
data 9
data 0,32,64,96,128,160,192,224,256

label values2
data 16
data 0,16,32,48,80,96,112,128,144
data 160,176,192,208,224,240,256

label values3
data 31
data 0,8,16,24,32,40,48,56,80,88
data 96,104,112,120,128,136,144
data 152,160,168,176,184,192,200
data 208,216,224,232,240,248,256
Title: Re: Another Colour Select/Randomizer
Post by: rain_storm on May 04, 2018
Not bad