-
Notifications
You must be signed in to change notification settings - Fork 0
/
dodge.html
129 lines (112 loc) · 2.44 KB
/
dodge.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>dodge</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 = "dodge";
characters = [
`
bbbbbb
`
];
description = `
[Tap] to
change
direction
and dodge
`;
let slider;
let slider_pos;
let fallingBalls;
let counter;
let speed;
let direction;
let ballLimit = 0;
options = {
isReplayEnabled: true
};
function update() {
if (!ticks) {
slider_pos = {
pos: vec(10, 95)
};
counter = 0;
speed = 1;
fallingBalls = [];
direction = true;
ballLimit = 3;
return;
}
color("black");
counter += 1;
if (input.isJustPressed)
{
direction = !direction;
}
if (direction)
{
if (slider_pos.pos.x < 90)
{
slider_pos.pos.x += 1;
}
}
else
{
if (slider_pos.pos.x > 5)
{
slider_pos.pos.x -= 1;
}
}
// if collides with box, it's game over
fallingBalls.forEach((ball) =>
{
color("red");
ball.pos.y += speed;
rect(ball.pos.x, ball.pos.y, 10, 5);
}
);
remove(fallingBalls, (box) => {
return box.pos.y > 100;
});
if (fallingBalls.length < ballLimit)
{
addScore(0.2);
fallingBalls.push(
{
pos: vec(rnd(0,100), rnd(0,15))
});
}
if (counter % 300 == 0)
{
ballLimit += 1;
}
color("black");
slider = char("a", slider_pos.pos);
if (slider.isColliding.rect.red)
{
end();
}
}
addEventListener("load", onLoad);
</script>
</head>
<body style="background: #eeeeee"></body>
</html>