Function wont work

Hey Everyone,
I have coded a very simple game which works perfectly except the part where the player loses.
I have a function called, dead with a condition that if deadSign == true show 2 pictures (PNG)
which one of the pictures is ReStart icon to basically reset the sketch and go back to the top of the Draw()
I have upload all the pictures + the sketch in a zip file

http://www.mediafire.com/file/ie024582qbnaq5y/myGame.zip/file

So if you download and play it.you will see the problem.
just start the game and then click GO - and then do nothing till timer hits 0
which mean you lose…
then you see the restart icon there…and you can even click on it…
but you see the problem…

i would really appreciate your help since im working on this work 2 weeks and cant figure this part out…

1 Like

sorry, i not know that game and i not know how to play,
yes, you put lots of work in it.

your restart after timeout question:
you must do some reset to return to beginning

  if ((mouseX>267) && (mouseY>119) && (mouseX<592) && (mouseY<166)) { //StarOver Button
    deadSign = false;
    lvl1 = false;
    lvl1nums = false;
    lvl2 = false;
    lvl2numss = false;
    lvl3 = false;
    lvl3numss = false;
    menu();
  }

nevertheless some other things seem to be bad,

try to move the canvas window and you see many other (level pictures ) flicker,
that means for me that you just draw all levels from start to death over an other
( well yes you do that in draw )
but in that functions you not disable them correctly
like when you check on

if (lvl1 == true) {

check “how long” that { } is, ( by placing the editor cursor behind the {
it should cover/disable the whole function i think.

1 Like

Thanks buddy,pretty good point…im gonna work on it, will post again…

@kornFusion===

  • as for your start button you have to reset all your booleans to false
  • in your code a lot of things are redundant: example in your menu(): you begin to show images then you add an if()…and show two or three of them, which is absolutely useless…
  • error line 166 (mouseClicked): if the user in the first level clicks there, it fires the winner level 3 and it s possible that this kind of event happens for other places; you can easily avoid that adding your booleans to the clicks so the user cannot go to the >level without having won the <ones.
if ((mouseX>442) && (mouseY>222) && (mouseX<472) && (mouseY<252) && lvl2winner && lvl1winner) {
    lvl3winner = true;
  }
1 Like

THe reason of redundancy is my stupid brain cant think like a programmer…i should code it like when mouseOver, scale that button.png file … but i couldnt figure it out so i used the stupid way lol

and thanks for pointing out that bug! i just realized those mouseClickes WORK EVERY WHERE!!!
But i used ur code which worked perfectly…so i have a lead now…

thank youu so much