★ TouchArcade needs your help. Click here to support us on Patreon.

Some general Cocoa Game questions

05-06-2009, 11:04 AM
#1
Joined: Mar 2009
Posts: 10
Some general Cocoa Game questions

I'm really happy with how far I've come with my "game", but I've hit a brick wall. From what I can tell, it's because Model - View -Controller seems a very limiting way to make a game. Do games usually conform to MVC? I would like to have a "unit" class have many or all of it's resources in one set of .m and .h files. So all I would have to do is initialize the unit and things that normally go into the ViewController like IBActions are setup and I don't have to link this button with that unit to that action.

I also think that Interface Builder is hurting more then it's helping at this point. Is it even possible to make a game using IB? It was nice starting out, but I've gotten to a point where I can see the limitations in my code, because it's just setup for what I allready put on the screen in IB. I can't have the user "create" more units in the middle of a game.
05-06-2009, 11:47 AM
#2
Joined: Dec 2008
Posts: 180
Quote:
Originally Posted by Armchairpilot View Post
I'm really happy with how far I've come with my "game", but I've hit a brick wall. From what I can tell, it's because Model - View -Controller seems a very limiting way to make a game. Do games usually conform to MVC? I would like to have a "unit" class have many or all of it's resources in one set of .m and .h files. So all I would have to do is initialize the unit and things that normally go into the ViewController like IBActions are setup and I don't have to link this button with that unit to that action.

I also think that Interface Builder is hurting more then it's helping at this point. Is it even possible to make a game using IB? It was nice starting out, but I've gotten to a point where I can see the limitations in my code, because it's just setup for what I allready put on the screen in IB. I can't have the user "create" more units in the middle of a game.
I'd say 99.99% of the games on app store are done with OpenGL. I hate to break it to you, but that really is the way to go. (and IB won't help there at all).

Wooden Labyrinth 3D - Apple Design Award winner!
Multitask Madness - test your brain, challenge your friends!
Need quality iPhone consulting or custom applications? Check out my company's website at Qvik.fi!

05-06-2009, 01:53 PM
#3
Joined: Mar 2009
Posts: 10
OK, I'll have to look into that. I haven't been looking at OpenGL at all because I assumed that it was used only for 3D stuff. I knew you could do
2d with it, but I thought that's not really what it was used for. I'll start reading up on OpenGL. Thanks.
05-06-2009, 02:09 PM
#4
Contrary to the impression you'd get reading beginner's tutorials, you don't need IB at all to build an app. In fact, I'd recommend against using it. You can programmatically create and control views, and if you do you'll have a much better understanding of MVC and Cocoa programming in general.
05-06-2009, 02:32 PM
#5
Quote:
Originally Posted by eVp View Post
I'd say 99.99% of the games on app store are done with OpenGL.
I'm sorry, but that is incorrect. There are a ton of non-OpenGL games. If all you need to do is move 2D images on the screen, at a not extreme speed, OpenGL is massive overkill, and has a very large learning curve. Yes, OpenGL opens the door to more types of games, but it's certainly not a requirement for making a winning game.

And to the original poster, you don't need to use Interface Builder, nor do you need to follow strictly to any model. None of my games use Interface Builder or OpenGL, and probably don't conform perfectly to MVC. But I'm not saying sticking to the model is a bad thing to strive for.
05-06-2009, 02:41 PM
#6
Joined: Mar 2009
Posts: 10
Yeah, that's what I was slowly figuring out. IB looks great for traditional apps, but I started to realize how useless it is for games. I'm cool with not using IB, I just need to find some toutorials that don't use it.

I actually could create an extremely rudimentary game with what I have now. The code would just look horrid, because there would be a lot of code that's more or less the same for each unit on the screen (right now I only have 2).

I was just hoping I could shove a lot of the code that would be in the ViewController for each unit, into the unit class itself so all I would need to do is initialize that class and I've got all the stuff I need. And I'm hoping I can do that if I build the interface programmically instead of using IB. Is that a proper way of doing it, or does MVC stand even in a game where you're probably not going to reuse any of the code anyway?
05-06-2009, 02:53 PM
#7
Joined: Mar 2009
Posts: 10
Quote:
Originally Posted by Little White Bear Studios View Post
I'm sorry, but that is incorrect. There are a ton of non-OpenGL games. If all you need to do is move 2D images on the screen, at a not extreme speed, OpenGL is massive overkill, and has a very large learning curve. Yes, OpenGL opens the door to more types of games, but it's certainly not a requirement for making a winning game.

And to the original poster, you don't need to use Interface Builder, nor do you need to follow strictly to any model. None of my games use Interface Builder or OpenGL, and probably don't conform perfectly to MVC. But I'm not saying sticking to the model is a bad thing to strive for.
Cool, that's what I was wondering. I've been cobbling together information and how-tos on how to make iphone apps to apply them to a game, and most of them are very strict with MVC and I wasn't sure how well that applied to games. I'm hoping that this new iPhone Game Projects book by PJ Cabrera that's comming out in June will help get me on the right track.

Oh, here's the link to that book if anyone's interested:

http://www.amazon.com/iPhone-Games-P...1639451&sr=8-1
05-06-2009, 02:54 PM
#8
Try using cocos2d: http://code.google.com/p/cocos2d-iphone/

It's helped me a LOT with iPhone game development.
05-06-2009, 02:56 PM
#9
Joined: Mar 2009
Posts: 10
Quote:
Originally Posted by ImNotWorking View Post
Try using cocos2d: http://code.google.com/p/cocos2d-iphone/

It's helped me a LOT with iPhone game development.
Awesome! Thanks for the link.
05-06-2009, 10:28 PM
#10
Quote:
Originally Posted by Armchairpilot View Post
Awesome! Thanks for the link.
No problem. Good luck!