Browse Source

new map, debug system

master
Victor Giers 5 years ago
parent
commit
e9e4d886ef
5 changed files with 71 additions and 30 deletions
  1. 30
    22
      CitizenClass.pde
  2. 1
    0
      Map.pde
  3. 35
    6
      UI.pde
  4. 5
    2
      citizen.pde
  5. BIN
      data/map/map.png

+ 30
- 22
CitizenClass.pde View File

@@ -1,30 +1,31 @@
import java.lang.Double;
Citizen[] citizen = new Citizen[10];

void initCitizen(){
void initCitizen() {
//namen: ethuriel, nathaniel, loriel, samuel, aluriel, aleriel, thaliel, suriel, kaliel,
citizen[0] = new Citizen(59, "Test");
citizen[1] = new Citizen(121, "Matze");
citizen[2] = new Citizen(18, "Freddy");
citizen[3] = new Citizen(59, "Korbi");
citizen[4] = new Citizen(121, "Lotte");
citizen[5] = new Citizen(18, "Reifi");
citizen[6] = new Citizen(59, "Grasso");
citizen[7] = new Citizen(121, "Nico");
citizen[8] = new Citizen(18, "Victor");
citizen[9] = new Citizen(59, "Paul");
int[][] claireArray = { { 00, 2 }, { 1, 3} };
println(int(hour()
citizen[0] = new Citizen(59, "Claire", claireArray);
//citizen[1] = new Citizen(121, "Matze");
//citizen[2] = new Citizen(18, "Freddy");
//citizen[3] = new Citizen(59, "Korbi");
//citizen[4] = new Citizen(121, "Lotte");
//citizen[5] = new Citizen(18, "Reifi");
//citizen[6] = new Citizen(59, "Grasso");
//citizen[7] = new Citizen(121, "Nico");
//citizen[8] = new Citizen(18, "Victor");
//citizen[9] = new Citizen(59, "Paul");

for (int i = 0; i < citizen.length; i++) {
citizen[i].spawn(int(random(0, houses.size())));
}
selectCitizen(0);
//citizen[2].spawn(59);
//citizen[2].spawn(59);
}

int i_selectedCitizen;
void selectCitizen(int i){
void selectCitizen(int i) {
citizen[i_selectedCitizen].b_selected = false;
citizen[i].b_selected = true;
i_selectedCitizen = i;
@@ -39,7 +40,7 @@ class Citizen {
float f_xPos, f_yPos;
float f_movementSpeed = 10;
boolean b_selected;
//0-100:
//motivation (bei arbeiter montag ~40, freitag ~80 - 100)
//7 emotionen?
@@ -54,11 +55,10 @@ class Citizen {



Citizen(int home, String name) {
Citizen(int home, String name, int[][] schedule) {
i_home = home;
S_name = name;
i_diameter = 15;

pathFinder = makePathFinder(gs, pathAlgorithm);
}

@@ -111,7 +111,12 @@ class Citizen {
} else {
b_moving = false;
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) {
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);
pg_map.ellipse(rNodes[rNodes.length-1].xf(), rNodes[rNodes.length-1].yf(), nodeSize, nodeSize);
}
pg_map.popStyle();
}
if(b_selected) pg_map.fill(c_selectedCitizen);
pg_map.ellipse(f_xPos, f_yPos, i_diameter, i_diameter);
pg_map.stroke(255);
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.text(S_name, f_xPos, f_yPos-10);
}

+ 1
- 0
Map.pde View File

@@ -1,6 +1,7 @@
import java.util.ArrayDeque;
import pathfinder.*;

PImage img_map;
PImage img_houses;
PImage img_streets;
PGraphics pg_map;

+ 35
- 6
UI.pde View File

@@ -1,6 +1,8 @@

int i_uiTransparency = 200;
void initUI() {
i_uiX = 0;
i_uiY = 420;
i_uiY = 520;
i_uiW = width;
i_uiH = height - i_uiY;
}
@@ -11,17 +13,44 @@ void drawUI() {
strokeWeight(1);
line(i_uiX, i_uiY, i_uiX+i_uiW, i_uiY);
strokeWeight(0);
fill(255, 230);
fill(255, i_uiTransparency);
rect(i_uiX, i_uiY, i_uiW, i_uiH);


rect(6, 4, 140, 31, 6);
fill(0);
textSize(30);
textAlign(LEFT);
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;

+ 5
- 2
citizen.pde View File

@@ -7,6 +7,7 @@ boolean b_drawPathDestination = true;
boolean b_randomRun = false;
float f_nodeResolution = 0.2; //defines density of path-finding nodes, multiplied with resolution
int i_pathAlgorithm = 3;
int i_debugTextSize = 12;
int i_mapW, i_mapH;
int i_windowW, i_windowH;
int i_viewportW, i_viewportH;
@@ -21,10 +22,11 @@ void setup() {
//blendMode(MULTIPLY);
i_windowW = width;
i_windowH = height;
img_map = loadImage(dataPath("map/map.png"));
if (b_smallerImage) img_houses = loadImage(dataPath("map/houses_with_borders_small.png"));
else img_houses = loadImage(dataPath("map/houses_with_borders.png"));
img_streets = loadImage(dataPath("map/streets.png"));
pg_map = createGraphics(img_houses.width, img_houses.height);

surface.setResizable(true);
@@ -55,7 +57,8 @@ void draw() {

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);

pg_map.fill(0);

BIN
data/map/map.png View File


Loading…
Cancel
Save