Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Type MyClass
- Global List:TList
- Field name:String
- Field x:Float
- Field y:Float
- Field id:Int
- Field spd:Float
- Field ypd:Float
- Function Add(name:String,id:Int)
- If Not List List=CreateList()
- Local c:MyClass = New MyClass
- c.x = Rnd(200,750)
- c.y = Rnd(50,500)
- c.spd = 1.0
- c.ypd = 1.0
- c.id = id
- c.name = name
- List.AddLast c
- End Function
- Function UpdateAll()
- If Not List Return
- For Local l:MyClass = EachIn List
- l.Update()
- Next
- End Function
- Method Update()
- y:-ypd
- x:-spd
- If x<0 Then spd=-spd
- If y<0 Then ypd=-ypd
- If y>600-TextHeight(name) Then ypd=-ypd
- If x>800-TextWidth(name) Then spd=-spd
- If id=3
- DrawText "X: " + Int(x) + " Y: " + Int(y),10,10
- If (Int(x)>25 And Int(x)<50) And (Int(y)>50 And Int(y)<100)
- spd=-spd
- ypd=-ypd
- End If
- End If
- Draw()
- End Method
- Method Draw()
- DrawText name,x,y
- End Method
- End Type
- '
- ' Main code
- '
- SeedRnd MilliSecs()
- Global seed:Int=RndSeed()
- Graphics 800,600
- MyClass.Add("Hello",1)
- MyClass.Add("There",2)
- MyClass.Add("You",3)
- MyClass.Add("Guyes!",4)
- Repeat
- Cls
- MyClass.UpdateAll()
- Flip
- Until KeyHit(KEY_ESCAPE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement