Conceptual OOP Question - AArgh!

BlitzMax Forums/BlitzMax Beginners Area/Conceptual OOP Question - AArgh!

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.

mudcat,
dont do that do somthing like this:
Type tbutton

	Field x, y
	Field w, h
	
	Function create:tbutton(x, y, w, h)
	
		Local button:tbutton = New tbutton
		
		button.x = x
		button.y = y
		button.w = w
		button.h = h
		
		Return button
		
	End Function
	
	Method render()
	
		' [ render code ]
		DrawRect x, y, w, h
		
	End Method
	
	Method IsOver(_x, _y)
	
		Return RectsCollide(x, y, w, h, _x, _y, 1, 1)
		
	End Method
	
	Method I@#!*(_button)
	
		If IsOver(MouseX(), MouseY()) Then
			Return MouseDown(_button)
		EndIf
		
		Return 0
		
	End Method
	
End Type

Function RectsCollide:Byte(x1:Float, y1:Float, w1:Float, h1:Float, x2:Float, y2:Float, w2:Float, h2:Float)
	If x2 => x1 And x2 + w2 =< x1 + w1 Then
		If y2 => y1 And y2 + h2 =< y1 + h1 Then
			Return True
		EndIf
	EndIf
	Return False
End Function

Global myButton:TButton = TButton.Create(10, 10, 100, 100)

Graphics 800, 600, 0, 60

While Not KeyHit(KEY_ESCAPE)

	Cls
	myButton.Render()
	If myButton.I@#!*(MOUSE_LEFT) Then End
	Flip
	
Wend

this way you can do different things for different buttons but keep it common. If you want to chang even more you can just extend TButton and change whatever method.