Monday, May 19, 2008

SDL, Aggravations

First, as a side note I want to put a link in to my youngest brother's website: http://kendrick.110mb.com/. I wrote it for him. I'm debating trying to find work as a website freelancer and I would appreciate criticism on how the site looks and how much I should charge for what talents I have.

From what I've seen so far, I like SDL. I really like the idea behind it. What I don't like is the documentation that's available for it. I find it very lacking. I'm used to the Java docs and maybe I'm spoiled but I never knew how much I depended on having documentation readily available. I've subscribed to the SDL mailing list which I've heard is very useful but I always find mailing lists to be intimidating. There are plenty of tutorials out there on the internet on how to use SDL but from what I've seen, they seem to all be written in C. I have a hard time reading C code and I have no interest in emulating it. I know that C is faster than C++ but it's painful. So, learning SDL, although it may be relatively simple, is more difficult than it needs to be.

So about the game that I'm making. I don't have a name for it yet but its coming together in my head at least if not on code. I started my life as a computer scientist using Java. In some ways this was good; I treat object in C++ the way they're treated in Java (for the most part). But, I'm terrible at handling memory.

Its not that I forget to write deconstructors. I'm paranoid; I just don't know how to test my code properly. I had a bug in my redraw function. Redraw, of course is called every time the main game loop is run so this is a lot of times. My redraw function would add another layer onto the main SDL_Surface a number nearing infinite times. I watched my ram being filled using the System Monitor and when it was almost full, I hit the exit button. My ram jumped back to its normal half-used state. This made me very happy because now I know that the deconstructor for my linked list is at least clearing almost all the data.

Now, I need to rethink the way I have my code setup. If I want a sprite to move in Swing I would change its position and add it to the screen again. Using SDL that doesn't seem to work. I'll need to check if I can move surfaces around that are already added. It seems that way. Oh dear.

I really would like a good textbook on SDL.

No comments: