2013-04-12 16:19:56 +00:00
|
|
|
/// <reference path="../../Phaser/Game.ts" />
|
|
|
|
/// <reference path="../../Phaser/Sprite.ts" />
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
2013-04-14 01:31:00 +00:00
|
|
|
// Here we create a quite tiny game (320x240 in size)
|
|
|
|
var myGame = new Game(this, 'game', 320, 240, init, create, update);
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
function init() {
|
|
|
|
|
2013-04-14 01:31:00 +00:00
|
|
|
// This sets a limit on the up-scale
|
|
|
|
myGame.stage.maxScaleX = 640;
|
|
|
|
myGame.stage.maxScaleY = 480;
|
|
|
|
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
|
|
|
|
myGame.stage.scaleMode = StageScaleMode.SHOW_ALL;
|
|
|
|
|
2013-04-12 16:19:56 +00:00
|
|
|
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
|
|
|
|
|
|
|
myGame.loader.load();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2013-04-14 01:31:00 +00:00
|
|
|
myGame.world.setSize(2000, 2000);
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < 1000; i++)
|
|
|
|
{
|
2013-04-14 01:31:00 +00:00
|
|
|
myGame.createSprite(myGame.world.randomX, myGame.world.randomY, 'melon');
|
2013-04-12 16:19:56 +00:00
|
|
|
}
|
|
|
|
|
2013-04-14 01:31:00 +00:00
|
|
|
myGame.onRenderCallback = render;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
|
|
|
|
if (myGame.input.keyboard.isDown(Keyboard.LEFT))
|
|
|
|
{
|
2013-04-14 01:31:00 +00:00
|
|
|
myGame.camera.scroll.x -= 4;
|
2013-04-12 16:19:56 +00:00
|
|
|
}
|
|
|
|
else if (myGame.input.keyboard.isDown(Keyboard.RIGHT))
|
|
|
|
{
|
2013-04-14 01:31:00 +00:00
|
|
|
myGame.camera.scroll.x += 4;
|
2013-04-12 16:19:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (myGame.input.keyboard.isDown(Keyboard.UP))
|
|
|
|
{
|
2013-04-14 01:31:00 +00:00
|
|
|
myGame.camera.scroll.y -= 4;
|
2013-04-12 16:19:56 +00:00
|
|
|
}
|
|
|
|
else if (myGame.input.keyboard.isDown(Keyboard.DOWN))
|
|
|
|
{
|
2013-04-14 01:31:00 +00:00
|
|
|
myGame.camera.scroll.y += 4;
|
2013-04-12 16:19:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-14 01:31:00 +00:00
|
|
|
function render() {
|
|
|
|
|
|
|
|
myGame.input.renderDebugInfo(16, 16);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-12 16:19:56 +00:00
|
|
|
})();
|