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

Username:   Password: 
 RegisterRegister   
 Help me with a mouse to graphic problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Vertico




PostPosted: Wed Apr 13, 2005 4:04 pm   Post subject: Help me with a mouse to graphic problem

i just would like to know how i could do it so that if i click somewhere on the screen with the mouse that an oval from the bottom corner will shoot out to that spot and stop there

i know to use Mouse.Where(mx,my,button) to get the x/y cordinates but i dont know how 2 get an oval from the bottom 2 go there and stop when it gets there
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Wed Apr 13, 2005 5:22 pm   Post subject: (No subject)

@possibility
Yes. Very much so.

@how to do it
If you know anything about vectors from physics, this should be no problem to do if you keep thinking along those lines. If not, think about a triangle from the bottom of the screen to the point (w/ the x & y axes being the opp. and adj. sides, and the connecting line being the hyp.). Now, think about movement as having a x- and y- componenet, and work from there.

Try this out first, if you get stuck repost, I'm sure someone will be able to give you a better explanation of vectors.

If you're really in a hurry, check out any of the many particle engines lying around. They have the basic concepts in there, you'll just need to apply them.
Token




PostPosted: Wed Apr 13, 2005 5:36 pm   Post subject: (No subject)

well if you wanted it to just be simple you could just draw it where you clicked, but if you are doing like Delos said then you'll need somthing like this

code:

setscreen ("graphics:max;max")
var x, y, b, playerx, playery : int := 0
var rise, run, bulletx, steps, bullety : real := 0


procedure shoot
    loop
        Mouse.Where (x, y, b)
        exit when b = 1
    end loop
    steps := Math.Distance (0, 0, x, y) / 2
    rise := ((y - 0) / steps)
    run := ((x - 0) / steps)

    bulletx := playerx
    bullety := playery

    loop

        drawfilloval (round (bulletx), round (bullety), 5, 5, blue)
        View.Update
        delay (2)
        drawfilloval (round (bulletx), round (bullety), 5, 5, white)
        bulletx += run
        bullety += rise

        exit when bulletx > maxx or bullety > maxy or bulletx < 0 or bullety < 0
    end loop
end shoot

colorback (white)
cls
loop
    shoot
end loop

its pretty self explanitory if you look at it closely, hope it helps. if you have any more questions just ask. and you should check the tutorials for help, thats how i learned
Vertico




PostPosted: Wed Apr 13, 2005 5:53 pm   Post subject: (No subject)

code:
'Distance' is not in the export list of 'Math'


got this error when i tryed running the program u had. Also u mentioned tutorial. can u give me the link to that. i tryed looking for it but could not find it.
Token




PostPosted: Wed Apr 13, 2005 6:02 pm   Post subject: (No subject)

Ummm, you need to update turing, or make it so that it finds the distance between those two points.
Martin




PostPosted: Wed Apr 13, 2005 6:06 pm   Post subject: (No subject)

code:
fcn Distance (x1, y1, x2, y2 : int) : int
    return ((x2 - x1) **2 + (y2 - y1)**2) ** 0.5
end Distance
Vertico




PostPosted: Sun Apr 17, 2005 4:42 pm   Post subject: (No subject)

i have another idea/problem. mostly i am wondering if its possible to have a "bullet" come from both ends of the bottom of the screen and come up to meet at the point clicked by the mouse. but meet there at the same time



so 1 "bullet" coming from the bottom left corner of the screen, and 1 "bullet coming from the bottom right corner meeting at the spot were the mouse was clicked.

so if the mouse cordinates was closer to the one on the left then the "bullet" coming from the right has 2 speed up so they both get there at the same time.

is this possible? and if so how do u exactly do this?
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  [ 7 Posts ]
Jump to:   


Style:  
Search: