added nextFrameBuffer with basic functions
This commit is contained in:
parent
de54803edf
commit
44503c5f44
70
GamePlay/Frames/nextFrameBuffer.java
Normal file
70
GamePlay/Frames/nextFrameBuffer.java
Normal file
@ -0,0 +1,70 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user