Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions GIFAnimator.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class GIFAnimator{
PVector size;
PVector position;
int index;
int fps;
float deltaTime;
boolean visible;
ArrayList <PImage> slides;

GIFAnimator(float xx, float yy, float ww, float hh){
position.x = xx;
position.y = yy;
size.x = ww;
size.y = hh;
index = 0;
fps = 2;
deltaTime = 0;
visible = true;
slides = new ArrayList<PImage>();
}

void setPosition(PVector tposition, PVector tsize){
position = tposition;
size = tsize;
}

void addSlide(PImage slide){
slides.add(slide);
}

void erase(){
slides.clear();
}

PImage get(int i){
return slides.get(i);
}

//display the animator
void display(){
deltaTime += frameRate/60;
if(deltaTime >= 60 - fps){
index -= 1;
if(index <= 0){
index = slides.size() - 1;
}
deltaTime = 0;
}

//draw the image
image(slides.get(index), position.x, position.y, size.x, size.y);
}

//display if there is a pattern
/*void display(int [] in){
deltaTime += 1/frameRate;
if(deltaTime >= fps){
index += 1;
if(index >= in.length){
index = 0;
}
deltaTime = 0;
}*/

//draw the image
image(slides.get(in[index]), position.x, position.y, size.x, size.y);
}
}
68 changes: 68 additions & 0 deletions GIF_Class.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class GIFAnimator{
PVector size;
PVector position;
int index;
int fps;
float deltaTime;
boolean visible;
ArrayList <PImage> slides;

GIFAnimator(float xx, float yy, float ww, float hh){
position.x = xx;
position.y = yy;
size.x = ww;
size.y = hh;
index = 0;
fps = 2;
deltaTime = 0;
visible = true;
slides = new ArrayList<PImage>();
}

void setPosition(PVector tposition, PVector tsize){
position = tposition;
size = tsize;
}

void addSlide(PImage slide){
slides.add(slide);
}

void erase(){
slides.clear();
}

PImage get(int i){
return slides.get(i);
}

//display the animator
void display(){
deltaTime += frameRate/60;
if(deltaTime >= 60 - fps){
index -= 1;
if(index <= 0){
index = slides.size() - 1;
}
deltaTime = 0;
}

//draw the image
image(slides.get(index), position.x, position.y, size.x, size.y);
}

//display if there is a pattern
void display(int [] in){
deltaTime += 1/frameRate;
if(deltaTime >= fps){
index += 1;
if(index >= in.length){
index = 0;
}
deltaTime = 0;
}

//draw the image
image(slides.get(in[index]), position.x, position.y, size.x, size.y);
}
}
23 changes: 23 additions & 0 deletions View_Class.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class View{
PVector position;
PVector startPosition;
PVector absolutePosition;
PVector size;

View(PVector tposition, PVector tsize){
position = tposition;
startPosition = position;
absolutePosition = position;
size = tsize;
}

void update(PVector tposition){
startPosition.x = tposition.x;
startPosition.y = tposition.y;
}

void mouseScroll(){
position.x = startPosition.x - width/2 - (width/2 - mouseX);
position.y = startPosition.y - height/2 - (height/2 - mouseY);
}
}
24 changes: 24 additions & 0 deletions View_class
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class View{
PVector position;
PVector startPosition;
PVector absolutePosition;
PVector size;

View(PVector tposition, PVector tsize){
position = tposition;
startPosition = position;
absolutePosition = position;
size = tsize;
}

void update(PVector tposition){
startPosition.x = tposition.x;
startPosition.y = tposition.y;
println("updating...");
}

void mouseScroll(){
position.x = startPosition.x - width/2 - (width/2 - mouseX);
position.y = startPosition.y - height/2 - (height/2 - mouseY);
}
}
131 changes: 131 additions & 0 deletions level_editor/Button.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
class Button{
int x, y;
int w, h;
int roundness;
int r, g, b, a;
int textR, textG, textB;
int textSize;
boolean hovering;
boolean clickDown;
boolean visible;
String buttonText;

Button(int xx, int yy, int ww, int hh){
//position variables
x = xx;
y = yy;
w = ww;
h = hh;

//colour variables
r = g = b = 0;
a = 255;
textR = textG = textB = 255;

//other variables
hovering = false;
clickDown = false;
buttonText = "undefined";
roundness = 10;
textSize = 18;
visible = true;
}

Button(){
//position variables
x = width/2;
y = height/2;
w = int(width*0.1);
h = int(height*0.1);

//colour variables
r = g = b = 0;
textR = textG = textB = 255;

//other variables
hovering = false;
clickDown = false;
buttonText = "undefined";
roundness = 10;
textSize = 18;
visible = true;
}

//change the background colour
void backColour(int rr, int gg, int bb){
r = rr;
g = gg;
b = bb;
}

//change the text colour
void textColour(int rr, int gg, int bb){
textR = rr;
textG = gg;
textB = bb;
}

//update the status of the button
void update(){
clicked();
checkHover();
display();
}

//check if the mouse is hovering over the button
void checkHover(){
if(mouseX < x-w/2 || mouseX > x+w/2 || mouseY < y-h/2 || mouseY > y+h/2){
if(hovering){
r -= 40;
g -= 40;
b -= 40;
hovering = false;
}
}else{
if(!hovering){
r += 40;
g += 40;
b += 40;
hovering = true;
}
}
}

//click detection method
boolean clicked(){
boolean res = false;
if(mouseX < x-w/2 || mouseX > x+w/2 || mouseY < y-h/2 || mouseY > y+h/2){
}else{
if(mousePressed){
if(!clickDown){
r -= 80;
g -= 80;
b -= 80;
clickDown = true;
}
res = true;
}else if(!mousePressed && clickDown){
r += 80;
g += 80;
b += 80;
clickDown = false;
}
}
return res;
}

void display(){
if(visible){
rectMode(CENTER);
fill(r, g, b, a);
rect(x, y, w, h, roundness);

//draw the text
fill(textR, textG, textB, a);
textSize(textSize);
textAlign(CENTER,CENTER);
text(buttonText,x,y);
textAlign(CORNER,CORNER);
}
}
}
Loading