Pointers-POINT me in the right direction :).

BlitzMax Forums/BlitzMax Beginners Area/Pointers-POINT me in the right direction :).

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.

Hi Ryan,

Here's an example - there's a list of circles. Each circle is processed in turn in the update (by iterating through the list). The circle radius is changed whenever the mouse is inside (the instance is identified through the update logic, that's all). Your interface can work a similar (if more complex way) (ie. a mouse event causes a function to test which item the mouse is over by checking through all your interface elements - ie your list)

SuperStrict

Type TCircle
	Field x:Float
	Field y:Float
	Field radius:Float
	
	Method Draw()
		DrawOval x-(radius/2), y-(radius/2), radius, radius		
	EndMethod
	
	Method IsMouseInside:Int()
		Local dx:Float = MouseX() - x 
		Local dy:Float = MouseY() - y 
		If( (dx*dx) + (dy*dy)) <= (radius*radius)/2
			Return True
		EndIf
		Return False
	EndMethod
		
	Function Create:TCircle( _x:Float, _y:Float, _radius:Float )
		Local newCircle:TCircle = New TCircle
		newCircle.x = _x
		newCircle.y = _y
		newCircle.radius = _radius
		Return newCircle
	EndFunction

EndType

Function ChangeCircleSize( c:TCircle, newRadius:Float )
	c.radius = newRadius
EndFunction


' Circle List
Global circleList:TList = New TList

' Add some circles to the list
For Local x:Int = 0 To 7
	For Local y:Int = 0 To 5
		circleList.AddLast( TCircle.Create( 50+(x*90),50+(y*90),50 ) )
	Next
Next


Graphics 800,600

' Process the list (changes the radius of the circle if the mouse is inside)
While Not KeyHit( KEY_ESCAPE )
	Cls
	For Local circle:TCircle = EachIn circleList
		If circle.IsMouseInside()
			ChangeCircleSize( circle, 75 )
		Else
			ChangeCircleSize( circle, 50 )		
		EndIf
	
		circle.Draw()
	Next
	Flip
Wend