June 2015
Intermediate to advanced
388 pages
7h 31m
English
I've been addicted to games since Pong in the '70s, and remember my delight when a friend actually had a Space Invaders machine in his home for about a week. Although what really made asteroids so much better than Space Invaders, was how quickly you could shoot. In that tradition, we will make a satisfying, rapid fire stream of bullets.
Create a new class called Bullet, which has one vertex and will be drawn with a point. Note that we also declare and initialize an inFlight Boolean.
public class Bullet extends GameObject { private boolean inFlight = false; public Bullet(float shipX, float shipY) { super(); setType(Type.BULLET); setWorldLocation(shipX, shipY); // Define the bullet // as a single point // in exactly the coordinates ...Read now
Unlock full access