First push to github

This commit is contained in:
Richard Davey
2013-04-12 17:19:56 +01:00
parent 5c705c4b31
commit a1a1ab3f30
368 changed files with 21609 additions and 2 deletions
+63
View File
@@ -0,0 +1,63 @@
// The first parameter to your function should always be 'game' which is an instance of the Game object.
FakeGame = function (game) {
// Store the reference and then use it through-out your code
this.game = game;
this.car;
this.bigCam;
};
FakeGame.prototype = {
init: function () {
this.game.loader.addImageFile('track', '../../assets/games/f1/track.png');
this.game.loader.addImageFile('car', '../../assets/games/f1/car1.png');
this.game.loader.load();
},
create: function () {
this.game.camera.setBounds(0, 0, this.game.stage.width, this.game.stage.height);
this.game.createSprite(0, 0, 'track');
this.car = this.game.createSprite(180, 298, 'car');
this.car.rotation = 180;
this.car.maxVelocity.setTo(150, 150);
this.bigCam = this.game.createCamera(640, 0, 100, 200);
this.bigCam.follow(this.car, Camera.STYLE_LOCKON);
this.bigCam.setBounds(0, 0, this.game.stage.width, this.game.stage.height);
this.bigCam.showBorder = true;
this.bigCam.borderColor = 'rgb(0,0,0)';
this.bigCam.scale.setTo(2, 2);
},
update: function () {
if (this.game.input.keyboard.isDown(Keyboard.LEFT))
{
this.car.rotation -= 4;
}
else if (this.game.input.keyboard.isDown(Keyboard.RIGHT))
{
this.car.rotation += 4;
}
if (this.game.input.keyboard.isDown(Keyboard.UP))
{
this.car.velocity.copyFrom(this.game.math.velocityFromAngle(this.car.angle, 150));
}
else
{
this.car.velocity.copyFrom(this.game.math.velocityFromAngle(this.car.angle, 60));
}
}
}
+72
View File
@@ -0,0 +1,72 @@
// The first parameter to your function should always be 'game' which is an instance of the Game object.
MainMenu = function (game) {
// Store the reference and then use it through-out your code
this.game = game;
this.monster;
this.isFalling = false;
this.hasClicked = false;
};
MainMenu.prototype = {
init: function () {
this.game.loader.addImageFile('car', '../../assets/pics/supercars_parsec.png');
this.game.loader.addSpriteSheet('monster', '../../assets/sprites/metalslug_monster39x40.png', 39, 40);
this.game.loader.load();
},
create: function () {
this.game.camera.backgroundColor = 'rgb(85,85,85)';
this.game.createSprite(80, 150, 'car');
this.monster = this.game.createSprite(80, 60, 'monster');
this.monster.animations.add('walk');
this.monster.animations.play('walk', 30, true);
this.monster.velocity.x = 50;
},
update: function () {
if (this.monster.x >= 710 && this.isFalling == false)
{
this.isFalling = true;
this.monster.velocity.x = 20;
this.monster.acceleration.y = 200;
this.monster.angularAcceleration = 100;
this.monster.animations.stop('walk');
}
if (this.game.input.mouse.isDown && this.hasClicked == false)
{
this.hasClicked = true;
this.game.switchState(FakeGame);
}
},
render: function () {
this.game.stage.context.fillStyle = 'rgb(0,0,0)';
this.game.stage.context.font = 'bold 48px Arial';
this.game.stage.context.textAlign = 'center';
this.game.stage.context.fillText('Super Racer', this.game.stage.centerX, 60);
this.game.stage.context.font = 'bold 22px Arial';
this.game.stage.context.textAlign = 'center';
this.game.stage.context.fillText('Click to "Play"', this.game.stage.centerX, 370);
}
}
+26
View File
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0" />
<title>Phaser Test Runner : JS State Test 1</title>
<link rel="stylesheet" href="../../phaser.css" type="text/css" />
<script src="../../phaser.js"></script>
<script src="MainMenu.js"></script>
<script src="FakeGame.js"></script>
</head>
<body>
<div id="game"></div>
<script type="text/javascript">
var myGame = new Game(this, 'game', 840, 400);
myGame.switchState(MainMenu);
</script>
</body>
</html>