This Week
Hello again TeamLiquid! Welcome back to my blog about the development of The Adventures of Sam the Pirate, the 2D platformer I'm creating as the final game project for my Bachelor of Software Engineering degree. Last week I covered the progress I'd made on the level editor, getting scrolling working, and performance issues I've run in to. This week I'll be talking about something, and showing off a couple videos I made during the week.
Progress
I managed to get the physics running at a frame rate of 60 fps, completely independent from the rendering frame rate. This has the benefit of 100% ensuring that everything is going to move around and react completely the same, no matter what machine you are running the game on. This also could open up the possibility of saving level replays, which is something I will definitely be thinking about in the future. Replays is not something I will be adding before the end of May, when I graduate, but it is something that I could add afterwards. If you want to know how I did it, this article is where I started. I did get stuck for a while on the last step, where you interpolate between the previous and current positions based on the ratio of accumulator time left vs your target delta time. Initially I was taking the result of this interpolation and saving it back into the current position, which was then used to render the object. As the article mentions, I ended up with a terrible stuttering effect. I don't think I quite understood the first time I read the article, that the result of the interpolation is the position you use to render.
Played around with movement a bit this week as well. Sped it up a bit, and now moving around feels a bit better. Some aspects of falling down, such as when you run off a platform, don't quite feel right. Almost seems like it takes a brief moment for gravity to actually take effect, so I'll be continuing to fiddle around with movement.
Performance
I tested the game at home over the weekend, on my laptop, and it was unfortunately completely unplayable. Debug mode simply sat at 0 fps, which was kind of depressing as it meant I couldn't really do any work at home. Release could be played, but the fps was massively unstable and swung up and down all the time, anywhere from 15, to 100. Somehow I've managed to get a bit of a performance increase this week, as I've noticed an fps increase, and I'm not even sure what I did. Maybe properly fixing the physics has helped, as previously there would be a small amount of time leftover at the end of the physics processing, which rolled over to the next frame. So eventually the physics system would process all the physics objects an extra time in order to keep up with the rendering. Now that this extra time is consumed, and there is no rollover between frames, perhaps everything is more stable and so I get an increase in performance? I'm not really sure but I don't know what else would have improved it so that is my best guess. The massive changes in fps in the release build on my laptop is something that points me towards this conclusion, so I'll find out next time I run it on my laptop.
I am still slightly concerned though, as like I said last week, I've still got enemies, moving platforms, etc to add in. So it is possible that performance will still drop to the point of being terrible and needing serious improvements. When I attempt a commercial release, I think I will definitely have to convert the rendering to OpenGL first, as I think it will be required to ensure better performance across a wider variety of machines. Using SDLs built in 2D rendering, which is what I am doing now, may probably be fine for the rest of the project, as long as it runs smoothly on these machines at school, I will be able to submit it for marking, demo it to the tutors, etc, no problem.
I will be testing it on my laptop at home again this weekend, and seeing if I really have improved performance enough to run it in debug mode at home. Otherwise I'll be seeing how performance goes over the next few months, before deciding whether I need to switch to OpenGL before finishing the project and graduating in May.
Videos
First up, I've got a gameplay video for you. You can see in this video that movement was pretty slow and floaty. As I mentioned earlier, I've been working on this and it is a bit better now, but I'll still be working on it.
Next up is a video of the level editor that I'm working on, and that I used to make the level shown in the gameplay video above. There is still quite a bit of work to be done here, both on UI stuff to create all the menus I need etc, and to allow me to add enemies, moving platforms, etc. I do quite like how I got the tiles to change depending on what other tiles are around them though, pretty pleased with that.
What's next?
Over the next week I will be continuing to fiddle with the movement, fix a couple bugs in the physics code relating to collision reactions and some jittering. I'll also be finally adding in new debug commands before my final alpha milestone is due next week.
Keep up to date!
Be sure to follow me on Twitter, and like the Facebook page to stay up to date on future content and blog posts when they happen. If you have any questions don't hesitate to ask, either through Twitter or Facebook!