can some 1 check my code! i cant work out the bugs . the particles wont freeze, and the text is at the top instead of the bottom of the screen :(
Graphics 1024,768,32,1
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Type bottle_rocket
Field x,y
Field vx,vy
Field hp
End Type
Type stream
Field x,y
Field vx,vy
Field gx,gy
End Type
Type dot
Field x,y
Field vx,vy
Field gx,gy
Field twitch
Field r,g,b
Field rlimit,glimit,blimit
Field fade
Field fade_rate
Field default_color
Field hp
End Type
Type liner
Field x1,y1
Field x2,y2
Field r,g,b
End Type
slowrate=100
truecls = True
froztxt$ = "no"
scrolly = 768
While Not KeyDown(1) ;MAIN LOOP;
makecursor()
updatedots()
If KeyDown(3) Then create_sparkler()
create_bottlerocket(); i didnt make this one yet
If KeyDown(4) Then linemaker(prevmousex,prevmousey)
prevmousex = MouseX()
prevmousey = MouseY()
updateline()
screenshot()
displayinfo()
If KeyHit(2) Then freeze_particles()
Flip
If truecls = 1 Then Cls
Wend
Function makecursor()
dot.dot = New dot
dot\x = MouseX()
dot\y = MouseY()
dot\r = Rand(230,255)
dot\g = Rand(230,255)
dot\b = Rand(230,255)
dot\hp = 0
dot\fade = 2
End Function
Function create_sparkler()
For number_of_particles = 1 To 3
dot.dot = New dot
dot\x = MouseX()
dot\y = MouseY()
dot\r = Rand(240,255)
dot\g = Rand(240,255)
dot\b = Rand(50,80)
dot\blimit = 2
dot\hp = 0
dot\vx = Rand(-7,7)
dot\vy = Rand(-6,6)
dot\gy = 1
dot\gx = MouseXSpeed/3
dot\fade = 5
dot\twitch = 1
Next
number_of_particles = 0
End Function
Function create_bottlerocket()
End Function
Function updatedots()
For dot.dot = Each dot
Select dot\default_color
Case 0
Color dot\r,dot\g,dot\b ;this draws the dot with its assigned color
Case 1
Color dot\r,dot\r,dot\r ;this draws the dot to the grey scale
Case 2
End Select
Plot dot\x,dot\y
dot\x = dot\x + dot\vx
dot\y = dot\y + dot\vy
dot\vx = dot\vx + dot\gx
dot\vy = dot\vy + dot\gy
If dot\twitch > 0 Then
dot\x = dot\x + Rand(-dot\twitch,dot\twitch)
dot\y = dot\y + Rand(-dot\twitch,dot\twitch)
EndIf
If freeze = 0
If dot\r > dot\rlimit Then dot\r=dot\r- Rand(dot\fade,dot\fade*1.2)
If dot\g > dot\glimit Then dot\g=dot\g- Rand(dot\fade,dot\fade*1.2)
If dot\b > dot\blimit Then dot\b=dot\b- Rand(dot\fade,dot\fade*1.2)
EndIf
If dot\r < 0 Or dot\g < 0 Or dot\b < 0 Then
Delete dot
EndIf
Next
End Function
Function screenshot()
If KeyHit(183)
If FileType("images") <> 2 Then CreateDir("images")
.check_if_file_exist
If FileType("screenshot"+screenshot_count+".bmp" <> 0 )Then
screenshot_count=screenshot_count+1
Goto check_if_file_exist
EndIf
SaveBuffer(BackBuffer(),"images\screenshot"+screenshot_count+".bmp")
EndIf
End Function
Function displayinfo()
If KeyHit(59) Then
Select scrolldirection
Case 0
scrolldirection = 1
Case 1
scrolldirection = 0
End Select
EndIf
Select scrolldirection
Case 0
If scrolly < GraphicsHeight()-20 Then scrolly = scrolly - 2
Case 1
If scrolly > GraphicsHeight() Then scrolly = scrolly + 2
End Select
Color 255,255,255
Text 512,scrolly,"frozen: "+froztxt$+" mouse corridnates: "+MouseX()+" , "+MouseY(),1,0
End Function
Function freeze_particles()
Select freeze
Case 0
freeze = 1
froztxt$ = "yes"
Case 1
freeze = 0
froztxt$ = "no"
End Select
Return freeze
End Function
Function linemaker(prevmousex,prevmousey)
liner.liner = New liner
liner\x1 = MouseX()
liner\y1 = MouseY()
liner\x2 = prevmousex
liner\y2 = prevmousey
liner\r = Rand(245,255)
liner\g = Rand(245,255)
liner\b = Rand(60,70)
End Function
Function updateline()
For liner.liner = Each liner
Color liner\r,liner\g,liner\b
Line(liner\x1,liner\y1,liner\x2,liner\y2)
liner\r = liner\r - Rand(1,2)
liner\g = liner\g - Rand(2,3)
If liner\b > 1 Then liner\b = liner\b - Rand(0,1)
If liner\r < 0 Or liner\g < 0 Then
Delete liner
EndIf
Next
End Function
|