Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!






Thoughts on porting Syzygy to iOS

  Posted by jwezorek, 16 March 2012 · 1,249 views

I’ve started trying to figure out the way in which I’m going to port Syzygy to iOS. I don’t actually own a Mac — though I may get one this weekend — so this is all theoretical at this point.

What I have right now is an implementation written in C++ to the Win32 API. Part of this implementation is a very basic 2D game framework. This 2D framework has an abstract widget class that has render and update methods. I didn’t call this class “sprite” because it is more general (and basic) than a sprite class : it can be implemented as anything that knows how to update and draw itself. For example, I have text widgets, that call the Win32 DrawText function in the draw method. Widgets are contained in GamePhase objects; GamePhases have a vector of lists of widgets, where each widget list represents a layer, so the order of a GamePhases’s list vector is effectively enforcing a z-order. GamePhases have update and render functions that can do phase specific rendering (e.g. draw a background) and then call the render and update methods of the widgets contained in the layers. GamePhases also have a predicate “IsPhaseComplete” and an accessor “GetNextPhase” which are used along with update and render to implement the game loop.

That’s basically it as far as a game engine goes. This code clearly is not logically platform-dependent. In practice Windows leaked into the implementation in the Render method which takes an HDC as a formal parameter and elsewhere where I wasn’t being careful in avoiding Win32 types. So my initial plan on porting to iOS was to refactor the 2D game framework part of the codebase to be truly platform independent and then to find an open source 2D drawing library that someone else implemented on top of OpenGL ES and reimplement the rendering code in terms of that 2d library.

The trouble is the 2D OpenGl-based library surprisingly doesn’t seem to exist. There is a project that someone did called Gles2d which is what I want but it is orphaned and never adapted to iOS anyway. It was implemented for the GamePark32 hardware, I believe. So my options are

(1) Stick with the original plan and adapt the Gles2D codebase to iOS myself.
(2) Stick with the original plan and write my own 2D graphics in OpenGL ES layer.
(3) Throw out everything and reimplement the application to Cocos2d in ObjectiveC.
(4) Keep whatever I can of my code and re-factor to use the Marmalade framework in C++.
(5) Keep whatever I can of my code and re-factor to use Cocos2d-x in C++.
(6) Stick with the original plan and write the platform dependent drawing stuff to SDL 1.3.

Long story short, I think I’m going to do (5).

(1) and (2) are just not work I feel like doing at this time. (3) would be a good solution but I’d be locked in to iOS and would have to gain more competence at ObjectiveC development than I feel like investing time-wise at this point — however, I may end up doing things this way if it becomes clear that it is the easiest approach . (4) is out because I don’t think I need a very poweful game engine, Marmalade costs money, and I wouldn’t be using most of it. I’m ruling out (6) because I don’t really trust SDL 1.3 on iOS; maybe I’m wrong about this but SDL doesn’t officially support iOS and it just seems like there will be problems.

So (5) … Cocos2d-x is a reimplementation of the Cocos2d API but to C++ rather than ObjectiveC. It is designed for cross-platform (i.e. across iOS and Android specifically) and the project looks alive and well. There is even a Win32 build of it that uses PowerVR’s GLES emulator for windows so I could in theory start work without actually owning a Macintosh. The only problem I see with Cocos2d-x is that documentation seems to be non-existent and it is being developed by guys who are clearly speaking English as a second language so I may have trouble finding answers to questions and so forth … we will see.

Anyway, … thoughts?

Source




PARTNERS