SFML community forums
Help => General => Topic started by: ravenheart 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?
-
Try having a look at this (http://www.gamedev.net/reference/articles/article735.asp). Of course there is other ways to do collision detection, but this is by far the easiest to implement.
-
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 :)
-
and how do i do it when i want to manage many bricks that disappear when hit?
something like a bool exists?
-
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.
-
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
-
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 :)