Working with computer graphics is both an art and a science. The art component is the relentless pursue for attention to detail, story telling, scene design, character animation and more. On the other hand in order to make the games render high quality images while doing thousands of other computations requires sophisticated algorithms and a good understanding of physics to describe the interaction between objects. Of course physical laws can be changed in virtual worlds such as changing the gravity variable. Imagine a game where gravity changes randomly not knowing what to expect. I am going to pitch the idea to my kids.
Well you are probably reading this because you actually want to get started so I will get right to it. Learning Python is a very good step if you want to learn how to make games. First it is very easy to read and you can describe real physical environments using advanced libraries such as VPython. Below the code used in the interactive section of this blog for bouncing ball:
from visual import *
floor = box (pos=vector(0,0,0), length=4, height=0.5, width=4, color=color.blue)
ball = sphere (pos=vector(0,4,0), radius=1, color=color.red)
ball.velocity = vector(0,-1,0)
dt = 0.01
while 1:
rate (100)
ball.pos = ball.pos + ball.velocity*dt
if ball.pos.y < ball.radius:
ball.velocity.y = abs(ball.velocity.y)
else:
ball.velocity.y = ball.velocity.y - 9.8*dt
Creating a full 3D animation that can be rotated, zoomed and panned in a very fast way in just few lines of code. Moreover the code is so easier to read and making the translation from Newtonian laws to code couldn't be easier. Since the example is simple it only plays in the x-y plane, but with a little twist it can be changed to consider the z plane as well. Also if you notice if that 9.8 (gravity constant) is changed to call a random function then you will have a bouncing ball in a virtual crazy world. And if you multiply by a negative factor, then your ball will shoot up flying instead. Also positions, angles, colours, etcetera can be easily customized and the velocity set by playing with vector used to define the ball velocity.
This library is used by scientists to model physical behaviour and to create simulations by simply writing code in Python to describe it.
Of course the previous example assumes you understand how the while loop and the conditional statements work. But if you are new to programming, no worries you can start by using simpler libraries such as Py Turtle by importing turtle library:
import turtle
t = turtle.Turtle()
t.forward(100)
This simple example will create a simple line of length 100. There are many methods or functions within the turtle library that can be accessed. This is probably the best way to get familiar with the Python language syntax and work your way up with many examples that are available on-line. Once you feel comfortable, you will outgrow turtle very quickly and then you can venture to use other libraries such as pygal designed to create different charting objects. This could be very useful when showing statistics for your players or you may consider using a spider chart as a navigation control giving you multiple axis control.
Next stop is pygame library is very rich and powerful for 2D animation. The interface allows more serious graphing capabilities and will allow you to learn the basics of animation principles such as controlling framing, boundary considerations, where logic needs to be placed, sprites which will require understanding of arrays, lists and classes. As you can see now it is becoming more serious in terms of programming knowledge. Nothing to worry about it, as you have learned your way up, it will be more natural to you.
However, in order to move to the next level, understanding of high school physics is required and vectorial maths will be a must. Yes matrices and algebra will come very handy once and for all. This might sound intimidating at first but once you jump over this hurdle then you are into really fancy stuff. For example you can use the Blender Game engine by importing bge and produce animation that control multiple objects as you can see in the video below:
Well you are probably reading this because you actually want to get started so I will get right to it. Learning Python is a very good step if you want to learn how to make games. First it is very easy to read and you can describe real physical environments using advanced libraries such as VPython. Below the code used in the interactive section of this blog for bouncing ball:
from visual import *
floor = box (pos=vector(0,0,0), length=4, height=0.5, width=4, color=color.blue)
ball = sphere (pos=vector(0,4,0), radius=1, color=color.red)
ball.velocity = vector(0,-1,0)
dt = 0.01
while 1:
rate (100)
ball.pos = ball.pos + ball.velocity*dt
if ball.pos.y < ball.radius:
ball.velocity.y = abs(ball.velocity.y)
else:
ball.velocity.y = ball.velocity.y - 9.8*dt
Creating a full 3D animation that can be rotated, zoomed and panned in a very fast way in just few lines of code. Moreover the code is so easier to read and making the translation from Newtonian laws to code couldn't be easier. Since the example is simple it only plays in the x-y plane, but with a little twist it can be changed to consider the z plane as well. Also if you notice if that 9.8 (gravity constant) is changed to call a random function then you will have a bouncing ball in a virtual crazy world. And if you multiply by a negative factor, then your ball will shoot up flying instead. Also positions, angles, colours, etcetera can be easily customized and the velocity set by playing with vector used to define the ball velocity.
This library is used by scientists to model physical behaviour and to create simulations by simply writing code in Python to describe it.
Of course the previous example assumes you understand how the while loop and the conditional statements work. But if you are new to programming, no worries you can start by using simpler libraries such as Py Turtle by importing turtle library:
import turtle
t = turtle.Turtle()
t.forward(100)
This simple example will create a simple line of length 100. There are many methods or functions within the turtle library that can be accessed. This is probably the best way to get familiar with the Python language syntax and work your way up with many examples that are available on-line. Once you feel comfortable, you will outgrow turtle very quickly and then you can venture to use other libraries such as pygal designed to create different charting objects. This could be very useful when showing statistics for your players or you may consider using a spider chart as a navigation control giving you multiple axis control.
Next stop is pygame library is very rich and powerful for 2D animation. The interface allows more serious graphing capabilities and will allow you to learn the basics of animation principles such as controlling framing, boundary considerations, where logic needs to be placed, sprites which will require understanding of arrays, lists and classes. As you can see now it is becoming more serious in terms of programming knowledge. Nothing to worry about it, as you have learned your way up, it will be more natural to you.
However, in order to move to the next level, understanding of high school physics is required and vectorial maths will be a must. Yes matrices and algebra will come very handy once and for all. This might sound intimidating at first but once you jump over this hurdle then you are into really fancy stuff. For example you can use the Blender Game engine by importing bge and produce animation that control multiple objects as you can see in the video below:
If you are looking for more advanced rendering, weather factors, sound effects, shadows,skinning (making humanoids as real as possible). Then you have to look for a game engine libraries such as Panda3D or Neoaxis. These are the same game engines used by the gaming and filming industry. Did you know Lucas Arts uses Python too?
Many of the game engines are free to use and very well supported. It takes a lot of time to master gaming techniques. It's a profession and many colleges are now offering accreditation and degrees as a reflection of how much the industry has evolved..It's the work of a team and requires many smart and creative people to produce the most popular games that my kids now enjoy.
I hope today's article gives you a vector with the added flavour to help you get started in game design. Cool I just realize I have added a new dimension to my vector :) I hope is as sweet to you as it is to me.
Cheers for now, and as always if you want to share your stories feel free to send me a comment.
Happy gaming design,
Omar
Many of the game engines are free to use and very well supported. It takes a lot of time to master gaming techniques. It's a profession and many colleges are now offering accreditation and degrees as a reflection of how much the industry has evolved..It's the work of a team and requires many smart and creative people to produce the most popular games that my kids now enjoy.
I hope today's article gives you a vector with the added flavour to help you get started in game design. Cool I just realize I have added a new dimension to my vector :) I hope is as sweet to you as it is to me.
Cheers for now, and as always if you want to share your stories feel free to send me a comment.
Happy gaming design,
Omar