baseballgirl292
YaBB Newbies
Offline
Posts: 6
problem with the mouse released funtion
Apr 17th , 2010, 5:24am
Hi, I'm making a click-based game. I'm using mousePressed and not mousePressed() in the draw function cuz there are different levels. I realize that there is a glitch with my logic and mouse can hold and move and get the game finish. Do i have to make mousePressed() function in order to make mouseReleased() work. if so how can i recall the function to work within draw. here's the main problem: boolean statments.. void draw () { if start-up == true{ statements} else if Mainhall1 == true{ statments} //other levels drawn// //objects appear in tool bar on the bottom screen// if bluekey == true { fill(0,0,255); ellipse(270,375,40,40); fill(0); ellipse (270,375,25,25); fill(0,0,255); noStroke(); rect(266,390,8,30); rect(244,420,30,7); rect(254,405,20,7); } else if redbook == true { drawing statements} else if greenstatue == true { drawing statments } //door and items clicks// //doors transition// //startup- to Mainhall1// if (mousePressed == true) { if ((mouseX > 125) && (mouseX < 260) && (mouseY> 185) && (mouseY<220)) { Mainhall1 = true; startup= false; keyroom = false; studyroom = false; mainhall2 = false; galleryroom = false; } //Mainhall1 to Keyroom// else if ((mouseX > 0) && (mouseX < 68 ) && (mouseY > 88) && (mouseY <180)){ startup = false; Mainhall1 = false; keyroom = true; studyroom = false; mainhall2 = false; galleryroom = false; bluekey = false; redbook = false; greenstatue = false; } //when correct key is clicked// else if ((mouseX>280) && (mouseX<360) && (mouseY>220) && (mouseY<310)){ Mainhall1 = false; keyroom = true; studyroom = false; mainhall2 = false; galleryroom = false; startup = false; bluekey=true; redbook = false; greenstatue = false; } //keyroom to studyroom// else if ((bluekey == true) && (mouseX>175) && (mouseX<235) && (mouseY>0) && (mouseY<75)){ bluekey = true; redbook = false; greenstatue = false; startup = false; Mainhall1 = false; keyroom = false; studyroom = true; galleryroom = false; mainhall2 = false; } //correct book// else if ((mouseX>110) && (mouseX<170) && (mouseY>190) && (mouseY<240)){ bluekey = true; redbook = true; greenstatue = false; startup = false; Mainhall1 = false; keyroom = false; studyroom = true; galleryroom = false; mainhall2 = false; } //studyroom to gallery// else if ((redbook == true) && (mouseX>20) && (mouseX<65) && (mouseY>80) && (mouseY<282)){ bluekey = true; redbook = true; greenstatue = false; startup = false; Mainhall1 = false; keyroom = false; studyroom = false; galleryroom = true; mainhall2 = false; } else if ((redbook == true) && (mouseX> 100) && (mouseX<140) && (mouseY>80) && (mouseY<260)){ bluekey = true; redbook = true; greenstatue = true; startup = false; Mainhall1 = false; keyroom = false; studyroom = false; galleryroom = true; mainhall2 = false; } else if ((greenstatue == true) && (mouseX>160) && (mouseX<230) && (mouseY>75) && (mouseY<230)){ bluekey = true; redbook = true; greenstatue = true; startup = false; Mainhall1 = false; keyroom = false; studyroom = false; galleryroom = false; mainhall2 = true; } } } so how do i incorporate mouseReleased and why does my game keep looping.