Game Development Reference
In-Depth Information
Objective complete - mini debriefing
Click on the script or on the <green lag> icon to test whether the script works correctly.
With these simple steps, we created a controllable player character. If your character moves
in the wrong direcion, check again if you changed the script appropriately. The let and
down direcion should have negaive values. Mixing this up can give odd results.
Classified intel
Why didn't we choose to use the much simpler movement script as shown in the
following screenshot?
The reason is that the easy way doesn't have quite the same result, and that is because most
keyboards have a peculiar way of operaing. When you irst press a key, the keyboard gives
one impulse to the computer, then pauses for a litle while. Only if you keep the key pressed,
the keyboard will start giving impulses repeiively.
This pause is included to prevent you from accidentally typing a stream of leters when
typing. Very useful for text ediing but not so much when creaing a game where you want
responsive controls that react immediately to your input.
With our loop and if key pressed combinaion, we take control of this procedure that checks
whether a buton has been pressed and can make sure that the game will respond right
away when a buton is pressed, without pausing to wait for the next impulse coming from
the keyboard.
Creating an enemy
The next step is to add an enemy for the player to dodge or defeat. We will look for another
suitable watery character to coninue the underwater theme of this game. We will make
some changes to the appearance of the character and then write some movement scripts
for the character.
Prepare for lift off
Let's search for a suitable enemy for the diver character using the following steps:
1. When we look through the library, we can ind several interesing water creatures;
crab, fish, shark, and starfish. Let's choose the starfish, because it can easily move
in diferent direcions without looking weird.
 
Search WWH ::




Custom Search