-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
143 lines (112 loc) · 2.72 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebGL</title>
</head>
<body>
</body>
<script src="js/pixi.js"></script>
<script>
const app = new PIXI.Application({
// backgroundColor: 0x593ebd,
backgroundColor: 0x000000,
});
document.body.appendChild(app.view);
var timer = 0
var animationSpeed = 2
var subTimer = 0
const saturn = PIXI.Sprite.from('img/saturn.png');
saturn.anchor.set(0.5);
saturn.height = 150
saturn.width = 150
saturn.x = 450;
saturn.y = 450;
app.stage.addChild(saturn);
const mars = PIXI.Sprite.from('img/mars.png');
mars.anchor.set(0.5);
mars.height = 80
mars.width = 80
mars.x = 210;
mars.y = 130;
app.stage.addChild(mars);
const earth = PIXI.Sprite.from('img/earth.png');
earth.anchor.set(0.5);
earth.height = 60
earth.width = 60
earth.x = 650;
earth.y = 130;
app.stage.addChild(earth);
const spaceShip = PIXI.Sprite.from('img/ss2.png');
spaceShip.anchor.set(0.5);
spaceShip.height = 80
spaceShip.width = 80
spaceShip.x = 730;
spaceShip.y = 550;
app.stage.addChild(spaceShip);
function giraEsquerda() {
spaceShip.rotation -= ((Math.PI * 2 * 0.125) / 3) * animationSpeed;
}
function giraDireita() {
spaceShip.rotation += ((Math.PI * 2 * 0.125) / 3) * animationSpeed;
}
function moveCima() {
spaceShip.y -= 1 * animationSpeed
}
function moveBaixo() {
spaceShip.y += 1 * animationSpeed
}
function moveDireita() {
spaceShip.x += 1 * animationSpeed
}
function moveEsquerda() {
spaceShip.x -= 1 * animationSpeed
}
app.ticker.speed = 2
app.ticker.add(() => {
subTimer = timer * animationSpeed
if (subTimer >= 0 && subTimer <= 500) {
moveCima()
}
if (subTimer >= 500 && subTimer <= 505) {
giraEsquerda()
}
if (subTimer >= 500 && subTimer <= 660) {
moveEsquerda()
}
if (subTimer >= 660 && subTimer <= 665) {
giraEsquerda()
}
if (subTimer >= 665 && subTimer <= 1150) {
moveBaixo()
}
if (subTimer >= 1155 && subTimer <= 1160) {
giraDireita()
}
if (subTimer >= 1160 && subTimer <= 1410) {
moveEsquerda()
}
if (subTimer >= 1410 && subTimer <= 1415) {
giraDireita()
}
if (subTimer >= 1415 && subTimer <= 1900) {
moveCima()
}
if (subTimer >= 1905 && subTimer <= 1910) {
giraEsquerda()
}
if (subTimer >= 1910 && subTimer <= 2100) {
moveEsquerda()
}
if (subTimer >= 2100 && subTimer <= 2105) {
giraEsquerda()
}
if (subTimer >= 2105 && subTimer <= 2900) {
moveBaixo()
}
timer += 1
// console.log(timer)
});
</script>
</html>