image Tutorial on Plot 6 - Bullets

image Any character in your game can shoot bullets.

Note: only the keyboard can be used to make the controlled player shoot. Mouse clicks cannot make the player character shoot. In the following examples, we assume the player controls the pointer:

The non-player characters (NPCs) can also shoot, but NPCs cannot shoot as fast as the player character, so that the game is possible to win.

What happens when a character is shot? We must describe that as well.

Note that "is shot" is preferred over "collides with" between a character and a bullet.

Now, let us consider about clarity of sentences. Consider the following sentence
When the pointer shoots an alien, the alien blows up.
While this above sentence might seem clear to you, it is actually ambiguous. Why so? Because when the pointer shoots, the bullet may or may not hit the target. In other words, we can think of the sentence as saying:
When the pointer fires a bullet at the alien, the alien blows up.
Hence, it is essentially implying that whenever the pointer is shooting at an alien, the alien will explode, irrespective of how far the alien is from the pointer or whether the bullets touches the alien. Do you get it? So the proper way is to say
When an alien is shot, the alien blows up.


Shooting out specific objects instead of bullets

Sometimes we would like to shoot out something other than bullets. Consider the following: The action of shooting out a pearl in this example is handled by a pair of insertion + movement of the pearl. More tutorials on insertion will be discussed in a later lesson.
Try it yourself: Try typing in the following into the textbox on GameChangineer, then click "Execute" near the bottom of that page to generate the code for your game plan. If there are no typos and everything is understood, click the button at the bottom to see your code in action!

Example 1:
There are twenty carrots scattered near the top in the playing area.
There is one pointer placed near the bottom of the area.
The player controls the pointer with the keyboard.
When right arrow is pressed, the pointer moves right.
When left arrow is pressed, the pointer moves left.
When spacebar is pressed, the pointer shoots up.
When a carrot is shot, it explodes.

Example 2:
There is a spinstar at the bottom of the canvas.
The spinstar is controlled by the mouse.
When Z is pressed, the spinstar shoots up.
There are 13 aliens scattered around the top half.
The aliens move towards the spinstar.
When an alien is shot, the alien dies.
When an alien collides with the spinstar, the game is over.

Quiz: What will the following do?

When an alien is shot, it is empowered. When an alien is shot and it is empowered, it explodes.

Will the alien ever explode? Try it and see!

How would you rewrite the following sentence?
When a fox is super and collides with a rabbit, the rabbit dies.

Hint: the clause containing 'collide' must include 2 characters.


Complete Sample Games using Bullets and Power-Ups

// Game #1. Destroy the dino by moving all aliens to their corresponding gem.


// Game #2. Get to the top. Shoot the precious stones to freeze some characters.


// Game #3. Destroy the rocks and avoid the converted balls.



Next page

Tutorials Home