Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javagame;
- import org.newdawn.slick.Image;
- import org.newdawn.slick.geom.Vector2f;
- public class Enemy {
- String name;
- float speed = 0.025f;
- int angle;
- int width = 30;
- int height = 39;
- int hp = 40;
- int xp = 20;
- Vector2f position = new Vector2f((int)(40+Math.random()*670),(int)(60+Math.random()*470));
- Vector2f velocity = new Vector2f(0,0);
- Box hitbox = new Box(0,0,30,39);
- Image image = null;
- boolean hit=false;
- int hitt = 0; // hit time , counter when mob was hit
- // follow
- // Yui Jegnan: or wonder around issac fly
- public Enemy(Image image, String name) {
- this.name = name;
- this.image = image;
- }
- void boundriesCheck()
- {
- if( this.position.x>720 )
- this.position.x=720;
- if( this.position.x<50 )
- this.position.x=50;
- if( this.position.y>520 )
- this.position.y=520;
- if( this.position.y<50 )
- this.position.y=50;
- }
- void update(int delta){
- if(hit == true){
- hitt+=delta;
- }
- if(hitt > 50) // ms
- {
- //image.setImageColor(1,1,1,1);
- image.setColor(0,1,1,1,1);
- image.setColor(1,1,1,1,1);
- image.setColor(2,1,1,1,1);
- image.setColor(3,1,1,1,1);
- hitt = 0; // reset time
- }
- }
- void hit(int dmg){
- this.hp -= dmg;
- this.hit = true;
- image.setColor(0,1,0,0,1);
- image.setColor(1,1,0,0,1);
- image.setColor(2,1,0,0,1);
- image.setColor(3,1,0,0,1);
- }
- public boolean isAlive(){
- if(hp<0 || hp == 0)
- return false;
- else
- return true;
- }
- public float getX(){
- return position.x;
- }
- public float getY(){
- return position.y;
- }
- public void giveVel(Vector2f a){
- this.velocity = a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement