-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflyingship.html
144 lines (126 loc) · 2.68 KB
/
flyingship.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
144
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>flying ship</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Y55LGP63JX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-Y55LGP63JX');
</script>
<meta
name="viewport"
content="width=device-width, height=device-height,
user-scalable=no, initial-scale=1, maximum-scale=1"
/>
<script src="https://unpkg.com/[email protected]/build/index.js"></script>
<script src="https://unpkg.com/[email protected]/build/index.js"></script>
<script src="https://unpkg.com/[email protected]/dist/pixi.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/pixi-filters.js"></script>
<script src="https://unpkg.com/[email protected]/docs/bundle.js"></script>
<script>
title = "flying ship";
characters = [
`
rrr
rr rr
rrr
`
];
description = `
[Tap] to
make
ball go high
`;
let ball;
let boxesBottom = [];
let boxesTop = [];
let counter;
let speed;
let fall_speed;
options = {
isReplayEnabled: true,
theme: "dark"
};
function update() {
if (!ticks) {
ball = {
pos: vec(10, 10)
};
counter = 0;
speed = 1;
fall_speed = 0.8;
return;
}
counter += 1;
if (input.isJustPressed && ball.pos.y > 15)
{
ball.pos.y -= 20;
}
else
{
if (ball.pos.y < 98)
{
ball.pos.y += fall_speed;
}
}
// if collides with box, it's game over
boxesBottom.forEach((box) =>
{
color("yellow");
box.pos.x -= speed;
rect(box.pos.x, 100 - box.pos.y, 10, box.pos.y);
}
);
boxesTop.forEach((box) =>
{
color("yellow");
box.pos.x -= speed;
rect(box.pos.x, 0, 10, box.pos.y);
}
);
remove(boxesTop, (box) => {
return box.pos.x < 0;
});
remove(boxesBottom, (box) => {
return box.pos.x < 0;
});
if (boxesBottom.length < 1)
{
addScore(1);
let a = rnd(0, 30);
let b = 70 - a;
let c = b;
if (rnd(0, 2) > 1)
{
b = a;
a = c;
}
boxesTop.push(
{
pos: vec(100, a)
});
boxesBottom.push({
pos: vec(100, b)
});
}
if (counter % 300 == 0)
{
speed += 0.1;
}
color("black");
a = char("a", ball.pos);
if (a.isColliding.rect.yellow)
{
end();
boxesBottom = [];
boxesTop = [];
}
}
addEventListener("load", onLoad);
</script>
</head>
<body style="background: #eeeeee"></body>
</html>