Skip to content

Commit 3338a5b

Browse files
author
Thomas
committed
first commit
0 parents  commit 3338a5b

8 files changed

Lines changed: 115 additions & 0 deletions

File tree

1/empty-project/assets/hello.png

3.26 KB
Loading

1/empty-project/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Empty project</title>
7+
8+
<style>
9+
#game_div {
10+
width: 500px;
11+
margin: auto;
12+
margin-top: 50px;
13+
}
14+
</style>
15+
16+
<script type="text/javascript" src="phaser.min.js"></script>
17+
<script type="text/javascript" src="main.js"></script>
18+
</head>
19+
20+
<body>
21+
22+
<div id="game_div"> </div>
23+
24+
</body>
25+
26+
</html>

1/empty-project/main.js

Whitespace-only changes.

1/empty-project/phaser.min.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1/hello-world/assets/hello.png

3.26 KB
Loading

1/hello-world/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Empty project</title>
7+
8+
<style>
9+
#game_div {
10+
width: 500px;
11+
margin: auto;
12+
margin-top: 50px;
13+
}
14+
</style>
15+
16+
<script type="text/javascript" src="phaser.min.js"></script>
17+
<script type="text/javascript" src="main.js"></script>
18+
</head>
19+
20+
<body>
21+
22+
<div id="game_div"> </div>
23+
24+
</body>
25+
26+
</html>

1/hello-world/main.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
// This initialise Phaser
3+
// Parameters: width of the game, height of the game, how to render the game, the name of the div in the html that will contain the game
4+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'game_div');
5+
6+
// An array to store the different states of our game (play, menu, credits, etc.)
7+
Game = {};
8+
9+
// Let's define our first state: play
10+
Game.Play = function() { };
11+
Game.Play.prototype = {
12+
13+
preload: function() {
14+
// Everything in this function will be executed at the beginning. That’s where we usually load the game’s assets (images, sounds, etc.)
15+
16+
// Load a sprite in the game
17+
// Parameters: name of the image, path to the image
18+
game.load.image('hello', 'assets/hello.png');
19+
},
20+
21+
create: function() {
22+
// This function will be called after the preload function. Here we set up the game: place sprites, add labels, etc.
23+
24+
// Display a sprite on the screen
25+
// Parameters: x position, y position, name of the sprite
26+
hello_sprite = game.add.sprite(200, 300, 'hello');
27+
},
28+
29+
update: function() {
30+
// This is where you will spend the most of your time. This function is called 60 times per seconds to update the state of your game.
31+
32+
// Increase the angle of the sprite by one
33+
hello_sprite.angle += 1;
34+
}
35+
}
36+
37+
// And we tell Phaser to add and start our play state
38+
game.state.add('Play', Game.Play);
39+
game.state.start('Play');

1/hello-world/phaser.min.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)