Drawing at 60 + FPS
In three simple steps, we will be able to glimpse our spaceship:
- Add a
SpaceShip
object to theGameManager
member variables:private boolean playing = false; // Our first game object SpaceShip ship; int screenWidth;
- Add a call to the new
SpaceShip()
to thecreateObjects
method:private void createObjects() { // Create our game objects // First the ship in the center of the map gm.ship = new SpaceShip(gm.mapWidth / 2, gm.mapHeight / 2); }
- Add the call to draw the spaceship in each frame in the
draw
method ofAsteroidsRenderer
:// Start drawing! // Draw the ship gm.ship.draw(viewportMatrix);
Run the game and see the output:
Not exactly ...
Get Android Game Programming: A Developer’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.