Video Games: How I Started Programming


Video games are pretty much the reason I originally learned programming. The first game that really interested me was Paratrooper, which I played for the first time on my uncle's DOS computer. I asked him how people make games like that. I knew you could tell a computer how to do things with simple DOS commands like "dir" and "cd", but I couldn't wrap my little (probably less than 10-year-old) head around how one could tell a computer what a helicopter was or to make that helicopter fly across the screen. Unfortunately, my uncle couldn't explain that to me, at least not in a way that I found satisfactory. I was still curious, but I didn't pursue it further at the time, even after my family got our own DOS computer.

A few years later, when I was about 12 years old, my favorite game was Banjo-Kazooie. Before the game came out, I downloaded all the preview gameplay videos I could find, tying up the phone line for hours with the dial-up connection. I remember that the game came out in June and it seemed like an awfully long time to wait from the last day of school sometime in May. I was pretty obsessed. Anyway, at some point I remember visiting the website of Rare, the game's developer, and looking at their jobs page. It seemed like the main skill required was C++.

I didn't exactly know what C++ was, but I almost immediately went and told my dad that I needed to buy a C++ book. We bought Sam's Teach Yourself C++ in 21 Days. It came with a CD that contained a compiler. Although that probably wasn't the best way for a beginner to learn programming, it was enough to get me started. I remember being so excited about that book that I had to restrain myself from reading through it too fast. I tried to only let myself read one "day"/chapter each day and did all the exercises.

Of course, I was eager to apply my new knowledge to games. I think the first real program I made that wasn't an exercise from the C++ book was a Tic-Tac-Toe game with ASCII graphics. I had a lot of fun making that game and creating the opponent "AI". But after doing that, I decided that I needed to learn how to draw real graphics.

I bought another book and this one was specifically about creating games. I learned how to control the graphics card using VGA mode 13h. I was so excited the first time I was able to draw a simple square on the screen. And I was even more excited when I could move that square around using the keyboard.

I started trying to make a clone of Paratrooper. In that game, you can rotate your gun's turret using the keyboard. I tried to trace out a circle, but I didn't really know how to do that. I took a guess at what I thought must've been the distance formula: x + y. Of course I had no idea that what I was looking for was called the "distance formula" or that the formula I'd used was Manhattan distance rather than Euclidean distance. But when my circle ended up looking like a square, I figured I better go learn some more math. I started reading my dad's old trigonometry book. It was a bit of a challenge for me since I hadn't taken Algebra yet, but I was able to find what I needed. I'd credit that experience with helping to spark my interest in math.

By the time I entered high school, I already had a pretty good grasp of the fundamentals of programming. And my projects got more sophisticated as I learned about Win32, DirectX, and 3D math. I created a simple, yet fully-functional top-down 2D space shooter and then a 3D version of the shooter. But once I entered college and started doing summer internships, all of which involved writing other sorts of programs, it seemed like there just wasn't enough time to work on games as much anymore.

Over the last 9 years of my career as a professional software engineer (outside of the game industry), I've occasionally started a new game project here and there, but never really gotten very far on them. I'd like to get back into game development, even if it's still only just a side project. I've recently started learning Unity 3D and Blender, but I'll talk about that in a future post. This post actually started off as an introduction to that post, but I got carried away and just decided to make this its own post.

The Bird Door


My girlfriend has a pet lovebird. When I was a kid, I had parakeets. But I was careless with going in and out of the house while the birds were out of their cage. One day, they flew away and I never saw them again. When my girlfriend and I were planning to move in together, I was very excited about having a pet bird again, but I didn't want to repeat that mistake. I knew we'd both be coming and going from the apartment at different times. And with a very adventurous, curious bird that needs at least two hours out of its cage every day, that was going to be a problem.

I figured other bird owners must have this problem too, so I searched online for solutions. I wanted to have a double door of some kind to keep the bird safe. I wanted something like what zoos have for their free-flight bird exhibits. Since we're renting, it would have to be something that could be installed temporarily. However, I wasn't really able to find any products that I could buy.

At first I was thinking about using something like a curtain rod. There are ones that hold themselves up with friction by pushing against the walls. I thought I might hang "strip curtains" from that. But ultimately, I decided that curtains might not be secure enough. I decided to try building a real door using the same principle of the curtain rods of pushing against the walls.

Push clamps

I didn't know how to achieve the pushing against the walls. I started searching for "push clamps", not even knowing if those existed (they do, apparently). But I eventually decided I could do what I wanted with just two blocks of wood, a threaded rod, and a nut. I screwed the threaded rod into one of the blocks, but not all the way through. Then I drilled a hole all the way through the other block, large enough to let the rod pass through freely. By putting the nut on the rod in between the two blocks, I could control the distance between the blocks by moving the nut.


Although my pushing mechanism seemed to work pretty well, I wasn't sure if it would really hold a door in place securely enough. I needed to build a full prototype. My idea was to build a frame just large enough for the door and then have the "push clamps" on the sides to hold the frame in place.

As you can see, the frame sits on the floor, so the clamps don't have to actually hold the weight of the frame and the door. All they need to do is keep the frame from sliding out of place. And they seem to work well for that.

I was actually hoping the prototype could just be used as the final product, but I didn't know yet where we were going to be living once we moved in. My apartment at the time was just about the perfect layout for this idea. It had a long hallway upon entering the front door, which gave me the two walls I needed to push against. But I knew wherever we moved into might not be so ideal. So I just did my best to make the design very general.


One thing I needed to do was make sure that the materials and parts I was using would be safe for the bird. There was no chance that the bird wouldn't end up chewing on the door eventually. For the wood parts, I used untreated Douglas fir 2x4s. For the metal parts, I used stainless steel. The only exceptions were parts that would be out of reach for the bird because they're on the opposite side of the door.

Here are some links I found helpful in selecting parrot-safe materials:

The door itself

The door itself is simply a hollow rectangle of 2x4s. The 2x4s are connected with half lap joints and glue. I had pretty much no woodworking experience when I started this project and very limited tools. But after watching a lot of Paul Sellers videos on YouTube, I decided to try making the joints by hand with a hand saw and a chisel. It took a long time, and I wasn't able to get the faces of the joints very flat, but it worked out. Even with the big gaps I had in the joints, they are very strong and rigid.


The frame that holds the door is also just a rectangle of 2x4s, but larger and with the boards rotated 90° so that the frame is "deeper" than the door. I got lazy and just used butt joints with screws for the frame — no glue. This is not great, because the frame is a bit wobbly. But it worked alright because my push clamps hold the frame in place and keep it from wobbling.


The last thing I did with the prototype was install an automatic closer. I went and bought the cheapest one they had at Home Depot, which was around $10 or $15. It was pretty easy to install. I don't think I had really planned out where the closer would go when I started the project, but fortunately I had room to mount it on the frame without it getting in the way of the door. To stop the door from swinging beyond parallel with the frame, I simply nailed a small piece of wood to the top of the frame in the right spot.

Final location

When we decided where we were going to live, I wasn't sure that I'd be able to make the bird door work there. It's a townhouse and the entrance leads immediately to a set of stairs. There isn't really a good place for the door at the bottom of the stairs. At the top of the stairs, the wall on one side ends right at the top, so I can't use my push clamps against the walls like in my previous apartment.

Since I don't have two walls to push against, I decided to use my clamps on the ceiling instead.

Clamping against the ceiling worked fine for keeping the door in place. However, the door no longer closed properly because the frame around the door was sagging out of square. I hadn't realized that when I was using my clamps against the walls they were keeping the frame from sagging side-to-side. The ceiling clamps, however, don't prevent that.

Wall grabber

The solution I came up with is something I call the wall grabber. It's basically an 'h'-shaped piece of wood that cantilevers off the end of the wall. This effectively extends the wall a bit, allowing me to use that wall to hold up the door frame and keep it from sagging to the side. As with the rest of the project, the grabber is not permanently attached to the wall. I built the grabber to fit the thickness of the wall as closely as I could so that it would mostly just hold itself up. But to make sure it stayed in place, I also just propped it up from the bottom with a 2x4 that leans against the wall.

This works surprisingly well, even though the grabber isn't really attached to the wall or the frame in any way.


The final thing that needed to be done was block the holes between the frame and the walls, and in the center of the door itself. I used a product called BirdBlock, which is pretty much like chicken wire, except it's made for gardening and it was cheaper because it's plastic.

I wasn't sure if the holes in the BirdBlock would be small enough to keep the bird from sticking his head in. I'm still not sure, actually, because he's never tried to do that. I was also wondering whether he'd be able chew through the wire, since it's pretty thin. Again, I can't say for sure because he doesn't really try to do that, but it seems like it might be too flexible for him to chew through it easily.

To attach the BirdBlock, I just cut it to the right size and then stapled it into place (using stainless steel staples). Since I didn't want holes in the walls, I just used tape to attach it to the walls. Surprisingly, the tape has held it on pretty well.

The only problem is that since the wire is so thin, it breaks easily. So if you accidentally get snagged on it on the way into or out of the door, you're likely to break it where it's stapled into the door. But we've only broken it in a couple places so far and it's nothing another staple or two couldn't fix.


Here's what the final product looks like.


After having used the bird door for the last year, I'd say that it's worked out even better than I imagined. It allows us to come and go without worrying about the bird's safety. I'm especially pleased that I haven't had to do any repairs, adjustments, or maintenance at all to the door during that time. Since I've never made anything like this before, I was expecting something to have to deal with some problems when we started using it on a daily basis. But it really has held up quite well.

If I were going to start over and do it again, there are a few things I'd consider changing:

  • I'd add another 2x4 going horizontally across the middle of the door so that you have something to push against. As it is, you can't really push the door open with your body when you have your hands full because there's nothing to push against except the BirdBlock.
  • Speaking of the BirdBlock, I'd consider using something stronger. The fact that it's so easy to break is a little annoying. However, whatever I replaced it with would still need to be flexible enough to wrap around corners. Also, it would probably need to be light enough to allow being taped to the wall.
  • I wouldn't cut the half-lap joints entirely by hand. That took forever. Since I did that, I've learned that the more typical technique would be to cut a bunch of slots with a circular saw, knock out the remaining pieces with a hammer, and then clean it up with a chisel. See
  • I would probably use real joints (i.e. something other than a butt joint) for the frame so that it would stay rigid on its own, without the clamps holding it. However, that would also mean I'd have to be more careful to make the frame and door the right size and keep them square.

This was a pretty fun project for me. I'm a pragmatic guy, so I enjoy building things that are going to be useful for me. And this is something that I use every day. Plus, the constraint of not modifying our apartment presented some interesting problems to solve. Another reason I liked this project was that I got to learn a lot about building physical stuff, which is something I don't have much experience with. I also accumulated several new tools that I can use on future projects.

Anyway, I hope you found this interesting. Thanks for reading!

Noise Textures


When I was in college, I wrote a program just for fun to generate Perlin noise textures. Perlin noise is technique used to create natural-looking textures — clouds, for example.

Later, for a technical writing course, I created a more user-friendly interface for that program and a web page where people could download the program, along with the source code. That page was the most popular part of my website — it was the first Google result for "perlin noise generator" at the time.

I also posted the source code for my program on that page. I eventually learned that my implementation of Perlin noise wasn't truly Perlin noise after all, but rather a simplified version. I hadn't realized that at the time because I hadn't taken enough math courses yet to fully understand Ken Perlin's original papers. I took down that site long ago, partly because I was embarrassed about having propagated that mistake. But strangely enough, you can still find copies of that source code on the web by searching for some of the variable names.

Anyway, true Perlin noise or not, I thought it might be fun to re-write that UI in XAML and submit it to the Windows app store. The version I submitted is about the same as my original version, except with a prettier, touch-friendly UI. Someday, I'd like to add more features and make it more of an educational tool to let people see visually how the noise is generated. But for now, it's fun to play with and can generate some pretty cool images.

Download the Noise Textures app

Adding Disqus Comments


I'm adding Disqus comments to this blog. It was really easy to set up. When I was using WordPress and its comment system, I got tons of spam despite having basically no audience. I only ever saw one legitimate comment, which was buried in thousands of spam messages. Hopefully this will go better.

My Robot


I've posted about robotics stuff before, but I never actually talked about the robot I was building. I haven't done robotics stuff lately, so I won't go into much detail, but I thought I should at least share this video of my robot that my dad took.

As you can see, it's basically just a slow remote-controlled car. Nothing fancy. Still, I'm kinda proud of it because I designed it myself, picked out all the parts, wrote the software, and even built the chassis out of wood.

One interesting part of the project was that I built the motor controller circuit myself. It was fun for me because I got to do a lot of soldering, which I haven't done much before (as you might be able to tell from the picture below).

Most of the code I wrote is just the "driver" for the Xbox 360 controller using the GHI USB library. Here are some links I found useful for interfacing with the controller:

It's not shown in the video, but I also added a small video camera and LCD screen. Being able to see from the perspective of the robot is pretty cool, but that's as far as I've taken it for now. I'd like to use the camera for some autonomous behavior, but I'm guessing my mainboard wouldn't really be powerful enough to do any real-time video processing.

Anyway, that's all I have to say about the robot for now. But here are a few more photos of the construction: