-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
47 lines (41 loc) · 901 Bytes
/
Copy pathmain.js
File metadata and controls
47 lines (41 loc) · 901 Bytes
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
function run () {
let app = document.getElementById('app')
let canvas = document.getElementById('main')
let ctx = canvas.getContext('2d')
let worldState = {
fps: 60,
playSpeed: 1,
gravitationalConstant: 3192053.26975
}
let myWorld = new GravityWorld({canvas: canvas, ctx: ctx}, worldState)
myWorld.resize(app.clientWidth, app.clientHeight)
app.onresize = function () {
myWorld.resize(app.clientWidth, app.clientHeight)
}
let ballSun = myWorld.newBall({
name: 'sun',
x: 800,
y: 500,
velocity: {
x: 0,
y: 0
},
mass: 30000,
color: 'red'
})
let ballEarth = myWorld.newBall({
name: 'earth',
x: 800,
y: 300,
velocity: {
x: 14.384233150225,
y: 0
},
mass: 100,
color: 'green'
})
myWorld.addBall(ballSun)
myWorld.addBall(ballEarth)
myWorld.start()
}
window.onload = run