views:

2667

answers:

7

I want to program a board game (similar to checkers) for the iPhone. Would OpenGL ES or CoreGraphics be a better option? What do most games of this type on the App Store use?

+4  A: 

OpenGL, if done right, will probably look better. However, my understanding is that it's a heck of a lot harder than CoreGraphics if you don't know how it works.

However, if you're unfamiliar with it, CoreGraphics is easier to pick up. I don't know very much about OpenGL, so when I was writing a game, I did it in CoreGraphics and it turned out pretty good.

Dave DeLong
+3  A: 

If your perspective is mostly top-view, the user view is at a fixed position, and you don't need runtime texture mapping or special lighting, then core graphics will be easier. Otherwise I'd go with OpenGL (or one of those third-party game-building kits like Unity that make it simple).

It really depends on what sort of look you're going for.

Ramin
+1  A: 

If you are not very performance hungry, which a board game probably isn’t, go with CoreGraphics. You get the luxury of working at a higher abstraction level and You also get some things you would have to write by hand, for example animations. (P.S. I assume You are talking about 2D.)

zoul
CoreGraphics for sure. It can easily handle animating 20 - 30 sprites on the screen at the same time with very little performance issues. It will be faster to modify because you can use tools like photoshop to re-build you images. OpenGLES might be really neat if you want to do maybe do some really cool camera moves or some really neat animations.
John Ballinger
You can certainly use your prized Photoshop with OpenGL too. Apple provides code to load UIImages as OpenGL textures.
Frank Krueger
+11  A: 

Actually, what I'd suggest in this case is Core Animation or even just UIViews themselves. If you do direct drawing of all of your elements in a single view via Core Graphics, then refresh that view for every animation frame, you'll get horrible performance.

I'd suggest drawing the discrete elements of the game board (pieces, counters, board squares, etc.) as individual UIViews or CALayers, then animating those layers or views around. UIViews aren't too much heavier than CALayers, and they use Core Animation behind the scenes to do simple movement, scaling, or fading animations. They can also respond to touch events. CALayers are useful if you want to build a more cross-platform (Mac and iPhone) game, or if you need to do more complex animations.

For a 2-D game, I'd hold off on OpenGL until you were absolutely sure that you couldn't get the kind of performance you want from Core Animation. OpenGL is a lot less elegant to code for.

For a good example of how to do a board game using Core Animation, Apple has provided the GeekGameBoard sample code. Although it's a Mac application, the Core Animation code can translate right across to the iPhone.

Brad Larson
+2  A: 

You might also check out cocos2d for iphone - it's a pretty full-featured 2d game library; it's got tilemaps, sprites, parallax, scheduling, etc. I'm using it for my game, and it's helped me quite a bit.

http://code.google.com/p/cocos2d-iphone/

John
A: 

OpenGL. It'll be worth it in the long run, and I thought the learning curve was even easier that CoreGraphics for 2D sprite stuff.

Nosredna
+2  A: 

For this one definitely core graphics and core animation. Jeff LeMarche has a sample template for a Black Jack game on his blog - I just finished a suduko puzzle this approach. As far as cocos2D which I am using for a platform game - openGL would not improve or enhance the graphics - it will definitely not make the graphics look better - you can photoshop your heart out on this one and feel safe and know it will look great. Learning Cocos2D for this is too much overhead - same with learning openGL ES - just use core graphics and get it out there. As far as knowing openGL ES for the future - of course - but you should understand Apple's "core" before attempting these.

TouchGameDev