First hello and problem

BlitzMax Forums/BlitzMax Beginners Area/First hello and problem

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ah, well I hadn't come to that part yet as i was trying out the initiating of the array. Yes, of course the Temp-object will be returned. Still it's really tricky this type of handling objects.
Now I'm stuck on another thing (as predicted). Hope I'm not a pain in the ass but I guess you can just stop answering me if I am. Here it goes, this is what it looks like now:
Type TObject Abstract 
	Const CTILE = 1
	Field Mesh
	Field Typ
	Field X
	Field Y
End type


Type TTile Extends TObject
	
	Field Letter
	
	
	Function Create:TTile(letter=0)
		Local Temp:TTile
		If Letter=0 Then Letter = Rand(65,80)
		Temp = New TTile
		Temp.Letter = Letter
		Temp.Typ = CTILE
		Return Temp
	End Function

End Type
Type TSquare
	Const CTILE = 1,CWATER = 0

	Field Obj:Object
	Field SqTyp%
End Type



Type TPond
	Const MaxSquareWidth% = 80
	Const MaxSquareHeight% = 20
	Field Squares:TSquare[,]
	Field SqWidth%
	Field SqHeight%
	
	Function Create:TPond(SqW,SqH)
		'Creates an empty pond. Returns a Pondobject.
		Local Temp:TPond=New TPond,n,m
		If SqW > MaxSquareWidth Then SqW = MaxSquareWidth
		If SqH > MaxSquareHeight Then SqH = MaxSquareHeight
		Temp.SqWidth = SqW
		Temp.SqHeight = SqH
		Temp.Squares=New TSquare[SqWidth,SqHeight]
		
		'Sets water in all Squares
		For n = 0 To SqWidth-1
			For m = 0 To SqHeigth-1
				Temp.Squares[n,m].SqTyp = 0
			Next
		Next
		
		Return Temp 
	End function
	
	Method AddObject(Obj:Object,x,y)
		Self.Squares[x,y].SqTyp = Obj.Typ
		Self.Squares[x,y].Obj = Obj
	End Method
	
End Type


I'm trying to make this as easy as possible. I have this basic foundational Type called TObject that has basic fields telling what kind of object it is and a handleholder for a mesh (don't ask).
The TPond-type is basically an array containing Squares. Each Square can contain any extended object from the basic TObject Type. Now in the last Method in TPond I'm trying to use fields from the basic TObject as I know only Objects extended from the TObject will wind up there.
This doesn't seem to work
Must I write an Add-function for every extended Type from TObject even if I'm just using fields from the basic TObject??

Edit: To clarify my question. I don't know WHAT Type of object will be passed into the AddObject Method, but I do know that all those objects will be extended from the Basic TObject and therefor I know all of them will have a Field called Typ.
Still trying to reach the field with Obj.typ will render an error. What do I do? Write Add for each Type that will be passed as a parameter?