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

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 | 2 Comments

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

Studying Old Games

I had a thought yesterday as I was heading to my “Intro to Film” class. In that class, we watch a few recent movies, but most of the movies and clips we watch are black and white films from decades ago. We study those because the effects are more simple and rough, not as smooth/hidden/perfect as modern-day films. Also the technology was more limited, so for example the movie we watched last night didn’t have zoom because it wasn’t invented yet (the camera had to dolly forward to “zoom” which isn’t quite the same). There also, obviously, wasn’t CGI, so any editing was done by hand.

Anyway I got to thinking, what if the same applies to computer games? We game developers constantly play modern games which are massive and complex and made by huge teams of people, but maybe it would be good for us to go back and seriously spend some time in the older, simpler games — the games which were created with older technology by fewer people with smaller budgets. Maybe those would be more realistic for me to play and try to imitate, rather than attempting a huge game which is way out of my league and failing.

Posted in Uncategorized | Leave a comment

From Chrome and Firefox to Safari

I often switch back and forth between Google Chrome and Mozilla Firefox. I can’t make up my mind! Chrome seems fast, even noticeably so right after switching from Firefox. But then I get annoyed by some little “niggle” of Chrome and end up running back to Firefox. Later Firefox starts being more unstable and it’s back to Chrome.

Well now I’ve decided to give Safari a good try, since I never actually gave it a wholehearted try. I’m so used to automatically shunning Internet Explorer that I equally shunned Safari as soon as I got my MacBook Pro.

It’s awesome that Adblock Plus is a Safari extension too, and works just as well as the Firefox version. I probably wouldn’t even consider using Safari without it. I can’t stand ads! Also Lastpass of course works in Safari and it seems to work just as well as Firefox, too! Xmarks worked well too, syncing my few bookmarks (mainly just the bookmark bar).

Other than developer extensions, the only other extension in my Firefox is Flashblock, but I’m hoping I won’t need that in Safari. I’ll see for sure, but my hopes are that the Flash plugin works well in Safari, in contrast to the many times it has slowed or frozen Firefox and Chrome (or even crashed, pretty frequently).

Only time will tell if I stay with Safari!

Posted in Uncategorized | Leave a comment

Game Development Stack Exchange

Wow, did I actually write all of this? And is it really 19 points higher than the second best answer? I hardly remember this time period, when the website was just starting with very few active members and I was obsessively answering questions and climbing towards the #1 spot on the site.

I did reach #1, and stayed there for quite some time (a month or two?), but by then I had lost interest. Or to phrase it better, other people started being active on the website and I felt like my job was being done for me. Where before I felt a responsibility to answer questions because they might not otherwise get answered, now other people smarter than me were posting great answers and I had little to add. So I pretty much left and focused on school work and other stuff.

Now I’m wondering if I should hop back on the site, at least to observe and read all the great game development knowledge that’s going around, and maybe answer a question here or there.

(by the way, I’m currently #3, my username is Ricket)

I’m nervous about my future as a game developer. It sounds like it can be a tough field to break into, and I’m a little worried that I will just end up as some other type of developer and just making games on the side. Is that such a bad thing? No, of course not. I’m not really worried if that’s where I end up. I just need to be ready for defeat when I apply to the various game companies around here. The likelihood of them hiring me is very low despite how skilled I may think I am.

And of course, as with any job, I need proof that I’m a good game programmer. I don’t have that proof yet (because I’m not a good game programmer yet).

Posted in Uncategorized | Leave a comment

Artificial Sweetener Stories

I was told the story of how Splenda was discovered by my professor in swim conditioning class several semesters ago. But I had no idea that every artificial sweetener has something of an interesting discovery story connected to it! I grabbed these from Wikipedia, but each one has credible sources. For each of these success/luck stories, I wonder how many similar events have happened where more dangerous chemicals have been ingested by scientists and didn’t have such good results.

Saccharin was first produced in 1878 by Constantin Fahlberg, a chemist working on coal tar derivatives in Ira Remsen’s laboratory at the Johns Hopkins University. The sweet taste of saccharin was discovered when Fahlberg noticed a sweet taste on his hand one evening, and connected this with the compound which he had been working on that day.

Cyclamate was discovered in 1937 at the University of Illinois by graduate student Michael Sveda. Michael Sveda was working in the lab on the synthesis of anti-fever medication. He put his cigarette down on the lab bench, and, when he put it back in his mouth, he discovered the sweet taste of cyclamate.

Aspartame (Equal, NutraSweet and Canderel) was discovered in 1965 by James M. Schlatter, a chemist working for G.D. Searle & Company. Schlatter had synthesized aspartame in the course of producing an antiulcer drug candidate. He accidentally discovered its sweet taste when he licked his finger, which had become contaminated with aspartame, to lift up a piece of paper.

Sucralose (Splenda) was discovered in 1989 by scientists from Tate & Lyle, working with researchers Leslie Hough and Shashikant Phadnis at Queen Elizabeth College (now part of King’s College London). While researching ways to use sucrose as a chemical intermediate in non-traditional areas, Phadnis was told to test a chlorinated sugar compound. Phadnis thought that Hough asked him to taste it, so he did. He found the compound to be exceptionally sweet.

Posted in Uncategorized | Leave a comment