Defining the shape

As we've learned from the previous part, we will first create a class of our pyramid in order to define our shape. So create a file to define the shape of our pyramid object.

Our pyramid has five faces, so we will require five vertices to draw our pyramid. So after you create your, we will define our vertices, as follows:

//Package name of our gamepublic class Pyramid {    private float[] vp = { // 5 vertices of the pyramid in (x,y,z)            -1.0f, -1.0f, -1.0f,  //left-bottom-back            1.0f, -1.0f, -1.0f,  //right-bottom-back            1.0f, -1.0f,  1.0f,  //right-bottom-front            -1.0f, -1.0f,  1.0f,  //left-bottom-front            0.0f,  1.0f,  0.0f   //top    };}

Alright, now we have our vertices set, but just like our triangle, we still have ...

Get Learning Android Game Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.