Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>main
parent
2ae7c9dc19
commit
8ba9307465
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,44 @@ |
||||
package sig.engine; |
||||
|
||||
public abstract class AnimatedObject extends Object{ |
||||
|
||||
double currentFrame; |
||||
double animationSpd; |
||||
AnimatedSprite animatedSpr; |
||||
|
||||
protected AnimatedObject(AnimatedSprite spr, double animationSpd, Panel panel) { |
||||
super(panel); |
||||
this.spr=this.animatedSpr=spr; |
||||
this.animationSpd=animationSpd; |
||||
this.currentFrame=0; |
||||
} |
||||
|
||||
public void update(double updateMult) { |
||||
this.currentFrame+=this.animationSpd*updateMult; |
||||
} |
||||
|
||||
public double getCurrentFrame() { |
||||
return currentFrame; |
||||
} |
||||
|
||||
public void setCurrentFrame(double currentFrame) { |
||||
this.currentFrame = currentFrame; |
||||
} |
||||
|
||||
public double getAnimationSpd() { |
||||
return animationSpd; |
||||
} |
||||
|
||||
public void setAnimationSpd(double animationSpd) { |
||||
this.animationSpd = animationSpd; |
||||
} |
||||
|
||||
public AnimatedSprite getAnimatedSpr() { |
||||
return animatedSpr; |
||||
} |
||||
|
||||
public void setAnimatedSpr(AnimatedSprite animatedSpr) { |
||||
this.animatedSpr = animatedSpr; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,35 @@ |
||||
package sig.engine; |
||||
|
||||
import java.io.File; |
||||
|
||||
public class AnimatedSprite extends Sprite{ |
||||
int frameWidth; |
||||
int frameHeight; |
||||
int frames; |
||||
Rectangle[] frames_to_Rectangle; |
||||
|
||||
AnimatedSprite(File filename, int width, int height){ |
||||
super(filename); |
||||
this.frameWidth = width; |
||||
this.frameHeight = height; |
||||
frames = (this.width/width)*(this.height/height); |
||||
frames_to_Rectangle = new Rectangle[frames]; |
||||
for(int i=0;i<frames;i++){ |
||||
int x_tile = i%(this.width/width); |
||||
int y_tile = i/(this.width/width); |
||||
frames_to_Rectangle[i] = new Rectangle(x_tile*width, y_tile*height, width, height); |
||||
} |
||||
} |
||||
public Rectangle getFrame(int index){ |
||||
return frames_to_Rectangle[index%frames]; |
||||
} |
||||
public int getFrame_count(){ |
||||
return frames; |
||||
} |
||||
public int get_original_width(){ |
||||
return this.width; |
||||
} |
||||
public int get_original_height(){ |
||||
return this.height; |
||||
} |
||||
} |
@ -0,0 +1,23 @@ |
||||
package sig.objects; |
||||
|
||||
import sig.engine.AnimatedObject; |
||||
import sig.engine.Panel; |
||||
import sig.engine.Sprite; |
||||
|
||||
public class Erinoah extends AnimatedObject{ |
||||
|
||||
public Erinoah(Panel panel) { |
||||
super(Sprite.ERINOAH, 4, panel); |
||||
} |
||||
|
||||
@Override |
||||
public void update(double updateMult) { |
||||
super.update(updateMult); |
||||
} |
||||
|
||||
@Override |
||||
public void draw(byte[] p) { |
||||
Draw_Animated_Sprite(16, 16, getAnimatedSpr(), getCurrentFrame()); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue