I am trying to create a simple game for Android. To start, I am trying to make the square move down the y-axis, but the way I am doing it, it doesn't move the square at all and I can't find any tutorials for GLES20.
The onDrawFrame
function in the render
class updates the user's position based on acceleration due to gravity, gets the transform matrix from the user
class which is used to move the square down, then the program draws it.
All that happens is that the square is drawn; no motion happens:
public void onDrawFrame(GL10 gl)
{
user.update(0.0, phy.AccelerationDewToGravity);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); // Re draws black background
GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false, 12, user.SquareVB);//triangleVB);
GLES20.glEnableVertexAttribArray(maPositionHandle);
GLES20.glUniformMatrix4fv(maPositionHandle, 1, false, user.getTransformMatrix(), 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
The update
function in the player
class is
public void update(double vh, double vv)
{
Vh += vh; // Increase horrzontal Velosity
Vv += vv; // Increase vertical velosity
//Matrix.translateM(mMMatrix, 0, (int)Vh, (int)Vv, 0);
Matrix.translateM(mMMatrix, 0, mMMatrix, 0, (float)Vh, (float)Vv, 0);
}