0

I'm working on creating games on OS X, using the Cocoa framework, the probably only and best way to utilize all the capabilities of this operating system. Since Cocoa is MVC, I have to frame my games around this style. Is there any problem with framing your game using a MVC design? What can I do to make game development easier or more efficient in Cocoa? To be particular, my method to creating games is displayed below:

Game Views

For each component in a game that can be rendered, I use a game view. For example in a 3D game with a GUI, a menu, etc., there would be a 3DView, GUIView, MenuView, etc.

Game Model and Logic

A game's data and logic are coupled together into separate objects that don't have much to do with Cocoa itself. For example, in a Tetris clone I made, there was a class for the Tetrimino object, with methods that affected itself and other objects, but not Cocoa. This applied to all other game objects.

Global Game Objects

The game views need certain data to render, and the game model needs to get its input from somewhere. So global objects are made that the model and view can both read and affect.

1 Answer 1

1

Design patterns don't have much to do with with languages you use. They attempt to separate an application to different elements in an effort to facilitate loose coupling and portability to different platforms to mention a couple.

I don't see why using MVC wouldn't be feasible in game development. The nature of the application very rarely defines the design pattern when it comes to views, etc. It is more your decision about what you want to use and available resources rather than enforcing specific choices.

Regarding your elements, I use namespaces a lot. For example, I have Model.3D, View.3D and Controller.3D but this is what I find convenient. I, also, use folders.

I am not very familiar with MVC (I use MVVM most of the time) but I think that your data and logic needs to spread out to both the model and the controller.

I am, also, not sure why you feel you need "global objects". I assume that when your game starts, you will have your first model (let's call it MainModel) and then whenever you need a new view you create its corresponding model and controller. So, your data from your "global objects" can be part of the MainModel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.