-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
87 lines (72 loc) · 2.03 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<script src="phaser.min.js"></script>
</head>
<body>
<script>
//WOW!
//Rawr xD
//LUL I was here. ME
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: 'arcade',
arcade: {
gravity: { y: 400 },
debug: false
}
},
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
function preload()
{
this.load.image('sunset', 'images/sunset.jpg');
this.load.image('platform-1', 'images/platform-1.png');
this.load.image('snowman', 'images/snowman.png');
}
var platforms;
function create()
{
this.add.image(0, 0, 'sunset').setOrigin(0, 0);
platforms = this.physics.add.staticGroup();
platforms.create(400, 568, 'platform-1').setScale(2).refreshBody();
platforms.create(600, 400, 'platform-1');
platforms.create(50, 250, 'platform-1');
platforms.create(750, 220, 'platform-1');
player = this.physics.add.sprite(100, 450, 'snowman');
player.setBounce(0.2);
player.setCollideWorldBounds(true);
this.physics.add.collider(player, platforms);
cursors = this.input.keyboard.createCursorKeys();
}
function update()
{
if (cursors.left.isDown) {
player.setVelocityX(-400);
} else if (cursors.right.isDown) {
player.setVelocityX(400);
} else {
player.setVelocityX(0);
}
if (cursors.up.isDown && player.body.touching.down) {
player.setVelocityY(-400);
}
// If the player is out of bounds, respawn the player.
// this.sprite.body.checkWorldBounds
if () {
}
}
// window.onload = function () {
// document.getElementsByTagName("canvas")[0].focus();
// }
</script>
</body>
</html>