2020-08-07 12:21:15 -04:00
|
|
|
import GameLoop from "./Loop/GameLoop";
|
2020-08-11 19:55:05 -04:00
|
|
|
import {} from "./index";
|
2020-10-07 15:00:28 -04:00
|
|
|
import BoidDemo from "./BoidDemo";
|
2020-10-18 12:03:40 -04:00
|
|
|
import MarioClone from "./_DemoClasses/MarioClone/MarioClone";
|
2020-10-28 14:55:32 -04:00
|
|
|
import PathfindingScene from "./_DemoClasses/Pathfinding/PathfindingScene";
|
2020-08-03 16:51:20 -04:00
|
|
|
|
2020-08-07 12:21:15 -04:00
|
|
|
function main(){
|
|
|
|
// Create the game object
|
2020-10-18 18:34:13 -04:00
|
|
|
let game = new GameLoop({canvasSize: {x: 800, y: 600}});
|
2020-08-07 12:21:15 -04:00
|
|
|
game.start();
|
2020-09-06 18:07:09 -04:00
|
|
|
let sm = game.getSceneManager();
|
2020-10-28 14:55:32 -04:00
|
|
|
sm.addScene(PathfindingScene);
|
2020-08-03 16:51:20 -04:00
|
|
|
}
|
|
|
|
|
2020-08-11 19:55:05 -04:00
|
|
|
CanvasRenderingContext2D.prototype.roundedRect = function(x: number, y: number, w: number, h: number, r: number): void {
|
|
|
|
// Clamp the radius between 0 and the min of the width or height
|
|
|
|
if(r < 0) r = 0;
|
|
|
|
if(r > Math.min(w, h)) r = Math.min(w, h);
|
|
|
|
|
|
|
|
// Draw the rounded rect
|
|
|
|
this.beginPath();
|
|
|
|
|
|
|
|
// Top
|
|
|
|
this.moveTo(x + r, y);
|
|
|
|
this.lineTo(x + w - r, y);
|
|
|
|
this.arcTo(x + w, y, x + w, y + r, r);
|
|
|
|
|
|
|
|
// Right
|
|
|
|
this.lineTo(x + w, y + h - r);
|
|
|
|
this.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
|
|
|
|
|
|
// Bottom
|
|
|
|
this.lineTo(x + r, y + h);
|
|
|
|
this.arcTo(x, y + h, x, y + h - r, r);
|
|
|
|
|
|
|
|
// Left
|
|
|
|
this.lineTo(x, y + r);
|
|
|
|
this.arcTo(x, y, x + r, y, r)
|
|
|
|
|
|
|
|
this.closePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
CanvasRenderingContext2D.prototype.strokeRoundedRect = function(x, y, w, h, r){
|
|
|
|
this.roundedRect(x, y, w, h, r);
|
|
|
|
this.stroke();
|
|
|
|
}
|
|
|
|
|
|
|
|
CanvasRenderingContext2D.prototype.fillRoundedRect = function(x, y, w, h, r){
|
|
|
|
this.roundedRect(x, y, w, h, r);
|
|
|
|
this.fill();
|
|
|
|
}
|
|
|
|
|
2020-08-07 12:21:15 -04:00
|
|
|
main();
|