Simulation von Bürgern
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

citizen_pgraph.pde 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. Citizen[] citizen = new Citizen[10];
  2. //settings
  3. boolean b_smallerImage = false; //use a cropped, smaller version of the 1920x1080 image for faster development
  4. 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...
  5. boolean b_drawNodes = false;
  6. boolean b_drawPathLine = false;
  7. boolean b_drawPathDestination = true;
  8. boolean b_randomRun = false;
  9. float f_nodeResolution = 0.2; //defines density of path-finding nodes, multiplied with resolution
  10. int i_pathAlgorithm = 3;
  11. int i_selectedCitizen = 0;
  12. int i_mapW, i_mapH;
  13. int i_windowW, i_windowH;
  14. int i_viewportW, i_viewportH;
  15. //void mousePressed() {
  16. // citizen[0].goTo(constrain(mouseX, 0, img_houses.width), constrain(mouseY, 0, img_houses.height));
  17. //}
  18. void setup() {
  19. size(700,600);
  20. //blendMode(MULTIPLY);
  21. i_windowW = width;
  22. i_windowH = height;
  23. if (b_smallerImage) img_houses = loadImage(dataPath("map/houses_with_borders_small.png"));
  24. else img_houses = loadImage(dataPath("map/houses_with_borders.png"));
  25. img_streets = loadImage(dataPath("map/streets.png"));
  26. pg_map = createGraphics(img_houses.width, img_houses.height);
  27. surface.setResizable(true);
  28. registerMethod("pre", this);
  29. i_mapW = pg_map.width;
  30. i_mapH = pg_map.height;
  31. initHouses();
  32. initPathFinding();
  33. initWeather();
  34. initCitizen();
  35. initUI();
  36. }
  37. void initCitizen(){
  38. //namen: ethuriel, nathaniel, loriel, samuel, aluriel, aleriel, thaliel, suriel, kaliel,
  39. citizen[0] = new Citizen(59, "Test");
  40. citizen[1] = new Citizen(121, "Matze");
  41. citizen[2] = new Citizen(18, "Freddy");
  42. citizen[3] = new Citizen(59, "Korbi");
  43. citizen[4] = new Citizen(121, "Lotte");
  44. citizen[5] = new Citizen(18, "Reifi");
  45. citizen[6] = new Citizen(59, "Grasso");
  46. citizen[7] = new Citizen(121, "Nico");
  47. citizen[8] = new Citizen(18, "Victor");
  48. citizen[9] = new Citizen(59, "Paul");
  49. for (int i = 0; i < citizen.length; i++) {
  50. citizen[i].spawn(int(random(0, houses.size())));
  51. }
  52. //citizen[2].spawn(59);
  53. }
  54. void pre() {
  55. if (i_windowW != width || i_windowH != height) {
  56. // Sketch window has resized
  57. i_windowW = width;
  58. i_windowH = height;
  59. i_uiW = width;
  60. i_uiH = height - i_uiY;
  61. }
  62. }
  63. void draw() {
  64. background(127);
  65. pg_map.beginDraw();
  66. pg_map.fill(0);
  67. pg_map.image(img_houses, 0,0, img_houses.width, img_houses.height);
  68. //image(img_streets, 0, 0, img_houses.width, img_houses.height);
  69. pg_map.textSize(7);
  70. pg_map.textAlign(CENTER);
  71. //for (House house : houses) {
  72. // house.display();
  73. //}
  74. if (b_drawNodes) drawNodes();
  75. for (int i = 0; i < citizen.length; i++) {
  76. if (citizen[i].b_linked) {
  77. citizen[i].update();
  78. citizen[i].display();
  79. }
  80. }
  81. pg_map.endDraw();
  82. image(pg_map, i_mapOffsetX, i_mapOffsetY, i_mapW, i_mapH);
  83. drawUI();
  84. }