Graphics Programs Reference
In-Depth Information
private final String _enemyVertexShaderCode =
"attribute vec3 aPosition; \n"
+ "uniform mat4 uM; \n"
+ "uniform mat4 uVP; \n"
+ "void main() { \n"
+ " vec4 vertex =
vec4(aPosition[0],aPosition[1],aPosition[2],1.0); \n"
+ " gl_Position = uM * vertex; \n"
+ " gl_Position = uVP * gl_Position; \n"
+ "} \n";
Interpolating Enemy Source Position
Now, we will add the code to interpolate the source position of Enemy objects ( Fig-
ures 6-8 to 6-10 , TANK FENCE GAME 5 application). For this, begin by adding
fields _dx and _dy of type float to the Enemy class. Initialize the field _dx with
a positive value, less than one. The x-coordinate of the enemy's source position will
be interpolated by _dx units.
Figure 6-8 . Setting enemy objects in motion
 
 
 
Search WWH ::




Custom Search