DroidQuest/src/com/droidquest/items/SkyGuard.java

57 lines
1.3 KiB
Java
Raw Normal View History

2014-02-02 18:39:08 -03:00
package com.droidquest.items;
import javax.swing.ImageIcon;
import com.droidquest.Room;
public class SkyGuard extends Item {
private int animationState = 0;
private int speed;
public SkyGuard(int X, int Y, Room r, int s) {
x = X;
y = Y;
room = r;
speed = s;
width = 28;
height = 32;
grabbable = false;
GenerateIcons();
}
public void GenerateIcons() {
icons = new ImageIcon[5];
for (int a = 0; a < 5; a++) {
2015-11-24 14:59:27 -03:00
icons[a] = new ImageIcon(getClass().getResource("/images/skyguard" + a + ".gif"));
}
currentIcon = icons[0].getImage();
}
public void Animate() {
animationState = 1 - animationState;
if (speed > 0) {
if (speed + x < 420) {
moveRight(speed);
currentIcon = icons[animationState].getImage();
}
else {
speed = -speed;
currentIcon = icons[2].getImage();
}
}
else if (speed < 0) {
if (speed + x > 112) {
moveLeft(-speed);
currentIcon = icons[3 + animationState].getImage();
}
else {
speed = -speed;
currentIcon = icons[2].getImage();
}
}
}
2014-02-02 18:39:08 -03:00
}