Motivation
The danger is increasing. Ripley already knows how to fight the aliens, but getting rid of them will not be so easy. At the end of our mission, a breeding ground for new aliens is emerging, which will awaken as soon as Ripley approaches.
Manager sends greetings from the operations center.
Instructions
Step 1: Threat from below
Task 1.1
In the package sk.tuke.kpi.oop.game, create the SpawnPoint class representing a breeding ground.
The class should have a constructor with one parameter that determines how many aliens can be created in the breeding ground. The breeding ground should be represented by the sprite spawn.
spawn.png (sprite size: 32x32).
Task 1.2
Ensure that a new alien is created at the location of the breeding ground as soon as Ripley comes within at least 50 points of the center of the breeding ground.
In this task, you can schedule an action using a method reference.
Task 1.3
Now a large number of aliens is being created in the breeding ground at a very fast pace. Each time a new alien is created, pause the creation of further aliens for 3 seconds.
Task 1.4
Finally, use the constructor parameter to deactivate the breeding ground so that it no longer creates new aliens.
To cancel the action, use the dispose() method.
Task 1.5
Verify your implementation.
The breeding ground should create as many aliens as specified in the constructor parameter. Aliens are created whenever Ripley is nearby, but there is always a three-second pause between them.
Additional Resources
- Java Tutorial: Anonymous Classes
- Callback: passing executable code as a function call argument, wikipedia.org
- Lambda expressions: wikipedia.org
- Observer design pattern: wikipedia.org, sourcemaking.com
- Decorator design pattern: wikipedia.org, sourcemaking.com