Uni projects: Brainvaders

March 20, 2008

This project was, by far, the most enjoyable one I’ve ever undertaken at university. The assignment was simple, as they often were – we had to remake Space Invaders using Blitz Basic. As it was the third and final assignment on my Computer Games Development module, I decided to pull out all of the stops and spend a solid month or so (I’m sad like that) creating what you see here.

Brainvaders juggles the Space Invaders formula around a bit. Instead of being stuck with the same old boring ‘pchoo rifle‘, you’re given the ability to upgrade your alien-blaster to a choice of four other weapons (rapid fire, double shot, triple shot and homing). You can also upgrade your shields to withstand more damage, and buy a few nifty extras like a tractor beam and ‘orbiters’, which help with the alien blasting. Upgrades can be purchased in exchange for alien brains (which are favoured for their mild creamy taste. Great on toast!), which must first be seperated from their original owners.

Brainvaders follow the typical Invaderesque style of movement (Drop down! Increase speed! Reverse direction!) with the added freedom of being able to swoop down to get a bit close and personal whenever they feel like it. This will happen more often as you kill more of them, so don’t stay still for too long…

As you dispose of waves of enemies, new ones will arrive that are slightly stronger and more aggressive. If you die, the game won’t actually end, you’ll just lose around half of your points. Thus, you’ll be able to keep playing until you get bored.

All of the content was made by me except the sound effects which were all made by my good friend, Matt Griffith, whose voice acting abilities are almost godlike.

Brainvaders Brainvaders
Brainvaders Brainvaders

Links:


Uni projects: Stick Tennis

March 19, 2008

Recently, I’ve been busier than ever. I’ve had no less than four projects to juggle, two of which are now – thankfully – complete. I’ve been working on the other two almost incessantly, but during my brief breaks I’ve been writing a computing article that should hopefully interest. For now, I’m just going to post the remainder of my university projects from last year. These ones are a bit more exciting!

The first is Stick Tennis. This is the first graphical game I got to make in university, and made a nice change from Interactive Fiction!. The assignment specification was incredibly simple: make a Pong game. Beyond that we had free rein, as long as it didn’t stray too far from the original concept.

The rules of Stick Tennis differ slightly to those of the original Pong. The scoring system is a dumbed-down version of tennis (each successive point is worth 15, 30, 40, etc) and the playing field is a lot longer than it is wide. I was actually quite lucky to pass this assignment with the score that I got (85%+) because I neglected one of the fundamental rules of Pong – that the ball should be able to bounce off the top and bottom of the field. Luckily, my lecturer overlooked this.

If you find it difficult to hit the ball, don’t worry – for a pong game it’s insanely difficult to control! You’ll probably get bored and stop playing before winning against the computer anyway. It’s not the exactly the most exciting game in the world, but it might keep you entertained for a few minutes while you watch the ridiculous budget stickman animations in action (which I’m actually really proud of).

I’ve included the source code for anyone interested in taking a peek. It’s in Blitz Basic format (.bb)

Stick Tennis Stick Tennis Stick Tennis

Links:

Source code & exe


Uni projects: School’s Out

February 4, 2008

In my first year of university, I made the mistake of taking Computer Games Technology as a result of my pipe dream to become a profesional games developer. I’ve had a little sense smacked into me since then, but in the time that I did spend on the course, I made three games which I’m releasing for all to play.

The first game is an interactive fiction (text adventure) game called School’s Out in which you play a school kid who manages to get himself locked in school at the beginning of the mid-term break. Using the objects lying around the school, and your own wits, you need to find your own way out before you die of boredom (or your own stupidity).

It was made using Inform 6, which is a functional but limited language (I’ve heard 7 is much better, but we couldn’t use that). To run the .z5 file you’ll need a z-machine interpreter; I recommend Frotz.

School’s Out was a collaborative effort by myself and two others in my group, Stuart Hayes and Ben Holland. We wrote out a walkthrough as part of the specification, but none of us seem to have it any more! I still remember how to complete it, though, so if you’re stuck, just post a comment or something and I can help.

Links:

Source code & .z5 file


Uni projects: 3D map

February 3, 2008

The the second assignment I had to undertake for my Programming (PR1201) module was to make an interactive map of an area (real or fictitious) using the Java applet API. The basic features it had to exhibit were:

  1. Interesting landmarks such as lakes, buildings, forests, etc. These were to be drawn with basic shapes – circles, rectangles, irregular polygons, etc.
  2. The ability to click on the map and be given info about the nearest landmark, as well as the distance from the cursor.
  3. Buttons corresponding to each landmark. Clicking on the should give information about that landmark.
  4. A bar representing the map’s scale (i.e. 100 pixels = 1 metre).
  5. A search box programmed with some basic search queries.

With a new-found penchant for making everything 3D, I started working on a new engine for rotating and tilting a world map and calculating the positions of sprites sitting on it. This was much easier to do than my previous project because the Java applet API can render filled polygons, but Java elements can’t.

I chose an imaginary nature park for my location, so there are plenty of trees and lots of water. If you look at allenk_groupG_Initialiser.java, you’ll see there are a hell of a lot of sprites dotted around. Luckily, I didn’t have to code them by hand – I modified my applet to output Java code to a file, and voila – a makeshift park editor.

I got a score of 90% for this applet, which is the highest score I’ve achieved for a piece of coursework so far.

Java map 1 Java map 2 Java map 3

Links:

Source code and class files
View the applet in your web browser


Uni projects: 3D spinning donut (torus) in Java

February 3, 2008

I’ve decided to release my university projects from last year onto the Internet for people to examine, scrutinise, use to help them with their own studies and hopefully enjoy.

The first project on display is my first Programming assignment, for which we were asked to create a short animation in Java using an educational package by Bailey & Bailey, Java Elements.
Skirting the assignment brief somewhat, I made a small 3D rendering engine which used Elements’ line drawing functionality to draw triangles, which in turn make up complex 3D shapes. I think I got away with this not strictly being ‘an animation’ because it spins about its axis.

I made this before I had any real concept of good OO practices such as encapsulation and decoupling, so there’s plenty of room for improvement. I’m still proud of it because this is the first time I’d tried making something of this nature and I have to say it went really well.

I scored around 85% for this, which I was happy with, but could have pushed towards 90% or possibly higher, had I followed the brief a bit more meticulously (one of the requirements was that I had to use all of the shapes provided by Elements, which I definitely didn’t do).

Java donut 1 Java donut 2

Links:

Source code and class files
Java Elements package (required to compile and run; include this in your Java classpath.)


C++, C# and speed

January 8, 2008

By the time I had gained some confidence in my programming abilities, I had pretty much become a hardcore C++ fan. I’m a bit of a speed freak when it comes to programming. If something isn’t working as efficiently as it could be, I get a compulsion to look inside it, see what’s slowing it down and try to find a better way to do things (I know, it’s a curse). C++ lets you do this more easily than some languages because of its relative closeless to the hardware (code is compiled to native instructions, so there’s very little ‘unavoidable overhead’) as well as its high degree of expressibility (for example, I can think of about five ways to implement arrays off the top of my head, each one best suited to a particular situation).

Since starting level 2 of my course, I’ve been inclined by myself and lecturers to take a look at the bigger picture of the software development industry (a picture I’ve not had much of a chance to see, since I haven’t quite “broken in” yet). The thing I’ve gradually come to realise is that the end users don’t care whether software is blazingly fast, as long as it’s fast enough to do the job at hand. Things like ease of debugging and the ability to quickly add new features should always be paramount. If you always aim dogmatically for the most efficient solution (which C++ often tempts me to do) you might just be shooting yourself in the foot.

One of my modules in Computing is “Software Development: Tools and Principles” in which we all use Microsoft C#. We just recently started a huge project which must be programmed exclusively in this, so we have plenty of time to get comfortable with it. Now, I’d never even touched C# (or any languages of that nature, like Java) before I started the course, but luckily it’s similar enough to C++ in syntax to make the transition a pleasant one.

So in the few monthsI’ve been using C#, here are some of the things I’ve noticed that are different from C++ (and it’s mostly good stuff):

  • No pointers – So that means no more messing around with the * character. You don’t seem to get as much control over memory, but going back to my point earlier: unless you’re concerned about super speed (in which case you probably wouldn’t be using a .NET language), it just means less hassle.
    You can still choose to pass objects by reference or value, and store objects as both classes (which exist on the heap) and structs (on the stack).
  • More straightforward syntax – In C++ you need to use . to access members of objects on the stack, :: to access static members and things in namespaces, and -> to access instance fields.
    In C#, all of these are accessed using the dot character. And why not? The compiler should know what kind of object you’re referencing from the context its in, so the less rules you need to remember, the better.
  • Garbage collection – Most programmers probably know this, but the .NET CLR uses a garbage collector by default. This means you don’t have to worry about freeing an object once it’s been created, because when you’re finished with it the memory will get recycled. If you’re not a big GC fan, you can override it by marking a block as ‘unsafe’, which will let you write unmanaged code, and allow you to use those lovely pointers.
  • Exceptions for error handling – Because they’re made by different groups of people, common libraries used in C++ use quite a variety of methods to report when something’s gone wrong. Some will return boolean false, others will return an integer. Some won’t return anything but will put an error value somewhere for you to find yourself. In the Framework Class Library (the collection of ‘built-in’ classes within the .NET framework), everything uses exceptions to report problems. I haven’t seen many, but most 3rd party libraries seem to all use them extensively, too. So you’ll have much more consistency in your code, even if it uses code made by others.
  • It’s JIT-compiled – This means your program can theoretically be ran on any system, because your code will stay in an abstract platform-independent form (known as Intermediate Language) until it’s ran, at which point it’s converted to the native code of the system it’s running on. This allows for processor-specific optimisations, which would be much more complicated to do in natively compiled apps. Some people aren’t fans of JIT-compiling because of the neccessary evils of extra memory and processor overhead, but processing power and memory are relatively cheap nowadays, especially for the kinds of companies who use JIT-compiled software in their industry.

So, in conclusion: if you want your software to be fast and in-touch with the hardware it’s on, use C/C++. If you want to be fast enough, and also instantly portable* onto other systems (see Mono), use .NET or Java.

* ok, this is arguable, but I still think it’s a step forward from natively compiled code.