Can't mind my error :S

BlitzMax Forums/BlitzMax Beginners Area/Can't mind my error :S

Well, I have an error somewhere in my code and I really can't find it, it says its at GAMEROOM = GAMEROOM.DrawAll(), some little assistance would be awesome :D

SuperStrict

' # INCLUDES # '
'...

' # CREATE # '
' Intro
Global INTRO:TRoom=New TRoom
INTRO.LRect=New TRect[1]
INTRO.LRect[0]=New TRect
INTRO.LRect[0].Create(10,10,100,100)

' Menu
Global MENU:TRoom=New TRoom


' # ALL VARS # '
Global GAMEROOM:TRoom = INTRO
Global GAMEEXIT:Int = False

Graphics 800, 600

' # MAIN LOOP # '
Repeat

	GAMEROOM = GAMEROOM.UpdateAll()
	
	Cls
	GAMEROOM = GAMEROOM.DrawAll()
	Flip

Until GAMEEXIT = True Or KeyHit(KEY_ESCAPE)
End

Type TRoom
	' Contain Instances
	Field LRect:TRect[]
	
	' Draw Instances
	Method DrawAll:TRoom()
		For Local R:Int = 0 To LRect.Length-1
			LRect[R].Draw()
		Next		
	End Method
	
	' Update Instances
	Method UpdateAll:TRoom()
		' nothing
	End Method
End Type

Type TRect
	Field x:Int
	Field y:Int
	Field w:Int
	Field h:Int
	Method Create( x2:Int, y2:Int, w2:Int, h2:Int )
		x=x2
		y=y2
		w=w2
		h=h2
	End Method
	
	Method Draw()
		DrawRect x, y, w, h
	End Method
End Type


your problem is you are assigning the result of the UpdateAll() method (which is non-existent (the result not the method)) to GAMEROOM, then you try and call DrawAll() on a null object.

SuperStrict

' # INCLUDES # '
'...

' # CREATE # '
' Intro
Global INTRO:TRoom=New TRoom
INTRO.LRect=New TRect[1]
INTRO.LRect[0]=New TRect
INTRO.LRect[0].Create(10,10,100,100)

' Menu
Global MENU:TRoom=New TRoom


' # ALL VARS # '
Global GAMEROOM:TRoom = INTRO
Global GAMEEXIT:Int = False

Graphics 800, 600

' # MAIN LOOP # '
Repeat

	GAMEROOM.UpdateAll()
	
	Cls
	GAMEROOM.DrawAll()
	Flip

Until GAMEEXIT = True Or KeyHit(KEY_ESCAPE)
End

Type TRoom
	' Contain Instances
	Field LRect:TRect[]
	
	' Draw Instances
	Method DrawAll:TRoom()
		For Local R:Int = 0 To LRect.Length-1
			LRect[R].Draw()
		Next		
	End Method
	
	' Update Instances
	Method UpdateAll:TRoom()
		' nothing
	End Method
End Type

Type TRect
	Field x:Int
	Field y:Int
	Field w:Int
	Field h:Int
	Method Create( x2:Int, y2:Int, w2:Int, h2:Int )
		x=x2
		y=y2
		w=w2
		h=h2
	End Method
	
	Method Draw()
		DrawRect x, y, w, h
	End Method
End Type