Games Fundamentals Exam
May 4, 2012 – 9:51 pmDate: 31 May
Time: 12:30 – 15:30
Venue: Room 2002, John Galsworthy Building
Downloadables:
A companion site for a module taught at Kingston University, London
Date: 31 May
Time: 12:30 – 15:30
Venue: Room 2002, John Galsworthy Building
Downloadables:
The BIG DAY is approaching fast! This Friday, 4th of May, we will all meet to see your project demos!
These are drop-in sessions, please check your time in the list below – you don’t have to come earlier and you don’t have to stay after your demo, but you may miss your marks if you arrive late! You are divided into five groups in five demo sessions between 1 and 6 p.m.
Attendance is mandatory. Absence will be considered a LATE SUBMISSION (40% cap on your marks). Mitigation circumstances apply.
No advice or feedback will be given by the teaching staff other than during your demo.
Demos are to be given on 1-to-1 basis (no public presentations). We have a very large group to mark, so you will have to demonstrate the main points of your project very quickly.
Important: If you are not happy with your project, and you think it is below the level of expectations – come to this session anyway! It’s always better to show off with not a very good project than to miss the demo completely. If you come, your marks become unlocked – and you can get some valuable advice before the final submission. If you don’t – your marks will be frozen at a maximum cap of 40%, but can go even lower. You can’t lose coming, but you may lose a lot staying at home!
Check the marking sheet we’ll be using on the day!
The Flight Simulator 2D game is now available in an updated version with some nice new features:
As an update to our recent lecture on space flight physics, this NASA picture (click on it to view a larger version) shows the orbit of 2012 EG5, an asteroid 62 metres across which will pass near our planet today (well, it’s April 1st today) in the lunar distance of 0.6 (or 143,000 miles, 0.6 of Earth – Moon distance). It’s been already nicknamed April Fool’s Asteroid, but what I found interesting in this picture is the shape of the orbit of this little asteroid – showed blue in the picture. It’s an elongated ellipse – just as we discussed in the lecture – and therefore it spends most of her life in remote and cold areas of the Solar System, much beyond Earth’s orbit, travelling – as you should know – relatively slowly. Only on its hazardous approach to our lonely planet it will abruptly speed up – in effect, it achieves its maximum speed right now, when it is just near us! And this speed may be many times faster than its normal trip far far away.

We will start with learning physics of rotations, or rotational physics. Swiveling, turning, pivoting, tossing, spinning, revolving, rotating – the sheer number of English words we have to call this physical phenomenon shows how ubiquitous it is. In games development, things most often rotate when hit. And so, we are revisiting today some topics, like dropping and throwing things, hitting and bouncing. We have discussed some of them in the past (lecture 3, “Roll and Fall“, and lecture 4, “Let’s bounce”) but this time we will get much more insightful view of the topic: first, we will discuss elastic and non-elastic collisions (colliding snooker balls and balls made of Plasticine), and the coefficient of restitution. But to propose the ultimate, realistic model of bouncing, the model which comprises what we know from everyday experience – that things often spin after they are hit – we need to combine what we know about collisions with rotational physics.
Handouts:
At the workshop, as usually near the end of the term, we will support you with the coursework – if time allows, as the lecture material is substantial today.

Aircraft simulation is very complex, due to complex and difficult underlying physics. In this lecture we are dealing with a very significantly simplified model, but results are quite fine. The sample software, Flight Simulator 2D, is limited in terms of control to the throttle and the elevator, but creates quite an enjoyable little game (to avoid problems with transparency, please upgrade to the latest version of GFC Library).
Technically more complex, historically much later, but in fact significantly simpler if to consider the physical model – space flight is also covered by this lecture. A very basic spacecraft simulator – simply called Orbit - is surprisingly helpful as an illustration of space flight physics.
Download the handouts (or updated version, with some extra material).
Coming on 22 March!
This lecture, led by Dr Vasilis Argyriou, will give you some insight into artificial intelligence techniques, and may give you plenty of ideas about how to enhance your game projects. Note that AI concepts will be considered as maths, in terms of marking, and quality AI implementation may even compensate for weaker physics, so it’s really worth of consideration!
Please bring your coursework to the workshop – there is no formal exercise for this week, but we can help you with your projects!
Need to consult your C++ programming problem? C++ Aid Sessions, every Monday 11 – 1 in JG0004, may be for you!
Today we are flying off to the Moon… First, a robust physical model must be constructed, including fuel consumprion and two different gravity forces (from the Moon and from the Earth). Before we start, click on the image and play to know what is it about…
The paper linked above contains some strong maths. Don’t worry – its conclusion is that it gets much much easier when you use it within a game engine. The trick is that updating the game state in every animation frame you effectively execute numerical integration procedure, which is capable to automatically calculate highly complex stuff in an easy way.
If you want to do some practice you can use the page 6 of this document and also download the workshop version of the Rocket program. You can then play flying the rocket to the Moon! Otherwise, you can continue with your coursework…
Download the full version of the Rocket program.
To drive a car you will not to be a licence holder today, but what you will have to do is to show high skills as a programmer, in this programming challenge today.
Download the Workshop Handouts and the start-up Cars source code.
Please notice that the source code above is a limited workshop version, prepared for you to finish. For the full version check the Resources tab (subject to availability).
Download PDF Handouts or PowerPoint slides.
Sample source code will be made available in the workshop.
Have you ever thought what happens when you drive a car? Or if someone else drives, if you don’t have a driving licence? When you press the gas pedal the car accelerates. It’s normal: there is an engine drive force that pushes the car forward, and according to the Newton’s second rule (a=F/m) this should cause an accelerated motion. But why, according to that law, you cannot accelerate your speed constantly ad infinitum? Why cars have their maximum speed beyond which there is no more any acceleration, even if the engine is working with its full power? What makes the Newton’s law cease to work?
At today’s lecture we will look closely at the air resistance, or the drag, as well as other types of mechanical resistances. We will analyse strongly how they affect the motion of cars. When the speed is low the resistance is also relatively small, so you can easily accelerate. But when the car moves faster, the resistance increases even faster than the speed: that’s why you cant’t accelerate indefinitely. At the car’s maximum speed the engine’s drive force is fully balanced with all the resistances. That’s why installing a spoiler can significantly impact your maximum speed!
Drive safely!
For a more advanced model look here: Car Physics for Games.
Another programming challenge is the Marble game, which contains elements of accelerated motion and collisions.
Download the initial version of the the Marble source code. You can compile and run it as a full version of the game – but some crucial parts of the source code are hidden. One of the lines in the MarbleGame.cpp file is marked to be deleted to get your limited workshop version.
Your task, traditionally, is to finish programming the game. You will find all the hints in the form of comments in the source code.
Additional resources: Implementation remarks - check the Lecture Note just below…
The Project Submission Site – your on-line drop box – is now open! Simply choose Project Submissions from the menu above and then follow the guidelines.
Teaching materials for today:
The topic for today: collisions. We will bounce marbles and bills, either from a wall or from each other. The physics behind a so called elastic collision is not complex, but in general case the geometry makes the calculations rather far from trivial – this is because marbles can come from different angles, and this must be taken into account to get a reliable simulation.
The demo program for today is a billiard game simulator. The collisions are not very complex from the point of view of physics, as these are almost ideally elastic collisions of two objects of almost exactly the same mass. But the geometry of the billiard game may be quite challenging…
The program is a working simulator, however it is not yet completed as a game and is not very playable at the moment.

Your task is a bit different today and you may find it a bit more difficult. Anyway, fewer lines of code to write than the last week! And, more importantly, for the first time we will apply some genuine Newtonian physics concepts in our programming!
Please download the source code of the Cannons game.
Compile and run it. It is not a working version yet! For the full version check the Resources tab (subject to availability).
Your task is to finish the game. This time we will tell you what to do, but not how. In theMyGame.cpp file, OnUpdate function, you will find a series of comments starting with TODO. They mark the places where you have something to do, and also tell you what to do.
Your games already has a lot of functionality: you will not have to create sprites, they are all already in-place. The user interaction is all done: the player can move the cannon (right mouse button) and aim and shoot (left mouse button) but — there are no collisions checked, so the game never knows if you hit a wall, and if the game is over (a cannon destroyed). More importantly, there is no gravity, so your balls travel along straight lines, which is rather not very enjoyable.
A couple of hints for you, but only read this if you are lost:
There is no separate workshop sheet.
If you have a working game, you can now award yourself with Paper Cannon XP, a nice heavily physics-based web game. Enjoy!
Oops, my mistake in calculation – the project proposals should be submitted by the end of NEXT week, not this week. So, the deadline is 24 February!
Download PDF Handouts or PowerPoint slides.
Please download the Roll and Fall source code.
Roll and Fall is our first physics-based game. It illustrates following phenomena:
This topic may be essential for your Assignment 2, which has been revealed today. One idea could be to create a next level for the Fall and Roll game.
These are downloadables for today:
1. After playing the Escapa game a while (just click the image above) find a TODO section in the Escapa source code and add the code for the blue rectangles to bounce off the edges of the game playfield.
The following three tasks you will be doing with Asteroid Fighter, a slightly new version of another Andreas Hoppe’s game that you should know perfectly well:
2. An easy one: add collision detection code here to check if the bullets hit any of the rocks. Locate a TODO section in the code. You may have done it a few weeks ago with Andreas, but this is a new version and things are a bit different now – we are using a list of sprites where Andreas used vectors. You cannot directly access indices and removing items is very much different now.
3. More advanced: Find another two TODO sections, both of them located within the mouse handler, and make the space ship follow the mouse cursor, and shoot bullets on the mouse click.
4. May be really tricky: add “intelligence” to the asteroids – make them follow the spaceship. A naive solution won’t work: all asteroids simply heading straight to the ship is easy to program, but tremendously difficult and unpleasant to play. So – you have to make them turn towards the spaceship gradually, just a fraction of the angle each time.
In this lecture we will talk about linear functions and how they can be used to show motion – both linear and accelerated. Other topics include: trigonometry, collision detection, Thales theorem and even some aspects of 3D perspective and 3D imagery.
As an lecture demo I am using Andreas Hoppe’s CatchIt game that you probably remember from the last year.
For those who are familiar with GFC (Games Fundamental Classes) this workshop may be a refresher, for all others – introduction to GFC programming.
You are supposed today to write your own, simple but complete game – all by yourself. This is an exercise in so called Guided Programming – so you will get a recipe showing in 12 steps how to achieve it.
Download your Guided Programming instruction.
By the way, you will need this image of an enemy spacecraft:

Some time after the workshop the full source code of your Space Battle game will be made available – please check the Resources Tab. There are even two versions of the game there!
NOT ENOUGH?
Download the The Maze 2010 game. Your another task – or homework – could be to analyse the code of the game and write your own new game level.
The image below is clickable.
This course will provide you with essential background in programming, mathematics and physics.
PROGRAMMING
Our obvious choice of the programming language is C++, simply because this is the most significant language in the games industry. Most games are written in C++ and C++ developers are sought after. Java is another popular language, quite often used in higher education as the first programming language, but it is rather scarce among games developers. One possible reason for that is – java is not supported by any major gaming or 3D platform – like DirectX, OpenGL, or game consoles. Especially the consoles are a very important driver of development in games industry – and incidentally, all consoles except XBox require either C or C++, and XBox requires C#, Microsoft specific language similar to C++. Another more and more powerful gaming platform, Apple’s iPhone and iPad use one more C-derived language called Objective C. This platform is also largely responsible for rather dramatic decline of Flash – until recently, a very popular engine for simple web-based games.
We will also continue using GFC (Games Fundamental Classes) – a 2D game engine written specially for this module! Most of you had an opportunity to familiarise with it in Introduction to Computer Games module. Today’s session is a refresher, entirely devoted to GFC basics. If you are new to GFC, no problem, you will be introduced today!
So, for a good start, listen to the song – and good luck with your C++ programming!
Now, if you think you would have any problems with C/C++ programming, here is a good link for you: A… B… C++ Tutorial.
MATHEMATICS
Mathematics is simply a foundation of any computer graphics, either 2D or 3D. That’s why we’ll spend some time learning maths. Bouncing, jumping, shooting – these are all highly mathematical concepts. First of all – maths is essential if you’re thinking about applying physics in your game!
PHYSICS
Falling down, accelerating, hitting, going, throwing, breaking, flying, swimming, riding, rotating, digging, aiming, shooting, striking, bouncing, driving, catching, exploding, reflecting, jumping, running, kicking, sailing - much more actions could be listed here. Modern games require gaming objects to behave realistically. Realistically means – like in the real world. The real world is ruled by physics. Therefore the virtual world must be also ruled by physics. The Matrix is an enormous, highly efficient physical simulator…
To add realistic effects in your games, you will need to learn physics. Try a simple “helicopter simulation” game below. These are simple applets written in java. Try the left-hand side one first, then the right-hand side one. What’s the difference? Which one is more challenging? Which one would you prefer?
GAMES FUNDAMENTAL CLASSES
Download the Power Point slides.
The Games Fundamental Classes (GFC) is a class library operating on top of SDL (Simple Directmedia Layer, SDL, http://libsdl.org) created to facilitate building simple 2D games in C++. The library was purposely developed as an aid to the Games Fundamentals module.
For GFC download, installation and usage instruction please check the Resources tab in this website. You will also find a number of sample games there.
Instead of signing a register – please send me a comment! In this comment I need your real-life name so that I could make the register later. But please also tell me the following things (as briefly as possible):