• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
BlinksTale

MVC and the in-betweens for game development

2 posts in this topic

Hello GameDev! I'm starting work on a new project now, and I want to fit it as nicely into MVC as possible. I feel comfortable distinguishing game logic from graphics from input, but I want to get better/cleaner at this. A couple edge cases still confuse me, for example, where do I put cutscenes? Is the timing between shots in game logic, even though it has no impact on the rules, or should it be 100% in graphics, since it's all visuals and no engine or interaction?

 

More what I'm trying to figure out (part 2) though is how to share information between the three. In my last game, I gave everything access to the game logic main file, and had things passed through a couple files to go up/down the hierarchy (from keyboardHandler to controller/input to model/game logic to playerHandler) but that felt sloppy to have things jump through so many steps. Any advice on this?

1

Share this post


Link to post
Share on other sites

I made my game client with a slightly modified MVC.

 

The MVC you think of with the database as model usually found in web development does not really suite a game engine, according to my own beliefs.

 

Here is what I did:

MVC+L (Model/View/Controller/Logic) because standard MVC does not state where your logic would fit into the architecture.

 

The model stores all persistent data, such as game objects, mouse pointer, open windows. A game object is a unique id with a number of properties. Like this

{

    id: 1231234

    mesh: "GruntyOgre.mesh"

    pos: 1, 3, 0

    speed: 0

    hp: 100

}

 

{

    id: 231231

    window: "MenuScreen.xml"

}

 

{

    id: 23123156

    mouse_pointer: "green_arrow.png"

    pos: 100, 231

}

It has no functionality other that creating, destroying game objects and adding/removing properties on game objects.

 

The view registers itself on the model and gets notified with game objects are created/destroyed or properties changed. When a game object with a graphical representation (for example having the property mesh) is created, it creates its own graphical object with the same id used to display stuff on the screen (including GUI).

 

The controller listens for input from keyboard, mouse, network etc, translates them to events and forwards them to the logic.

 

The logic is a state machine that does all logic (duh) in the game. It creates, destroys, changes properties in the model.

 

All 4 different layers are completely decoupled and only communicates with callbacks registered in each other.

 

This gives my engine flexibility and some interesting properties such as:

- I can choose not to create a view, thus I can make it easy to create a multiplayer game (if add the feature for the layers to registers themselves on remote machines).

- I can choose to switch resultions and even graphics implementations (opengl/directx) during runtime without having to shut down the game

- I can make any type of game with the engine by just replacing the logic layer.

- I can dynamically upgrade/restart all parts of the game but the model without loosing any game data (since the model is just a stupid container chances are low I would have to update it).

 

On a side effect, this architecture makes it also easy to add and remove features since changes can not cause shockwaves of changes outside their own layers.

Edited by flodihn
0

Share this post


Link to post
Share on other sites

I have discussed this methodology with my professors at University. Essentially the reply was, MVC doesn't fit exactly into a game system. Mike McShaffery, writer of Game Coding Complete uses something similar to it, and it could be worth reading his book (I'd reccomended either the third or fourth edition) in order to get an idea. Essentially, the way I see it, you have your game screens, intro, main menu, level 1, level 2, etc. But you define your logic completely seperately and use controllers to CONTROL the gamer as it were. Sometimes you just need to have the rendering and the logic closely tied together, games are awesome like that.... yeah. One method Mike uses is an event based system. The view (being the screen lets say) accepts input, handles rendering and playing sound. Events will trigger, for example, player is shot which will be sent to the logic which will update and if required return player is dead, and the screen will update accordingly.

 

Thats a pretty rough explanation, but should set you on the right track. Essentially what flodihn is saying.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0