Saturday 21 November 2009

3D Renderer - A Working Progress


In our Introduction to 3D Graphics Programming module we have all been working very hard to develop a 3D renderer. This has all been programmed in C++ and the graphics have been achieved through using the Microsoft Windows GDI+ class based API and also Quake 2's MD2 file format loader.

Now as it stands my program can only load MD2 files, draw MD2 models to screen space and rotate MD2 models by the x, y and z axis. I have so much more work to do if I want to implement features such as lighting and texturing into my project. Anyway I have provided some screenshots of my program in action.









Saturday 24 October 2009

Assembly Language Programming



So last week in Console Development we began looking at some assembly code for the games based on whatever consoles we had opened up in the first week of the module, which in my case was the NES.

I must say looking at some assembly code for the very first time was pretty daunting. I found it really difficult to make little sense from any of the code in the files that I had read. Unfortunately non of the assembly source I obtained was official Nintendo assembly code, however it would seem there are quite a few NES development hobbyists out there. Thanks to them I was able to take a look at some assembly code for the NES. The below is some example assembly for the 6502 processor..

lda #$3F sta $2006 lda #$00 sta $2006 lda #$21 ;background [powder blue] sta $2007 lda #$30 ;cloud inside [white] sta $2007 lda #$11 ; highlight [blue] sta $2007 lda #$0d ;outline [black] sta $2007 lda #DELAYSCROLL sta $21 lda #NTShow sta $22 lda #SCROLL sta $24

The above apparently loads up some colour values in memory. The assembly code was programmed by Cory Arcangel whom had hacked a Mario Brothers NES cartridge, you can check it out at http://www.21cmagazine.com/issue2/cory_clouds.html

This week and the last had also been spent learning and researching the MIPS assembly programming language! For you that haven't met MIPS assembly yet..



What? Yes well to begin with MIPS assembly doesn't seem very friendly and it's syntax is very alien. However after giving a little time and effort over the past week in learning MIPS assembly, I found it easier to understand and the syntax less alien. I have provided some of my MIPS assembly code I've done this week with comments on each line of code to roughly describe what's going on (it's pretty trivial). If you have any trouble viewing the code it's probably because the image has been resized, simply click on the picture to get a larger view.


Here are the values in there designated registers after the program had finished executing..





Saturday 17 October 2009

Vectors, Matrices and C++



This week in the Introduction to 3D Graphics Programming module we have been programming our own matrix class. So some revision on the good old matrices we met back in the Computational Mathematics module (from last year) was key. The same can be said for the vector class we had programmed from last week.

So before we could all start any programming we had to be perfectly clear on, not only what a vector and matrix was but also several important operations that are carried out whilst using vectors and matrices. To enforce this we was asked to revise as we’d all be taking a test on them. The list contains everything I had studied and revised before taking the in-class tests.

  • Vector Addition & Subtraction
  • (Vector) Scalar Multiplication
  • Obtaining a Vectors Magnitude
  • Normalizing a Vector (obtaining the unit vector)
  • The Dot Product
  • The Cross Product
  • Matrix Addition & Subtraction
  • (Matrix) Scalar Multiplication
  • Matrix - Matrix Multiplication
  • Vector - Matrix Multiplication
  • The Transpose of a Matrix
  • The Identity Matrix

Once we had finished our tests we got given a Visual Studio solution with header files and source files for the vector and matrix classes (vectors was last week). These files contained minimal amounts of code as they were just interfaces to work with, we were all expected to program the functionality for the majority of the above vector/matrix operations. This was surprisingly fun for me to program, I didn’t really expect to find it so entertaining (I don’t get out much). Anyway I have provided screenshots of some of my code for performing some of the above operations, see below. If you have any trouble seeing the code it's probably because the images have been resized, just click on the image to get a bigger view.

So here's the code for finding the dot product in my vector class..


Here is the function used for testing that..


Here is the output..

Now the code for finding the cross product in my vector class..

The above code (looking at it a second time) is obviously inefficient and can be done better. The code in the screenshot below is a lot more efficient and a lot less expensive (computationally).

Here is the function used for testing that..


Now a little matrix code. Here is the code for my matrix addition..


It's probably worth mentioning here, that the matrix subtraction code is exactly the same as the addition. Where the addition sign is used the subtraction sign replaces it. Here is the output..

Now the code for matrix - matrix multiplication..


That's the clean way of doing it, before I coded the for loop it looked like this..


I'm not sure if the for loop is more efficient than the 'hard coded' version but its certainly easier to type in. Anyway here is the function used for testing that..

Here is the output..


Sunday 11 October 2009

What I've been doing over the summer!



Well all of us from the Computer Games Programming course at Derby University were supposed to of been working on our game design documents for our Famous Five project, which is for the Game Development Techniques module. However some of us had more interesting things to do :p .In my spare time over the summer I kind of got carried away with working on my own little XNA game project. The project was my attempt at developing a 2D 'slash & hack' sort of genre game. I wanted to create something that looked cool and that was addictive to play, so with that and the huge amounts of spare time I had (being wasted on staring at the four walls because I have no friends) I began making "Slash & Smash"..

This game basically starts off with the player having the option of customizing the appearance of the "Knight" you play as. You can customize the Head, Body/Torso and Weapons. Well by customize, I actually mean you get to select three different parts for each part of the player. You are then presented with an instructions screen, where obviously you are shown the controls and tips/hints for gameplay.

The player is able to jump, attack and block. The jumping is only really used to avoid enemy fireballs, the blocking and attacking are pretty self explanatory.

Jumping
Used to avoid fireballs.

Attacking
Used to attack your enemies and counter enemy fireballs.

Blocking
Used to defend yourself from projectile & melee attacks.

Now at the moment I've only got a one minute playable demo of it, if that. Since I've started my second year at university I haven't had the time to continue with this, ill get round to finishing it though. I've provided a few screenshots of my really really rough, unfinished, probably rubbish game in the below.










Another year of computer games programming!



So it's our second year in studying computer games programming at Derby University and it looks like we all have a busy year ahead of us. I'm pretty excited about what were going to be studying this year as well as a little scared. I’ve been told we'll be looking at using some DirectX, OpenGL, C, C++, Java and MIPS assembly code this year, should be fun! The modules we have this year are as follows..

  • Introduction to 3D Graphics Programming
  • Interactive 3D Graphics Programming
  • Console Development
  • Game Development Techniques
  • Applied Game Development
  • Mobile Devices

Introduction to 3D Graphics Programming

The first week in the Introduction to 3D Graphics Programming module we had a look at some Windows API programming. We had a look at the general structure Windows programs go through whilst they are running, which is basically just a while loop with several must have functions that are called. Once we got familiarized with its structure, we began researching some GDI+ which is just a set of functions and libraries that allow us to enable simple graphics in our Windows programs. With this research we were expected to program a simple paint program as homework for the week. I didn't spend as much time as I’d of liked to on this program, however I think it’s probably still up there with the likes of Photoshop CS4. ;)

Game Development Techniques

Recently in GDT we have just been going over time management for our game projects, as well as tweaking our game design documents (which we should have done over the summer) for the Famous Five game we will be working on through the entire module. We will be using the Unreal game engine (UnrealEd) to develop this game, and basing it around Enid Blyton’s Famous Five Intellectual Property is compulsory. ¬_¬

The Famous Five game i'll be developing will be based on the book/episode "Five Go Off To Camp" which is all about 'spook trains', it's really good.

We haven't actually started developing anything in the UnrealEd yet for our game projects, however we have all been given a group project task this week.We are all expected to work as a team to produce a level of our group choice, which was the inside of the Red Dwarf starship. In our group we were divided into smaller teams of five, each with its own team leader. My group was assigned the task of creating the entertainment area of the Red Dwarf starship. It has now been my task this week to create the CopaCabana Cocktail Bar which forms part of the entertainment area of the level. I have provided a screenshot of what iv done so far in the below, and yes i know it's hardly a masterpeice.



Console Development

The introduction to Console Development last week was pretty interesting and fun. We were all put into teams of four and then randomly given games consoles to open up and investigate. The consoles handed out ranged from the Atari's Jaguar all the way to the likes of Sony's Playstation 2 and Microsoft's XBOX. The team I was apart of got given the Nintendo Entertainment System to open up and investigate, yes I was a little gutted not getting the XBOX or Playstation 2, but still enthused about opening up a Nintendo console!

Turns out opening up a Nintendo Entertainment System really isn't as easy as it seemed, took our team at least 15 minutes to remove about 8 screws? Was embarrassing. Once we all had our consoles opened up, we were all expected to get the details of the hardware and research a little behind the workings of the consoles. We also took pictures of the hardware parts, as it was necessary for the presentations we had to put together and present.