Help, How do you make counters that act upon mouse clicks?
Author |
Message |
icedesi
|
Posted: 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.
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Thuged_Out_G
|
Posted: Mon Jan 05, 2004 8:12 pm Post subject: (No subject) |
|
|
code: |
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
|
Posted: Mon Jan 05, 2004 8:14 pm Post subject: (No subject) |
|
|
Thank you. - However I still don't Get it. |
|
|
|
|
|
recneps
|
Posted: Thu Jan 08, 2004 5:06 pm Post subject: (No 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
code: |
var x, y, button:int
buttonwait("down", x, y, button) %something liek that
if x <ballx + ballwidth and x>ballx - ballwidth then
counter:=counter+1
elsif y<bally+ballheight and 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
|
Posted: Thu Jan 08, 2004 5:07 pm Post subject: (No subject) |
|
|
OR! you could use radius' of circles and stuff.... i dont have time to figure that out right now gl |
|
|
|
|
|
CITC
|
Posted: Thu Jan 08, 2004 8:09 pm Post subject: (No 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 |
|
|
|
|
|
DanShadow
|
Posted: Thu Jan 08, 2004 8:46 pm Post subject: (No subject) |
|
|
Or if your lazy, use whatdotcolor!
code: |
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. ) |
|
|
|
|
|
santabruzer
|
Posted: Thu Jan 08, 2004 9:18 pm Post subject: (No subject) |
|
|
where's the whatdotcolour warrior when you need him |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DanShadow
|
Posted: Fri Jan 09, 2004 3:00 pm Post subject: (No subject) |
|
|
Good question, lol. Well, I, the Demon Array Master , shall fill in for him in his absence, mauahaha. |
|
|
|
|
|
|
|