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

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




PostPosted: Sun Aug 05, 2007 11:10 am   Post subject: Mouse Question

Im making a game where you click of boxes that do things depending on their colours etc... However im not sure what I should be using for the mouse. I tried Mouse.Where but I dont know the parameters, any help?!?

--edit--

okay, no answer yet, but i tried out the Mouse.Where and experimented with whatdotcolour. test it out, for now it just puts out 12 random boxes, blue or orange. to test the mouse, it'll say if the box is blue or orange, but shouldn't it only check when the mouse has been clicked? Also, is there a way to prevent the error of "oustside clipping range" ? Another question, i put GUI stuff at the start and end, is that necessary for Mouse.Where? heres the code...


code:

import GUI in "%oot/lib/GUI"
setscreen("graphics:800;600")
procedure boxblue(x,y:int)
    drawfillbox(x,y,x+50,y+50,9)
    drawbox(x,y,x+50,y+50,black)
    drawbox(x+1,y+1,x+49,y+49,55)
    drawbox(x+2,y+2,x+48,y+48,55)
    drawbox(x+3,y+3,x+47,y+47,55)
end boxblue

procedure boxorange(x,y:int)
    drawfillbox(x,y,x+50,y+50,42)
    drawbox(x,y,x+50,y+50,black)
    drawbox(x+1,y+1,x+49,y+49,43)
    drawbox(x+2,y+2,x+48,y+48,43)
    drawbox(x+3,y+3,x+47,y+47,43)
end boxorange

procedure boxerase(x,y:int)
    drawfillbox(x,y,x+50,y+50,white)
end boxerase

var xposition:int:=0
var difficulty:int:=1
var boxcolour:int

for z:1..12
    if difficulty=1 then
        randint(boxcolour,1,2)
        if boxcolour=1 then
            boxblue(xposition,50)
        elsif boxcolour=2 then
            boxorange(xposition,50)
        end if
        xposition:=xposition+50
    elsif difficulty=2 then
    elsif difficulty=3 then
    end if
end for

var x,y,c:int
loop
Mouse.Where(x,y,c)
    if whatdotcolour(x,y)=9 then
        locatexy(0,500)
        put "it is blue"
    elsif whatdotcolour(x,y)=42 then
        locatexy(0,500)
        put "it is orange"
    end if
end loop

loop
    exit when GUI.ProcessEvent
end loop 
Sponsor
Sponsor
Sponsor
sponsor
Aziz




PostPosted: Mon Aug 06, 2007 10:13 am   Post subject: RE:Mouse Question

First off, no you don't need the GUI module. You don't use anything from the GUI module (GUI.something).

Second, check out some of these tutorials:

http://www.compsci.ca/v2/viewtopic.php?t=3275
http://www.compsci.ca/v2/viewtopic.php?t=6

This code is correct:

code:
var x,y,c:int
loop
Mouse.Where(x,y,c)
    if whatdotcolour(x,y)=9 then
        locatexy(0,500)
        put "it is blue"
    elsif whatdotcolour(x,y)=42 then
        locatexy(0,500)
        put "it is orange"
    end if
end loop


That is a simple loop. You could replace the whatdotcolour check with check to the boundaries of the box. Say the box is at (10,10) to (30, 30). The check would be:

code:
if x >= 10 and x <= 30 and y >= 10 and y <= 30 then
    % some code
end if

...etc
Clayton




PostPosted: Mon Aug 06, 2007 7:18 pm   Post subject: RE:Mouse Question

Except, we won't be hardcoding those values in now will we? Wink
Aziz




PostPosted: Tue Aug 07, 2007 9:59 am   Post subject: RE:Mouse Question

Let me quote that Hyundai commercial:

Hyundai commerical wrote:
Duh!


Yes, the correct way to do this would to be have the box coordinates as variables. Or even better, make a 'box' type as a record that holds x1,y1,x2,y2.

Cheers, and good luck!
MichaelM




PostPosted: Tue Aug 07, 2007 5:36 pm   Post subject: Re: Mouse Question

thanks guys Very Happy
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  [ 5 Posts ]
Jump to:   


Style:  
Search: