Skip to content

Instantly share code, notes, and snippets.

@gokmen
Created January 4, 2013 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokmen/4454950 to your computer and use it in GitHub Desktop.
Save gokmen/4454950 to your computer and use it in GitHub Desktop.
Bounce Coffee example for KD framework
# 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