Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lordshigi.platinumeel;
- import java.nio.ByteBuffer;
- import java.nio.ByteOrder;
- import java.nio.FloatBuffer;
- import java.nio.ShortBuffer;
- import javax.microedition.khronos.opengles.GL10;
- public class mob_runner {
- private float verticies[] = {
- 0f,3f, 1f,-1f, -1f,-1f
- };
- private short index[] = {
- 0,1,2,
- };
- private FloatBuffer vertBuffer;
- private ShortBuffer indexBuffer;
- private int health = 10;
- public static int attack = 10;
- public static float speed = 2.0f;
- public int getHealth() {
- return health;
- }
- public boolean takeDamage(int d) {
- health -= d;
- //if the damage is under 0 (object is destroyed) send true
- if(health <= 0) {
- return true;
- }
- else {
- return false;
- }
- }
- public mob_runner() {
- ByteBuffer bBuffer = ByteBuffer.allocateDirect(verticies.length * 4);
- bBuffer.order(ByteOrder.nativeOrder());
- vertBuffer = bBuffer.asFloatBuffer();
- vertBuffer.put(verticies);
- vertBuffer.position(0);
- ByteBuffer iBuffer = ByteBuffer.allocateDirect(index.length*2);
- iBuffer.order(ByteOrder.nativeOrder());
- indexBuffer = iBuffer.asShortBuffer();
- indexBuffer.put(index);
- indexBuffer.position(0);
- }
- public void Draw(GL10 gl) {
- gl.glFrontFace(GL10.GL_CW);
- gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
- gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertBuffer);
- gl.glDrawElements(GL10.GL_TRIANGLES, index.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);
- gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment