Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: Jim on October 18, 2006

Title: yabasic demo
Post by: Jim on October 18, 2006
I wrote this to see if I really understood Shockwave's lovely twisting bar code, and I wrote it in yabasic just to prove it can still be done, and then I added copper bars because no demo is complete without copper bars is it?
Have fun!
Jim

Code: [Select]
'twisty fatty shrinky barry thing, with copper bars
'by Jim 18/10/2006
sw=640
sh=512
hsw=sw/2
open window sw,sh

'twisty barry thing stuff
ascale=3.14/180
w=100
inc=0
iinc=0.01
dim c(4,3)
c(0,0)=255:c(0,1)=0:c(0,2)=0
c(1,0)=0:c(1,1)=0:c(1,2)=255
c(2,0)=0:c(2,1)=255:c(2,2)=0
c(3,0)=255:c(3,1)=255:c(3,2)=0
c(4,0)=c(0,0):c(4,1)=c(0,1):c(4,2)=c(0,2)

'copper bar stuff
dim cuy(3)
dim cui(3)
dim rgb(3)
cuy(0)=0:cuy(1)=0:cuy(2)=0
cui(0)=.005:cui(1)=.007:cui(2)=.012
cuh=80

repeat
setdispbuf d
d=1-d
setdrawbuf d
clear window

copperbars()

a=0
inc=inc+iinc
for y=0 to sh-100*abs(inc)
x1 = w * (7+abs(inc))/7 * sin(a*ascale)
x2 = w * (7+abs(inc))/7 * cos(a*ascale)
x1=abs(x1):x2=abs(x2)
q=int(a/90)
if and(q,1)<>0 then
t = x1:x1 = x2:x2 = t
fi
ow = hsw-((x1+x2)/2)
setrgb 1,c(q+1,0),c(q+1,1),c(q+1,2)
line ow,y,ow+x1,y
setrgb 1,c(q,0),c(q,1),c(q,2)
line ow+x1,y,ow+x1+x2,y
a=a+inc
if a<0 a=a+360
if a>=360 a=a-360
next
if inc>2 or inc<-2 iinc=-iinc
until (peek("port1")<>0)

sub copperbars()
for y=0 to sh-1
rgb(0)=0
rgb(1)=0
rgb(2)=0
for c=0 to 2
if y>cuy(c) and y<cuy(c)+cuh then
rgb(c)=(cuh/2-abs(y-cuy(c)-(cuh/2)))*(255/cuh)
fi
cuy(c)=cuy(c)+cui(c)
if cuy(c)>=sh-cuh or cuy(c)<=0 then
cui(c)=-cui(c)
fi
next
if rgb(0)<>0 or rgb(1)<>0 or rgb(2)<>0 then
setrgb 1,rgb(0),rgb(1),rgb(2)
line 0,y,sw,y
fi
next
end sub

<edit>it was fast already, but I just stopped it drawing black where there are no copper bars
Title: Re: yabasic demo
Post by: Clanky on October 18, 2006
haha! Real Neat!
wish i could program like that!!
Title: Re: yabasic demo
Post by: Shockwave on October 18, 2006
That rules  ;D
Title: Re: yabasic demo
Post by: Jim on October 18, 2006
Well, they do say imitation is the sincerest form of flattery ;)

Jim
Title: Re: yabasic demo
Post by: taj on October 19, 2006
Is this a really dumb question (basic being interpreted) but can I get an exe?
Title: Re: yabasic demo
Post by: Jim on October 19, 2006
You have to download the interpreter from here http://members.iinet.net.au/~jimshaw/Yabasic/ps2yabasic1.6b3.zip

Jim
Title: Re: yabasic demo
Post by: Shockwave on October 19, 2006
Taj, if you try and copy / paste this or any other yabasic program into Jims excellent emulator, make sure that you add an extra return at the end of the source or it won't run.
This is not a fault of the emulator, it's the way Yabasic is.

There are a shed load of cool things written in Yabasic, I wrote dozens of demos myself, and a few games too.
Title: Re: yabasic demo
Post by: taj on October 19, 2006
OK thanks guys, I got the emulator and ran the demo which is very nest for so little code (I like that :-). It says PS2 on the windows, what has yaBasic got to do with PS2?

Title: Re: yabasic demo
Post by: Shockwave on October 19, 2006
The PS2 came with a demo disk (European Pal PS2's) and on that disk was a very bugged and very cool basic language that you could use the joypad as a keyboard and save your programs (which had to use in built gfx , polygons, dots ,lines) and no sound effects.

Some really cool stuff was made with it.
I'm decided, I'm going to have a trawl through my demos and add some of them in here!