Wow, Thx for the Replies ! Great Forum , verry humble and instructive ! In lots of other forums there were guys arround , showing beginners her mistakes in a verry arrogant way ( nasty coments ).
This here is really cool , good kinda vibe ! Thx. :-)
For the Programm , i just extend the Code , added a Type ( state ) and another Condition to the Mouse Collision Method . It works ! Some mistakes ?
I will try Imaginarys Code example too.
This here is really cool , good kinda vibe ! Thx. :-)
For the Programm , i just extend the Code , added a Type ( state ) and another Condition to the Mouse Collision Method . It works ! Some mistakes ?
I will try Imaginarys Code example too.
Rem OOP Test Rectangle Select End Rem SuperStrict Graphics 800,600 Global x:Int Global y:Int Type button Field x_pos : Int Field y_pos : Int Field width :Int,height :Int Field color_r :Int,color_g :Int ,color_b :Int Field name : Int Field pbMouseDown:Int = False Field pbMouseDownOutside:Int = False Field pbMouseDownInside :Int = False ' Mouse Pressed Inside Method drawbutton() SetColor (color_r,color_g,color_b) DrawRect (x_pos,y_pos,width,height) End Method Method highlight() SetColor (255,255,255) DrawRect (x_pos-5,y_pos-5,110,110) DrawText "Button : " + name ,x_pos,y_pos+120 End Method Method MouseCollision() If x>= X_pos And y>= Y_pos And x <= X_pos + width And y <= Y_pos + height Then 'mouse rollover If Not pbMouseDownOutside & Not pbMouseDown & MouseDown(1) Then 'mouseDown() event pbMouseDown = True ElseIf pbMouseDown & MouseDown(1) Then 'mouseStillDown() pbMouseDownInside = True ElseIf pbMouseDown & Not MouseDown(1) Then 'mouseUp() event pbMouseDown = False ElseIf pbMouseDownOutside & Not MouseDown(1) Then pbMouseDownOutside = False End If Else If MouseDown(1) & Not pbMouseDownOutside Then 'mouseDownOutside() pbMouseDownOutside = True ElseIf pbMouseDown & Not MouseDown(1) Then ' mouseUpOutside() pbMouseDown = False pbMouseDownOutside = False ElseIf pbMouseDownOutside & Not MouseDown(1) Then pbMouseDownOutside = False pbMouseDownInside = False End If End If ' This is the Extension for keepin it pressed outside of the Range If pbMouseDownInside = True And pbMouseDown = True highlight() End If End Method End Type ' create instances of the Class " button " Local one:button = New button Local two:button = New button Local three:button = New button one.x_pos = 20 one.y_pos = 20 one.width = 100 one.height = 100 one.color_r = 255 one.color_g = 0 one.color_b = 255 one.name = 1 two.x_pos = 200 two.y_pos = 20 two.width = 100 two.height = 100 two.color_r = 0 two.color_g = 0 two.color_b = 255 two.name = 2 three.x_pos = 400 three.y_pos = 20 three.width = 100 three.height = 100 three.color_r = 0 three.color_g = 255 three.color_b = 0 three.name = 3 While Not KeyHit(KEY_ESCAPE) Cls x=MouseX() y=MouseY() one.mouseCollision() one.drawbutton() two.mouseCollision() two.drawbutton() three.mouseCollision() three.drawbutton() Flip Wend