Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Few mathsey problems

Options
  • 01-08-2001 9:07pm
    #1
    Registered Users Posts: 1,842 ✭✭✭


    I'm writing a little game at the moment, and have become kind of stuck. I'd be grateful for any help anyone can provide.

    It's a little windows Spacewar! clone, and I need some kind of collision-detection, because it's pretty damn useless otherwise! smile.gif

    First problem is to know when a missile has hit a spaceship, or to put it another way, when a given point is within a given circle.

    The information I'd have for this is:
    mX,mY, missile x and y co-ords

    sX, sY, spaceship center co-ords, and sR, radius of the circle.

    I really have no idea how to go about this...

    The other problem is the lasers, I need to know if a line goes through a given circle. Could probably adapt the solution of the above problem?

    Information available for this is the x,y values of both points of the line (laser) and the circle x,y and radius as above.

    Please help, game is useless without collision detection smile.gif


Comments

  • Registered Users Posts: 27,645 ✭✭✭✭nesf


    It's not complicated really, you could just write a subroutine to check if either if
    the distance (mx,my) to (sx,sy) is = sR

    If it is then a missile has hit. You can use simple junior cert level geometry for this.

    You could write a more complicated sub for the second prob, where you check the perp distance from the line to the centre of the spaceship circle, leaving cert formula, if this is <= sR then you got a hit.

    Any help to you?


  • Closed Accounts Posts: 1,136 ✭✭✭Bob the Unlucky Octopus


    Moved to programming- the math folks there could probably help you more smile.gif

    Bob the Unlucky Octopus


This discussion has been closed.
Advertisement