How can I fixed it the "Identifier 'o' not found" (there is clue down blow with the code showing ' << Error) that need to be fixed please.
SuperStrict
Global GameObjectList:TList=CreateList()
' -----------------------TYPES-----------------------------
Type TGameObject
Field X:Int = 320
Field Y:Int = 420
Field Speed:Int=3
Field Image:TImage
Method DrawSelf()
DrawImage Image,X,Y
End Method
Method UpdateState() Abstract
End Type
Type ShipType Extends TGameObject
Field X:Int,Y:Int 'For Player
Field Image:TImage
Field Speed:Int =5 'Speed for Player
Function Create:ShipType(File:String,xstart:Int,ystart:Int)
Local Ship:ShipType = New ShipType
Ship.X=xstart
Ship.Y=ystart
Ship.Image=LoadImage(file)
If Ship.Image=Null
Print "Not able to load image file. Program aborting"
End
EndIf
ListAddLast GameObjectList, Ship
Return Ship
End Function
Method Draw()
DrawImage Image,X,Y
End Method
Method Move()
If KeyDown(Key_Right) Then X:+Speed
If KeyDown(Key_Left) Then X:-Speed
'If KeyDown(Key_Up) Then Y:-Speed
'If KeyDown(Key_Down) Then Y:+Speed
' Collisions for Wall on each side to stop
' Player going off the playing area!
If X<0 Then X=0
If X>770 Then X=770
End Method
End Type
Type TAlienShip Extends TGameObject
Field X:Int = 320
Field Y:Int = 0
Field Speed:Int=3
Field Image:TImage
Function Create:TAlienShip(File:String,xstart:Int,ystart:Int)
Local Alien:TAlienShip=New TAlienShip
Alien.X=xstart
Alien.Y=ystart
Alien.Image=LoadImage(LoadBank(File))
If Alien.Image=Null
Print "Not able to load image file. Program aborting 2"
End
EndIf
ListAddLast GameObjectList,Alien
Return Alien
End Function
Method UpdateState()
X :- Speed
If X<-ImageWidth(Image) Then X=620
End Method
Method DrawSelf()
DrawImage Image,X,Y
End Method
End Type
Local myShip:ShipType = ShipType.Create("gfx/blobship.png",400,500)
Local Alien:TAlienShip = TAlienShip.Create("Gfx/cartoonufo_1-1.png",320,0)
' ---------------SETUP GAME CONDITION---------------
Graphics 800, 600, 0
HideMouse
' ---------------------MAIN LOOP-------------------------
While Not KeyDown(Key_Escape)
Cls
For o:TGameObject=EachIn GameObjectList ' << Error
o.DrawSelf()
o.UpdateState()
Next
Flip
Wend
|