4. Remove Objects

1. Removing Objects

Open the editor for your main character.

Underneath the if statements for using the arrow keys is where we type the removal code.

If you have chosen a different collectible object, type the exact name of that class instead of Orange (e.g. Apples or Ants).

2. Add Danger to your Game

Use the same code as you did earlier but change the class (instead of Orange.class I have chosen Sheep.class).

Time to code your main character to be removed if they are touched by the enemy objects!

Open the editor for your enemy class.

The removal code is placed beneath the code you have already written.

Check out the extension page if you want the game to stop when the main character is removed.

© CSNewbs 2021