Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Collision per vectors ?  (Read 4351 times)

0 Members and 1 Guest are viewing this topic.

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Collision per vectors ?
« on: September 23, 2008, 07:40:02 pm »
hello again =)

i have a breakout and now i want to now if the ball hits a rectangle, then it should bounce off

is there any possibility to manage that per normals- vectors?

or are if clauses better?

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Collision per vectors ?
« Reply #1 on: September 24, 2008, 01:47:26 am »
Try having a look at this. Of course there is other ways to do collision detection, but this is by far the easiest to implement.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Collision per vectors ?
« Reply #2 on: September 24, 2008, 09:30:33 am »
make a google search for "circle rectangle intersection" or something similar and you should probably get some good results :) but for a breakout clone i think rectangle-rectangle intersections will suffice. And they are dead simple to do :)
//Zzzarka

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Collision per vectors ?
« Reply #3 on: September 24, 2008, 10:52:55 am »
and how do i do it when i want to manage many bricks that disappear when hit?

something like a bool exists?

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Collision per vectors ?
« Reply #4 on: September 24, 2008, 11:16:06 am »
Quote from: "ravenheart"
and how do i do it when i want to manage many bricks that disappear when hit?

something like a bool exists?


yeah that will work :). you could also look into managing your objects dynamically in some way this would probably be a "nicer" solution start with checking out std::vector.
//Zzzarka

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Collision per vectors ?
« Reply #5 on: September 24, 2008, 12:12:39 pm »
and how can i get the direction from where my ball came? only collision is not enough, i need to know where the ball hit ,
my bat can be moved up down left and right, so i need to know in what direction the ball should bounce

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Collision per vectors ?
« Reply #6 on: September 24, 2008, 03:14:04 pm »
Quote from: "ravenheart"
and how can i get the direction from where my ball came? only collision is not enough, i need to know where the ball hit ,
my bat can be moved up down left and right, so i need to know in what direction the ball should bounce



prev_position - cur_positon = direction_vector

a good way of defining how the ball should move would be a direction vector and a speed value. then you just have to read up on some vector math and be ready to go :)
//Zzzarka

 

anything