add colors to config

This commit is contained in:
Alexander Popov 2021-07-07 01:26:29 +03:00
parent 22a20a9305
commit 76fcb27110
Signed by: iiiypuk
GPG Key ID: 398FC73478D97286
4 changed files with 15 additions and 19 deletions

View File

@ -1,4 +1,5 @@
## TODO: ## TODO:
- image border
- info widget - info widget
- finish game image - finish game image
- desktop (landscape) orientation - desktop (landscape) orientation
@ -7,7 +8,7 @@
- make docs/ - make docs/
- make quests editor - make quests editor
## Done ## DONE:
- background music [c814f77] - background music [c814f77]
- several correct answer [498ab55] - several correct answer [498ab55]
- loading all quest images with loading [b8aa4b6] - loading all quest images with loading [b8aa4b6]

View File

@ -19,7 +19,7 @@
html { height: 100%; } html { height: 100%; }
body { body {
background-color: #6E5967; background-color: #2f3542;
font-family: 'Yanone Kaffeesatz'; font-family: 'Yanone Kaffeesatz';
padding: 0; padding: 0;
margin: 0; margin: 0;

View File

@ -1,17 +1,12 @@
// функции рисоввания // функции рисоввания
export function clearContext(canvas) { export function clearContext(canvas, color) {
// var:canvas -- канвас, на котором рисуем
let cW = canvas.width; let cW = canvas.width;
let cH = canvas.height; let cH = canvas.height;
let context = canvas.getContext('2d'); let context = canvas.getContext('2d');
let graBack = context.createLinearGradient(cW / 2, 0, cW / 2, cH); context.fillStyle = color;
// graBack.addColorStop(0, config.scene.backGradient[0]);
// graBack.addColorStop(1, config.scene.backGradient[1]);
// context.fillStyle = graBack;
context.fillStyle = "#444444";
context.fillRect(0, 0, cW, cH); context.fillRect(0, 0, cW, cH);
} }

View File

@ -222,7 +222,7 @@ function update() {
// Draw to canvas func ---------------------------------- // Draw to canvas func ----------------------------------
function draw() { function draw() {
clearContext(canvas); // clean canvas clearContext(canvas, config.colors.back); // clean canvas
// render splash screen ----------------------------- // render splash screen -----------------------------
if (!game.loadedState) { if (!game.loadedState) {
@ -248,13 +248,13 @@ function draw() {
// change progress item color by status answer // change progress item color by status answer
switch (gameData.questions[i].status) { switch (gameData.questions[i].status) {
case null: case null:
context.fillStyle = "gray"; context.fillStyle = config.colors.answer.notPassed;
break; break;
case true: case true:
context.fillStyle = "green"; context.fillStyle = config.colors.answer.right;
break; break;
case false: case false:
context.fillStyle = "red"; context.fillStyle = config.colors.answer.wrong;
break; break;
} }
@ -274,8 +274,8 @@ function draw() {
context.fillText(gameData.questions[game.currentQuest].question, cW / 2, areas.game.labelQuestion.y + 30); context.fillText(gameData.questions[game.currentQuest].question, cW / 2, areas.game.labelQuestion.y + 30);
// draw answer buttons // draw answer buttons
context.fillStyle = "purple"; context.fillStyle = "#2ed573";
context.strokeStyle = "navy"; context.strokeStyle = "#000000";
context.lineWidth = 2; context.lineWidth = 2;
let answerButtonsArray = [buttons.answerButton0, buttons.answerButton1, let answerButtonsArray = [buttons.answerButton0, buttons.answerButton1,
@ -296,8 +296,8 @@ function draw() {
}); });
// draw UI buttons // draw UI buttons
context.fillStyle = "purple"; context.fillStyle = "#2ed573";
context.strokeStyle = "navy"; context.strokeStyle = "#000000";
context.lineWidth = 2; context.lineWidth = 2;
for (const [key, value] of Object.entries(buttonsUi)) { for (const [key, value] of Object.entries(buttonsUi)) {
@ -340,8 +340,8 @@ function draw() {
context.fillText(resultInfo, cW / 2, areas.finish.labelTotalInfo.y + 55); context.fillText(resultInfo, cW / 2, areas.finish.labelTotalInfo.y + 55);
// draw btnRestart // draw btnRestart
context.fillStyle = "purple"; context.fillStyle = "#2ed573";
context.strokeStyle = "navy"; context.strokeStyle = "#000000";
context.fillRect(buttons.btnRestart.x, buttons.btnRestart.y, buttons.btnRestart.w, buttons.btnRestart.h); context.fillRect(buttons.btnRestart.x, buttons.btnRestart.y, buttons.btnRestart.w, buttons.btnRestart.h);
context.strokeRect(buttons.btnRestart.x, buttons.btnRestart.y, buttons.btnRestart.w, buttons.btnRestart.h); context.strokeRect(buttons.btnRestart.x, buttons.btnRestart.y, buttons.btnRestart.w, buttons.btnRestart.h);