Click here to Skip to main content
15,905,967 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Polymorphic pointer points to what? Pin
Cedric Moonen17-May-06 1:21
Cedric Moonen17-May-06 1:21 
GeneralRe: Polymorphic pointer points to what? Pin
Stephen Hewitt17-May-06 5:06
Stephen Hewitt17-May-06 5:06 
GeneralRe: Polymorphic pointer points to what? Pin
Cedric Moonen17-May-06 5:15
Cedric Moonen17-May-06 5:15 
GeneralRe: Polymorphic pointer points to what? Pin
Stephen Hewitt17-May-06 14:04
Stephen Hewitt17-May-06 14:04 
GeneralRe: Polymorphic pointer points to what? Pin
Cedric Moonen17-May-06 21:26
Cedric Moonen17-May-06 21:26 
GeneralRe: Polymorphic pointer points to what? Pin
Stephen Hewitt18-May-06 0:52
Stephen Hewitt18-May-06 0:52 
GeneralRe: Polymorphic pointer points to what? Pin
Cedric Moonen18-May-06 1:52
Cedric Moonen18-May-06 1:52 
GeneralRe: Polymorphic pointer points to what? Pin
Stephen Hewitt18-May-06 2:42
Stephen Hewitt18-May-06 2:42 
We'll stick with asteroids as that's the original topic. My original comment was against switching on object type, be it by using typeid, dynamic_cast or an enum in a base class. I don't think I need to go over this further given that the article I posted a link to explains it better than I could.

Now let’s get to the collision detection. As I pointed out you need not check for collisions between every pair of object as; for example, bullets can't collide with each other. If you've got n objects there are (n*(n-1))/2 = (n^2-n)/2 pairs to test: so it's probably a good idea to limit the size on n since the growth is quadratic. I admit in a game of asteroids, with today’s computers, you probably need not worry. I would probably use multiple lists as not every aspect of an objects behavior need be determined by it: some aspects can be controlled by its environment. For example, which container it's listed in. This need not be a limitation as you control which objects are added to which lists.

I don't want to get into too much of a debate however, as a lot of this is all theoretical. To really get into it we would need a concrete example to work with and spend some time analyzing it and then contrast different implementation strategies; that's a lot of work to win an argument.


Steve
GeneralRe: Polymorphic pointer points to what? Pin
Cedric Moonen18-May-06 2:58
Cedric Moonen18-May-06 2:58 
GeneralRe: Polymorphic pointer points to what? Pin
Stephen Hewitt18-May-06 3:44
Stephen Hewitt18-May-06 3:44 
AnswerRe: Polymorphic pointer points to what? Pin
Sarath C17-May-06 1:23
Sarath C17-May-06 1:23 
GeneralRe: Polymorphic pointer points to what? Pin
Cedric Moonen17-May-06 1:37
Cedric Moonen17-May-06 1:37 
GeneralRe: Polymorphic pointer points to what? Pin
markkuk17-May-06 3:18
markkuk17-May-06 3:18 
GeneralRe: Polymorphic pointer points to what? Pin
Cedric Moonen17-May-06 3:46
Cedric Moonen17-May-06 3:46 
AnswerRe: Polymorphic pointer points to what? Pin
Sarath C17-May-06 1:35
Sarath C17-May-06 1:35 
QuestionRe: Polymorphic pointer points to what? Pin
David Crow17-May-06 3:13
David Crow17-May-06 3:13 
AnswerRe: Polymorphic pointer points to what? Pin
SimonSays17-May-06 10:47
SimonSays17-May-06 10:47 
GeneralRe: Polymorphic pointer points to what? Pin
G_urr_A17-May-06 11:49
G_urr_A17-May-06 11:49 
GeneralRe: Polymorphic pointer points to what? Pin
G_urr_A17-May-06 13:14
G_urr_A17-May-06 13:14 
GeneralRe: Polymorphic pointer points to what? Pin
Stephen Hewitt17-May-06 13:52
Stephen Hewitt17-May-06 13:52 
QuestionWSAGetLastError() 10061 with connect() Pin
Just Baballa17-May-06 1:12
Just Baballa17-May-06 1:12 
JokeRe: WSAGetLastError() 10061 with connect() Pin
RicoH17-May-06 4:11
RicoH17-May-06 4:11 
QuestionRegarding timers Pin
Raja Bose C Leo17-May-06 1:04
Raja Bose C Leo17-May-06 1:04 
AnswerRe: Regarding timers Pin
Cedric Moonen17-May-06 1:11
Cedric Moonen17-May-06 1:11 
AnswerRe: Regarding timers Pin
Sarath C17-May-06 1:15
Sarath C17-May-06 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.