Small Basic - Controls are Shapes
All of the Controls (Buttons, TextBoxes etc) that can be created with the Controls object can be manipulated with the Shapes object methods.
This can create some fun effects and make your games or programs more visually interesting.
Here is a simple example - it is possible to click it, but pretty hard!
https://smallbasic.com/program/?CWT060
gw `` = ``600
gh `` = ``600
GraphicsWindow``.`` Width `` = ``gw
GraphicsWindow``.`` Height `` = ``gh
clickMe `` = ``Controls``.``AddButton``(``"Click Me"``,``0``,``0``)
Controls``.``SetSize``(``clickMe``,``70``,``30``)
GraphicsWindow``.`` MouseMove `` = ``OnMouseMove
Controls``.`` ButtonClicked `` = ``OnButtonClicked
Sub ``OnMouseMove
`` x `` = ``Math``.``Abs``(``gw``-``GraphicsWindow``.``MouseX``)
`` y `` = ``Math``.``Abs``(``gh``-``GraphicsWindow``.``MouseY``)
`` dist `` = ``Math``.``SquareRoot``(``(``x``-``gw``/``2``)``*``(``x``-``gw``/``2``)``+``(``y``-``gh``/``2``)``*``(``y``-``gh``/``2``)``)
``Shapes``.``SetOpacity``(``clickMe``,``dist``-``20``)
``Shapes``.``Zoom``(``clickMe``,``dist``/``20``,``dist``/``20``)
``Shapes``.``Move``(``clickMe``,``x``-``35``,``y``-``15``)
EndSub
Sub ``OnButtonClicked
``GraphicsWindow``.`` BackgroundColor `` = ``"Red"
EndSub
Comments
Anonymous
August 01, 2014
Don't fall for the trap! Don't click the big "Click Me" button! =^)Anonymous
August 01, 2014
Ha - Didn't think of that.Anonymous
August 02, 2014
I could clicked this button! If you succeed, you can see red background. smallbasic.com/programAnonymous
July 25, 2015
I keep trying to click the button in the game, and I still can't click it!