Updating enemy sprites

Space Age has four levels; for each level, a special enemy sprite is responsible for the attack and they are as follows:

  • Level one: Rock
  • Level two: Monster
  • Level three: Robot
  • Level four: Mother Ship

In the starter project, there are only two enemy sprites: Rock and Mother Ship. Both the Rock and Mother Ship have complete scripts and are ready to participate in the game. We will copy Rock to create Monster and Robot, and then tweak their local variables to increase the difficulty.

Prepare for lift off

The Rock sprite attacks by crashing and firing ammo. When created as a clone, it continues to fall down at a random speed and randomly fires rounds. The speed of falling as well as the frequency of firing the ammo are configured through min_speed, max_speed, and shoot_random_wait.

Before duplicating Rock to create new sprites, first test the Rock sprite by playing the game. Click on the green flag, and hit the Start button to start playing. If all is well, you should see the Level One information page scrolling by and the Rock clones shown as a drove. Hold the ammo, because we have yet to add scripts to the Spaceship Ammo sprite.

Prepare for lift off

Engage thrusters

Now, let's create a Monster:

  1. Right-click on Rock and select duplicate to create Rock2.
    Engage thrusters
  2. To change the name from Rock2 to Monster, click on the round i icon, and change the name to Monster.
    Engage thrusters
  3. Next, go to the Costumes tab, and delete the existing costumes. Click on Upload costume from file, and navigate to <chap4_images_dir>costumesenemiesmonster, select normal.svg and hit.svg, and click on OK.
  4. Verify whether the Monster sprite has both the normal and hit costumes as shown in the following diagram:
    Engage thrusters

Now, let's create the Robot sprite:

  1. Right-click on Rock and select duplicate to create Rock2.
  2. To change the name from Rock2 to Robot, click on the round i icon, and change the name to Robot.
  3. Create the Robot sprite costumes by navigating to <chap4_images_dir>costumesenemies obot and then import normal_robot.svg and hit_robot.svg.
  4. Verify whether the Robot sprite has both the normal and hit costumes as shown in the following diagram:
    Engage thrusters

Let's make Monster and Robot faster and shoot out more ammo. To do so, we will change the min_speed, max_speed, and shoot_random_wait variables. Navigate to Monster's Scripts tab and change its scripts as follows:

  1. Add the when <green flag> clicked script.
  2. Use set <min_speed> to () and change its value from 4 to 5.
  3. Use set <max_speed> to () and change its value from 8 to 10.
  4. Use set <shoot_random_wait> to () and change its value from 1000 to 100 (wait less, shoot more often).

The final script will look like the following screenshot:

Engage thrusters

Repeat the same steps for Robot, but make it harder:

  1. Find the when <green flag> clicked script.
  2. Use set <min_speed> to () and change its value from 4 to 6.
  3. Use set <max_speed> to () and change its value from 8 to 10.
  4. Use set <shoot_random_wait> to () and change its value from 1000 to 75 (wait less, shoot more often).

The final script will look like the following screenshot:

Engage thrusters

Objective complete – mini debriefing

We have created two new sprites by first making two copies of the Rock sprite and named them Monster and Robot. Then, we tweaked each new sprite to fall faster (min_speed and max_speed) and shoot more often (shoot_random_wait).

Classified intel

To add a copy of a sprite from one project to another project, one can right-click the sprite and select save to local file. The sprite is then saved to a file named Rock.sprite2. which can then be imported to another project.

Classified intel
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.132.99