Game Development Reference
In-Depth Information
8.
Just keep in mind that the cannon consists of two separate shapes. You can color
them separately, or you can color them together by irst selecing both the shapes
while holding the Shift key.
Objective complete - mini debriefing
We've now got ourselves a cannon and some ammuniion to shoot with.
Starting scripts
Let's have some fun making the cannon shoot its cannonball. It's always a good idea
to script and test the interacive parts of your game as early as possible. Without scripts,
it's just a bunch of prety pictures! They might be nice to look at, but they won't keep the
player entertained for long.
Engage thrusters
We have two objects to script. Object is an official programmer word that means something
that performs an acion in a program.
In this case the objects are visible. Our sprites are our objects. We have a cannonball and
a cannon. The player will be able to control the direcion of the cannon. The cannonball will
ly away in a certain direcion based on which way the cannon is poining. So the way things
are controlled is:
player → cannon → cannonball
Let's create a short script for the cannon. This script will save the direcion the cannon is
poining to, so that the cannonball will know in which direcion to ly.
 
Search WWH ::




Custom Search