Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: bikemadness on August 16, 2007

Title: Word Maker
Post by: bikemadness on August 16, 2007
I haven't seen this one in a while.
It simulates a alphabet tumblar, like the one on 'The Davinci Code'
I put it together in hope of using it as an input string and dragged it out,
each time I had a new idea to make it work.

L/R d-pad to move the highlighted letter.
U/D d-pad to change the highlighted letter
The amount of letters can be changed with the square (less) and circle (more).

Code: [Select]
open window 640,512
sx=1
sy=105
letters=20
dim x(letters),y(letters),z(letters)
for a=1 to letters
x(a)=a
y(a)=100
z(a)=1
next a
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,200,200,0
fill rectangle 0,0 to 640,512
go1=go1+1
if go1>10 go1=10
c=peek("port1")
if and(c,128)>0 and go1=10 then
go1=0
sx=sx-1
endif
if and(c,32)>0 and go1=10 then
go1=0
sx=sx+1
endif
if sx<1 sx=1
if sx>letters sx=letters
if and(c,16)>0 then
my=-1
else
my=0
endif
if and(c,64)>0 my=1
setrgb 1,0,0,0
rectangle 98+(sx*20),sy to 115+(sx*20),sy-15
go2=go2+1
if go2>5 go2=5
if and(c,8192)>0 and go2=5 then
letters=letters+1
go2=0
endif
if and(c,32768)>0 and go2=5 then
letters=letters-1
go2=0
endif
if letters<1 letters=1
if letters>20 letters=20
go3=go3+1
if go3>5 go3=5
for a=1 to letters
if sx=x(a) and go3=5 then
z(a)=z(a)+my
go3=0
endif
if z(a)<1 z(a)=26
if z(a)>26 z(a)=1
text x(a)*20+100,y(a),chr$(z(a)+64)
next a
until (1=0)

Have a Yahappy day.


Title: Re: Word Maker
Post by: Clanky on August 16, 2007
Haven't seen the De Vinci Code, but, your code is nice! Well done.