Created
January 4, 2013 18:55
-
-
Save gokmen/4454950 to your computer and use it in GitHub Desktop.
Bounce Coffee example for KD framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your awesome Koding App Code | |
class MainView extends JView | |
constructor:-> | |
super | |
@ball = new KDView | |
cssClass : 'ball' | |
@_width = 400 | |
@_height = 300 | |
@.$().css width : @_width | |
@.$().css height: @_height | |
@_x = @x = @_y = @y = 1 | |
@updateBallPosition() | |
updateBallPosition:-> | |
@x += @_x | |
@y += @_y | |
@_x = -1 if @x >= @_width - 50 | |
@_x = 1 if @x == 0 | |
@_y = -1 if @y >= @_height - 50 | |
@_y = 1 if @y == 0 | |
@ball.$().css top: @y | |
@ball.$().css left:@x | |
setTimeout => | |
@updateBallPosition() | |
, 5 | |
pistachio:-> | |
""" | |
{{> @ball}} | |
""" | |
appView.addSubView new MainView | |
cssClass: "bounce" | |
# /* Your awesome Koding App CSS Code */ | |
# .bounce { | |
# border: 1px solid orange; | |
# margin: 10px; | |
# } | |
# .ball { | |
# width: 50px; | |
# height: 50px; | |
# border-radius: 50px; | |
# background-color: red; | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment