Skip to content

Instantly share code, notes, and snippets.

@giginet
Created December 4, 2011 22:07
Show Gist options
  • Select an option

  • Save giginet/1431443 to your computer and use it in GitHub Desktop.

Select an option

Save giginet/1431443 to your computer and use it in GitHub Desktop.
enchant()
class SampleGame extends Game
constructor : ->
super 320, 320
@fps = 30
SampleGame.game = @
@preload "miku.gif"
@onload = ->
@rootScene.addChild new Player(100, 100)
@start()
class Player extends Sprite
constructor: (x, y) ->
super 44, 32
@x = x
@y = y
game = SampleGame.game
@image = game.assets['miku.gif']
@addEventListener 'enterframe', ->
if game.input.up
@y -= 5
else if game.input.down
@y += 5
if game.input.left
@x -= 5
else if game.input.right
@x += 5
window.onload = ->
new SampleGame()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment