NetBeans
Over the course of the past 24 or so hours, I have inadvertently come to the conclusion that NetBeans is pretty cool, and that I should use it more.
It started when I was doing some research into different IDEs, and out of curiosity, I decided to look into options for an IDE that runs on Linux that would give me C and C++ autocompletion. There are many vim plugins that tout this ability, but none of them have given me any glimmer of hope in the past.
So I installed NetBeans and started tinkering around with it, and I just went and hit the “New Project” button. I was surprised somewhat to see an option that allows you to create a project from existing code. ”Cool, let’s try it!”, I said to myself, maniacally. As it turns out, this feature is a lot more impressive than I thought. I pointed it to the directory for my Joy project, and it not only pulled in all my source and content directories nicely, it also found my Makefile and configured the project to use it. On top of this, the actual project files go in their own subdirectory, completely separate from any of the existing code or content, and it automatically added the necessary project files to my .gitignore file. How cool is that?!
The only customization I had to do was to modify the command it uses to run my project. It found the binary just fine, however since I’m using a locally compiled version of SDL, and I don’t have my /usr/local/lib directory bound to anything, the way I’ve been running it is with a custom line in my Makefile which modifies the LD_LIBRARY_PATH variable each time it runs. Totally hacky, but it was trivial to get NetBeans to run the project using my Makefile instead of directly.
After all that, I came to the conclusion that NetBeans is awesome. So yesterday I started writing a Markdown filetype handler for it, and last night at about 3 AM, I got it working to an acceptable level of legitimacy. The goal of this was simply to add a custom handler for Markdown files that would display a rendered version of the file in the Design pane of the editor. I used the NetBeans File Type Integration Tutorial, and force fed it a small portion of MarkdownJ, and after a good hour of trying to write a Perl script that would successfully pull out all the relevant bits of the github stylesheet, I ended up with something that actually looks somewhat legitimate.
It’s certainly not in a state to release, but after a bit of polish I think it could be something I can put online that someone might actually use someday. I don’t think I’ve ever done that.
Collision
I implemented collision detection and response in my current project early last week. Then I reimplemented it the next day. Then, a couple days ago, I polished it up into a decent implementation that actually works correctly. I also created a character animation spritesheet using inkscape, and a primitive animation framework to run it in. The result is a little blue guy, who is animated, and can run around and collide with the level.
I believe that I’m making good progress. This progress will inevitably slow down over the next few weeks as I crank through finals, organize my move to Madison, and actually do the move, however I will try to keep the momentum up at least a little bit.
My main focus now is breaking out my collision code into a reusable module, then implementing enemies that use both the collision and animation modules. I hope to be putting in actual game mechanics by the end of the month, but having never finished a game of this scale, and having never written a project of this scale in C, I’m not sure how accurate an estimate that is. I’ll be sure to update here frequently.
Structured procrastination
I once read (on Hacker News probably) about a technique for combating procrastination called “Structured Procrastination”. Apparently the idea is that when you have something you should probably be doing, but would rather not do it at this moment, you do something else that you should also probably be doing, but that you would prefer to do in place of that first thing. In this way, you are supposed to be able to get smaller, yet still inconvenient tasks done while you’re procrastinating on bigger, even less convenient tasks.
When I initially read about this, my first inclination, as it is with most of the content that comes out of the self-improvement realm of Hacker News, was to write it off completely and laugh in haughty celebration of my higher level of self control and unflappable willpower.
How surprised I was to realize early last week that I was unconsciously partaking in this exact technique that others do on purpose. After making but a meager attempt at studying for my computer architecture midterm on Tuesday, I found myself with an incredibly clean room and conquered copy of The C Programming Language. I’ve done much the same this week in my progress with my supercratebox ripoff. I’ll be sure to update next week about whether I’ve made a bunch more progress on that project or whether I’ve finished The Pragmatic Programmer.
C
I’m pretty much done with The C Programming Language. I didn’t even come close to doing all of the exercises, and I may have skimmed a chapter or two, but I have a pretty good handle on the essentials now.
I have also come to a good stopping point in Zed Shaw’s Learn C The Hard Way. Once I got to the chapters where there was evidence of “incompleteness” (it’s still in alpha), I called it quits. I think I have a much better understanding of how people actually use C now though.
But I’ve always been of the opinion that the best way to really learn a language is to do some projects in it, so that’s exactly what I’m doing. A while back I did some tinkering with SDL and C++ via Lazy Foo’s Tutorials, however since SDL is a C library, the code looked a bit messy to me (C idioms mixed with C++ idioms). Now that I’m working in C, I figured I’d take another stab at SDL in C.
Originally, my plan was to create a straight ripoff of the game supercratebox, however I enjoy playing it with an Xbox 360 controller. As a result, my current project is to first create a simple library for easily interfacing with a 360 controller in SDL (like you would in XNA). After several rewrites, I’m almost done, however I have some doubts about my design. Moving from a lot of C# work straight to C makes me yearn for lots of language features that I’ve taken for granted until now. Things like typesafe enums, and namespaces.
I’ve been poking through the Quake 2 source for some cues as to how to organize a project in C without these features, however the thing to do may just be to find a good book on the subject. I’ll check the library.
Learn C The Hard Way
I am now working through Zed Shaw’s Learn C The Hard Way. His teaching style focuses on learning by example. Every chapter quickly introduces a concept, presents a complete program demonstrating the concept, shows you how to break the concept (encouraging running the broken version in valgrind), and then asks you to tinker around with the concept on your own.
It would also appear that he doesn’t spend an inordinate amount of time on the absolute basics, which I like. It does appear that the book turns into a bit of a data structures course in part 2, though I’m not a professional C programmer so I don’t really know how common it is for people to write their own linked lists for example (as opposed to using a library). I always assumed that this wasn’t a common thing.
Anyway, I’m liking the book so far. I don’t really have any plans for projects in C at the moment, but I figured that since I’m brushing up on C++, I may as well try to get a decent basis in C as well.