diff --git a/GIFAnimator.pde b/GIFAnimator.pde new file mode 100644 index 0000000..bdb288d --- /dev/null +++ b/GIFAnimator.pde @@ -0,0 +1,68 @@ +class GIFAnimator{ + PVector size; + PVector position; + int index; + int fps; + float deltaTime; + boolean visible; + ArrayList 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(); + } + + 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); + } +} diff --git a/GIF_Class.pde b/GIF_Class.pde new file mode 100644 index 0000000..df30c02 --- /dev/null +++ b/GIF_Class.pde @@ -0,0 +1,68 @@ +class GIFAnimator{ + PVector size; + PVector position; + int index; + int fps; + float deltaTime; + boolean visible; + ArrayList 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(); + } + + 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); + } +} diff --git a/View_Class.pde b/View_Class.pde new file mode 100644 index 0000000..7827edd --- /dev/null +++ b/View_Class.pde @@ -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); + } +} diff --git a/View_class b/View_class new file mode 100644 index 0000000..8f1ddb1 --- /dev/null +++ b/View_class @@ -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); + } +} diff --git a/level_editor/Button.pde b/level_editor/Button.pde new file mode 100644 index 0000000..c628ff2 --- /dev/null +++ b/level_editor/Button.pde @@ -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); + } + } +} \ No newline at end of file diff --git a/level_editor/Grid_Class.pde b/level_editor/Grid_Class.pde new file mode 100644 index 0000000..4ea9ba0 --- /dev/null +++ b/level_editor/Grid_Class.pde @@ -0,0 +1,106 @@ +class Grid{//The class for the grid will also be placed here + int x, y; + int w, h; + int rows, cols; + float XOffset, XMove; + float YOffset, YMove; + float coordX, coordY; + + Grid(int xx, int yy, int ww, int hh){ + x = xx; + y = yy; + w = ww; + h = hh; + rows = cols = 72; + + XOffset = 0.0; + XMove = XOffset; + YOffset = 0.0; + YMove = YOffset; + + coordX = coordY = 0; + } + + void display(){ + //offsets + if(XOffset > 0){ + XOffset = 0; + } + if(YOffset > 0){ + YOffset = 0; + } + + XMove = XOffset%(rows*mapZoom); + YMove = YOffset%(cols*mapZoom); + + //colomns + for(int i = 0; i < (rows*mapZoom) * (w/(rows*mapZoom) + (rows*mapZoom)); i += (rows*mapZoom)){ + if(x + i + XMove <= x + w){ + line(x + i + XMove, y, x + i + XMove, y + h); + fill(23, 54, 175); + if(x + i + XMove < x + w){ + textAlign(CORNER, CORNER); + textSize((rows*mapZoom)/3); + text(str(int((i/(rows*mapZoom)) + 1 + int(abs(XOffset / (rows*mapZoom))))), x + i + XMove + 10, y ); + } + } + } + + //rows + for(int i = 0; i < (cols*mapZoom) * (h/(cols*mapZoom) + (cols*mapZoom)) + 1; i += (cols*mapZoom)){ + if(y + i + YMove >= y){ + line(x, y + i + YMove, x + w, y + i + YMove); + fill(23, 54, 175); + if(y + i + YMove < y + h){ + textAlign(CORNER, CORNER); + textSize((cols*mapZoom)/3); + text(str(int(i/(cols*mapZoom) + 1 + int(abs(YOffset / (cols*mapZoom))))), x ,y + i + YMove + 20 ); + } + } + } + + //load tile map preview + for(int i = 0; i < tileLocations.size(); i++){ + PImage tempIMG = loadImage(tileLocations.get(i).filename); + if(((tileLocations.get(i).location.x - x)*mapZoom + XOffset)+ x + tileLocations.get(i).size > 0 && ((tileLocations.get(i).location.x - x)*mapZoom + XOffset)+ x + tileLocations.get(i).size < width && ((tileLocations.get(i).location.y - y)*mapZoom + YOffset) + y + tileLocations.get(i).size > 0 && ((tileLocations.get(i).location.y - y)*mapZoom + YOffset) + y + tileLocations.get(i).size < height){ + image(tempIMG,((tileLocations.get(i).location.x - x)*mapZoom + XOffset)+ x, ((tileLocations.get(i).location.y - y)*mapZoom + YOffset) + y, tileLocations.get(i).size *mapZoom, tileLocations.get(i).size *mapZoom); + } + } + + //highlight + if(displaying){ + if(!(mouseX < x || mouseX > x + w || mouseY < y || mouseY > y + h)){ + fill(0, 255, 0); + rectMode(CORNER); + tint(255, 200); + image(prevIMG, x + (rows*mapZoom) * int((mouseX - x - XMove)/(rows*mapZoom)) + XMove, y + (cols*mapZoom) * int(((mouseY - y - YMove)/(cols*mapZoom))) + YMove, rows*mapZoom, cols*mapZoom); + rectMode(CENTER); + } + + //check for clicks + if(mousePressed && !(mouseX < x || mouseX > x + w || mouseY < y || mouseY > y + h)){ + if(mouseButton == LEFT){ + mousePressed = false; + boolean isIn = false; + + //delete tiles + for(int i = 0; i < tileLocations.size(); i++){ + if(((rows*mapZoom) * int((mouseX - x - XOffset)/(rows*mapZoom)))/mapZoom + x < tileLocations.get(i).location.x + 10 && ((rows*mapZoom) * int((mouseX - x - XOffset)/(rows*mapZoom)))/mapZoom + x > tileLocations.get(i).location.x - 10 + && ((cols*mapZoom) * int((mouseY - y - YOffset)/(cols*mapZoom)))/mapZoom + y < tileLocations.get(i).location.y + 10 && ((cols*mapZoom) * int((mouseY - y - YOffset)/(cols*mapZoom)))/mapZoom + y > tileLocations.get(i).location.y - 10){ + if(typeList.content.get(typeList.currIndex) == tileLocations.get(i).type){ + tileLocations.remove(i); + isIn = true; + } + } + } + + if(!isIn){ + noTint(); + tileLocations.add(new Tile(new PVector(((rows*mapZoom) * int((mouseX - x - XOffset)/(rows*mapZoom)))/mapZoom + x, + ((cols*mapZoom) * int((mouseY - y - YOffset)/(cols*mapZoom)))/mapZoom + y), tileLoadText.getText(), rows, typeList.content.get(typeList.currIndex))); + } + } + } + } + } +} \ No newline at end of file diff --git a/level_editor/ListBox.pde b/level_editor/ListBox.pde new file mode 100644 index 0000000..53d0d67 --- /dev/null +++ b/level_editor/ListBox.pde @@ -0,0 +1,114 @@ +class ListBox{ + int x, y; + int w, h; + int r, g, b; + int lr, lg, lb; + int currIndex; + String label; + String status; + boolean hover; + ArrayList content; + + ListBox(String tlabel, int xx, int yy, int ww, int hh){ + label = tlabel; + x = xx; + y = yy; + w = ww; + h = hh; + + r = g = b = 0; + lr = lg = lb = 0; + + currIndex = 0; + content = new ArrayList(); + status = "up"; + hover = false; + } + + void addContent(String cont){ + content.add(cont); + } + + void removeContent(int index){ + content.remove(index); + } + + void colour(int rr, int gg, int bb){ + r = rr; + g = gg; + b = bb; + + lr = rr - 50; + lg = gg - 50; + lb = bb - 50; + } + + int clicked(){ + int value = -1; + for(int i = 0; i < content.size(); i++){ + if(!(mouseX < x - w/2|| mouseX > x + w/2 || mouseY < y - h/2 + i*h + h || mouseY > y + h/2 + i*h + h)){ + if(mousePressed){ + value = i; + } + } + } + return value; + } + + void drawMain(){ + //rectangle + fill(r, g, b); + rectMode(CENTER); + rect(x, y, w, h); + + //text + fill(255, 255, 255); + textAlign(CENTER, CENTER); + textSize(h - 4); + text(label + " :" + content.get(currIndex), x, y); + } + + void display(){ + //hovering and clicks + if(!(mouseX < x - w/2 || mouseX > x + w/2 || mouseY < y - h/2 || mouseY > y + h/2)){ + if(!hover){ + r += 40; + g += 40; + b += 40; + hover = true; + } + + if(mousePressed){ + mousePressed = false; + if(status == "up") + status = "down"; + else if(status == "down") + status = "up"; + } + }else{ + if(hover){ + r -= 40; + g -= 40; + b -= 40; + hover = false; + } + } + if(status == "up"){ + drawMain(); + }else if(status == "down"){ + drawMain(); + for(int i = 0; i < content.size() && i < 5; i++){ + //rectangle + fill(lr, lg, lb); + rectMode(CENTER); + rect(x, y + (i+1)*h, w, h); + + //text + fill(255, 255, 255); + textAlign(CENTER, CENTER); + textSize(h - 4); + text(content.get(i), x, y + (i+1)*h); + } + } + } +} \ No newline at end of file diff --git a/level_editor/Scroller_Class.pde b/level_editor/Scroller_Class.pde new file mode 100644 index 0000000..283a93c --- /dev/null +++ b/level_editor/Scroller_Class.pde @@ -0,0 +1,64 @@ +class Scroller{ + int x, y; + int w, h; + int r, g, b; + char demention; + Button left, right; + + Scroller(int xx, int yy, int ww, int hh){ + x = xx; + y = yy; + w = ww; + h = hh; + + demention = 'x'; + + left = new Button(int(x - w*0.45), y, int(w*0.1), h); + left.roundness = 0; + left.backColour(0, 180, 180); + left.buttonText = " "; + right = new Button(int(x + w*0.45), y, int(w*0.1), h); + right.roundness = 0; + right.backColour(0, 180, 180); + right.buttonText = " "; + } + + void colour(int rr, int gg, int bb){ + r = rr; + g = gg; + b = bb; + } + + void changeDem(char dem){ + if(dem == 'X' || dem == 'x'){ + + }else if(dem == 'y' || dem == 'Y'){ + left.y = int(y - h/2 + h*0.05); + left.x = x; + left.w = w; + left.h = int(h*0.1); + + right.y = int(y + h/2 - h*0.05); + right.x = x; + right.w = w; + right.h = int(h*0.1); + } + } + + void display(){ + //draw bar + stroke(0); + strokeWeight(1); + rectMode(CENTER); + fill(140); + rect(x, y, w, h); + + //buttons + left.backColour(r, g, b); + right.backColour(r, g, b); + left.update(); + left.display(); + right.update(); + right.display(); + } +} \ No newline at end of file diff --git a/level_editor/Tile_Class.pde b/level_editor/Tile_Class.pde new file mode 100644 index 0000000..02b8a7c --- /dev/null +++ b/level_editor/Tile_Class.pde @@ -0,0 +1,13 @@ +class Tile{ + PVector location; + String filename; + String type; + int size; + + Tile(PVector tlocation, String tfilename, int tsize, String ttype){ + location = tlocation; + filename = tfilename; + size = tsize; + type = ttype; + } +} \ No newline at end of file diff --git a/level_editor/Variables.pde b/level_editor/Variables.pde new file mode 100644 index 0000000..8d0dda9 --- /dev/null +++ b/level_editor/Variables.pde @@ -0,0 +1,24 @@ +Grid tileMap; + +//preview +PImage prevIMG; + +//buttons +Button loadButton; +Button editTab; +Button loadTab; + +//Controls +ListBox sizeList; +ListBox typeList; +Textfield tileLoadText; +Textfield savePath; +Textfield trueTileLoadText; +Scroller leftRightScroller; +Scroller topDownScroller; + +//functionallity variables +boolean displaying = false; +ArrayList tileLocations = new ArrayList(1); +String state = "edit"; +float mapZoom = 1.0; \ No newline at end of file diff --git a/level_editor/level_editor.pde b/level_editor/level_editor.pde new file mode 100644 index 0000000..02e0a15 --- /dev/null +++ b/level_editor/level_editor.pde @@ -0,0 +1,185 @@ +import controlP5.*; +ControlP5 mainControl; + +void setup(){ + size(700, 600); + + init(); +} + +void draw(){ + background(127); + + tileMap.display(); + + //draw underlay + displayUnderlay(); + + noStroke(); + if(state == "edit"){ + editTab.backColour(24, 23, 100); + editTab.hovering = false; + }else if(state == "load"){ + loadTab.backColour(24, 23, 100); + loadTab.hovering = false; + } + editTab.update(); + editTab.display(); + loadTab.update(); + loadTab.display(); + + if(loadTab.clicked()){ + mousePressed = false; + state = "load"; + editTab.backColour(23, 54, 175); + }else if(editTab.clicked()){ + mousePressed = false; + state = "edit"; + loadTab.backColour(23, 54, 175); + } + stroke(0); + + if(state == "edit"){ + trueTileLoadText.setVisible(false); + tileLoadText.setVisible(true); + savePath.setVisible(true); + loadButton.buttonText = "Save Map"; + sizeList.display(); + typeList.display(); + + //use the save button + if(loadButton.clicked()){ + mousePressed = false; + SaveMap(); + } + + //use lists + if(sizeList.clicked() != -1 && sizeList.status == "down"){ + tileMap.rows = tileMap.cols = int(sizeList.content.get(sizeList.clicked())); + sizeList.currIndex = int(sizeList.clicked()); + tileMap.XMove = tileMap.XOffset%tileMap.rows; + tileMap.YMove = tileMap.YOffset%tileMap.cols; + sizeList.status = "up"; + } + + if(typeList.clicked() != -1 && typeList.status == "down"){ + typeList.currIndex = int(typeList.clicked()); + typeList.status = "up"; + } + }else if(state == "load"){ + trueTileLoadText.setVisible(true); + tileLoadText.setVisible(false); + savePath.setVisible(false); + loadButton.buttonText = "Load Map"; + + if(loadButton.clicked()){ + mousePressed = false; + LoadMap(); + } + } + + //loadButton + loadButton.update(); + loadButton.display(); + + //scrollers + leftRightScroller.display(); + topDownScroller.display(); + + if(leftRightScroller.right.clicked()){ + tileMap.XOffset -= 5; + }else if(leftRightScroller.left.clicked()){ + tileMap.XOffset += 5; + } + + if(topDownScroller.right.clicked()){ + tileMap.YOffset -= 5; + }else if(topDownScroller.left.clicked()){ + tileMap.YOffset += 5; + } + + DisplayPreview(); +} + +void mouseWheel(MouseEvent event) { + float e = event.getCount(); + if(e > 0){ + mapZoom += 0.01; + }else if(e < 0){ + mapZoom -= 0.01; + if(mapZoom <= 0.2){ + mapZoom = 0.2; + } + } +} + +void init(){ + mainControl = new ControlP5(this); + + //tile map + tileMap = new Grid(20, 80, height - 100, height - 100); + + //buttons + loadButton = new Button(int(width*0.87), int(height*0.95), 140, 20); + loadButton.buttonText = "Save Map"; + loadButton.backColour(23, 54, 175); + loadButton.roundness = 0; + + editTab = new Button(int(width*0.81), int(height*0.04), int(width*0.13), int(height*0.08)); + editTab.roundness = 0; + editTab.buttonText = "Edit"; + editTab.backColour(23, 54, 175); + + loadTab = new Button(int(width*0.935), int(height*0.04), int(width*0.13), int(height*0.08)); + loadTab.roundness = 0; + loadTab.buttonText = "Load"; + loadTab.backColour(23, 54, 175); + + //text field(s) + PFont font = createFont("arial",20); + + tileLoadText = mainControl.addTextfield("tile loader") + .setPosition(width*0.77,height*0.6) + .setSize(140,30) + .setFont(font) + .setFocus(true) + .setColor(color(255,255,255)) + ; + + trueTileLoadText = mainControl.addTextfield("map loader") + .setPosition(width*0.77,height*0.6) + .setSize(140,30) + .setFont(font) + .setFocus(true) + .setColor(color(255,255,255)) + ; + + savePath = mainControl.addTextfield("save path") + .setPosition(width*0.77,height*0.85) + .setSize(140,30) + .setFont(font) + .setFocus(true) + .setColor(color(255,255,255)) + ; + + //list boxes + sizeList = new ListBox("Tile Size", int(width*0.87), int(height*0.4), 150, 20); + sizeList.colour(23, 54, 175); + sizeList.addContent("72"); + sizeList.addContent("64"); + sizeList.addContent("32"); + sizeList.addContent("24"); + sizeList.addContent("16"); + + typeList = new ListBox("Tile Type", int(width*0.87), int(height*0.25), 150, 20); + typeList.colour(23, 54, 175); + typeList.addContent("Object"); + typeList.addContent("Scene"); + + //scrollers + leftRightScroller = new Scroller(int(width * 0.386), height - 10, height - 100, 20); + leftRightScroller.colour(23, 54, 175); + topDownScroller = new Scroller(10, int(height*0.567), 20, int(height - 80)); + topDownScroller.changeDem('y'); + topDownScroller.colour(23, 54, 175); +} \ No newline at end of file diff --git a/level_editor/tile.png b/level_editor/tile.png new file mode 100644 index 0000000..c1bc673 Binary files /dev/null and b/level_editor/tile.png differ diff --git a/level_editor/void_DisplayPreview.pde b/level_editor/void_DisplayPreview.pde new file mode 100644 index 0000000..b9937c0 --- /dev/null +++ b/level_editor/void_DisplayPreview.pde @@ -0,0 +1,12 @@ +void DisplayPreview(){ + File file = new File(sketchPath(tileLoadText.getText())); + if(displaying){ + image(prevIMG, width*0.8, height*0.7 + (tileMap.w/tileMap.cols), tileMap.cols, tileMap.rows); + if(!(file.exists() && tileLoadText.getText().length() > 0)){ + displaying = false; + } + }else if(displaying == false && file.exists() && tileLoadText.getText().length() > 0 && tileLoadText.getText().charAt(0) != '/'){ + prevIMG = loadImage(tileLoadText.getText()); + displaying = true; + } +} \ No newline at end of file diff --git a/level_editor/void_LoadMap.pde b/level_editor/void_LoadMap.pde new file mode 100644 index 0000000..961706e --- /dev/null +++ b/level_editor/void_LoadMap.pde @@ -0,0 +1,16 @@ +void LoadMap(){ + File file = new File(sketchPath(trueTileLoadText.getText())); + + if(file.exists()){ + JSONArray values = loadJSONArray(sketchPath(trueTileLoadText.getText())); + + for (int i = 0; i < values.size(); i++) { + + JSONObject object = values.getJSONObject(i); + tileLocations.add(new Tile(new PVector(object.getInt("x"), object.getInt("y")), object.getString("filename"), object.getInt("size"), object.getString("type"))); + } + println("Map Loaded from file " + trueTileLoadText.getText()); + }else{ + println("No file exists called " + trueTileLoadText.getText()); + } +} \ No newline at end of file diff --git a/level_editor/void_SaveMap.pde b/level_editor/void_SaveMap.pde new file mode 100644 index 0000000..8a8b185 --- /dev/null +++ b/level_editor/void_SaveMap.pde @@ -0,0 +1,18 @@ +void SaveMap(){ + JSONArray values = new JSONArray(); + + for(int i = 0; i < tileLocations.size(); i++){ + JSONObject tileObject = new JSONObject(); + + tileObject.setInt("x", int(tileLocations.get(i).location.x)); + tileObject.setInt("y", int(tileLocations.get(i).location.y)); + tileObject.setInt("size", int(tileLocations.get(i).size)); + tileObject.setString("type", tileLocations.get(i).type); + tileObject.setString("filename", tileLocations.get(i).filename); + + values.setJSONObject(i, tileObject); + } + + saveJSONArray(values, sketchPath(savePath.getText())); + println("Map Saved to file " + savePath.getText()); +} \ No newline at end of file diff --git a/level_editor/void_displayUnderlay.pde b/level_editor/void_displayUnderlay.pde new file mode 100644 index 0000000..dfe2e5d --- /dev/null +++ b/level_editor/void_displayUnderlay.pde @@ -0,0 +1,7 @@ +void displayUnderlay(){ + rectMode(CENTER); + fill(24, 23, 100); + noStroke(); + rect(width*0.874, height*0.5, width*0.26, height); + stroke(0); +} \ No newline at end of file diff --git a/void_Game.pde b/void_Game.pde new file mode 100644 index 0000000..6402a49 --- /dev/null +++ b/void_Game.pde @@ -0,0 +1,15 @@ +void Game() { + mainView.update(myPlayer.position); + mainView.mouseScroll(); + timer.time(); + myPlayer.display(); + myPlayer.calculateVelocity(); + myPlayer.move(); + + ArrayList entities = new ArrayList(); + for (int i = 0; i < walls.size(); i++) { + walls.get(i).display(); + entities.add(walls.get(i)); + } + timer.call(); +} diff --git a/void_LoadLevel.pde b/void_LoadLevel.pde new file mode 100644 index 0000000..412ddc0 --- /dev/null +++ b/void_LoadLevel.pde @@ -0,0 +1,13 @@ +void LoadLevel(String filepath){ + JSONArray values = loadJSONArray(sketchPath("../" + filepath)); + + for(int i = 0; i < values.size(); i++){//load walls + JSONObject entity = values.getJSONObject(i); + int type = entity.getInt("type"); + println(str(type == 0)); + if(type == 0){ + println("yes"); + walls.add(new Wall(new PVector(entity.getInt("x"), entity.getInt("y")) , new PVector(entity.getInt("w"), entity.getInt("h")) ,5, mainView)); + } + } +}