86 lines
2.4 KiB
Plaintext
86 lines
2.4 KiB
Plaintext
//settings
|
|
boolean b_smallerImage = false; //use a cropped, smaller version of the 1920x1080 image for faster development
|
|
boolean b_loadSun = false; //load sun from web-api instead of local json file (local file is adressed to january 4th 2019. might implement a check that downloads today's information only once...
|
|
boolean b_drawNodes = false;
|
|
boolean b_drawPathLine = false;
|
|
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;
|
|
color c_selectedCitizen = color(128, 50, 50);
|
|
//void mousePressed() {
|
|
// citizen[0].goTo(constrain(mouseX, 0, img_houses.width), constrain(mouseY, 0, img_houses.height));
|
|
//}
|
|
|
|
|
|
void setup() {
|
|
size(700, 600);
|
|
//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);
|
|
registerMethod("pre", this);
|
|
|
|
i_mapW = pg_map.width;
|
|
i_mapH = pg_map.height;
|
|
|
|
initHouses();
|
|
initPathFinding();
|
|
initWeather();
|
|
initCitizen();
|
|
initUI();
|
|
}
|
|
|
|
void pre() {
|
|
if (i_windowW != width || i_windowH != height) {
|
|
// Sketch window has resized
|
|
i_windowW = width;
|
|
i_windowH = height;
|
|
i_uiW = width;
|
|
i_uiH = height - i_uiY;
|
|
}
|
|
}
|
|
|
|
void draw() {
|
|
background(127);
|
|
|
|
pg_map.beginDraw();
|
|
|
|
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);
|
|
//pg_map.textSize(7);
|
|
//pg_map.textAlign(CENTER);
|
|
//for (House house : houses) {
|
|
// house.display();
|
|
//}
|
|
|
|
if (b_drawNodes) drawNodes();
|
|
|
|
for (int i = 0; i < citizen.length; i++) {
|
|
if (citizen[i].b_linked) {
|
|
citizen[i].update();
|
|
if (i != i_selectedCitizen)
|
|
citizen[i].display();
|
|
}
|
|
}
|
|
citizen[i_selectedCitizen].display();
|
|
|
|
pg_map.endDraw();
|
|
image(pg_map, i_mapOffsetX, i_mapOffsetY, i_mapW, i_mapH);
|
|
drawUI();
|
|
}
|