Re: Last Screenshot

I suppose I should explain my last post a bit further. I got a bit carried away making a test GameScreen, and had a little fun with some sprites. They all slowly scroll down at different rates. However, even if I did get a bit carried away, I did discover a few interesting things.

In the update function of the GameScreen, I had dropped a call to my Logging class to keep an eye on what was being rendered. In doing so, my framerate took a considerable hit – going from smooth to less than a single frame per second. At first I thought this was because of my recent changes to my logging class (which now raises an event when a new message is logged, so that other things can listen in to it, rather than it knowing about those other things). I was a bit worried that raising that many events per frame had killed my framerate, or that something that was listening to that event was killing the framerate. That was only partially true. The real root of the issue turned out to be that I was calling it inside a loop. A loop that was getting called 1500 times. Per frame.

Moral of the story: Don’t do stupid things in loops.

I also did a little bit of thinking last night about how I’d like to do some sort of basic scripting system. I was in the process of creating a couple variables that track whether to show some debug information or not, and thought to myself “This would sure be a lot easier if I could control this via some sort of variable through a scripting system, rather than having to add variables for everything in the code.” Bittermanandy already covered something like this with a fairly basic solution that allowed you to check options with a sort of true/false value. I’m thinking it could be handy to have something a bit more robust than that, that would allow variables of different types to be created. I realize that he later goes on to cover some more scripting type stuff, which is also pretty nifty.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s