Jump to content

Move A 2d Square On Y Axis On Android Gles2


Recommended Posts

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 dosent move the square at all and i cant find any tutorials for GLES20 The on draw frame function in the render class updates the users position based on accleration dew 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);
	}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...