From 2d3ce1982c8ab2a2e161c7892c8ebb58d8e11e89 Mon Sep 17 00:00:00 2001 From: Talon Date: Mon, 24 Apr 2023 13:23:56 +0200 Subject: [PATCH] CSS styles --- src/game/commands/dark.js | 3 + src/game/index.html | 181 +++++++++++++++++++++++++++++++++----- src/game/index.js | 76 ++++++++-------- 3 files changed, 202 insertions(+), 58 deletions(-) create mode 100644 src/game/commands/dark.js diff --git a/src/game/commands/dark.js b/src/game/commands/dark.js new file mode 100644 index 0000000..4ed7e6d --- /dev/null +++ b/src/game/commands/dark.js @@ -0,0 +1,3 @@ +export default async function DarkCommand(args, context) { + document.body.classList.toggle('dark-theme'); +} \ No newline at end of file diff --git a/src/game/index.html b/src/game/index.html index cee7ad7..233a351 100644 --- a/src/game/index.html +++ b/src/game/index.html @@ -1,22 +1,161 @@ - - -Assassin bug - - -

Assassin bug

- - - -
-

Welcome

- -
- + + + + Assassin bug + + + + +

Assassin bug

+ + + +
+

Welcome

+ +
+ + \ No newline at end of file diff --git a/src/game/index.js b/src/game/index.js index 976972f..2a9ba2f 100644 --- a/src/game/index.js +++ b/src/game/index.js @@ -1,37 +1,39 @@ -import Game from '../engine'; -import Rooms from './rooms'; -import Items from './items'; -import MeowCommand from './commands/meow'; - -if (localStorage.getItem("save")) { - document.getElementById("save-game-found").hidden = false; - document.getElementById("before-play").hidden = true; - document.getElementById("load-save-game").addEventListener("click", () => { - document.getElementById("save-game-found").hidden = true; - document.getElementById("play-area").hidden = false; - startGame(false); - }) - document.getElementById("start-new-game").addEventListener("click", () => { - document.getElementById("save-game-found").hidden = true; - document.getElementById("play-area").hidden = false; - startGame(true); - }) -} - -document.getElementById("begin").addEventListener("click", () => { - document.getElementById("before-play").hidden = true; - document.getElementById("play-area").hidden = false; - startGame(true); -}) - -function startGame(newGame) { - const game = new Game(newGame); - - game.init({ - rooms: Rooms, - commands: [ - [["meow", "mew"], MeowCommand] - ], - items: Items - }); -} +import Game from '../engine'; +import Rooms from './rooms'; +import Items from './items'; +import MeowCommand from './commands/meow'; +import DarkCommand from "./commands/dark"; + +if (localStorage.getItem("save")) { + document.getElementById("save-game-found").hidden = false; + document.getElementById("before-play").hidden = true; + document.getElementById("load-save-game").addEventListener("click", () => { + document.getElementById("save-game-found").hidden = true; + document.getElementById("play-area").hidden = false; + startGame(false); + }) + document.getElementById("start-new-game").addEventListener("click", () => { + document.getElementById("save-game-found").hidden = true; + document.getElementById("play-area").hidden = false; + startGame(true); + }) +} + +document.getElementById("begin").addEventListener("click", () => { + document.getElementById("before-play").hidden = true; + document.getElementById("play-area").hidden = false; + startGame(true); +}) + +function startGame(newGame) { + const game = new Game(newGame); + + game.init({ + rooms: Rooms, + commands: [ + [["meow", "mew"], MeowCommand], + [["dark"], DarkCommand] + ], + items: Items + }); +}