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; }
</style>
<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>
<body>
<div id="leader" aria-hidden="true">

View File

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

View File

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