Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Mouse CLiCK
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
coolest35




PostPosted: Tue Dec 02, 2003 9:27 pm   Post subject: Mouse CLiCK

Hi Smile , i have previosly made a battleship game, which the user can click on the grid to draw a miss or a hit 8) , that is what i used, now i have another assignment Embarassed where i need buttons, how can i do this Question Rolling Eyes .. i mean i don't understand i just for got everything! Crying or Very sad
below is a part of the script i used on my battleship! lemmie now if you want the whole file .. ok.. i'h attached it so check it out.. and help me out thanx!

code:


 elsif mnpx >= 120 and mnpx <= 160 then
        x := 2

    elsif mnpx >= 160 and mnpx <= 200 then
        x := 3

    elsif mnpx >= 200 and mnpx <= 240 then
        x := 4

    elsif mnpx >= 240 and mnpx <= 280 then
        x := 5
    elsif mnpx >= 280 and mnpx <= 320 then
        x := 6
    elsif mnpx >= 320 and mnpx <= 360 then
        x := 7
    elsif mnpx >= 360 and mnpx <= 400 then
        x := 8
    elsif mnpx >= 400 and mnpx <= 440 then
        x := 9
    elsif mnpx >= 440 and mnpx <= 480 then
        x := 10
    end if

    if mnpy >= 159 and mnpy <= 199 then
        y := 1

Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Tue Dec 02, 2003 9:55 pm   Post subject: (No subject)

Clicking on a grid is a little easier. For your BS you could have basically used:
x:=(mnpx-160) div 40 + 2
y:=(mnpy-159) div 40 + 1

When you are clicking on a button (and not using the GUI) your need to check 5 things

mouseBtn = 1 and mouseX >= buttonX and mouseX <= buttonX + width and mouseY >= buttonY and mouseY <= buttonY + height
coolest35




PostPosted: Tue Dec 02, 2003 11:35 pm   Post subject: what ? ??

i don't under stand that 1 bit.. if anyone has other ways that this can be.. done.. plz post them.. thnx Confused
Tony




PostPosted: Wed Dec 03, 2003 12:41 am   Post subject: (No subject)

eh... another way of doing it would be to grab your X/Y values... and then just figure out what cell its clicked on. Easiest example would be if grid starts at 0,0 and each cell is 10 pixels wide.

code:

%get x/y values
%row is y/10
%column is x/10
cell(x/10,y/10) = true


or something... basically figure out what part of the grid is being clicked.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
McKenzie




PostPosted: Wed Dec 03, 2003 12:58 am   Post subject: Re: Mouse CLiCK

coolest35 wrote:
code:
now i have another assignment  :oops: where i need buttons,


When you say buttons, do you mean that you are clicking on a box to do something? Something like:

code:
var mx,my,mb:int

% the button
drawfillbox(50,60,90,80,green)

loop
mousewhere(mx,my,mb)
if mb =1 and mx > 50 and my > 60 and mx < 90 and my < 80 then
put "The green button"
end if
end loop
coolest35




PostPosted: Thu Dec 04, 2003 7:12 pm   Post subject: Yep

Hi, i need to make a GUI Button for the following : LOAD DATA FROM KEYBOARD, LOAD DATA FROM A FILE, SHOW DATA, SHOW MOST EXPENSIVE, SHOW LEAST EXPENSIVE, SHOW AVERAGE PRICE, SHOW OUT OF STOCK, SHOW TOTAL WORTH, EXIT. How would i make them into GUI buttons.. the turing reference doesn't give me a clue.... thnx
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: