O'Reilly logo

Android Game Programming by Example by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bringing the spaceship to life

First, we need to add a bit more functionality to our GameObject class. We do so in GameObject because bullets and asteroids share a surprising amount of similarities with a spaceship.

We need a bunch of getters and setters to get and set the rotation rate, traveling angle, and facing angle. Add the following methods to the GameObject class:

public void setRotationRate(float rotationRate) { this.rotationRate = rotationRate; } public float getTravellingAngle() { return travellingAngle; } public void setTravellingAngle(float travellingAngle) { this.travellingAngle = travellingAngle; } public float getFacingAngle() { return facingAngle; } public void setFacingAngle(float facingAngle) { this.facingAngle = facingAngle; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required