Nu for real, playeranimatie

This commit is contained in:
Dofensmirtsz
2015-06-08 09:53:16 +02:00
parent 38c4785fd2
commit bbc6747d41
5 changed files with 41 additions and 6 deletions
+40 -5
View File
@@ -9,25 +9,54 @@ import java.awt.image.BufferedImage;
public class Player extends DrawObject {
private BufferedImage img;
private BufferedImage img,pulse;
private AffineTransform transform;
private int lastindex;
private Point2D middlePoint;
private int subImgX,subImgY, indexCursor =0;
private int subImgXBeat, indexBeat = 0;
private boolean beat = false;
public Player(int x, int y){
img = Images.getImage(Images.ImageType.player2);
width = img.getWidth();
height = img.getHeight();
img = Images.getImage(Images.ImageType.cursor);
pulse = Images.getImage(Images.ImageType.pulse);
width = 100;//img.getWidth();
height = 100;//img.getHeight();
lastindex = -10;
middlePoint = new Point2D.Double(x,y);
}
public void draw(Graphics2D g2){//
g2.drawImage(img, transform, null);
subImgX = (indexCursor % 8)*100;
subImgY = (indexCursor / 8)*100;
subImgXBeat = (indexBeat % 9)*100;
BufferedImage subImg2 = pulse.getSubimage(subImgXBeat,0,100,100);
g2.drawImage(subImg2, transform, null);
BufferedImage subImg = img.getSubimage(subImgX,subImgY,100,100);
g2.drawImage(subImg, transform, null);
}
public void update(float update){
if(beat){
indexBeat++;
if(indexBeat >= 9)
{
indexBeat = 0;
beat = false;
}
}
indexCursor++;
indexCursor%=32;
if(lastindex != index){
transform = new AffineTransform();
transform.rotate(Math.toRadians(index*45),middlePoint.getX(),middlePoint.getY());
@@ -35,5 +64,11 @@ public class Player extends DrawObject {
lastindex = index;
}
}
public void setBeat() {
beat = true;
indexBeat = 0;
}
}