Game Development 102 (for dummies like me)

Alright, so I said that I would have something to display, for Game Development – particularly 102.

In this post – we’ll explore Trigonometry and how games use it, assuming you followed the previous post and brushed up on the subjects (physics wasn’t really necessary, but I did say it was a bonus, it’s basically for the more advanced stuff such as “trajectory” and kinetic energy, I didn’t do Physics but it’s a fundamental unwritten rule for Development of a game to understand terms – I’ll elaborate later on this, if you plan on building a shooter game, you’ll need to determine how long a bullet travels for at whatever angle, and what the trajectory would be, what the loss of acceleration blah blah (didn’t do physics excuse)… a perfect example for this is Battlefield and it’s somewhat simulated coding for “Bullet Drop”.. but that’s for another time..(when I actually understand it in a little more detail)

I want to talk about AI, How much do you know about Artificial Intelligence? Alot? .. This much?… Not so much? It doesn’t matter

Know your Trig’


To many a person’s surprise, Trigonometry is a major factor in 3D and 2D games,
Everyone uses Trig at some point, some don’t even realise it – let’s examine the above Triangle

ok! first thing I think we notice is it’s a Right Triangle,  the longest side of a Triangle is always called the Hypotenuse

and always sits opposite a Right angle, the next thing to take into consideration is the Opposite and Adjacent, which are always to the left and the right of a right angle  BUT depend on the “point of angle” e.g from angle β (Beta)  Adjacent would = α (Alpha’s) Opposite


above and below: your functional weaponry to find angles for triangles with lengths


more functions to think about.

So What’s so cool about Trigonometry

Probably the coolest thing about Trig is it can be used to find out a lot of things in games if you’re given very little information for example


Those Triangles, I added.. because that’s how this game works – a 2D plane with 2 Axis the largest blue one shows “Matilda’s” position in an X,Y format, the smaller one, the distance between Matilda and Razer and same again, the RED triangle is Razer’s position, the smaller one being Razer’s distance to Matilda we have the length of X (based on the length of the triangle’s Opposite side) which we could say is  estimated around 600 pixels and we want to find out what Y is.. STOP! (for a second and attempt to solve this yourself.. what function would I need to use to find Y?? if X = 600 take note that This image uses what is known as the “Descartes Co ordinates” rather than what most people would be used to (Google: Cartesian Plane/ Co ordinates))

Did you get it?? sin(45) * 600 Hint – Right angle Triangles Operate at a 90 45 45  and 30 60 90 angle systems to create the half-circle 180 angles (among the most commonly used triangles)..

sin(45) * 600 = 510
so our X=600
and Y=510
assuming my Math is right.(I suck at math)

but looking at the image it looks about right.. Y could be a little more close to 500? making X 580 no precision here we’re not working with floats or doubles yet… but just take it as an example, gaming uses trigonometry..
OK enough talk about Maths, functions and trig – lets start..

First you’ll need to visit Robocode and download the most recent software..
Next and I do this myself… READ THE DOCUMENTATION – even if you don’t understand it, READ IT!!!
Look at other Robocoder’s coding, try and interpret it in a way that you can explain it and re-write it in your own form,
and build your own robot, Next semester you can pitch your robot against mine (Jan 2015) since mine is still in beta builds you can explore other options for problem solving, plan your robot’s “personality” (Is it a 1v1 bot, a sniper? (huge sized battlefields and a bot that shoots with 100% guarantee a hit unless dodged) a melee bot (rambot) is it a Dodge bot? is it a scan and shoot (see myfirstrobot) Use robocode to introduce yourself to AI and Methods, statements and classes (Your robot is pretty much a class file).. it’s a good idea to generalise your idea and build further, prepare your code before hand – if you plan on making any alterations, copy the blocks of code, comment out the originals and that way you have a back up of your original concepts, if you find yourself losing your footing.. start again, just make sure you can understand your code..

If you’ve got any suggestions please post a comment, if you have an itch to scratch and would like to test bots and do some codestorming just post a comment..