Skip to content

Instantly share code, notes, and snippets.

@danleyb2
Last active August 29, 2015 14:20
Show Gist options
  • Save danleyb2/6bee0a61a557c8f7d735 to your computer and use it in GitHub Desktop.
Save danleyb2/6bee0a61a557c8f7d735 to your computer and use it in GitHub Desktop.
import java.awt.*;
import javax.swing.ImageIcon;
public class Enemy {
Image img;
int x, y;
boolean isAlive = true;
public Enemy(int startX, int startY, String location)
{
x = startX;
y = startY;
ImageIcon l = new ImageIcon(location);
img = l.getImage();
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public boolean Alive()
{
return isAlive;
}
public Image getImage()
{
return img;
}
public void move(int dx, int left)
{
if (dx == 1 && !((left + dx )< 150))//Added this to only move enemy when character moves forward (not back)
x = x - dx;
}
public Rectangle getBounds()
{
return new Rectangle(x,y, 19, 23);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment