Multiple Game Loops

All the game development books and tutorials teach one game loop. Sometimes they implement some sort of finite state machine, but they pretty much always use one main game loop, with some sort of conditional statements to choose what to draw at what time.

But why limit yourself to just one loop? The general format of a game loop is pretty simple, so instead of transitioning with booleans or a state machine object, why not transition with the natural flow of the language, by exiting one loop and entering another? This generally cleans up code. Take for example the following example main loop:

while(!userQuit) {
    clearScreen();
    if(stillLoading()) {
        loadingImage.draw();
    } else {
        stuff.draw();
        gui.draw();
        // etc.
    }
    presentScreen();
}

That’s just a simple example, and that conditional could potentially have more branches for transitions between levels, a pause menu, etc. But why not, for discrete states, do the following?

while(stillLoading()) {
    clearScreen();
    loadingImage.draw();
    presentScreen();
}
while(!userQuit) {
    clearScreen();
    stuff.draw();
    gui.draw();
    // etc.
    presentScreen();
}

This is much cleaner and easier to follow.

Posted in Uncategorized | Leave a comment

Downloading Content From Mediasite

If your professor disabled the ability to download the lectures, here’s the way to get around it. First, here’s the snippet you will need; then read below it for instructions.

javascript:__doPostBack('__Page','DownloadPresentation:1299fb37-f10a-31be-97fe-0224842e6cdd')

On the lectures list, hover over the link to the lecture you want and copy the peid from the URL. Put it after “DownloadPresentation” in the above JavaScript snippet, and add dashes exactly where that peid has them – you should have an extra “1d” on the end which you should just delete. Then run that javascript on the lecture list, and the download dialog will pop up.

Posted in Uncategorized | 5 Comments

Windows Event ID 50034 and 50068 repeatedly displayed

Are you getting events in the event viewer every few seconds? Event IDs 50034 and 50068? The text of event 50034 is “An error has occurred in initializing the adapter 15. Error Code is 0x1392” (perhaps a different adapter number), and event 50068 is “Address 192.168.1.100 being plumbed for adapter 15 already exists” (with a different address and/or adapter number). Here’s the solution:

First check if one of your adapters has a static IP address that you assigned it.

If not, then just disable one of the adapters. Suddenly the other one will be connected no problem. The reason is┬ásimply that one of the adapters was previously assigned address 192.168.1.100 (or whatever your error is saying), and even though that adapter is disconnected, it is still conflicting with your new adapter trying to become 192.168.1.100. The DHCP-client service won’t assign two adapters the same address, so it keeps renewing attempting to get a new IP, but the DHCP server (your router) keeps assigning it the same conflicting address.

It’s safe to leave the adapter disabled, but if you don’t like the idea of having one of your adapters disabled even when it’s unplugged, then re-enable it and plug it in to something which assigns the adapter (via DHCP) a new address. Then Windows will allow your other adapter to take the address it has been trying to get all along.

I saw this in my own laptop. It has an ethernet adapter (Local Area Connection) and wireless adapter. The ethernet was unplugged and I was trying to connect to my wireless network, but the wireless network kept connecting and disconnecting repeatedly. The solution was to disable my local area connection adapter. Then suddenly the wireless one was connected! The underlying problem was some static DHCP settings I had set in the past.

Also, if you’re reading this and it fixed your problem, you probably also enabled static DHCP like I did. If so, make sure to assign a different IP to each of your adapters even to the same computer; i.e. assign 192.168.1.100 to the ethernet adapter and 192.168.1.101 to the wireless adapter. Even if they will never both be connected at the same time, this and other problems can arise by them being set to the same DHCP address.

Hope this helped you. Feel free to add any other information in the comments below.

Posted in Uncategorized | 1 Comment

MIDI Lag

I got a keyboard (piano) and USB-midi module for it for Christmas a few years ago from my dad and step-mom. I played around with it quite a bit but there was always a huge lag of about 1 second, so it was really tough to do anything good with it.

I just dusted the piano off and plugged the USB thing into my MacBook Pro and then opened up GarageBand. I was surprised to find there is zero lag.

I always assumed the lag was because of the USB interface causing a delay or something. But nope; it was Windows’s fault. I tried all sorts of settings, even tried it across different versions of Windows, and different programs. Everything in Windows had a delay, I was so CERTAIN that it was the USB module! But just now I literally muted my piano’s output and played the piano with the sound coming out of my MBP’s speakers. There was no delay at all. That’s incredible.

And of course it was as easy as plugging in the USB cord and opening GarageBand. Nothing to install or set up, it just worked. Hooray!

Posted in Uncategorized | Leave a comment

This is the safety warning notice that came with my Cr-48. I love the sense of humor.­čÖé

Posted in Uncategorized | Leave a comment

Firefox Problems

Here is an account of my latest browser switches, for documentation purposes.

In Safari I read a news item about a Firefox update, to 4 beta 10. The changelog listed some improvements which matched the reasons I moved away from Firefox: “Compatibility and stability improvements when using Adobe Flash on Mac OS X” and “Improvements in memory usage”. So I decided to give it another try. It’s really awesome! I think I feel most at-home in Firefox (at least on Mac; in Windows I clearly prefer Chrome and have finished juggling browsers).

But for a while now I’ve noticed that it develops a weird stutter. Like every few seconds, it will freeze for about one second; it’s not so noticeable when browsing, but when a YouTube video keeps freezing in place, well, it bugged me.

I got out a watch and found that it happened every 10 seconds. How convenient! There is a HUGE difference between doing a Google search for “firefox stutters periodically” and “firefox “every 10 seconds”“; the latter search returns every instance where someone has complained about Firefox doing something every 10 seconds, and I don’t imagine what else it might be other than freezing.

So I found some old articles. Apparently Firefox used to freeze every 10 seconds due to saving the tab session, which is the feature that will reload your tabs if the browser crashes or if you close and reopen it. There was a config option to change that, but it already defaulted to 15 seconds, so I didn’t think that was it. Nevertheless, I changed it to 300 seconds (5 minutes) and restarted Firefox. Soon after, the every-10-second stutter was back.

I couldn’t find anything recent or specifically relating to OS X. I then ran around my add-ons, looking for preferences set to do something every 10 seconds, but there were none. I never actually took the time to try and disable each add-on to find a specific one that might be causing this problem, mainly because I don’t think I want to sacrifice any of my add-ons. I don’t have any extras as it is; they’re trimmed down to only the essentials that I use all the time.

So I’m back in Chrome now, because Firefox in my Mac OS X was stuttering every 10 seconds in YouTube videos and typing and pretty much everything.

Chrome seems to be the browser of choice for many developers nowadays anyway. It used to be the too-lightweight browser without extensions, but now it’s a very full-featured browser which directly competes with Firefox and in many cases is still lighter-weight in a good way.

Plus, it integrates with my Google account for syncing and such. When I first got my Cr-48, I turned it on and logged in with my Gmail username and password. Immediately, it pulled down my theme, extensions, preferences, and so on from my Google account. The whole browser (therefore the whole computer) was all set up, just because I’d already set up my desktop copy of Chrome and it synchronized everything with my account.

So I’m now in Google Chrome. I don’t remember what made me change from it last time, but hopefully if I find it again, it will either have been fixed or I will remember to write it here so I can move forward instead of continuing to go in circles.

Posted in Uncategorized | Leave a comment

Google Cr-48

A Google Cr-48 arrived on my doorstep Monday! I’ve been using it nonstop since then. I’m still giving it thought but I’ll post a blog entry detailing it soon. Suffice to say I love it though!

Posted in Uncategorized | Leave a comment