| Hi, 
 I'm trying to create my first game, of course a Pong clone. ;-)
 
 It's OOP, and I have a problem with my vars here.
 
 
 
AutoMidHandle(True)
Graphics 640,480
HideMouse()
Global GameObjectList:TList = CreateList()
Type TGameObject
	Field X:Int = 0
	Field Y:Int = 0
	Field Image:TImage
	
	Method DrawSelf()
		DrawImage Image, X, y		
	End Method
	
	Method UpdateState() Abstract
End Type
Type TBall Extends TGameObject
  Field OrigSpeed:Int = 3
	Field SpeedX:Int = OrigSpeed
	Field SpeedY:Int = OrigSpeed
Function Create:TBall(Filename:String, xstart:Int = 320, ystart:Int = 240)
		Local Ball:TBall = New TBall
		Ball.X = xstart
		Ball.Y = ystart
		Ball.Image = LoadImage(filename)
		Ball.SpeedX = Rand(-OrigSpeed, OrigSpeed)
		Ball.SpeedY = Rand(1, OrigSpeed)
		ListAddLast GameObjectList, Ball
		Return Ball
	End Function
	Method UpdateState()
	  DrawText (X, 0, 0)
		DrawText (Y, 0, 20)
		DrawText (SpeedX, 0, 30)
		DrawText (SpeedY, 0, 40)
		X:+SpeedX
		Y:+SpeedY
		If X > 640
			SpeedX = -OrigSpeed
		End If
		If X < 0
			SpeedX = OrigSpeed
		End If
		If Y > 480
			SpeedY = -OrigSpeed
		End If
		If Y < 0
			SpeedY = OrigSpeed
		End If
	End Method
End Type
Ball:TBall = TBall.Create("ball.png")
Repeat
	Cls
	For o:TGameObject = EachIn GameObjectList
		o.DrawSelf()
		o.UpdateState()
	Next
	Flip
Until KeyDown(KEY_ESCAPE) Or AppTerminate()
 That's the code for my ball class, missing the player classes (which works). The ball is set, but whatever I try, it always stays in the center of the screen. I thought, with setting the speed vars within my Create function they would move. But they don't.
 
 Can anyone tell me, why this happens?
 
 Thanx,
 Oliver
 
 
 |