Click here to Skip to main content
15,897,226 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPolymorphic pointer points to what? Pin
G_urr_A17-May-06 1:12
G_urr_A17-May-06 1:12 
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 
Stephen Hewitt wrote:
I haven't thought it through, but I'd probably use multiple lists instead on one super list.


Mmmhh, I see a big restriction in that way of thinking: what happens if you want to add a new entity type, say 'bonus' (that gives you lives or new weapon) ? Then, you got a problem in your design because you have to manage a new list which can result in a lot of changes in the existing code...

Right now, what we are doing is that we have a factory that can create specific entities. The different entities register themselves in the factory at the program startup (in fact they register their name and a function that create one instance of the entity, so no need to modify the factoty when new entities are added, it's just map names to a creation function). So, if you want to create a new entity type, you just have to create the new class (and the creation function) and register it in the factory at startup and that's done ! No modifications in the rest of the code.
You will tel me: 'Ok, but to be used, these new entites needs to be created so you need to know if they exist or not'. In fact this step is not 'directly' required because the creation of the levels of the game is made through an editor. The editor retrieves the available entities from the factory and allow the end user to place them in the level (so, there also, there is no need to know these entities).

With your design, I see a flaw when you want to add new entity types that were not planned.

Stephen Hewitt wrote:
These distinctions should be reflected in our design to minimize the amount of work we need to do to detect collisions.


It's perfectly doable with the method I exposed you: in the ResolveCollision of each entity type, it's up to you to take action on one or several 'collisions type'

PS: I don't want to prove you're wrong, but this is an interesting debate and I'm interested in your opinion.


Cédric Moonen
Software developer

Charting control
GeneralRe: Polymorphic pointer points to what? Pin
Stephen Hewitt18-May-06 2:42
Stephen Hewitt18-May-06 2:42 
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 

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.