-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
139 lines (135 loc) · 3.9 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
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.15.1/dist/phaser-arcade-physics.min.js"></script>
</head>
<body>
<script>
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
var RGBToHEX = function(r, g, b) {
return (r << 16) | (g << 8) | b;
};
function preload() {
this.load.image(
"sky",
"https://cdn.glitch.com/002fa3bd-f6fe-4c8b-ac29-5f3ad9da83c7%2Fsky.png?v=1575297509191"
);
this.load.image(
"star",
"https://cdn.glitch.com/002fa3bd-f6fe-4c8b-ac29-5f3ad9da83c7%2Fstar.png?v=1575297509100"
);
}
/*
velocity = 150ft/sec
x-i = 9.38, 0
y-i = 0
max val = 351.56ft
axis of symmetry = 4.69sec
*/
//var graphics = new Phaser.GameObjects.Graphics();
function create() {
var xzoom = 50,
yzoom = 1;
var zerox = 100,
zeroy = 100;
var prev = [zerox, 600 -zeroy];
this.add.image(400, 300, "sky");
this.add
.line(0, 0, 0, 600 - zeroy, 800, 600 - zeroy, RGBToHEX(0, 0, 0))
.setOrigin(0, 0);
this.add
.line(0, 0, zerox, 600, zerox, 0, RGBToHEX(0, 0, 0))
.setOrigin(0, 0);
var max = 0;
var i = 20;
var ball = this.add
.image(zerox, 600 - zeroy, "star")
.setDisplaySize(20, 20)
.setInteractive();
var timeline = this.tweens.createTimeline();
var acc = 0.05
for (let i = 0; quadratic(-16, i, 150, 0) >= 0 || i < 1; i += acc) {
var quad = quadratic(-16, i, 150, 0);
timeline.add({
targets: ball,
duration: 1000 * acc,
x: i * xzoom + zerox,
y: 600 - zeroy - quad * yzoom
});
this.add
.line(
0,
0,
prev[0],
prev[1],
i * xzoom + zerox,
600 - zeroy - quad * yzoom,
RGBToHEX(0,200,0)
)
.setOrigin(0, 0);
prev[0] = i * xzoom + zerox;
prev[1] = 600 - zeroy - quad * yzoom;
}
timeline.play();
ball.on("pointerdown", function() {
console.log("click");
timeline.play();
});
/*var lines = this.add.group();
var points = this.add.group();
for (let i = 0; quadratic(-16, i - 1, 150, 0) >= 0 || i < 1; i += 0.2) {
var quad = quadratic(-16, i, 150, 0);
if (quad > max){
max = quad
}
console.log(i + " // " + quad);
if (prev.length == 2) {
lines.add(
this.add
.line(
0,
0,
prev[0],
prev[1],
i * xzoom + zerox,
600 - zeroy - quad * yzoom,
RGBToHEX(0, 0, 0)
)
.setOrigin(0, 0)
);
//line.width = 500;
//console.log("Cool");
}
//var point =
points.add(
this.add
.image(i * xzoom + zerox, 600 - zeroy - quad * yzoom, "star")
.setDisplaySize(10, 10)
);
prev[0] = i * xzoom + zerox;
prev[1] = 600 - zeroy - quad * yzoom;
}*/
}
function update() {}
function quadratic(gravity, time, initVelo, initHeight) {
return gravity * (time * time) + initVelo * time + initHeight;
/*let timeSq = time * time;
let one = gravity * timeSq;
let two = initVelo * time;
let three = initHeight;
return(one + two + three);*/
}
</script>
</body>
</html>
t