Programming for Games 1
Welcome
Advance organiser
Introduce you to module team.
Explanation of module and assessment.
How to study programming.
Programming languages.
Compilers.
Module team
Dave Harrison (head honcho)
Chris Rook (flunky)
–
–
–
Contact details in module guide
Dave Harrison is module tutor, so contact him for
module queries.
Contact either for information about programming.
The Module
20-point module.
Two lectures a week.
Single two-hour lab session.
Three assessments, due in weeks 7,9,12?
To be followed by Programming for Games 2
next semester. (Big exam.)
The scheme
Year 1, semester 1. PFG1
–
Year 1, semester 2. PFG2
–
Complex 2D games.
Year 2, semester 2. PFG4
–
Simple 2D arcade games.
Year 2, semester 1. PFG3
–
Text adventures.
3D games on a console.
Year 4. Games case project. Individual
project. Specialist Games Programming
Subject matter
How to program in C++.
How to program in any language.
Good programming practice.
Games? Where possible, but you are just
starting out.
See module guide for subject matter each
week.
Schedule
Check module guide
Check eLearning portal
Your work each week.
Two lectures.
The seminar – work through exercises,
making use of tutor’s assistance.
Eight hours of own time – online quiz and
continue with exercises.
Three hours of own time – self-directed
study.
Best to start week’s exercises BEFORE
seminar.
Your work each week.
Lectures
–
–
–
–
–
–
Listen and absorb. Ask yourself: “Do you
understand this?”
Ask questions.
Add to the notes. (Bring a pen and notepaper.)
Keep the notes in a file.
Review the notes afterwards and before the next
lecture.
Summarise?
Your work each week.
Exercises:
–
–
–
–
–
Written questions on the eLearning Portal.
Orders to find stuff out from the lectures.
Programming problems from the workbook.
Programming exercises from the workbook.
Case study from the workbook.
eLearning exercises
Each week, there are a number of short
questions on the eLearning Portal.
–
–
–
These are all multi-choice, one-word answer or
true/false type questions.
You get some feedback if you get them wrong.
You also get a mark, but this does not affect your
module mark.
Sometimes I may be expecting a particular answer, and
you give a different, but also correct answer. The
computer may tell you that you are wrong.
Get over it.
Lab book
The booklet has lots of programming
exercises in it.
–
–
Some large, some small.
Some are a case study of a text adventure you
should make during the term.
We expect you to do ALL of the exercises in
the book.
–
If you do, you will get a high mark.
How to study programming
Do problems.
Programming is not typing.
Find answer if you are stuck, but understand it.
Think like the computer.
Think large and small at the same time.
Programming is problem solving.
It is as much about FINDING OUT how to do
something as KNOWING how to do something.
Course texts
Several alternatives
–
–
See library
Lots of copies of Dale, Weems and Headington.
See module guide
–
–
Consider the books by Stroustrup
Needed for next module …and for life.
I already know how to program!
Complete newbies – no problem, but pay close
attention in the first few weeks.
Some understanding, possibly in a different
language – That will help. Be careful not to drift off.
C++ has some oddities.
Already know C++ – Systematic approach from
scratch may improve your knowledge. We are
teaching more than just language. Games
programming asks you to REALLY understand.
Get on with it, then!
Computers are cool.
It’s the programs that make them cool.
But what is a program?
A Computer
To a physicist, a computer is lots of different
materials (metals, semiconductors and so
on) with electric and magnetic fields acting
on them in a complex way.
This viewpoint is too complex to create a
program with.
We need to simplify.
First Abstraction
We can treat the voltages as being either
“high” or “low”. 1 or 0.
These act on components (gates, transistors)
that behave in certain ways when these
voltage values are applied.
This is the view of the component engineer.
Damn hard to create a program this way.
Next Abstraction
We create systems in such a way that groups
of these numbers will act as an “instruction”
to the system.
So “11001010” means “add the number in
one part of the computer to the number in
another part of the computer.”
This is the view of the assembly programmer.
Possible to create a program this way, but
hard.
Next Abstraction
The numbers are hard to remember, so you
replace them with a word to remind you and
get a program to replace the words with
numbers. So “ADD 3A, 1F” means “add the
number in location 3A the the number in
location 1F”. Or whatever.
Assembly programmers again.
Next Abstraction
These instructions are mostly used to move
data around.
So create a higher-level language that
performs standard sets of assembly
instructions.
“Print 32;” means “run all the assembly
instructions that displays the number 32 on
the screen.
This is the viewpoint of the programmer.
Next Abstraction
It doesn’t stop there. Languages get more
and more abstracted.
“SetCooperationLevel( ddCL);” is a C++
instruction which performs lots of other C++
instructions. They may lead to other
instructions.
But they are REALLY groups of assembly
language instructions. And that is REALLY
voltages moving around wires.
if(!pTheDrawEngine) return FAILURE;
if(pTheDrawEngine->Validate()==FAILURE) return
FAILURE;
if(!pTheInputs) return FAILURE;
pTheInputs->SampleKeyboard();
pTheInputs->SampleMouse();
pTheStarField->Draw();
if(!pTheEntities) return FAILURE;
pTheEntities->Move();
pTheViewPort->Move();
pTheEntities->Draw();
Abstraction
A language that is “more abstract” is a
language that is further away from what is
really going on.
A language that is more abstract is:
–
–
–
–
More suitable for a specific job.
Easier to write large programs in.
Less efficient (slower, more memory)
Often looks more like a natural language (English)
Real programming
Real programming is not about just using the
language that is already there.
–
That’s OK for amateurs.
It’s about using the language to make your
own language.
–
More abstraction.
–
pTheViewPort->Move();
pMissile.SetTarget(player);
–
Next Abstraction
You can just keep abstracting.
The system designer often does not deal
with actual code, but with diagrams of the
program, leaving the actual coding to the
programmer.
And the information strategist does not worry
about how a program works, but where and
why to use it.
Layers of abstraction
Information strategy
Program design
High level code
Low level code
Assembly language
Gates and transistors – high and low
Voltages and currents
This module
Layers of abstraction
Information strategy
Program design
High level code
Low level code
Assembly language
Gates and transistors – high and low
Voltages and currents
This course
How do we code?
The computer understands assembly
language or “machine code”.
But it is easier for us to program at a higher
level of abstraction.
We write in a “programming language” which
gets turned into assembly language by a
program called a “compiler”.
Compiling
#include <iostream.h>
void main( )
0001101111010101
{
1100101011011010
cout << “Hello world”;
1101101010101010
1101101011010101
}
1111011010001010
Compile
1010100101101010
1101010010101000
1111111110111111
0011001101001010
Etc………..
Compiling
The code that we write is called “source
code”.
–
–
It is really just a text file.
It is only useful to a human reader or a compiler.
The file that is produced is the “executable”.
–
–
It is a program.
It can run, or “execute”.
Programming languages
There are several different languages.
–
–
–
–
–
–
–
Ada
Basic
C
C++
C#
Haskell
Java
- Fortran
- Pascal
- Dark Basic
- Perl
- SmallTalk
- Autocode
- Algol
(See http://www.roesler-ac.de/wolfram/hello.htm)
Programming languages
Some of these compile in a different way
than I have discussed.
For example, they might compile while they
are running, line by line.
This is called “interpreting”.
C++
We are going to use C++.
Why?
–
–
–
–
–
–
It is popular.
It is the main language used by the games
industry.
Many other languages are based on it.
It is fast.
It is very powerful.
It is evil.
C++
C++ is based on C.
–
–
It make is easier to create your own “language”
using things called “objects”.
It is an “object oriented” language.
JAVA is similar to C++
–
–
–
But more “object oriented”
More abstract
Less efficient (slower)
C++
Problems:
–
–
–
–
C++ is notoriously dangerous. If you make a
mistake, you can easily crash the computer.
It is easy to make mistakes.
Some parts of the language work in an irritating
way. Especially text.
Pointers.
Visual C++
The compiler we will use is “Visual Studio
C++”.
Nearly all our labs have it.
On LINUX machines, you can use G++, or
one of various other compilers.
Summary
Welcome.
The module.
How to study.
Abstraction.
Programming languages.
C++.
Work
Do the eLearning exercises.
Start the workbook.
Come to the next lecture.
Come to the seminar.
© Copyright 2026 Paperzz