Skip to content

Instantly share code, notes, and snippets.

@giginet
Created June 4, 2012 05:55
Show Gist options
  • Select an option

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

Select an option

Save giginet/2866577 to your computer and use it in GitHub Desktop.
enchant()
class Shooting extends Game
config : {
WIDTH : 640,
HEIGHT : 480,
FPS : 30
}
constructor : ->
super @config.WIDTH, @config.HEIGHT
@fps = @config.FPS
@keybind(90, 'a')
@keybind(88, 'b')
Shooting.game = @
Shooting.config = @config
root = new MainScene()
root.setup()
@start()
window.onload = ->
new Shooting()
class MainScene extends Scene3D
setup : ->
@setDirectionalLight = new DirectionalLight()
camera = @getCamera()
camera.y = 20
camera.z = 80
camera.centerY = 10
@ball = new Cube()
@ball.mesh.texture = new Texture "resources/images/gigicat.png"
@ball.z = -10
@ball.rotX = 0
@ball.addEventListener 'enterframe', (e) ->
@rotX += 0.01
@rotation = [
Math.cos(@rotX), 0, -Math.sin(@rotX), 0,
0, 1, 0, 0,
Math.sin(@rotX), 0, Math.cos(@rotX), 0,
0, 0, 0, 1
]
@addChild @ball
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment