|
Post by Azan on May 11, 2005 21:09:37 GMT -5
Ok in an effort to help the masses understand types please post any simple program that uses types (please include notes(but not too many, people need to learn it for themselves) and it should require external media) and only one program per post (double posting is ok) [glow=red,2,300]And if your new to types, try to write your own and post em here [/glow]
|
|
|
Post by Azan on May 11, 2005 21:10:45 GMT -5
Creates a bunch of falling circles, the smaller they are the slower they move, and it has random colors too. Graphics 400,400 SetBuffer BackBuffer() Type ball ;the type ball Field x Field y Field Colorr,Colorg,Colorb Field ds End Type While Not KeyHit(1) createball() ; if the space bar is hit create b updateballs() ;increases each b why value and draws the circle Flip Cls Wend Function createball() ;creates a new instance called b following the type ball b.ball=New ball b\x=Rnd(1,400) ;set b x and why values b\y=0 b\Colorr=Rnd(1,256) b\Colorg=Rnd(1,256) b\Colorb=Rnd(1,256) b\ds=Rnd(1,12) End Function Function updateballs() For b.ball=Each ball ;targets all b b\y=b\y+b\ds ;for each b it has its why value increased Color b\Colorr,b\Colorg,b\Colorb Oval b\x,b\y,b\ds,b\ds ;draws a circle at each b coordinates If b\y>400 Then Delete b EndIf Next End Function
#nosmileys
|
|
|
Post by Azan on May 11, 2005 21:13:47 GMT -5
Creates a falling circle where ever you click with the mouse Graphics 400,400 SetBuffer BackBuffer() Type ball ;the type ball Field x Field y End Type
While Not KeyHit(1) If MouseHit(1) createball() ; if the space bar is hit create b updateballs() ;increases each b why value and draws the circle Flip Cls Wend Function createball() ;creates a new instance called b following the type ball b.ball=New ball b\x=MouseX() ;set b x and why values b\y=MouseY() End Function Function updateballs() For b.ball=Each ball ;targets all b b\y=b\y+5 ;for each b it has its why value increased Oval b\x,b\y,10,10 ;draws a circle at each b coordinates If b\y>400 Then Delete b EndIf Next End Function
|
|
|
Post by Umbrafire on May 12, 2005 16:41:57 GMT -5
slightly more complicated but more in depth edit on the previous program: Graphics 400,400 SetBuffer BackBuffer() SeedRnd MilliSecs() Type ball ;the type ball Field x,y Field r,g,b End Type
While Not KeyHit(1) If MouseHit(1) createball() ; if the space bar is hit create b updateballs() ;increases each b why value and draws the circle Flip Cls Wend End
Function createball() ;creates a new instance called b following the type ball b.ball=New ball b\x=MouseX() ;set b x and why values b\y=MouseY() b\r = Rand(1,255) b\g = Rand(1,255) b\b = Rand(1,255) End Function Function updateballs() For b.ball=Each ball ;targets all b b\y=b\y+5 ;for each b it has its why value increased Color b\r,b\g,b\b Oval b\x,b\y,10,10 ;draws a circle at each b coordinates If b\y>400 Then Delete b EndIf Next End Function
#nosmileys
|
|
|
Post by Azan on May 12, 2005 20:06:51 GMT -5
Graphics 400,400 Global co=0 SetBuffer BackBuffer() Type ball ;the type ball Field x Field y Field Colorr,Colorg,Colorb Field ds Field fl End Type While Not KeyHit(1) If MouseDown(1) createball() ; if the space bar is hit create b updateballs() ;increases each b why value and draws the circle Text 10,10,co Flip Cls Wend Function createball() ;creates a new instance called b following the type ball b.ball=New ball b\x=MouseX() ;set b x and why values b\y=MouseY() b\Colorr=Rnd(1,256) b\Colorg=Rnd(1,256) b\Colorb=Rnd(1,256) b\ds=Rnd(1,12) b\fl=0 co=co+1 End Function Function updateballs() For b.ball=Each ball ;targets all b ;b\y=b\y+b\ds ;for each b it has its why value increased Color b\Colorr,b\Colorg,b\Colorb Oval b\x,b\y,b\ds,b\ds ;draws a circle at each b coordinates If b\y>400 Then b\fl=1 EndIf If b\fl=1 Then b\y=b\y-b\ds*2 EndIf If b\y<0 Then b\fl=0 EndIf If b\fl=0 Then b\y=b\y+b\ds EndIf Next End Function
|
|