A few initial questions about my first game (2D)

Found this forum through the multitude of helpful responses indexed by Google.

By way of introduction: I'm a formally trained (i.e degree in computing) programmer, with 10 years coding experience, mostly in Java (but lots of bits of other stuff, to varying degrees), and mostly financial applications. So I'm a newbie both in the sense of Objective-C and games programming. Been playing around with the SDK a bit, and finding Obj-C intuitive enough.

I am now embarking on my first game, and first iphone app (hey, I do enough 'serious' programming in my day job!).

Very brief description of the game:

1) 2 player abstract boardgame (bit like a cross between Go and Chess). One player is green, the other red
2) There are hexagonal pieces on the nodes of a hexagonal/isometric lattice (6 nodes to a side). The pieces can move from each node to the other along any of the six connecting lines.
3) Aim is to surround your opponent's centre piece with your 'strike' pieces.

So, I quite quickly got something working with Cocos2D, just to get a feel for how the board/pieces might look, and how one might control the pieces. It's just one 'Menu' scene, with a 'Start Game' option, which transitions to a 'Game' scene, with a PNG of the board, and 26 pieces placed on the board, and 'touch' enabled. Zero logic implemented (you can move the pieces anywhere, not just the node)

So some questions:

1) I want to get the game logic sorted completely separately from the interface; the primary reason being it makes no sense to fire up the simluator every time I tweak the game logic. The game is simple enough that I could easily represent the board state in ASCII, and issue simple 'move a,b to x,y' commands. Normally in the Java world I'd do this by just writing what's essentially a console based app. My first thought it to just use one of the non-iphone Xcode templates - but my worry there is I might end up using some Mac-only part of the Obj-C libraries. How do you guys manage this? I know you can do unit tests with the iphone, which I will defintiely do, but it wouldn't be a sufficient replacement for console-based development.

2) With the above separation in mind - would it also then make sense to do the game core in something a little more portable, like C++, and just leave the visual stuff in Obj-C? Both still have a bit of a learning curve for me, but C++ is more prevalent generally.

3) Given that the pieces/board are abstract (simple hexagons), they are easily described as vectors. In my initial tests, I actually created the pieces in a vector editor, then generated a .png. But I can see from the Quarz framework sample code from Apple that it's pretty easy to generate this sort of shapes. My worry is that it won't be possible to get the smooth anti-aliased effect you could get by using bitmaps. What would you recommend? Has anyone written an SVG XML file to Quartz converter? I can't decided in this case whether Cocos2D would be overkill? I can see the potential, if I have time, to have essentially 3D effects (the hexagonal pieces might, for instance, be made to rise above the board and turn, catching the light, before moving back down to their destination) - would it therefore make more sense to start from scratch with OpenGL ES? Also, to do the higlighting, would you just super-impose some alpha-belnded circle, or can you think of some other method?

4) Because the board is quite large, to fit it on the screen the pieces end up being about 30 pixels. This actually turns out to be large enough to accurately drag the pieces around, but small enough to be completely obscrued by one's finger. For that reason, I'm considering instead having the user tap once to highlight a piece, then tap a second time for the destination. I'd then like the piece to animate in a smooth speed up/slow down way. If there's a piece already in the destination, that piece should also simultaneously swap places. A further option for beginner player would be to highlight valid move destinations. What would be your methods/frameworks/libraries of choice for these kind of animations?

marcosscriven Wrote:1) I want to get the game logic sorted completely separately from the interface; the primary reason being it makes no sense to fire up the simluator every time I tweak the game logic. The game is simple enough that I could easily represent the board state in ASCII, and issue simple 'move a,b to x,y' commands. Normally in the Java world I'd do this by just writing what's essentially a console based app. My first thought it to just use one of the non-iphone Xcode templates - but my worry there is I might end up using some Mac-only part of the Obj-C libraries. How do you guys manage this? I know you can do unit tests with the iphone, which I will defintiely do, but it wouldn't be a sufficient replacement for console-based development.

2) With the above separation in mind - would it also then make sense to do the game core in something a little more portable, like C++, and just leave the visual stuff in Obj-C? Both still have a bit of a learning curve for me, but C++ is more prevalent generally.

Yes. I think the second question basically answers the first; if you implement the game core in pure portable code, you can just compile for the Mac for testing, then port to the phone to add the actual UI layer. Sounds like a perfectly sane approach to me.