Advertisement
Guest User

Untitled

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