General Game Structure: Part 2

BlitzMax Forums/BlitzMax Beginners Area/General Game Structure: Part 2

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.

Here is a great tutorial on types if you haven't read it yet.
http://www.blitzbasic.com/Community/posts.php?topic=59233

I'd might do your example like this, keeping Update() within the type:
Graphics 800,600,0


Local intro:TRoom=New TRoom
Local CurrentRoom:TRoom = intro 'point CurrentRoom to the first room

intro.Name="Intro"

Local menu:TRoom=New TRoom
menu.Name="Menu"

intro.NextRoom = menu 'the room you enter when you press "Enter" key
menu.NextRoom = intro

While Not KeyHit(KEY_ESCAPE)
	Cls
	CurrentRoom = CurrentRoom.Update()

	Flip
Wend

Type TRoom
	Field Name:String
	Field NextRoom:TRoom
	
	Method Update:TRoom()
		DrawText Name,10,10
		
		If KeyHit(KEY_ENTER)
			Return NextRoom 'if enter is pressed, return the next room
		Else
			Return Self 'if not, then return the current room
		End If
	End Method
End Type