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

Username:   Password: 
 RegisterRegister   
 Using whatdotcolor with mouse (this ones for u dodge)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Skizzarz




PostPosted: Wed Jan 21, 2004 9:50 pm   Post subject: Using whatdotcolor with mouse (this ones for u dodge)

How do i get it so what dot color works with the mouse, i want it so that when i click on a purple ball it does something, this is my code, whats wrong?

code:
var nx, ny : int
var x, y, buttonnumber, buttonupdown, buttons : int
var posx, posy, dx, dy, randnum : int := 0
posx := Rand.Int (0, maxx)
posy := Rand.Int (0, maxy)
loop
    dx := maxx div 2 - posx
    dy := maxy div 2 - posy

    randint (randnum, - 1, 1)

    if randnum = - 1 then
        posx += Rand.Int ( - 1, 1)
        posy += Rand.Int ( - 1, 1)
    elsif randnum = 0 then
        posx += 1 * sign (dx)
    elsif randnum = 1 then
        posy += 1 * sign (dy)
    end if

    drawfilloval (posx, posy, 10, 10, 4)
    delay (10)
    cls

     mousewhere (nx,ny,buttons)
     if whatdotcolor (nx, ny) = 4 then
         put "ENEMY HIT!"
     delay (1000)
    end if

end loop


lol asian sensation, look familiar? Laughing
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Wed Jan 21, 2004 10:36 pm   Post subject: (No subject)

code:
var nx, ny : int
var x, y, buttonnumber, buttonupdown, buttons : int
var posx, posy, dx, dy, randnum : int := 0
posx := Rand.Int (0, maxx)
posy := Rand.Int (0, maxy)
loop
    dx := maxx div 2 - posx
    dy := maxy div 2 - posy

    randint (randnum, -1, 1)

    if randnum = -1 then
        posx += Rand.Int (-1, 1)
        posy += Rand.Int (-1, 1)
    elsif randnum = 0 then
        posx += 1 * sign (dx)
    elsif randnum = 1 then
        posy += 1 * sign (dy)
    end if

    mousewhere (nx, ny, buttons)
    if sqrt ((nx - posx) ** 2 + (ny - posy) ** 2) < 10 and buttons = 1 then
        locate (1, 1)
        put "ENEMY HIT!"
        delay (1000)
        cls
    end if
    drawfilloval (posx, posy, 10, 10, 4)
    delay (10)
    drawfilloval (posx, posy, 10, 10, colorbg)
end loop


basicly, I checked, by distance formula, to see if the click was in the circle. No whatdotcolor needed, because you are often dealing with flashing circles, and the color is not always guarentees to be red.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: