What I’ve been up to.

For some reason I find working AND updating a blog completely impossible. Maybe I just have a terrible memory or are very lazy… Anyway, I just thought I’d post an update on what I’ve been doing since my last post.

Mobile Devices

Our task in this module is to create an android application. It can be anything so naturally I chose to make a game. The game itself is a zombie survival top down shooter. The idea is that you awaken in the middle of the night to the sound of zombies breaking through your windows. You need to close the windows, kill the zombies and survive for as long as possible.  The windows will reopen eventually, but you need to makes sure they aren’t all open otherwise you will get mobbed.

Here are a few screenshots:

It’s all a bit bare at the moment, I especially think the art good do with some improving.

Direct3D 11

Another module I’m currently doing at university, we have to create a basic 3D game engine using DirectX 11. So far, I have worked on creating a scene graph, a content manager, heightmap terrain. Here’s a screenshot of it running

I use a 3d texture to map a different texture for different heights, and I also blend in another texture depending on how steep a face is. This sort of procedurally generates a texture for me.

I think I’ll finish off this update tomorrow, since it’s getting late.

Loyds Tale. Ludum Dare was fun =)

So I entered the Ludum Jam last weekend with my housemates. We went in completely unprepared with no libraries at all. We made everything from scratch in those 3 days, including a tile engine, all the art, the level loader T_T. We didn’t get too much sleep  haha. You can play our game here. We named our games character Loyd Hasketh as its the first thing a random name generator pumped out. So our game is called Loyds Tale.

This bits actually quite tricky.

Our game idea was that you played a pirate, rabbit .. thing you finds himself ship wrecked on desert island with a mysterious bed in the middle of it. When you wake up from your slumber, the whole island had lifted out of the ocean and turned into a huge tower. You then have to make your way down the tower in a typical platforming fashion.

We made sure to have no other humanoid enemies, in order to reinforce the “Alone” theme. We did add some birds in there to give it some difficulty however.

We used Tiled as our map editor. It’s free, has a nice and easy to load XML map format, and is pretty flexible to use. We did have to resort to some pretty strange ways of inserting entities into the map, but it still worked.

Post Mortem

Day 1

On the first day we focused on getting the tile engine finished. I worked on the map loading whilst the others sorted out the actual drawing of the tiles. At this point our motivation was pretty high, as the code was still reasonable clean. We also wrote a simple entity system to go alongside the map, and created some sprite for the tiles and character.

Day 2

We fleshed out the entity system and the collision for the player (understanding that this is always a big problem in creating platformers we worked on this a lot). I worked on creating some hazards for the player, like spikes and breakable blocks. As the day went on we got less and less motivated. The code was getting messy as we had to hack things in to make them work, it was dawning on us how terrible our game was T_T.

Day 3

Sill demoralized from day 2, we worked on adding more hazards and designing the level. One of our team members had to leave about half way through the day to go home, so it ended up with just two of us adding the finishing touches. I spent most of the day creating the level. As we finally finished the game and submitted it, we could relax. It wasn’t long after that we realized that the game we created wasn’t *that* bad. You know it was passable considering that we created it from scratch in 3 days.

The Good

  1. We got on with it, and finished it within a reasonable amount of time. We didn’t spend to long thinking of the idea and concept.
  2. Using Tiled was a brilliant idea, it saved us a lot of time. We wouldn’t have even considered writing a platformer without it.
  3. XNA was great. We all knew XNA very well as we all have a lot of experience using it. I would have preferred to use something more portable however =(
  4. This is amazing. Bfxr is an improved version of Sfxr which is simply amazing for creating simple sound effects. My friend at university swears by it.

The Bad

  1. We weren’t prepared. We really should have written a library to help us create a game in the weeks before the competition. It would have saved us a lot of time and kept our code more tidy. It wasn’t really feasible to do this time because we had a lot of assignments in the weeks leading up to the ludum dare.
  2. Next time we do the ludum dare, we will definitely try to steer clear of platformers. They are a lot of work to program the back end to (collision mostly), and it is difficult to create unique gameplay using them (our game is pretty generic haha). We would definitely want to do something different in April.
  3. We shouldn’t have resorted to messy code so early. We should have set most of the framework and ideas from the start rather than making them up as we went along. This resulted in horrible code that was painful to debug and lot’s of code repetition.

Other thoughts

Next time we might want to be more active in the community as the we are making the game. Like participating in the IRC channels or creating a timelapse video. Perhaps we will do one of those nextime =)

Click here to read another team members thoughts on LD22.

Tagged , , , , , , ,

The finished renderer.

I’ve finally finished my software renderer. I’ve added texturing and phong shading, so it looks shiny and pretty now =).

Shiny Rayman =)

A Textured Rayman!

It also supports animated MD2 models now. It can load pretty much any image file using Devil.

You can download the finished version here.

Demo: http://dl.dropbox.com/u/664062/Stuff/Dokuro3DDemo.zip

Source:  http://dl.dropbox.com/u/664062/Stuff/Dokuro3DSRC.zip

Tagged , , , , , , ,

Drawing a Pokeball in MIPS assembly.

Pokeball in MIPS

For a university assignment we have been tasked with making a bunch of graphics functions in MIPS assembly. This is going to lead up to doing actual development on the PSP hardware (PSP Dev kits).

As a test program I decided to make it draw this pokeball in the MIPS emulator =). In its current state I have written functions for line drawing (including Cohen Sutherland  clipping), rectangle drawing (filled and unfilled), circle drawing (filled and unfilled), polygon drawing (unfilled only).

I implemented all of these functions in C first then “translated” them into MIPS assembly, optimizing them as I went. I might get around to implementing some other functions too =).

 

 

 

Triangle Rasterization

I’ve been experimenting with different algorithms for rasterizing triangles in my 3D software renderer. I came across this article on gamedev and had a go at implementing it.

A shot from far away.

A shot from far away.

This algorithm is different from the standard scan lines algorithm in that it goes through all of the pixels in a tight bounding box around the triangle and uses half space functions to determine whether or not a pixel is in the triangle.

A half space function is basically a plane equation. The side of the line that the point is on is determined by the sign of the half space function.

Using this to rasterize triangles sounds slow at first, but a lot can be done to optimize it. You can rid the main loop of divisions and multiplication by incrementally calculating the plane equations.

It can be optimized even further by dealing with blocks of pixels. You can quickly eliminate blocks of pixels that are entirely outside the triangle, and quickly fill blocks that are entirely inside the triangle. Blocks that are on a boundary are the only parts that take a lot of time.

In the pictures above and below you can see that the blocks that are entirely inside the triangle are colored green, and the blocks that are on the edges are red. An odd effect of using this method, is that rasterizing this model is actually faster when you zoom in. It is slower at rendering small triangles, because it has to go through each pixel.

A close up view

A closer view.

Another thing good about this method is that it easily lends itself to parallelism unlike the scanlines method. It wouldn’t be too hard to use SSE instructions to process interpolation, etc in 2×2 blocks at once.

I’m wondering that it might be possible to improve the algorithm by changing the size of blocks depending on the size of the triangle that is trying to be drawn. Possibly using 2 rasterizing functions, one that uses this block method, and another that just does per pixel depending on the size of the triangle.

You can see the algorithm in action here.

A 3D Software Renderer (University Project)

We’re doing a module at university called “Introduction to 3D”. It sounds pretty simple, but actually, we have to write our own 3D renderer from scratch.. Which is far from just and introduction I think…

Anyway, this module has been very interesting. I’d already written a 3d renderer during the summer holidays (I knew we were going to be doing this), but it was terribly slow and the code had gotten a bit messy, so I decided to start from scratch again for this module.

So currently my 3D renderer can load MD2 files and display them in wireframe or filled mode. (Filled mode is still a bit dodgey because I still haven’t sorted out the fill convention). You can move around the model using FPS controls (WASD to strafe, SPACE to go up, SHIFT to go down, MOUSE to look around). Fustrum culling is working as well as back face culling.

Miku in Dokuro3D =)

Next I should be working on the fill convention and then maybe adding lighting =)

You can download the current version HERE

 

 

 

 

 

Blog from scratch – Ruby on Rails

I’ve always been irritated about the inflexibility of blogs on WordPress.com . Sure you can upgrade to pro and have a domain name, install plugins, etc, but you’ll never have the same amount of freedom as you would have on your own server. So I thought “I should get a VPS and do it all my self!”.

So I headed off to http://lowendbox.com to look for a cheap VPS. I found that there was a special offer on at http://qualityservers.co.uk in September, and got a 256mb slice for a year (£25). I set about putting a webserver and installing PHP with wordpress, when it hit me that even in doing that, I still wouldn’t have much customization options. I thought about writing plugins for wordpress.. but then I remembered that it was written in PHP… Uh.. No thanks.

I have used Django with python in the past and found it much easier to use than the PHP I had done previously. I had a few problems with it however. I liked that it was in python, as I’m very comfortable with it, but actually deploying django is a little difficult and involves messing with fastcgi, and is laiden with all sorts of traps and gotcha’s.

I took a look into other scripting languages with web frameworks and remembered that when I was learning django I had dismissed learning an alternative written in ruby. Ruby on Rails is pretty much django written in ruby, but there is much more documentation for Ruby on Rails and it is much more supported. It was very easy to setup on my vps. The deployment is made extremely easy with things like modrails (phusion passenger) .

I looked for a blog already written in ruby that I could hack apart, but not knowing any ruby, that seemed a little farfetched. I’ve decided that I’ll write my own blog from scratch, learning ruby on the way.

Anywhos, I’ll blog about my progress, and hopefully soon I can start transferring stuff to my new blog =)

Follow

Get every new post delivered to your Inbox.