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), ...

Get OpenGL ES 2 for Android 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.