new map, debug system
This commit is contained in:
@@ -1,19 +1,20 @@
|
|||||||
import java.lang.Double;
|
import java.lang.Double;
|
||||||
Citizen[] citizen = new Citizen[10];
|
Citizen[] citizen = new Citizen[10];
|
||||||
|
|
||||||
void initCitizen(){
|
void initCitizen() {
|
||||||
//namen: ethuriel, nathaniel, loriel, samuel, aluriel, aleriel, thaliel, suriel, kaliel,
|
//namen: ethuriel, nathaniel, loriel, samuel, aluriel, aleriel, thaliel, suriel, kaliel,
|
||||||
|
int[][] claireArray = { { 00, 2 }, { 1, 3} };
|
||||||
citizen[0] = new Citizen(59, "Test");
|
println(int(hour()
|
||||||
citizen[1] = new Citizen(121, "Matze");
|
citizen[0] = new Citizen(59, "Claire", claireArray);
|
||||||
citizen[2] = new Citizen(18, "Freddy");
|
//citizen[1] = new Citizen(121, "Matze");
|
||||||
citizen[3] = new Citizen(59, "Korbi");
|
//citizen[2] = new Citizen(18, "Freddy");
|
||||||
citizen[4] = new Citizen(121, "Lotte");
|
//citizen[3] = new Citizen(59, "Korbi");
|
||||||
citizen[5] = new Citizen(18, "Reifi");
|
//citizen[4] = new Citizen(121, "Lotte");
|
||||||
citizen[6] = new Citizen(59, "Grasso");
|
//citizen[5] = new Citizen(18, "Reifi");
|
||||||
citizen[7] = new Citizen(121, "Nico");
|
//citizen[6] = new Citizen(59, "Grasso");
|
||||||
citizen[8] = new Citizen(18, "Victor");
|
//citizen[7] = new Citizen(121, "Nico");
|
||||||
citizen[9] = new Citizen(59, "Paul");
|
//citizen[8] = new Citizen(18, "Victor");
|
||||||
|
//citizen[9] = new Citizen(59, "Paul");
|
||||||
|
|
||||||
for (int i = 0; i < citizen.length; i++) {
|
for (int i = 0; i < citizen.length; i++) {
|
||||||
citizen[i].spawn(int(random(0, houses.size())));
|
citizen[i].spawn(int(random(0, houses.size())));
|
||||||
@@ -24,7 +25,7 @@ void initCitizen(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int i_selectedCitizen;
|
int i_selectedCitizen;
|
||||||
void selectCitizen(int i){
|
void selectCitizen(int i) {
|
||||||
citizen[i_selectedCitizen].b_selected = false;
|
citizen[i_selectedCitizen].b_selected = false;
|
||||||
citizen[i].b_selected = true;
|
citizen[i].b_selected = true;
|
||||||
i_selectedCitizen = i;
|
i_selectedCitizen = i;
|
||||||
@@ -54,11 +55,10 @@ class Citizen {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Citizen(int home, String name) {
|
Citizen(int home, String name, int[][] schedule) {
|
||||||
i_home = home;
|
i_home = home;
|
||||||
S_name = name;
|
S_name = name;
|
||||||
i_diameter = 15;
|
i_diameter = 15;
|
||||||
|
|
||||||
pathFinder = makePathFinder(gs, pathAlgorithm);
|
pathFinder = makePathFinder(gs, pathAlgorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,12 @@ class Citizen {
|
|||||||
} else {
|
} else {
|
||||||
b_moving = false;
|
b_moving = false;
|
||||||
nextNode = 0;
|
nextNode = 0;
|
||||||
if (b_randomRun)goTo(int(random(0, pg_map.width)), int(random(0, pg_map.height)));
|
if (!b_randomRun) {
|
||||||
|
//check if standing on an other citizens position
|
||||||
|
|
||||||
|
} else {
|
||||||
|
goTo(int(random(0, pg_map.width)), int(random(0, pg_map.height)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,15 +134,18 @@ class Citizen {
|
|||||||
}
|
}
|
||||||
if (b_drawPathDestination) {
|
if (b_drawPathDestination) {
|
||||||
pg_map.stroke(160, 0, 0);
|
pg_map.stroke(160, 0, 0);
|
||||||
if(b_selected) pg_map.fill(255, 0, 0);
|
if (b_selected) pg_map.fill(255, 0, 0);
|
||||||
else pg_map.fill(0);
|
else pg_map.fill(0);
|
||||||
pg_map.ellipse(rNodes[rNodes.length-1].xf(), rNodes[rNodes.length-1].yf(), nodeSize, nodeSize);
|
pg_map.ellipse(rNodes[rNodes.length-1].xf(), rNodes[rNodes.length-1].yf(), nodeSize, nodeSize);
|
||||||
}
|
}
|
||||||
pg_map.popStyle();
|
pg_map.popStyle();
|
||||||
}
|
}
|
||||||
if(b_selected) pg_map.fill(c_selectedCitizen);
|
pg_map.stroke(255);
|
||||||
pg_map.ellipse(f_xPos, f_yPos, i_diameter, i_diameter);
|
|
||||||
pg_map.fill(0);
|
pg_map.fill(0);
|
||||||
|
if (b_selected) pg_map.fill(c_selectedCitizen);
|
||||||
|
pg_map.ellipse(f_xPos, f_yPos, i_diameter, i_diameter);
|
||||||
|
pg_map.fill(255);
|
||||||
|
pg_map.textAlign(CENTER);
|
||||||
pg_map.textSize(10);
|
pg_map.textSize(10);
|
||||||
pg_map.text(S_name, f_xPos, f_yPos-10);
|
pg_map.text(S_name, f_xPos, f_yPos-10);
|
||||||
}
|
}
|
||||||
|
|||||||
1
Map.pde
1
Map.pde
@@ -1,6 +1,7 @@
|
|||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import pathfinder.*;
|
import pathfinder.*;
|
||||||
|
|
||||||
|
PImage img_map;
|
||||||
PImage img_houses;
|
PImage img_houses;
|
||||||
PImage img_streets;
|
PImage img_streets;
|
||||||
PGraphics pg_map;
|
PGraphics pg_map;
|
||||||
|
|||||||
41
UI.pde
41
UI.pde
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
|
int i_uiTransparency = 200;
|
||||||
void initUI() {
|
void initUI() {
|
||||||
i_uiX = 0;
|
i_uiX = 0;
|
||||||
i_uiY = 420;
|
i_uiY = 520;
|
||||||
i_uiW = width;
|
i_uiW = width;
|
||||||
i_uiH = height - i_uiY;
|
i_uiH = height - i_uiY;
|
||||||
}
|
}
|
||||||
@@ -11,17 +13,44 @@ void drawUI() {
|
|||||||
strokeWeight(1);
|
strokeWeight(1);
|
||||||
line(i_uiX, i_uiY, i_uiX+i_uiW, i_uiY);
|
line(i_uiX, i_uiY, i_uiX+i_uiW, i_uiY);
|
||||||
strokeWeight(0);
|
strokeWeight(0);
|
||||||
fill(255, 230);
|
fill(255, i_uiTransparency);
|
||||||
rect(i_uiX, i_uiY, i_uiW, i_uiH);
|
rect(i_uiX, i_uiY, i_uiW, i_uiH);
|
||||||
|
rect(6, 4, 140, 31, 6);
|
||||||
|
|
||||||
fill(0);
|
fill(0);
|
||||||
textSize(30);
|
textSize(30);
|
||||||
textAlign(LEFT);
|
textAlign(LEFT);
|
||||||
text(String.format("%02d", hour()) + ":" + String.format("%02d", minute()) + ":" + String.format("%02d", second()), 10, 30);
|
text(String.format("%02d", hour()) + ":" + String.format("%02d", minute()) + ":" + String.format("%02d", second()), 10, 30);
|
||||||
|
|
||||||
textSize(15);
|
|
||||||
text("FPS: " + int(frameRate), 10, i_uiY + 15);
|
String[] debug = {
|
||||||
|
"FPS: " + int(frameRate),
|
||||||
|
" ",
|
||||||
|
"Selected Citizen ID: " + i_selectedCitizen,
|
||||||
|
"Name: " + citizen[i_selectedCitizen].S_name,
|
||||||
|
"x: " + citizen[i_selectedCitizen].f_xPos + " y: " + citizen[i_selectedCitizen].f_yPos,
|
||||||
|
"Movement speed: " + citizen[i_selectedCitizen].f_movementSpeed,
|
||||||
|
"Velocity: ",
|
||||||
|
"Outside",
|
||||||
|
"Mood: "
|
||||||
|
};
|
||||||
|
int ts = i_debugTextSize;
|
||||||
|
textSize(ts);
|
||||||
|
int line = 0;
|
||||||
|
int maxLinesPerColumn = i_uiH/ts;
|
||||||
|
if (maxLinesPerColumn > 0) {
|
||||||
|
int requiredColumns = (debug.length/maxLinesPerColumn)+1;
|
||||||
|
for (int i = 0; i < requiredColumns; i++) {
|
||||||
|
while (((line-(maxLinesPerColumn*i)) * ts + ts)+i_uiY<height && line < debug.length) {
|
||||||
|
text(debug[line], 10+(150*i), i_uiY+(ts*((line-(maxLinesPerColumn*i))+1)));
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//text("FPS: " + int(frameRate), 10, i_uiY + 15);
|
||||||
|
//text("Selected Citizen: " + i_selectedCitizen, 10, i_uiY + 30);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean b_mouseChangeMapOffset, b_mouseChangeUiHeight;
|
boolean b_mouseChangeMapOffset, b_mouseChangeUiHeight;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ boolean b_drawPathDestination = true;
|
|||||||
boolean b_randomRun = false;
|
boolean b_randomRun = false;
|
||||||
float f_nodeResolution = 0.2; //defines density of path-finding nodes, multiplied with resolution
|
float f_nodeResolution = 0.2; //defines density of path-finding nodes, multiplied with resolution
|
||||||
int i_pathAlgorithm = 3;
|
int i_pathAlgorithm = 3;
|
||||||
|
int i_debugTextSize = 12;
|
||||||
int i_mapW, i_mapH;
|
int i_mapW, i_mapH;
|
||||||
int i_windowW, i_windowH;
|
int i_windowW, i_windowH;
|
||||||
int i_viewportW, i_viewportH;
|
int i_viewportW, i_viewportH;
|
||||||
@@ -21,10 +22,11 @@ void setup() {
|
|||||||
//blendMode(MULTIPLY);
|
//blendMode(MULTIPLY);
|
||||||
i_windowW = width;
|
i_windowW = width;
|
||||||
i_windowH = height;
|
i_windowH = height;
|
||||||
|
img_map = loadImage(dataPath("map/map.png"));
|
||||||
if (b_smallerImage) img_houses = loadImage(dataPath("map/houses_with_borders_small.png"));
|
if (b_smallerImage) img_houses = loadImage(dataPath("map/houses_with_borders_small.png"));
|
||||||
else img_houses = loadImage(dataPath("map/houses_with_borders.png"));
|
else img_houses = loadImage(dataPath("map/houses_with_borders.png"));
|
||||||
img_streets = loadImage(dataPath("map/streets.png"));
|
img_streets = loadImage(dataPath("map/streets.png"));
|
||||||
|
|
||||||
pg_map = createGraphics(img_houses.width, img_houses.height);
|
pg_map = createGraphics(img_houses.width, img_houses.height);
|
||||||
|
|
||||||
surface.setResizable(true);
|
surface.setResizable(true);
|
||||||
@@ -55,7 +57,8 @@ void draw() {
|
|||||||
|
|
||||||
pg_map.beginDraw();
|
pg_map.beginDraw();
|
||||||
|
|
||||||
pg_map.image(img_houses, 0, 0, img_houses.width, img_houses.height);
|
pg_map.image(img_map, 0, 0, img_houses.width, img_houses.height);
|
||||||
|
//pg_map.image(img_houses, 0, 0, img_houses.width, img_houses.height);
|
||||||
//image(img_streets, 0, 0, img_houses.width, img_houses.height);
|
//image(img_streets, 0, 0, img_houses.width, img_houses.height);
|
||||||
|
|
||||||
pg_map.fill(0);
|
pg_map.fill(0);
|
||||||
|
|||||||
BIN
data/map/map.png
Normal file
BIN
data/map/map.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 MiB |
Reference in New Issue
Block a user