From 24e07ff3bc01d7d39de07c596d4f528addd38eff Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Fri, 29 Jul 2022 02:34:47 +0300 Subject: [PATCH] add styles --- public/index.html | 3 +++ public/styles.css | 20 ++++++++++++++++++++ src/canvas.js | 0 src/config.json | 3 +++ src/index.js | 36 ++++++++++++++++++++++++++++++++++++ webpack.config.js | 3 +-- 6 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 public/styles.css create mode 100644 src/canvas.js create mode 100644 src/config.json diff --git a/public/index.html b/public/index.html index ccdeaef..3f2fc07 100644 --- a/public/index.html +++ b/public/index.html @@ -4,6 +4,7 @@ test +
@@ -13,5 +14,7 @@
+ + diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..adbcb18 --- /dev/null +++ b/public/styles.css @@ -0,0 +1,20 @@ +@font-face { + font-family: 'Monogram'; + src: url('/assets/monogram-extended.ttf') format('truetype'); + font-weight: 500; + font-style: normal; + font-display: swap; +} + +body { + margin: 0; +} + +div.canvas { + text-align: center; + padding: 8px; +} + +canvas#game { + border: 2px solid #5d5d5d; +} diff --git a/src/canvas.js b/src/canvas.js new file mode 100644 index 0000000..e69de29 diff --git a/src/config.json b/src/config.json new file mode 100644 index 0000000..1572bd6 --- /dev/null +++ b/src/config.json @@ -0,0 +1,3 @@ +{ + "debug": true +} diff --git a/src/index.js b/src/index.js index e69de29..77d0ea1 100644 --- a/src/index.js +++ b/src/index.js @@ -0,0 +1,36 @@ +'use strict'; + +// engine config file +import config from './config.json'; + +const DEBUG = config.debug; +let canvas = null; +let context = null; +let cW = null; +let cH = null; + +window.onload = function() { + canvas = document.getElementById('game'); + context = canvas.getContext('2d'); + cW = canvas.width; + cH = canvas.height; + + // print canvas size + if (DEBUG) console.log(`Canvas size ${cW} x ${cH}`); + + window.requestAnimationFrame(gameLoop); +} + +function gameLoop(timeStamp) { + update(); + draw(); + + window.requestAnimationFrame(gameLoop); +} + +function update() { + // +} + +function draw() { +} diff --git a/webpack.config.js b/webpack.config.js index b7ff738..b42c7a2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,8 +5,7 @@ module.exports = { entry: './src/index.js', output: { filename: 'game.js', - publicPath: 'public', - path: path.resolve(__dirname, 'dist'), + path: path.resolve(__dirname, 'public'), }, devServer: { static: path.join(__dirname, 'public'),