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.

Did you read the tutorial in the link I provided? It will give you a lot of info about types and how to better use them.
As far as different objects in the room, it is quite possible to have each room with it's own TButtons, TTexts, TItems, TMonsters, etc.... Each room can have the same number, different number or none at all.
There are different ways to do this, reading the tutorial and some of the posts here will show you a few. One way is to use arrays.
SuperStrict
Graphics 800,600,0

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

intro.Name="Intro"
intro.Buttons = New TButton[3] 'add 3 buttons to intro
For Local i:Int = 0 To 2
	intro.Buttons[i] = New TButton
	intro.Buttons[i].create(i*100,30,90,30,"intro "+i)
Next

Local menu:TRoom=New TRoom
menu.Name="Menu"
menu.Buttons = New TButton[5] 'add 5 buttons to menu
For Local i:Int = 0 To 4
	menu.Buttons[i] = New TButton
	menu.Buttons[i].create(i*80,30,70,50,"menu "+i)
Next

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
	Field Buttons:TButton[]
	
	Method Update:TRoom()
		SetColor 255,255,255
		DrawText Name,10,10
		For Local i:Int = 0 To Buttons.length - 1
			Buttons[i].Draw()
		Next
		
		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

Type TButton
	Field x:Int, y:Int
	Field width:Int
	Field height:Int
	Field text:String
	
	Method create( xstart:Int, ystart:Int, wstart:Int, hstart:Int, textstart:String)
		x=xstart
		y=ystart
		width=wstart
		height=hstart
		text=textstart
	End Method
	
	Method Draw()
		SetColor 255,255,0
		DrawRect x,y,width,height
		SetColor 0,0,0
		DrawText text,x+2,y+2
	End Method
End Type