71 lines
1.2 KiB
Java
71 lines
1.2 KiB
Java
package Frames;
|
|
|
|
/**
|
|
* This will handle the next frames to be played by each entity.
|
|
* @author Victor Azra
|
|
*/
|
|
public class nextFrameBuffer {
|
|
|
|
private Frame current;
|
|
private nextFrameBuffer next;
|
|
|
|
/**
|
|
* creates a new framebuffer, empty for now
|
|
*/
|
|
public nextFrameBuffer() {
|
|
this.current = null;
|
|
this.next = null;
|
|
}
|
|
|
|
public void setCurrentFrame(Frame f) {
|
|
this.current = f;
|
|
}
|
|
|
|
public void clone(nextFrameBuffer f) {
|
|
this.current = f.current;
|
|
this.next = f.next;
|
|
}
|
|
|
|
public void setNext(nextFrameBuffer f) {
|
|
this.next.clone(f);
|
|
}
|
|
|
|
public void emptyQueue() {
|
|
this.next = null;
|
|
}
|
|
|
|
public void empty() {
|
|
this.current = null;
|
|
this.next = null;
|
|
}
|
|
|
|
public void goToNext() {
|
|
this.current = this.next.current;
|
|
this.next = this.next.next;
|
|
}
|
|
|
|
public Frame getCurrentFrame() {
|
|
return this.current;
|
|
}
|
|
|
|
public Frame getNextframe() {
|
|
return this.next.current;
|
|
}
|
|
|
|
/**
|
|
* Adds a frame at the end of the buffer
|
|
* @param f the frame to add at the end
|
|
*/
|
|
public void addFrameToQueue(Frame f) {
|
|
if(this.current == null) {
|
|
this.current = f;
|
|
} else if(this.next == null){
|
|
nextFrameBuffer fb = new nextFrameBuffer();
|
|
fb.current = f;
|
|
this.next = fb;
|
|
} else {
|
|
this.next.addFrameToQueue(f);
|
|
}
|
|
}
|
|
}
|