-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.js
70 lines (50 loc) · 1.51 KB
/
game.js
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
//Set up basic game with Phaser
//brackets IDE
let config = {
width : 800,
height : 600,
scene : {
preload : preload,
create : create,
update : update,
}
};
let game = new Phaser.Game(config);
function preload(){
//load an image
console.log(this);
this.load.image('background',"Assets/back.jpg");
this.load.image('wheel',"Assets/wheel.png");
this.load.image('stand',"Assets/stand.png"); this.load.image('pin',"Assets/pin.png");
}
function create(){
//create that image
let W = game.config.width;
let H = game.config.height;
this.add.sprite(0,0,'background');
let pin = this.add.sprite(W/2,H/2-250,'pin').setScale(0.25);
pin.depth = 5;
this.add.sprite(W/2,H/2 + 250,'stand').setScale(0.25);
//let create wheel
this.wheel = this.add.sprite(W/2,H/2,"wheel");
this.wheel.setScale(0.25);
console.log(this.wheel.depth);
this.input.on("pointerdown",spinwheel,this);
}
function update(){
console.log("In Update");
//this.wheel.angle -= 1;
}
function spinwheel(){
console.log("Time to spin the wheel");
let rounds = Phaser.Math.Between(2,4);
console.log(rounds);
let extra_degrees = Phaser.Math.Between(0,11)*30;
let total_angle = rounds*360 + extra_degrees;
let tween = this.tweens.add({
targets: this.wheel,
angle: total_angle,
ease:"Cubic.easeOut",
duration: 3000
});
}