June 2015
Intermediate to advanced
388 pages
7h 31m
English
This class is nice and simple, although it will evolve with the project. The constructor receives the starting location within the game world. We set the ship's type and world location using the methods from the GameObject class, and we set a width and height.
We declare and initialize some variables to simplify the initialization of the model space coordinates, and then we go ahead and initialize a float array with three vertices that represent the triangle that is our ship. Note that the values are based around a center of x = 0 and y = 0.
All we do next is, call setVertices(), and GameObject will prepare the ByteBuffer ready for OpenGL:
public class SpaceShip extends GameObject{ public SpaceShip(float worldLocationX, float worldLocationY){ ...Read now
Unlock full access