Advertisement
Guest User

Untitled

a guest
Apr 10th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. package javagame;
  2.  
  3.  
  4. import org.newdawn.slick.Image;
  5. import org.newdawn.slick.geom.Vector2f;
  6.  
  7. public class Enemy {
  8.    
  9.     String name;
  10.     float speed = 0.025f;
  11.     int angle;
  12.     int width = 30;
  13.     int height = 39;
  14.     int hp = 40;
  15.     int xp = 20;
  16.     Vector2f position = new Vector2f((int)(40+Math.random()*670),(int)(60+Math.random()*470));
  17.     Vector2f velocity = new Vector2f(0,0);
  18.     Box hitbox = new Box(0,0,30,39);
  19.     Image image = null;
  20.     boolean hit=false;
  21.     int hitt = 0; // hit time , counter when mob was hit
  22.  
  23.  
  24.     // follow
  25.     // Yui Jegnan: or wonder around  issac fly
  26.  
  27.    
  28.     public Enemy(Image image, String name) {
  29.        
  30.         this.name = name;
  31.         this.image = image;
  32.     }
  33.  
  34.  
  35.  
  36.     void boundriesCheck()
  37.     {
  38.         if( this.position.x>720 )
  39.             this.position.x=720;
  40.        
  41.         if( this.position.x<50 )
  42.             this.position.x=50;
  43.        
  44.         if( this.position.y>520 )
  45.             this.position.y=520;
  46.        
  47.         if( this.position.y<50 )
  48.             this.position.y=50;
  49.        
  50.  
  51.     }
  52.    
  53.     void update(int delta){
  54.         if(hit == true){
  55.             hitt+=delta;
  56.         }
  57.         if(hitt > 50) // ms
  58.         {
  59.             //image.setImageColor(1,1,1,1);
  60.             image.setColor(0,1,1,1,1);
  61.             image.setColor(1,1,1,1,1);
  62.             image.setColor(2,1,1,1,1);
  63.             image.setColor(3,1,1,1,1);
  64.             hitt = 0; // reset time
  65.    
  66.         }
  67.     }
  68.     void hit(int dmg){
  69.         this.hp -= dmg;
  70.         this.hit = true;
  71.         image.setColor(0,1,0,0,1);
  72.         image.setColor(1,1,0,0,1);
  73.         image.setColor(2,1,0,0,1);
  74.         image.setColor(3,1,0,0,1);
  75.  
  76.     }
  77.     public boolean  isAlive(){
  78.        
  79.         if(hp<0 || hp == 0)
  80.             return false;
  81.         else
  82.             return true;
  83.     }
  84.    
  85.     public float getX(){
  86.         return position.x;
  87.     }
  88.    
  89.     public float getY(){
  90.         return position.y;
  91.     }
  92.    
  93.     public void giveVel(Vector2f a){
  94.         this.velocity = a;
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement