Guest User

Untitled

a guest
Jun 3rd, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. package com.lordshigi.platinumeel;
  2.  
  3. import java.nio.ByteBuffer;
  4. import java.nio.ByteOrder;
  5. import java.nio.FloatBuffer;
  6. import java.nio.ShortBuffer;
  7.  
  8. import javax.microedition.khronos.opengles.GL10;
  9.  
  10. public class mob_runner {
  11.    
  12.     private float verticies[] = {
  13.         0f,3f,  1f,-1f,   -1f,-1f
  14.     };
  15.    
  16.     private short index[] = {
  17.             0,1,2,
  18.         };
  19.    
  20.     private FloatBuffer vertBuffer;
  21.     private ShortBuffer indexBuffer;
  22.    
  23.     private int health = 10;
  24.     public static int attack = 10;
  25.     public static float speed = 2.0f;
  26.    
  27.     public int getHealth() {
  28.         return health;
  29.     }
  30.    
  31.     public boolean takeDamage(int d) {
  32.         health -= d;
  33.         //if the damage is under 0 (object is destroyed) send true
  34.         if(health <= 0) {
  35.             return true;
  36.         }
  37.         else {
  38.             return false;
  39.         }
  40.     }
  41.    
  42.     public mob_runner() {
  43.         ByteBuffer bBuffer = ByteBuffer.allocateDirect(verticies.length * 4);
  44.         bBuffer.order(ByteOrder.nativeOrder());
  45.         vertBuffer = bBuffer.asFloatBuffer();
  46.         vertBuffer.put(verticies);
  47.         vertBuffer.position(0);
  48.        
  49.         ByteBuffer iBuffer = ByteBuffer.allocateDirect(index.length*2);
  50.         iBuffer.order(ByteOrder.nativeOrder());
  51.         indexBuffer = iBuffer.asShortBuffer();
  52.         indexBuffer.put(index);
  53.         indexBuffer.position(0);
  54.     }
  55.    
  56.     public void Draw(GL10 gl) {
  57.         gl.glFrontFace(GL10.GL_CW);
  58.         gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  59.         gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertBuffer);
  60.         gl.glDrawElements(GL10.GL_TRIANGLES, index.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);
  61.         gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment