Friday, April 22, 2011

Build ZDoom from source in Xcode 4

Update 5/8/2011 I have received word that this tutorial works with Xcode 3.2.4 as well as Xcode 4. Thanks to andreb. I'd like to thank him for pointing out I could use the $SRCROOT variable instead of /absolute/path/to/workspace/ZDoom-Xcode.

When I was younger, I used to make maps and other mods for the popular old school game Doom. The community of mappers for the game was already quite established by the time I got into it, due to Doom being one of the original games to develop a large modding community. Even after it's heyday (and still to this day) the community thrives due to two things: the game is classically enjoyable and fun to mod for and the existence of source ports has kept the game relatively up to date. Almost no one runs vanilla Doom these days, due to the slow but steady deprecation of DOS support on many systems but plenty of programmers have kept the game alive by creating modified engines (or source ports) which run on modern operating systems without a hitch and add features to the game to make it more interesting while allowing it to keep it's charm and simplicity. This is thanks to John Carmack and id Software's open sourcing of the Doom engine back in 1997. ZDoom is one of the more popular updated engines and has been around for a long time.

A few years ago, I switched from PC to Mac and although I am happy with this change the one thing I left behind was gaming. Although I don't care too much these days if the latest game is being ported to OS X or not, I did miss some of the old games I used to play. There are so many free maps and add ons from the Doom community that just buying Doom, downloading a source port and getting some mods is enough to keep one entertained indefinitely. It will also only set you back about ten dollars to purchase Doom, making it extremely cheap gaming.

There are plenty of ports for Doom which release OS X binaries and these are all great ports, however ZDoom has such a large number of maps and features that you miss out on a lot of good mods if you aren't running it. I had never gotten around to running it on OS X before because they didn't have any binaries, but I finally decided to dive in and build it myself. Luckily, they support OS X by using CMake, but unluckily, nothing works perfectly and this is what had halted me from getting too deep before. As great as running CMake and then make would be, the build process doesn't work quite that easily. Before I continue however, I discovered that the DRD Team already hosted unofficial OS X builds of ZDoom so if you would like to spare yourself a headache and just download those, you can run ZDoom on OS X without building anything.

Wednesday, April 20, 2011

Space Opera, an x86 assembly arcade game

Screenshot of Space Opera, in action

Back in 2008, as a freshman in my second semester of college, I wrote a game in x86 assembly language as my final project for a core computer science class I was taking. The class was Computer Systems Organization, taught by Professor Nathan Hull and I think it was one of the more important classes that I took. This class came fairly early in the track (once you were out of the introductory Java classes) and it was one of the classes that began to explore the field of programming and computer science on a lower level than contrived OOP simulations of unrealistic problems.

A lot of people do not like learning assembly and it certainly is directly inapplicable in most fields these days, however I am one of the people who believes it is very important to at least have some experience in it because you really start to understand what is happening behind the scenes in any language once you have worked in it. To have such a low level knowledge of what is happening is useful and interesting, and I credit this class with helping to draw a clear line between my high school self and post-high school self in terms of understanding paradigms beyond introduction-to-Java type programming. Not to say that all the work I did in high school was that simplistic or bad, but that the mentality I had was rooted in easy to digest examples of OOP paradigms from introductory books and this starts to become limiting, at a point.

Thursday, April 14, 2011

Vintage 1970s haiku generator by my granddad

Ross Ainsworth Dierdorff, 1922-2011

Back in January, I received a bundle of my grandfather's papers, following his passing, from my uncle. The papers detailed a simple algorithm my grandfather written to randomly generate haikus. My uncle, who also works in the field of math and computer science, had wanted me to take the notes, the BASIC implementation and the hand written word lists and see if I could recreate the program.

In this day and age, writing a haiku generator would not be much of a challenge. It would likely be an extra credit assignment in an Introductory 101 Java class. I felt that porting from BASIC to a modern day language would be a bit backwards, when I could just write a haiku generator in a modern language using modern paradigms. However, if I were to do that, then all I would have is a haiku generator with no relation to the one I was trying to memorialize. The point would be missed, I realized, the more that I thought about it.

Then I realized that the point isn't to recreate a haiku generator, which is something today's technically inclined youth could teach themselves to do thanks to the abundance of freely available programming environments and introductions to programming and mathematics. The point is to put the original haiku generator on display, because what makes it better than a cheesy Javascript implementation* is that back in the 1970s, people like my granddad were programming computers to do things that were cool. Something like a computer program that generated haikus in the 1970s was not abstract mathematical nonsense. It was something real. You could show it off to your friends, enjoy the motivating feeling of tangible success and most importantly, have created something cool that breaks out of the occasionally dry realm of mathematics and science.

Wednesday, April 13, 2011

ActionScript foray into fast Fourier transforms

I am aware that this image matches my blog :) Preview my FFT implementation

Sometime late December/early January of this year, I realized that I would need to learn how to implement a fast Fourier transform in ActionScript and, quite honestly, in general. I was working on my game and as I said in a previous post, my game is partially reliant on a powerful audio engine I am working on.

Some people reading this may be aware that Adobe already has an FFT implementation. In their SoundMixer class, there is a computeSpectrum() function and if you choose true for the FFTMode boolean parameter, the spectrum returned will be a Fourier transform of the current frame of audio. However, this function is only available on the SoundMixer which is Adobe's static global sound control class and so the transform represents the transform of all sound going through the Flash application and not just, say, a single music track. This isn't a problem if all you are playing is the track you want to transform but this isn't always going to be the case. You may want to perform the transform on a music track, while sound effects playing in the background, for example.

I ended up writing an FFT implementation in ActionScript. However, it wasn't super fast and I shelved it for a few months. Recently, I decided to optimize it, so I spent the last few days cleaning it up and making a faster implementation. Although it is not as fast as perfect implementations written in C, I have managed to make it run fairly quickly, however it is optimized for real data such as audio (as opposed to data consisting of complex numbers).

Sunday, April 10, 2011

Gravity tables for side scroller physics

As I mentioned earlier, I am working on a game in ActionScript (in other words, a Flash game but one that is programmed as opposed to developed primarily on the timeline). It is a two dimensional side scrolling game and as expected, one of the main movements of the player (besides going right and left) is jumping (and by extension, falling).

In order to implement jumping and falling, not just for the player but for anything, I needed to build a rudimentary physics engine to handle gravity. Now, since this is just a two dimensional arcade style game the physics do not have to move beyond a high school level but they need to be implemented well.

Single serving website: Is Family Guy Currently Playing On Adult Swim?

Last summer, an idea came to me. I had been staying up late and watching Adult Swim on Cartoon Network and although I enjoy a lot of their programming, it is sometimes hit or miss for me. For starters, I really dislike anime a lot so whenever I turned on Adult Swim and saw anime it would be like a punch to the gut of disappointment. Although I enjoy Aqua Teen Hunger Force and The Venture Brothers, the show that is consistently funny for late night mindless consumption is Family Guy. So whenever Family Guy was on, I didn't have to worry about it being something that I wasn't that into playing on Adult Swim.

However, turning on the television to find out if Family Guy was on was not good enough, I soon realized. The let down from finding out something stupid was playing, quickly following the anticipatory turning on of the television, was too much for me. So I came up with a solution. I would create a website that would quickly tell me if Family Guy was currently playing on Adult Swim. Clearly, this was the easiest and least convoluted solution. And so was born.

Saturday, April 9, 2011

Make your music pump like Parisian house

The Prydzifier* (or Daft Punkifier or Parisian House-ifier)

First of all, welcome to my blog, to whoever may be reading it. This is my first post, as opposed to an introductory post, however in order to properly introduce my blog, I will say a few words about how it came to be. I am Samuel, a computer scientist who majored at NYU and this blog is designed to share my small projects and code that I am working on. It is pretty much a run of the mill software developer blog in which I ramble about things I have worked on and maybe someone will find it interesting or helpful.

That being out of the way, I recently have been working in ActionScript and Flash. I know that the initial reaction of many developers is one of distaste when hearing about Flash development, and I was one of those people fairly recently, myself. However after years and years of putting it off, I took a Flash Programming class my senior year because I knew that I should at least know how it works for my resumé, even if I didn't think I would ever use it.

As it turned out, I really enjoyed it and found it more powerful than I had expected. It still has many of the shortcomings you probably could rattle off to me in a heartbeat but it also is much cleaner these days than what I always imagined it to be like. Plus, the work I do in it is easily accessible inside the browser so that I can show off things I create somewhat easier. You also you have to have good development practices and knowing your application is going to be running inside Flash inside a browser means you really have to make sure that everything is coded tightly.

This post is specifically about a spin off from a larger project (a game actually) that I am working on. My game has an entire audio engine that is being worked on as necessary for the game, and one of the things I needed was the ability to plug in various effects, especially a dynamic range compressor. I hope to talk about the game more in future posts. After creating the compressor for the game, I ported it over to a standalone Flash application so that it could be played with on its own.