Skip to content

Instantly share code, notes, and snippets.

@nilium
Created April 7, 2010 04:39
Show Gist options
  • Save nilium/358532 to your computer and use it in GitHub Desktop.
Save nilium/358532 to your computer and use it in GitHub Desktop.
SuperStrict
'buildopt:threads
'buildopt:gui
Import "Source/Nihilit/Animation.bmx"
Type NButton
Field c_r%, c_g%, c_b%
Field x!, y!, width!, height!
Method Init:NButton(x!, y!, width!, height!)
Self.x = x
Self.y = y
Self.width = width
Self.height = height
Self.c_r = 255
Self.c_g = 255
Self.c_b = 255
Return Self
End Method
Method Draw()
Local c_or%, c_og%, c_ob%, c_oa#
GetColor(c_or, c_og, c_ob)
c_oa = GetAlpha()
SetAlpha(1.0)
SetColor(c_r, c_g, c_b)
DrawRect(x, y, width, height)
SetAlpha(c_oa)
SetColor(c_or, c_og, c_ob)
End Method
End Type
Global Running:Int = True
Graphics(800, 600, 0)
Local button:NButton = New NButton.Init(0, 0, 64, 32)
Local expanded:Int = False
While Running
Repeat
Local event:Int = PollEvent()
Select event
Case EVENT_APPTERMINATE
AtomicSwap(Running, False)
Case EVENT_KEYDOWN
If CurrentEvent.data = KEY_SPACE Then
If expanded Then
Animate(button, "width", 64, 500)
Animate(button, "height", 32, 500)
Else
Animate(button, "width", GraphicsWidth(), 500)
Animate(button, "height", GraphicsHeight(), 500)
EndIf
expanded = Not expanded
EndIf
Case 0
Exit
End Select
Forever
Cls
button.Draw()
Animation.UpdateAnimations()
Flip
Wend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment