Skip to content
Snippets Groups Projects
Commit c8b6e7b7 authored by Bye's avatar Bye
Browse files

day one failures

parents
No related branches found
No related tags found
No related merge requests found
assets/byemclogo.png

205 B

File added
File added
favicon.ico

3.19 KiB

game.js 0 → 100644
/*
For js13k 2022
Theme: death
*/
// Functions for my little game engine thing
const log = (logType, msg) => {
console.log(`[${logType}] ${msg}`);
}
class Canvas {
constructor(id) {
this.canvas = document.getElementById(id);
this.ctx = this.canvas.getContext('2d');
this.width = this.canvas.width;
this.height = this.canvas.height;
}
fill(color) {
this.ctx.fillStyle = color;
this.ctx.fillRect(0, 0, this.width, this.height);
}
// Drawing
drawImg(img, x, y, w, h) {
this.ctx.drawImage(img, x, y, w, h);
}
}
// CONFIG
const fontStack = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif';
// INIT CANVAS
var canvas = new Canvas('gameCanvas');
if (canvas.ctx == null) {
log('ERROR', 'Could not initialize canvas');
alert('Your browser doesn\'t support canvas. Most modern browsers support it, so please upgrade to IE 9 or newer.');
}
gameCtx = canvas.ctx;
canvas.fill("#1c1c1c");
// Logo and opening
var logo = new Image();
logo.src = 'assets/byemclogo.png';
logo.onload = function() {
canvas.drawImg(logo, 0, 0, 128, 128);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Untitled Game 2022</title>
<style>
#gameCanvas {
display: block;
margin: auto;
}
</style>
</head>
<body>
<canvas width="800" height="600" id="gameCanvas">
</canvas>
<script src="/game.js"></script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment