123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- Citizen[] citizen = new Citizen[10];
-
- //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_selectedCitizen = 0;
- int i_mapW, i_mapH;
- int i_windowW, i_windowH;
- int i_viewportW, i_viewportH;
- //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;
-
- 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 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");
-
- for (int i = 0; i < citizen.length; i++) {
- citizen[i].spawn(int(random(0, houses.size())));
- }
- //citizen[2].spawn(59);
- }
-
-
- 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.fill(0);
- 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.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();
- citizen[i].display();
- }
- }
-
- pg_map.endDraw();
- image(pg_map, i_mapOffsetX, i_mapOffsetY, i_mapW, i_mapH);
- drawUI();
- }
|