----------------------------------- icedesi Mon Jan 05, 2004 7:16 pm Help, How do you make counters that act upon mouse clicks? ----------------------------------- I am making a game that involves a ball that constantly moves and you must click on, however i want to make a counter that keeps track of how many times you have clicked on the ball. In addition, i would appreciate if someone can help me in the commented range that i have put in; when you type 'easy' , the value E1 = final thusly setting the difficulty of the game. %The 'Ball' Game (Original) %%%%%% Choosing Portion %%%%%%% setscreen ("offscreenonly") setscreen ("graphics:400;350") var easy, medium, hard,text :string var final:int const E1 := 0.1 const M1 := 0.3 const H1 := 0.9 % put "Hi!" % % put "Type Easy, Medium, or Hard to begin!".. % % get text % % case text of % % label "easy" or "Easy" then E1 = Final? - need help on this. % % %%%%%% Function Portion %%%%%% var ballx, bally : real var ballxmov, ballymov : real ballx := Rand.Int (0, maxx) bally := Rand.Int (0, maxy) ballymov := final ballxmov := final loop cls colorback (black) drawfilloval (round (ballx), round (bally), 5, 5, 10) if ballx > maxx and ballxmov > 0 then ballxmov := -ballxmov elsif ballx < 0 and ballxmov < 0 then ballxmov := -ballxmov elsif bally > maxy and ballymov > 0 then ballymov := -ballymov elsif bally < 0 and ballymov < 0 then ballymov := -ballymov end if ballx += ballxmov bally += ballymov View.Update end loop %And making a counter to show amt of clicks on ball. ----------------------------------- Thuged_Out_G Mon Jan 05, 2004 8:12 pm ----------------------------------- var x,y,button:int var counter:=0 loop Mouse.Where(x,y,button) if the user clicks on the ball then counter:=counter+1 end if end loop for the click part...it would be something like if x>then the x coord of the ball and y< then the y coord of the ball then counter:=counter+1 ...something like that, im not positive though :? ----------------------------------- icedesi Mon Jan 05, 2004 8:14 pm ----------------------------------- Thank you. :D - However I still don't Get it. ----------------------------------- recneps Thu Jan 08, 2004 5:06 pm ----------------------------------- this is the mouse command i know (im not exactly sure if i got all parts here... but you can look it up in turing help var x, y, button:int buttonwait("down", x, y, button) %something liek that if x ballx - ballwidth then counter:=counter+1 elsif y bally - ballheight then counter:=counter +1 end if note: you'll need to either create constants ballheigh ballwidth, or just input the height and width of the ball where i said ballheight ballwidth :) hope that helps ya ----------------------------------- recneps Thu Jan 08, 2004 5:07 pm ----------------------------------- OR! you could use radius' of circles and stuff.... i dont have time to figure that out right now :) gl ----------------------------------- CITC Thu Jan 08, 2004 8:09 pm ----------------------------------- read the help file on the Mouse.Where thingy if you still don't understand that part. its bad to just use code without understanding it. BTW, for that counter := counter + 1 I like to use (since its shorter and the exact same thing) counter += 1 :-) cheers ----------------------------------- DanShadow Thu Jan 08, 2004 8:46 pm ----------------------------------- Or if your lazy, use whatdotcolor! var counter,x,y,b:int:=0 loop Draw.FillOval(200,200,20,20,12) mousewhere(x,y,b) if (b =1) and (whatdotcolor(x,y)=12) then b:=0 counter :=counter+1 delay(5) end if Hope that helps. (The delay is too make sure the counter doesnt give like 3 points for one click. :wink: ) ----------------------------------- santabruzer Thu Jan 08, 2004 9:18 pm ----------------------------------- where's the whatdotcolour warrior when you need him :P ----------------------------------- DanShadow Fri Jan 09, 2004 3:00 pm ----------------------------------- Good question, lol. Well, I, the :twisted: Demon Array Master :twisted: , shall fill in for him in his absence, mauahaha.