fix obvious bugs

This commit is contained in:
2025-08-19 18:38:54 +03:00
parent d6fe7d5475
commit 037bf03518
3 changed files with 10 additions and 7 deletions

View File

@@ -14,7 +14,7 @@
#leader ol { margin:.2rem 0 0 1rem; padding:0; } #leader ol { margin:.2rem 0 0 1rem; padding:0; }
</style> </style>
<script language="javascript" type="text/javascript" src="libraries/p5.min.js"></script> <script language="javascript" type="text/javascript" src="libraries/p5.min.js"></script>
<script language="javascript" type="text/javascript" src="sketch_250819b.js"></script> <script language="javascript" type="text/javascript" src="sketch_250819b_CMYKGame.js"></script>
</head> </head>
<body> <body>
<div id="leader" aria-hidden="true"> <div id="leader" aria-hidden="true">

View File

@@ -1,2 +1,3 @@
main=sketch_250819b_CMYKGame.js
mode=p5.js mode=p5.js
mode.id=processing.mode.p5js.p5jsMode mode.id=processing.mode.p5js.p5jsMode

View File

@@ -128,17 +128,18 @@ function drawTarget(){
function drawOptions(){ function drawOptions(){
const gridRows = 2; const gridRows = 2;
const gridCols = 3; const gridCols = 3;
const gap = 16; const gapX = 16;
const gapY = 48;
const areaTop = height*0.6; const areaTop = height*0.6;
const cellW = (width - gap*(gridCols+1)) / gridCols; const cellW = (width - gapX*(gridCols+1)) / gridCols;
const cellH = (height*0.36 - gap*(gridRows+1)) / gridRows; const cellH = (height*0.36 - gapY*(gridRows+1)) / gridRows;
optionBoxes = []; optionBoxes = [];
let idx = 0; let idx = 0;
for(let r=0; r<gridRows; r++){ for(let r=0; r<gridRows; r++){
for(let c=0; c<gridCols; c++){ for(let c=0; c<gridCols; c++){
const ox = gap + c*(cellW+gap); const ox = gapX + c*(cellW+gapX);
const oy = areaTop + gap + r*(cellH+gap); const oy = areaTop + gapY + r*(cellH+gapY);
const opt = options[idx]; const opt = options[idx];
// laatikon tausta // laatikon tausta
fill(28,28,36); rect(ox-8, oy-8, cellW+16, cellH+16, 18); fill(28,28,36); rect(ox-8, oy-8, cellW+16, cellH+16, 18);
@@ -165,7 +166,7 @@ function drawGameOver(){
} }
function mousePressed(){ function mousePressed(){
if(state==='menu'){ startGame(); return; } if(state==='menu' || state==='gameover'){ startGame(); return; }
if(state!=='playing') return; if(state!=='playing') return;
// Tarkista osumat laatikoihin // Tarkista osumat laatikoihin
@@ -181,6 +182,7 @@ function touchStarted(){
// Estä sivun vieritys kioskissa // Estä sivun vieritys kioskissa
return false; return false;
} }
function handleSelection(i){ function handleSelection(i){
const chosen = options[i]; const chosen = options[i];
const distChosen = rgbDist(rgbFromCMYK(chosen), rgbFromCMYK(target)); const distChosen = rgbDist(rgbFromCMYK(chosen), rgbFromCMYK(target));