Last active
August 29, 2015 14:20
-
-
Save danleyb2/6bee0a61a557c8f7d735 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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