Jump to content
  • Advertisement
Sign in to follow this  
JesseStruyvelt

Game Engine, based on a pattern..

This topic is 2523 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there all.

Since I started to write my own game engine I have encoutered much problems.. (I'm studying gamedev, therefore I was a webdeveloper).

And I'm asking myself the question if it would be possible to use the MVC (Model-View-Control) structure for getting an OpenGL Game Engine. Since I'm used to it to make MVC frameworks.
A game engine is just a framework that handles the user's code, and renders it to the screen? So basically and MVC would be just right for a game engine?


Model – Gameplay (game entities, eg. Player, Weapons)
View – Rendering
Controller – Input and non-gameplay flow (menu’s etc)

What do you guys think? Advising me anything else?

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement

And I'm asking myself the question if it would be possible to use the MVC (Model-View-Control) structure for getting an OpenGL Game Engine. Since I'm used to it to make MVC frameworks.
A game engine is just a framework that handles the user's code, and renders it to the screen? So basically and MVC would be just right for a game engine?


I suspect you'll find that everyone's definition of a game engine is likely somewhat different, but in my experience, a game engine is a collection of heterogeneous frameworks for handling one specific module of work (rendering, file i/o, events, physics simulations, sound, networking). An engine goes beyond a "framework" where it actually connects there different frameworks together in order to deliver a solution to a problem. Depending upon your generalization and use of abstraction, you may be able to buy the use of an engine for various games, but typically an engine is more specific than that and typically applies to a small subset of genre-like games.

Either way, I have seen some neat uses of the MVC pattern; however it wasn't applicable at the actual "core" of the engine. I have usually seen the MVC pattern applied mostly at the entity/component system framework around game objects and their behavior rather than at the lower level engine modules.

Share this post


Link to post
Share on other sites


Model – Gameplay (game entities, eg. Player, Weapons)
View – Rendering
Controller – Input and non-gameplay flow (menu’s etc)


It's certainly a good idea to keep these separate and loosely coupled. But don't get hung up on it. Most MVC and assorted pattern wisdom has its heritage in the enterprise [web] applications world, the usage patterns of which don't really align with video games.

Share this post


Link to post
Share on other sites

[quote name='Jessestr' timestamp='1324313568' post='4895351']
Model – Gameplay (game entities, eg. Player, Weapons)
View – Rendering
Controller – Input and non-gameplay flow (menu’s etc)


It's certainly a good idea to keep these separate and loosely coupled. But don't get hung up on it. Most MVC and assorted pattern wisdom has its heritage in the enterprise [web] applications world, the usage patterns of which don't really align with video games.
[/quote]
Agreed. The only time I've seen MVC expressed in game engines is shown below

Model - btRigidBody, MovableObject/SceneObject, AIObject
View - RigidBodyComponent, RenderableComponent, AIComponent
Controller - PhysicsSystem, RenderSystem, AISystem

Controllers manage components and the components hold a reference to a model object. Often these model objects are the lowest representation used by the internal framework that the system wraps. For example, btRigidBody represents a bullet physics engine rigid body for collisions. The component holds a reference to this object and the physics system simulates physics by stepping the bullet engine at a fixed rate interval each game loop.

Share this post


Link to post
Share on other sites

Hi there all.

Since I started to write my own game engine I have encoutered much problems.. (I'm studying gamedev, therefore I was a webdeveloper).

And I'm asking myself the question if it would be possible to use the MVC (Model-View-Control) structure for getting an OpenGL Game Engine. Since I'm used to it to make MVC frameworks.
A game engine is just a framework that handles the user's code, and renders it to the screen? So basically and MVC would be just right for a game engine?


Model – Gameplay (game entities, eg. Player, Weapons)
View – Rendering
Controller – Input and non-gameplay flow (menu’s etc)

What do you guys think? Advising me anything else?

Thanks in advance.

That is more or less what I've done in my engine (at the time I started my engine, around 1998, component based development was the current art and I was quite fond of the MVC pattern. As already said, a pattern alone should be just a pattern and I modified it for my purposes(more polling , less pushing data around etc.).

My current game is developed on this game engine and after more than 12 years of development, I must say, that it was one of the best decision I've ever made. The strong separation of model,view,controller helped alot to keep data separated at the right places. I can disable certain components without any problem, i.e. disable/remove the "view" components for a server only without touching any code. Several components, like the phyiscs component or input component, has been completly rewritten without much effect on the rest of the game engine.

You got my vote for a MVC like game engine :wink:

Share this post


Link to post
Share on other sites
My first exposure to the MVC pattern was creating a custom Joomla Web Component and its my intention to apply the pattern to the Game Engine's GUI framework. I believe that MVC can be accomplished at a `core` level within the engine by developing an internal GUI system that treats the entire 3D Game-world as a Graphical User Interface. GUI Entities (aka Widget) are constructed using aggregated Component Objects (see Entity Component Systems) that manage input, physics, and rendering. The Component Objects use a messaging system handles inter-communication between them, which is also suitable for MVC inter-com.

Share this post


Link to post
Share on other sites

Most MVC and assorted pattern wisdom has its heritage in the enterprise [web] applications world, the usage patterns of which don't really align with video games.


What? MVC existed more than a decade before the web as we know it existed.

And it aligns fantastically with video games, which often need to reuse game logic with different controllers (AI, testing infrastructure, replay engines, normal user, scripts) and different views (network chatter, AI feedback, testing infrastructure, normal screen UI).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!