O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

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

Updating Our Objects

Now that we have an object builder, we’ll need to update our Mallet class since we’re no longer drawing it as a point. We’ll also need to add a new Puck class. Let’s start with the puck. Create a new class in the same package called Puck, and add the following code to the class:

AirHockeyWithImprovedMallets/src/com/airhockey/android/objects/Puck.java
 
private​ ​static​ ​final​ ​int​ POSITION_COMPONENT_COUNT = 3;
 
 
public​ ​final​ ​float​ radius, height;
 
 
private​ ​final​ VertexArray vertexArray;
 
private​ ​final​ ​List​<DrawCommand> drawList;
 
 
public​ Puck(​float​ radius, ​float​ height, ​int​ numPointsAroundPuck) {
 
GeneratedData generatedData = ObjectBuilder.createPuck(​new​ Cylinder(
 
new​ ​Point​(0f, 0f, 0f), ...

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