Archived
Private
Public Access
1
0

Initial commit

This commit is contained in:
2022-09-04 12:45:01 +02:00
commit f4a01d6a69
11601 changed files with 4206660 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package de.craftix.game;
import java.awt.image.BufferedImage;
public class Animation {
private int state;
private int frame;
private int frames;
private long delay;
private long startTime;
private Spritesheed sprite;
private boolean started;
public Animation(Spritesheed sprite, int state, int frames, long delay){
this.sprite = sprite;
this.state = state;
this.frames = frames;
this.delay = delay;
frame = 0;
startTime = System.currentTimeMillis();
started = true;
}
public Animation(Spritesheed sprite, long delay) {
this.sprite = sprite;
this.delay = delay;
started = false;
}
public void update() {
if (started && System.currentTimeMillis() - startTime >= delay) {
frame++;
if (frame == frames) frame = 0;
startTime = System.currentTimeMillis();
}
}
public void start(int state, int frames) {
this.frames = frames;
this.state = state;
startTime = System.currentTimeMillis();
frame = 0;
started = true;
}
public void stop() {started = false;}
public BufferedImage getImage() {return sprite.getTexture(frame, state);}
public int getState() {return state;}
public void setImages(int state, int frames) {
this.state = state;
this.frames = frames;
frame = 0;
startTime = System.currentTimeMillis();
}
}