Game Project: Weekly Recap #3

It's been slow going on the indie front with a major deadline coming up at the day job.  There's one positive spin for the lack of progress - recognizing that a solo developer can't do it all if the goal is to release a game within a reasonable time.

While I haven't given in and switched to Unity, I decided that writing components from scratch like a 2d OpenGL (+ES) renderer, key/mouse input (+touch) event handling, audio, etc for mulitple platforms is totally unnecessary.   So I looked into two C rendering/media/device libraries that supported both desktop and touch devices: Allegro and SDL.  After a brief look at Allegro, I settled on the newest version of SDL

It's been a favorite of C/C++ developers who needed a cross-platform media library with a (mostly) common interface.  There's support for just about any non-console platform you can think of.  And now that 2.0 has a release candidate and is under the more permissive zlib license, it seems ready for commercial use.

SDL isn't a panacea though.  It's not a game engine but an API C/C++ developers can use to implement the not-so-fun aspects of game development.  You still have to write the object system, AI, etc - the fun stuff.

An API that lets me write a traditional run loop under both OS X - Cocoa, Linux and Windows just feels right.

int main(int argc, char *argv[])
{
    if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        NSLog(@"SDL Failed to initialize : %s", SDL_GetError());
        return 1;
    }

    SDL_Window *win;
    win = SDL_CreateWindow("Overview Engine",
                           SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                           1024, 768,
                           SDL_WINDOW_SHOWN);
    if (win)
    {
        SDL_Renderer* renderer;
        renderer = SDL_CreateRenderer(win, -1,
                                      SDL_RENDERER_ACCELERATED |
                                      SDL_RENDERER_PRESENTVSYNC);
        if (renderer)
        {
            Game game;
            bool active = true;
            while (active)
            {
                SDL_Event e;
                if (SDL_PollEvent(&e)) {
                    if (e.type == SDL_QUIT) {
                        active = false;
                        continue;
                    }
                }

                game.update();

                SDL_RenderClear(renderer);
                /* 
                 * Render code goes here
                 */
                SDL_RenderPresent(renderer);
            }

            SDL_DestroyRenderer(renderer);
        }

        SDL_DestroyWindow(win);
    }
    else
    {
        return 1;
    }

    SDL_Quit();
    return 0;
}