![]() |
Not logged in, Join Here! or Log In Below:
|
|
Hello everyone, I was thinking quite a while on this problem, but could not figure it out! |
|
There are many ways of doing what you want, but here's one suggestion. |
|
I think your teacher is basically trying to make you understand the difference between a *game* and an *engine*. |
|
I am indeed happy to understand one very simple, in fact straightforward concept: "What is"! What is a grenade, a mine, a door, etc... :) You opened my eyes, thank you!!! Another question is if the messages, or events that are happening are also two categories: game-specific and engine-specific. And I obviously have a difficulty separating game from engine. I can tell why: for example player pressed '2' key, which changes from current weapon to the second one. The change of skins should happen when the animation of "holster current weapon" is over. Here I stuck in the mud. Animation shoud be part of the "engine" and weapons part of the "game", should they? How will the engine send a message to something it doesn't "know" about? Most of all, changing of skins is not a common functionality of all entities, or am i wrong? |
|
One more thing I doubt about: For example, when some explosion(visual) has to happen, the engine must be able to render it. So, I suppose that engine should support it, and render through the basic funcionality data, no matter how deep in the entity hierarchy is the caller??? |
|
OK, I see an example is in order - you asked that if the engine needs to control game-specific elements, how can it accomplish this if it has no knowledge of the game built upon its foundation functionality?
Now the engine need only store a list of engineInputObject's, and call handleInputEvent on them, the magic of inheritance will do the rest (pah). The same technique can be expanded to all of your game and engine related classes... possibly :o) -Scoot |
|
Scoot answered part of your question, about event handling, but not the part about skin changes. So you're basically wondering: playing an animation is the engine's business, but how will the engine know that it has to do something (change the skin) after the animation has finished? |
|
I still think you should try to completely divorce your engine from game code. The animation and skinning part can all be accomplished using inheritance in much the same way as the input-handling mechanism i explained earlier...
NOTE: all of the base functions are fully overridable to produce totally different behaviour in more advanced objects. I hope you can see how this base object can be extended to support any type of geometry and animation data, and can then be further extended to react to events signalled by the base objects (in much the same way as my previous post). In this way your engine can operate solely on base objects, with the inherent functionality *automatically* called - all with the engine needing no knowledge of the way you have overridden the base objects. -Scoot |
|
I read "Game entity factory" in GPG3, where a gameCharacter can own a State and Media manager, while you suggest that the character 'is a' animation object... Well, I certainly cannot immediately decide which is more suitable :) |
|
Well i don't really understand your reply - because I would need to know a lot more about your engine construction. |
|
While inheritance is an absolutely valid way to construct your object system, it can make it brittle. I don't have a good concrete example, so here are a few ugly ones:
Again, this is a pretty incomplete example, but here your Character isn't locked into a single representation. It can do whatever it wants, as the gameCharacter is the 'controller' of any engine supplied functionality that exists. Inheritance is certainly an okay starting place; if your hierarchy is likely to stay shallow, it may work very well. In my experience, the deeper a hierarchy gets and the more problematic it can be. |
|
In reality it is very difficlut to COMPLETELY separate the engine from the game. So you must decide on general things vs. specific things. |
|
I was off the discussion so I could read and exeriment, and I got to some ideas. |
|
Here is a class I am currently making in c# that addresses the gameentity/gameobject issue.
As you can see the actual texture that the object in question would use is determined by the texture state enumeration. So if the state of the object in question has changed from Alive, Damaged, or dead it loads the appropriate texture. Of course a lot more code would have to go into control what actually changes the states.
GameObject could be abstract and GameEntity could inherit the base information from GameObject. GameObject defines base characteristics that any object would require to appear (be rendered) in a game world. Where GameEntity defines the behaviour of a particular type of gameobject in the world. GameObject(render) -> GameEntity(behavior) -> GameObjectOrc(A Orc) GameObject(render) -> GameStaticObject(static items) -> GameObjectTree(a tree) We could go further and make a Class called ORC and have it inherit from GameEntity -> the Orc class could then define the actual properties of the GameEntity class and possibly override the Methods defined within GameEntity. Start thinking in terms of Abstraction. If something is a type of something else look at the commom functions/and properties that may be required for commom items, and group these in a class. Slazer777 |
|
|
