Last active
August 29, 2015 14:02
-
-
Save fritzy/488162754a58e13443b4 to your computer and use it in GitHub Desktop.
A basic start to a pixi game.
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
function Game(somediv) { | |
this.stage = new PIXI.Stage(0xFFFFFF); | |
this.renderer = PIXI.autoDetectRenderer(800, 600); | |
somediv.appendChild(this.renderer.view); | |
this.lastframe = Date.now(); | |
this.rocket = new Rocket(this); | |
this.update(); | |
} | |
Game.protototype.update = function () { | |
requestAnimationFrame(this.update.bind(this)); | |
var now = Date.now(); | |
var frameMS = now - this.lastframe; | |
this.lastframe = now; | |
this.rocket.update(frameMS); | |
//loop through and update any other objects to deal with their | |
//individual logic and update their sprites positions | |
this.renderer.render(this.stage); | |
} | |
function Rocket(game) { | |
this.game = game; | |
this.sprite = PIXI.Sprite.fromImage("rocket.png"); | |
this.game.stage.addChild(this.sprite); | |
} | |
Rocket.prototype.update = function (frameMS) { | |
//Some update to this.sprite.position scaled with frameMS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment