-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8592588
commit 6e051ed
Showing
3 changed files
with
117 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,47 @@ | ||
import { Vector2 } from "./Vector2.js"; | ||
import * as polyModule from "./Polygon.js" | ||
import * as polyModule from "./Polygon.js"; | ||
|
||
let src = document.getElementById("source"); | ||
let ctx = src.getContext("2d"); | ||
|
||
let newPoly = new polyModule.Polygon([ | ||
new Vector2(-1, 1), | ||
new Vector2(1, 1), | ||
new Vector2(1, -1), | ||
new Vector2(-1, -1) | ||
new Vector2(-50, 50), | ||
new Vector2(50, 50), | ||
new Vector2(50, -50), | ||
new Vector2(-50, -50) | ||
]) | ||
|
||
console.log(newPoly) | ||
|
||
let vector = new Vector2(1, 1); | ||
let vector2 = new Vector2(5, 3) | ||
let vector2 = new Vector2(5, 3); | ||
|
||
function render(dt) { | ||
newPoly.render(ctx); | ||
} | ||
|
||
function calculate(dt, t) { | ||
|
||
} | ||
|
||
let time = 0; | ||
function loop(t) { | ||
let dt = (t/1000) - time; | ||
|
||
ctx.canvas.width = src.clientWidth; | ||
ctx.canvas.height = src.clientHeight; | ||
|
||
newPoly.pos.x = ctx.canvas.width / 2 | ||
newPoly.pos.y = ctx.canvas.height / 2 | ||
|
||
calculate(dt, t); | ||
render(dt); | ||
|
||
time += t / 1000; | ||
window.requestAnimationFrame(loop); | ||
} | ||
|
||
function startup() { | ||
loop(); | ||
} | ||
|
||
startup(); |