Communication between objects in games?

  • Communication between objects in games? jmasterx

    I want to make a simple game where I have some characters fighting on a plane (level). I find the trickiest part as figuring out who should do what here.

    I want my terrain to have friction (so you could play on ice).

    I also want fairly customizable characters.

    At first I was thinking of a mediator pattern where the game gathers information about the current player state and modifies them based on that, but I do not think this offers enough flexibility.

    I was thinking more along the lines of each player / character does have some logic.

    The Input from the game gives it the command the player pressed, then the character would load the correct animation for this.

    As for friction and whatnot, I was thinking that the world would somehow need to multiply the player's velocity vector by its coefficient of friction. Because I don't think the player needs to know about the level (and preferably the level does not know about characters)

    It's in these little design aspects that I get a bit confused.

    Is this a good design? What could be improved / changed / added given what I want to do?


  • Well, it's not how I would do it. Since the velocity of the character is a property of the character, I would attach that information to the character. In fact, I would have the character know both its position and velocity, Heisenberg be damned. If that means the character needs to "know about" the level, at least insofar as being able to ask what the coefficient of friction is at its position so as to be able to update its velocity, then so be it. Radical decoupling is a virtue only toward a particular purpose, not in and of itself.

    I think you were on the right track to some extent with your mediator pattern, though. Pushing the control input directly to the character object and making it solely responsible for animation makes it awkward to, for example, have an action interrupted by external interference. I would make the character object responsible for modeling what it's attempting to do, while being open to being told that something else is actually happening by the mediator, and for providing animation information to a view which would do the actual management of the animation (rather than the character model doing so itself).

    This isn't to say that I think all logic should live in the mediator. As implied above, I would make the character model responsible for logic that's about it. The mediator should be responsible for resolving things in a broader scope.

c++ 2d architecture
Related questions and answers
  • areas of concern I have and wanted to get some opinions on the proper way others have solved them or would solve them. 1. Cyclical Dependencies When I was doing the game in C#, I didn't really have... question about it is, is this a worthwhile approach at all? If it's a bad design I want to know now before I invest too much more time making all the screens I'm going to need. How do you build up... sort of designs other people used to overcome them, or would use. For a little background, I started working on it in my free time last summer. I was initially making the game in C#, but about 3 months

  • program this effectively and efficiently? I am thinking to build this with C and Lua. C++ is also an option. I would store the game state and display the graphics using C. The part that I don't know how...The idea I have an idea for a game. A few games, actually, that can built on top of the same general design. There is a game world that the player and the other actors exist in. The player can get... actors. They are the player's competition. Instead of navigating the world and performing actions based on human input, a script should decide what they do. An example I want to do this using a 2d

  • My game will be made up of objects. Essentially the level editor will give me a bunch of objects to choose from and I can drag them in and thus a level is made. The objects could have animation..., but then I cannot do atlasing. I'd like to do atlasing. I was thinking that animated objects can just use their own frame sheet. But objects which are not animated should use atlasing. I know this can be categorized as premature optimization, but I don't want to eventually find out that it is horribly slow. Any design suggestions / comments would be welcome. Does it seem like a good idea to try

  • language, in my case Lua. On the other hand I want to use a component based design for my entities, and here starts my questions: 1) Should I define my componentes in C++? If I do this in C++ won't I...) Where should I place the messaging system for my game engine? Lua? C++? I'm tempted to just have C++ object to behave as servers, offering services to lua business logic. Things like physics system... instantiate them. All this, is what I can think of now. I know my editor can still be using game objects even if it is external, but the game am I into is for iphone using cocos2d and the editor

  • with different types of objects in the same scene. I was also thinking about making a MeshNode class and then make a Mesh object that contains them, but then I have some conflict on where to store some data... know if my speculations are ok, as I don't have much experience with 3d animations yet. I want to make a well decision as any option I choose would require a lot of work to get it to render and I... shader in every node. Other option I was thinking was making some helper functions to deal with the simpler cases, which would set some default parameters and would ask only the most basic ones

  • I've decided I want to write a central ResourceManager/ResourceCache class for my hobby game engine, but am having trouble designing a caching scheme. The idea is that the ResourceManager has...). If the resource isn't loaded, then the manager will mark the object to be loaded at the next opportunity, (usually at the end of drawing the frame). Note that, although my system does do some reference... is, to keep the total data usage hovering around / under the soft limit, the manager will have to have a smart way of determining which objects to unload. I'm thinking of using some kind

  • I've been thinking about adding 3d support in my roguelike. It would still be top-down like other roguelikes, yet it would have layers, such that things like platforms, tunnels, and bridges, etc, could be added to levels. Whether I do this hinges on whether I can get the fov routine I'm using working with the layers. Note that I don't care that it doesn't make sense to some of you that I'm trying to have a 3d field of view routine for a 2d roguelike. The roguelike does have a 3d space, and I want to determine what the player can see, even if what the player can see can't logically

  • in the process of building a hitmanesque game, just because i love that style of game and I want to increase my skills on something fun, so if you do know what i'm talking about have some examples...I am just curious as to how in many games (namely games like arkham asylum/city, manhunt, hitman) do they make it so that your character can "grab" a character in front of you and do stuff to them. I... model dynamically interact with whatever other model you come across, so in hitman when you come up behind some one with the fibre wire you strangle the other character or if you have the anesthetic

  • and likely won't turn out to be an actual game, I'll be happy to make a nice graphics demo and learn about 3d rendering and c++ design. My intent is to use direct3d9 for rendering as I have some little... be implemented for d3d11, opengl... My question then is what level is it best to do this at? I'm thinking that an interface capable of creating and later drawing Vertex buffers and index buffers Textures Vertex and Pixel "shaders" Some representation of drawing state (blending modes etc...) In other words a fairly low level interface where my code to draw for example an animated model would

Data information