Skip to content

Commit

Permalink
Added Tutorial 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Dec 7, 2013
1 parent 13a03f3 commit 74e0cfb
Show file tree
Hide file tree
Showing 29 changed files with 1,060 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/games/invaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var lives;
var enemyBullet;
var firingTimer = 0;
var stateText;
var livingEnemies=[];

function create() {

Expand Down Expand Up @@ -226,7 +227,7 @@ function enemyFires () {
// Grab the first bullet we can from the pool
enemyBullet = enemyBullets.getFirstExists(false);

var livingEnemies=[];
livingEnemies.length=0;

aliens.forEachAlive(function(alien){

Expand Down
18 changes: 14 additions & 4 deletions examples/wip/tilemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ function preload() {

game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON);
game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32);
game.load.image('phaser', 'assets/sprites/phaser-ship.png');
// game.load.image('phaser', 'assets/sprites/phaser-ship.png');
// game.load.image('phaser', 'assets/sprites/mushroom2.png');
// game.load.image('phaser', 'assets/sprites/wabbit.png');
// game.load.image('phaser', 'assets/sprites/arrow.png');
game.load.image('phaser', 'assets/sprites/arrow.png');
// game.load.image('phaser', 'assets/sprites/darkwing_crazy.png');

}
Expand All @@ -30,11 +30,11 @@ function create() {
// Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) {

// layer = game.add.tilemapLayer(0, 0, 800, 600, null, map, 0);
layer = game.add.tilemapLayer(0, 0, 400, 600, null, map, 0);
layer = game.add.tilemapLayer(0, 0, 800, 600, null, map, 0);

// layer2 = game.add.tilemapLayer(0, 0, 400, 600, null, map, 0);
// layer.cameraOffset.x = 400;
layer.alpha = 0.5;
// layer.alpha = 0.5;

// tileset = game.add.tileset('tilesNes');
// layer = game.add.tilemapLayer(0, 0, map.layers[0].width*tilesetNes.tileWidth, 600, tileset, map, 0);
Expand All @@ -45,6 +45,16 @@ function create() {
sprite = game.add.sprite(260, 100, 'phaser');
sprite.anchor.setTo(0.5, 0.5);

// This adjusts the collision body size.
// 100x50 is the new width/height.
// 50, 25 is the X and Y offset of the newly sized box.
// In this case the box is 50px in and 25px down.
sprite.body.setSize(16, 16, 8, 8);





// We'll set a lower max angular velocity here to keep it from going totally nuts
sprite.body.maxAngular = 500;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/02 Making your first game/assets/star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions tutorials/02 Making your first game/js/phaser.min.js

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions tutorials/02 Making your first game/part1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Phaser - Making your first game, part 1</title>
<script type="text/javascript" src="js/phaser.min.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>

<script type="text/javascript">

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {
}

function create() {
}

function update() {
}

</script>

</body>
</html>
37 changes: 37 additions & 0 deletions tutorials/02 Making your first game/part2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Phaser - Making your first game, part 1</title>
<script type="text/javascript" src="js/phaser.min.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>

<script type="text/javascript">

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {

game.load.image('sky', 'assets/sky.png');
game.load.image('ground', 'assets/platform.png');
game.load.image('star', 'assets/star.png');
game.load.spritesheet('dude', 'assets/dude.png', 32, 48);

}

function create() {
}

function update() {
}

</script>

</body>
</html>
40 changes: 40 additions & 0 deletions tutorials/02 Making your first game/part3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Phaser - Making your first game, part 1</title>
<script type="text/javascript" src="js/phaser.min.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>

<script type="text/javascript">

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {

game.load.image('sky', 'assets/sky.png');
game.load.image('ground', 'assets/platform.png');
game.load.image('star', 'assets/star.png');
game.load.spritesheet('dude', 'assets/dude.png', 32, 48);

}

function create() {

game.add.sprite(0, 0, 'star');

}

function update() {
}

</script>

</body>
</html>
62 changes: 62 additions & 0 deletions tutorials/02 Making your first game/part4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Phaser - Getting started</title>
<script type="text/javascript" src="js/phaser.min.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>

<script type="text/javascript">

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {

game.load.image('sky', 'assets/sky.png');
game.load.image('ground', 'assets/platform.png');
game.load.image('star', 'assets/star.png');
game.load.spritesheet('dude', 'assets/dude.png', 32, 48);

}

var platforms;

function create() {

// A simple background for our game
game.add.sprite(0, 0, 'sky');

// The platforms group contains the ground and the 2 ledges we can jump on
platforms = game.add.group();

// Here we create the ground.
var ground = platforms.create(0, game.world.height - 64, 'ground');

// Scale it to fit the width of the game (the original sprite is 400x32 in size)
ground.scale.setTo(2, 2);

// This stops it from falling away when you jump on it
ground.body.immovable = true;

// Now let's create two ledges
var ledge = platforms.create(400, 400, 'ground');
ledge.body.immovable = true;

ledge = platforms.create(-150, 250, 'ground');
ledge.body.immovable = true;

}

function update() {
}

</script>

</body>
</html>
74 changes: 74 additions & 0 deletions tutorials/02 Making your first game/part5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Phaser - Getting started</title>
<script type="text/javascript" src="js/phaser.min.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>

<script type="text/javascript">

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {

game.load.image('sky', 'assets/sky.png');
game.load.image('ground', 'assets/platform.png');
game.load.image('star', 'assets/star.png');
game.load.spritesheet('dude', 'assets/dude.png', 32, 48);

}

var platforms;

function create() {

// A simple background for our game
game.add.sprite(0, 0, 'sky');

// The platforms group contains the ground and the 2 ledges we can jump on
platforms = game.add.group();

// Here we create the ground.
var ground = platforms.create(0, game.world.height - 64, 'ground');

// Scale it to fit the width of the game (the original sprite is 400x32 in size)
ground.scale.setTo(2, 2);

// This stops it from falling away when you jump on it
ground.body.immovable = true;

// Now let's create two ledges
var ledge = platforms.create(400, 400, 'ground');
ledge.body.immovable = true;

ledge = platforms.create(-150, 250, 'ground');
ledge.body.immovable = true;

// The player and its settings
player = game.add.sprite(32, game.world.height - 150, 'dude');

// Player physics properties. Give the little guy a slight bounce.
player.body.bounce.y = 0.2;
player.body.gravity.y = 6;
player.body.collideWorldBounds = true;

// Our two animations, walking left and right.
player.animations.add('left', [0, 1, 2, 3], 10, true);
player.animations.add('right', [5, 6, 7, 8], 10, true);

}

function update() {
}

</script>

</body>
</html>
79 changes: 79 additions & 0 deletions tutorials/02 Making your first game/part6.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Phaser - Getting started</title>
<script type="text/javascript" src="js/phaser.min.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>

<script type="text/javascript">

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {

game.load.image('sky', 'assets/sky.png');
game.load.image('ground', 'assets/platform.png');
game.load.image('star', 'assets/star.png');
game.load.spritesheet('dude', 'assets/dude.png', 32, 48);

}

var player;
var platforms;

function create() {

// A simple background for our game
game.add.sprite(0, 0, 'sky');

// The platforms group contains the ground and the 2 ledges we can jump on
platforms = game.add.group();

// Here we create the ground.
var ground = platforms.create(0, game.world.height - 64, 'ground');

// Scale it to fit the width of the game (the original sprite is 400x32 in size)
ground.scale.setTo(2, 2);

// This stops it from falling away when you jump on it
ground.body.immovable = true;

// Now let's create two ledges
var ledge = platforms.create(400, 400, 'ground');
ledge.body.immovable = true;

ledge = platforms.create(-150, 250, 'ground');
ledge.body.immovable = true;

// The player and its settings
player = game.add.sprite(32, game.world.height - 150, 'dude');

// Player physics properties. Give the little guy a slight bounce.
player.body.bounce.y = 0.2;
player.body.gravity.y = 6;
player.body.collideWorldBounds = true;

// Our two animations, walking left and right.
player.animations.add('left', [0, 1, 2, 3], 10, true);
player.animations.add('right', [5, 6, 7, 8], 10, true);

}

function update() {

// Collide the player and the stars with the platforms
game.physics.collide(player, platforms);

}

</script>

</body>
</html>
Loading

0 comments on commit 74e0cfb

Please sign in to comment.