Dark Bit Factory & Gravity
PROGRAMMING => Other languages => Blitz => Topic started by: Shockwave on May 02, 2006
-
Just a dot tunnel in Blitz 2D to get things started off in this forum..
I didn't like seeing it without any posts!
;
; Dot Tunnel
; (C) Shockwave 2006.
;
;================================================================================
Const xres = 800
Const yres = 600
Const halfx=xres/2
Const halfy=yres/2
Graphics xres,yres,0,1
SetBuffer BackBuffer()
;--------------------------------------------------------------------------------
Const ringnum = 70
Dim rlx(ringnum); X location of rings
Dim rly(ringnum); Y location of rings
Dim rlz#(ringnum); Z location of rings
Dim ringstart(ringnum)
Dim crx#(7200)
Dim cry#(7200)
Global wavepointer=0
Global floop#=1
Global fuck=0
Global bn=ringnum
;--------------------------------------------------------------------------------
; We need to generate ring positions for all rings at first.
;--------------------------------------------------------------------------------
For a=1 To ringnum
ringstart(a)=fuck
fuck=fuck+7
If fuck>80 fuck=fuck-80
rlx(a)= 800*Sin(wavepointer/2)
rly(a)= 800*Cos(wavepointer)
rlz#(a)= floop#
floop#= floop#+.5
wavepointer=wavepointer+5
Next
For aa=1 To 7200
crx#(aa)=2000*Sin(Float(aa)/20)
cry#(aa)=2000*Cos(Float(aa)/20)
Next
;--------------------------------------------------------------------------------
; Main loop;
;--------------------------------------------------------------------------------
While Not KeyDown(1)
rings()
Flip
Cls
Wend
Function rings()
LockBuffer BackBuffer()
For a=1 To ringnum
tx=(rlx(bn)/rlz(bn))+halfx
ty=(rly(bn)/rlz(bn))+halfy
fl=0
If bn Mod 4 = 0 Then
clr1=$040404*a
clr2=$010301*a
clr3=$000100*a
fl=1
Else
clr1=$010201*a
EndIf
If tx>0 And tx<xres And ty>0 And ty<yres Then
WritePixelFast tx,ty,clr1
End If
For b=ringstart(bn) To 7200 Step 80
xpl=(crx(b)/rlz(bn))+tx
ypl=(cry(b)/rlz(bn))+ty
If xpl>1 And xpl<xres-1 And ypl>1 And ypl<yres-1 Then
WritePixelFast xpl,ypl,clr1
If fl=1 Then
WritePixelFast xpl+1,ypl,clr2
WritePixelFast xpl-1,ypl,clr2
WritePixelFast xpl,ypl-1,clr2
WritePixelFast xpl,ypl+1,clr2
WritePixelFast xpl+2,ypl,clr3
WritePixelFast xpl-2,ypl,clr3
WritePixelFast xpl,ypl-2,clr3
WritePixelFast xpl,ypl+2,clr3
End If
End If
Next
ringstart(bn)=ringstart(bn)+14
If ringstart(bn)>80 ringstart(bn)=ringstart(bn)-80
rlz#(bn)=rlz#(bn)-.1
If rlz#(bn)<=0 Then
rlz#(bn)=rlz#(bn)+35
rlx(bn)= 800*Sin(wavepointer/2)
rly(bn)= 800*Cos(wavepointer)
wavepointer=wavepointer+5
bn=bn+1
End If
bn=bn-1
If bn<=0 bn=ringnum
Next
UnlockBuffer BackBuffer()
End Function
-
I had to change the boundary checkline as I got a MAV on colour3s wpf, to this for it to work too btw dude:
If xpl>2 And xpl<xres-2 And ypl>2 And ypl<yres-2 Then
Nifty dot tunnel Shockie, and neat on showing the central pivots of the rings.
Wonder what that'll turn out like in FB mate! :)
Cheers and all the best,
Clyde.
-
Funny you should say that.. . .
I feel a code challenge coming on soon.