Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Type MyClass
  3.     Global List:TList
  4.    
  5.     Field x:Float
  6.     Field y:Float
  7.     Field r:Int,g:Int,b:Int
  8.    
  9.     Field spd:Float
  10.     Field ypd:Float
  11.    
  12.  
  13.     Function Add(spd:Float,r:Int,g:Int,b:Int)
  14.         If Not List List=CreateList()
  15.         Local c:MyClass = New MyClass
  16.         c.x = Rnd(0,800)
  17.         c.y = Rnd(0,600)
  18.         c.r = r
  19.         c.g = g
  20.         c.b = b
  21.         c.spd = spd
  22.         c.ypd = 0.0
  23.         List.AddLast c
  24.        
  25.     End Function
  26.    
  27.     Function UpdateAll()
  28.         If Not List Return
  29.         For Local l:MyClass = EachIn List
  30.             l.Update()
  31.         Next
  32.     End Function
  33.    
  34.     Method Update()
  35.         y:-ypd     
  36.         x:-spd
  37.  
  38.         If x<-5 Then x = GraphicsWidth()+1
  39.        
  40.         Draw()
  41.     End Method
  42.    
  43.     Method Draw()
  44.         SetColor r,g,b
  45.         Plot x,y
  46.         SetColor 255,255,255
  47.     End Method
  48.  
  49. End Type
  50.  
  51. '
  52. ' Main code
  53. '
  54.  
  55. For Local i:Int=0 To 200
  56.     MyClass.Add(1.0,255,255,255)
  57.     MyClass.Add(0.7,155,155,155)
  58.     MyClass.Add(0.2,55,55,55)
  59. Next
  60.  
  61.  
  62.  
  63.  
  64. SeedRnd MilliSecs()
  65. Global seed:Int=RndSeed()
  66.  
  67. Graphics 800,600
  68.  
  69.  
  70. Repeat
  71.     Cls
  72.     MyClass.UpdateAll()
  73.     Flip
  74. Until KeyHit(KEY_ESCAPE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement