Computer Science Canada Help, How do you make counters that act upon mouse clicks? |
Author: | icedesi [ Mon Jan 05, 2004 7:16 pm ] |
Post subject: | 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. Quote: %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. |
Author: | Thuged_Out_G [ Mon Jan 05, 2004 8:12 pm ] | ||
Post subject: | |||
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 |
Author: | icedesi [ Mon Jan 05, 2004 8:14 pm ] |
Post subject: | |
Thank you. - However I still don't Get it. |
Author: | recneps [ Thu Jan 08, 2004 5:06 pm ] | ||
Post subject: | |||
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
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 |
Author: | recneps [ Thu Jan 08, 2004 5:07 pm ] |
Post subject: | |
OR! you could use radius' of circles and stuff.... i dont have time to figure that out right now gl |
Author: | CITC [ Thu Jan 08, 2004 8:09 pm ] |
Post subject: | |
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 |
Author: | DanShadow [ Thu Jan 08, 2004 8:46 pm ] | ||
Post subject: | |||
Or if your lazy, use whatdotcolor!
Hope that helps. (The delay is too make sure the counter doesnt give like 3 points for one click. ) |
Author: | santabruzer [ Thu Jan 08, 2004 9:18 pm ] |
Post subject: | |
where's the whatdotcolour warrior when you need him |
Author: | DanShadow [ Fri Jan 09, 2004 3:00 pm ] |
Post subject: | |
Good question, lol. Well, I, the Demon Array Master , shall fill in for him in his absence, mauahaha. |