views:

91

answers:

3

I've created several Cocoa applications now, but I'm unsure of basic concepts of game development. I've written apps using very few custom interface elements and only very simple graphics work, and I'm looking to write a pretty basic 2D game to get started (but in realtime, not checkers or something (which I think I could handle already myself)).)

Here are some examples of the sorts of questions I'm encountering:

  • I'm putting drawing code in my game view, but I suppose I'll need some sort of loop telling the entities to update?
  • Should I then tell my view to update within that same loop, or should that be a separate thread?
  • How should I gather mouse and keyboard information?
  • Should each entity know how to draw itself, passed a context dictionary from the game view, or should the game view read each entity's properties and know how to draw everything?

Ideally, I'm looking for a tutorial with sample code that assumes basic knowledge of Cocoa, but absolutely no knowledge of game development. I'm not looking for a game library that handles these questions for me; I want to learn the answers and code something simple myself.

+1  A: 
corprew
A: 

Check out something like this: http://oreilly.com/catalog/9780596159863

Sounds like you're talking about desktop Cocoa on a Mac, and that will be different in some ways from an iPhone in terms of the lowest levels of the game loop update and some of the graphics and sound, but the anatomy of a game engine stuff is all the same. There are tons of books out there about iPhone game stuff, so I'd start there. Most of them talk Cocoa.

quixoto
+1  A: 

For a 2D game, learn CoreAnimation. That's the simplest and fastest path to a game that uses basic sprites/tiles. Additionally, you'll learn a ton of concepts that can be used in later games.

For keyboard/mouse info, just use Cocoa events.

Eventually you'll want to learn OpenGL for 3D or advanced 2D games, but you can do a TON with CoreAnimation.

Wade Williams