Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So it always surprises me how successful some really simple games like this can be my son absolutely
loves playing this sort of game on his iPod.
And this is entirely based at this stage on addition and subtraction.
So even with these simple mechanics we can have a lot of fun.
So let's dive in and start with the very basics of mathematics addition and subtraction so you in the
Okay guys let's get moving let's get on with addition and subtraction the very starting point now look
I'm not going to keep you too long with this because it's simple stuff but there are a few gotchas with
regards to game development that I want to show you about.
So throughout this course we're going to be using something that I'm going to call the number line as
a starting point.
So that's just a line in space I'm drawing here.
All right.
And then we're going to imagine to start with that we have a zero point maybe on the left hand side
here.
So this is just a line that represents numbers and this guy here is zero.
So as our numbers progressed we've got one and then maybe two and then maybe three and then maybe four.
OK.
Now addition is simply moving to the right on this number line like so each time we add one we're doing
this.
If we were to add four we would be doing this nice and simple.
So that's addition what is subtraction.
Well subtraction is moving left.
So maybe I use a different color for subtraction perhaps a gain a green if we were to take four and
subtract two we get down to two.
OK.
And if we were to subtract take one and subtract one we get down to zero.
Very simple.
So the other option that we have here is to have a negative values on the number of lines.
Let's take a little look at how that would work.
So we can have a very similar number line.
But this time let's imagine that this number line the zero is shifted across and that we have zero here.
All right.
Right in the middle there.
Let's say now we can play with things called negative numbers.
So if I have maybe 0 1 sheep or two sheep or three sheep and I want to take away a certain number of
sheep then if you said hey you've got two sheep give me three.
We would end up back here at a number that we're going to call minus one.
So negative numbers.
All right super simple.
That's all I'm going to say about the number line for the moment for you.
So what we need to think about when we're using a game engine with numbers is a few things.
Firstly we want to look at overflow limit.
So if I pop here this is an older version of Unity game engine and it doesn't matter it's the same in
a lot of languages and I start with a big number.
Now I've chosen this number for a reason.
This is we'll find out later.
A 32 bit integer.
So this means the total size that this can be is just over 2 billion.
So I've set them under just under its limits and then I've just got a thing that's going to print out
the number and then keep updating it.
So let's just look at that happening.
So I come along I hit play.
We go to the console and look what happens if we scroll back in the console the number goes up and up
and up and up and then eventually hook ups suddenly goes negative.
Mm hmm.
So we'll find out what's going on there.
At another stage in the course when we look at the floating point representation.
But what you need to understand is that one of the gotchas on a computer is the idea that you have limits
of a number.
And it may not fail nicely you may end up with it going from 2 billion to minus 2 billion when your
code said to do is to add what's so big got you.
There are other things we need to look at is the idea that when we're placing things together on a computer
we're not necessarily dealing with the same time.
We may have on one side of this we may have a hole number somewhere else we may have a decimal number
so we need to be a little bit careful of that plus operators on computers tend to do lots of different
things and you sometimes need to hover over them or look in your documentation to find out exactly what
your your thing is doing on machines day.
And the other thing to say about addition and subtraction is it can be done in any order so addition
can be done in any order one plus two equals two plus one.
The same thing they both equal three when it comes to subtraction.
They can't be done in any order one minus two does not equal and I'm going to use that symbol there
which is an equals with a cross rate does not equal to minus one because one minus two is minus one
as we saw before and that does not equal to two minus one which is one.
All right.
So be careful of the order of subtraction.
Understand that you could blow your limits on a computer of what is possible in terms of the range of
the numbers you're dealing with and be a little bit careful those plus operators because I can catch
you out they might do things you're not expecting that's enough on addition of subtraction for now let's
dive into the next lecture.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.