Thread: Question about Inheritence

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    There is no use in arguing about the low-level design of the fight system if the high-level design of the game is unknown. For example, in the typical JRPG style game, you have several game modes. You have the map mode, where you walk around. You have the menu mode, where you browse your inventory and stuff. And finally you have the fight (actually, you'd probably call it battle) mode that you enter when you stumble upon a monster.
    In such a design, Battle is very much a class, implementing the GameMode interface. It is passed two arrays of FightingCharacter (as opposed to non-fighting characters like shopkeepers) pointers, which denote the two teams involved in the battle. The Battle will query those characters for actions in turn. This will probably return a pointer to an Action object. The Battle will then tell the Action to execute itself, deducting or adding HPs and MPs as appropriate. The Battle will then query the characters for their status and decide if the battle is finished or goes on.

    Or you could have a completely different design.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Warming leftovers takes much longer than I expected. ;_;

    Is this your main point?
    The forth sentence was my point: a model where every action requires absolute knowledge of every actor is almost always the worst possible model.

    Frankly, all that rambling [...] trying to get across.
    That wasn't rambling, that was exposition. ^_^

    Overloading and static [...] aren't any special animations.
    O_o

    You have got to be joking. That doesn't even approximate the conceptual situation in my response to Bubba. (Though, it is an example of compile time polymorphism I noted as a possibility, and one that I also implied has many problems. You've managed to introduce every problem with a surprisingly simple bit of code.) That doesn't model a situation where each "IEntity" fights differently. That is a perfect model of where every "IEntity" fights exactly the same. (Worse than that, every fight is a series of repeated actions of every other fight.) The only thing that is different: what is shown when they do the same actions! Does that make any sense to you? Anyone?

    Oh, and if you really intend to ignore the true "kind" of "IEntity", you don't need a template.

    Soma

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by phantomotap View Post
    You have got to be joking. That doesn't even approximate the conceptual situation in my response to Bubba. (Though, it is an example of compile time polymorphism I noted as a possibility, and one that I also implied has many problems. You've managed to introduce every problem with a surprisingly simple bit of code.) That doesn't model a situation where each "IEntity" fights differently. That is a perfect model of where every "IEntity" fights exactly the same. (Worse than that, every fight is a series of repeated actions of every other fight.) The only thing that is different: what is shown when they do the same actions! Does that make any sense to you? Anyone?
    It makes big sense to me.
    Those are the basic requirements for a battle. If you don't like them, then specialize the template.
    It then calls animations for each. All the classes would need to do is derive from a common base class for the "basic" fighting animation. If it needs special animations, it could overload functions for the special animations.
    It makes perfect sense to me, so please, if you can, point out the problems and how to address them.

    Quote Originally Posted by CornedBee View Post
    There is no use in arguing about the low-level design of the fight system if the high-level design of the game is unknown. For example, in the typical JRPG style game, you have several game modes. You have the map mode, where you walk around. You have the menu mode, where you browse your inventory and stuff. And finally you have the fight (actually, you'd probably call it battle) mode that you enter when you stumble upon a monster.
    In such a design, Battle is very much a class, implementing the GameMode interface. It is passed two arrays of FightingCharacter (as opposed to non-fighting characters like shopkeepers) pointers, which denote the two teams involved in the battle. The Battle will query those characters for actions in turn. This will probably return a pointer to an Action object. The Battle will then tell the Action to execute itself, deducting or adding HPs and MPs as appropriate. The Battle will then query the characters for their status and decide if the battle is finished or goes on.

    Or you could have a completely different design.
    Actually, that sounds like a very nice abstraction, provided you need such a flexible design.
    Last edited by Elysia; 11-28-2008 at 10:09 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    There is no use in arguing about the low-level design of the fight system if the high-level design of the game is unknown.
    Who is talking about the design?

    Personally, I'm talking about the conceptual model of "Fight".

    Granted, I've made references to C++ to do it, but still...

    Soma

  5. #20
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Who is talking about the design?

    Personally, I'm talking about the conceptual model of "Fight".
    Where's the difference between design and conceptual model?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #21
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    It makes big sense to me.
    That's kind of sad, but not strictly relevant.

    Those are the basic requirements for a battle.
    Indeed.

    If you don't like them, then specialize the template.
    This is actually an implementation detail and not part of your model. (I originally addressed it because you offered it as a way to implement a model very different from yours.)

    Using compile time polymorphism as an implementation mechanism buys you all the problems of compile time polymorphism. Do you not know those problems? I'll give you an example, your save file loader function functions as a factory to load the player state: what type does that function return? Use some base you say? Which base should you return? Return "Hero" you say? How do you get '*player_hero' to work with a template? Use a reference to "Hero" you say? How do you specialize the template so that my "Wizard" "Fights" differently than your "Warrior" in the context of your source? Don't use a factory you say? How do you load the save state? Examine it and selectively load it into the correct type you say? How do you choose which execution path to take? Use templates to implement all of it you say? That is an option, but you had better have a very limited number of actors... like two.

    Actually, that sounds like a very nice abstraction, provided you need such a flexible design.
    Indeed. He needs a few points for that...

    Where's the difference between design and conceptual model?
    O_o

    If you have a flawed conceptual model you have no chance to design a reasonable model ready for implementation.

    I don't know much about chemistry, and if I start off with this flawed conceptual model than any simulation I make will be poor and any implementation probably worthless. How I choose to model the interactions between elements is one thing, but if I model the transition elements the same as the others, because I was working from this flawed conceptual model, you can bet my code will be virtually useless regardless of how perfect I modeled the interactions in my implementation.

    Soma

  7. #22
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If the design is what CornedBee is alluding to then I would agree that Fight would then need to be a class since it actually represents a larger object than just a simple action and probably opens up a whole set of new actions. But if the characters just fight one another in real time then I cannot see how making Fight a class makes any sense. Are you going to make walk, talk, and eat a class too?

    But without knowing the design it's impossible to say which is the best approach. It really depends on the circumstances.

    I don't like the template idea b/c it will only allow a hero and a monster to fight. It won't allow two monsters to fight or two heroes to fight. It also does not account for other 'interested' parties to get involved in the fight. But again I'm coming from a real-time non Final Fantasy style of fighting. Oblivion style fighting would be a good example of what I'm talking about. Fallout 3 or the Final Fantasy series would be an example of the type of fighting CornedBee is talking about.
    Last edited by VirtualAce; 11-28-2008 at 12:59 PM.

  8. #23
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by phantomotap View Post
    If you have a flawed conceptual model you have no chance to design a reasonable model ready for implementation.
    If you don't know the high-level design of the application, you don't even know what Fight is referring to. How can you make a reasonable conceptual model of it?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM