pathfinding update
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
//sunrise / sunset API: https://sunrise-sunset.org/api
|
||||
PVector v2_coordinates = new PVector(48.799337, 9.794482); //badmauer; x: latitude, y: longitude
|
||||
|
||||
boolean b_isRaining;
|
||||
|
||||
void initWeather(){
|
||||
|
||||
|
||||
|
||||
//sunrise / sunset API: https://sunrise-sunset.org/api
|
||||
JSONObject sun;
|
||||
if(b_loadSun) sun = loadJSONObject("https://api.sunrise-sunset.org/json?lat=" + v2_coordinates.x + " &lng=" + v2_coordinates.y);
|
||||
else sun = loadJSONObject(dataPath("weather/today.json"));
|
||||
|
||||
@@ -1 +1,73 @@
|
||||
Citizen mensch;
|
||||
|
||||
|
||||
|
||||
PImage img_houses;
|
||||
|
||||
void setup() {
|
||||
size(400, 300);
|
||||
fill(0);
|
||||
//ft = new SimpleDateFormat ("HH:mm:ss");
|
||||
|
||||
img_houses = loadImage(dataPath("houses_with_borders_small.png"));
|
||||
|
||||
|
||||
blendMode(MULTIPLY);
|
||||
|
||||
surface.setSize(img_houses.width, img_houses.height);
|
||||
|
||||
}
|
||||
|
||||
class Citizen{
|
||||
int i_xSpawn, i_ySpawn, i_xPos, i_yPos, i_diameter;
|
||||
boolean b_linked;
|
||||
int i_home;
|
||||
String S_name;
|
||||
|
||||
|
||||
//0-100:
|
||||
//motivation (bei arbeiter montag ~40, freitag ~80 - 100)
|
||||
//7 emotionen?
|
||||
|
||||
// berufsfeld: webdesigner, pädagoge, schmuckdesigner, schmied
|
||||
// berufsstatus: beamter, selbstständiger, unternehmer, angestellter, grundschüler, gymnasiast, hauptschüler, realschüler, azubi, student, rentner
|
||||
|
||||
// identität: gelbhemd, lokal, regional, national, international, fremd,
|
||||
|
||||
//names of pathfinding algorithms: greedy best first search, uniform cost search, a star search
|
||||
|
||||
Citizen(int home, String name){
|
||||
i_home = home;
|
||||
S_name = name;
|
||||
i_diameter = 15;
|
||||
}
|
||||
|
||||
void goTo(int house){
|
||||
println("want to go to house " + house);
|
||||
}
|
||||
|
||||
void spawn(int house){
|
||||
PVector v2_spawnPoint = spawnAreas.get(house).v2_randomSpawnPoint();
|
||||
i_xSpawn = int(v2_spawnPoint.x);
|
||||
i_ySpawn = int(v2_spawnPoint.y);
|
||||
i_xPos = i_xSpawn;
|
||||
i_yPos = i_ySpawn;
|
||||
b_linked = true;
|
||||
}
|
||||
|
||||
void despawn(){
|
||||
b_linked = false;
|
||||
}
|
||||
|
||||
void display(){
|
||||
ellipse(i_xPos, i_yPos, i_diameter, i_diameter);
|
||||
textSize(10);
|
||||
text(S_name, i_xPos, i_yPos-10);
|
||||
}
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
image(img_houses, 0, 0, img_houses.width, img_houses.height);
|
||||
//image(img_streets, 0, 0, img_houses.width, img_houses.height);
|
||||
}
|
||||
|
||||
BIN
archive/citizen_pathfinding/data/houses_with_borders_small.png
Normal file
BIN
archive/citizen_pathfinding/data/houses_with_borders_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
20
citizen.pde
20
citizen.pde
@@ -4,9 +4,9 @@ Citizen mensch;
|
||||
boolean b_smallerImage = true; //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...
|
||||
|
||||
void mouseClicked(){
|
||||
mensch.goTo(112);
|
||||
}
|
||||
//void mouseClicked(){
|
||||
//mensch.goTo(112);
|
||||
//}
|
||||
|
||||
class Citizen{
|
||||
int i_xSpawn, i_ySpawn, i_xPos, i_yPos, i_diameter;
|
||||
@@ -15,6 +15,10 @@ class Citizen{
|
||||
String S_name;
|
||||
|
||||
|
||||
//0-100:
|
||||
//motivation (bei arbeiter montag ~40, freitag ~80 - 100)
|
||||
//7 emotionen?
|
||||
|
||||
// berufsfeld: webdesigner, pädagoge, schmuckdesigner, schmied
|
||||
// berufsstatus: beamter, selbstständiger, unternehmer, angestellter, grundschüler, gymnasiast, hauptschüler, realschüler, azubi, student, rentner
|
||||
|
||||
@@ -52,6 +56,10 @@ class Citizen{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
size(400, 300);
|
||||
fill(0);
|
||||
@@ -68,6 +76,7 @@ void setup() {
|
||||
|
||||
surface.setSize(img_houses.width, img_houses.height);
|
||||
|
||||
initPathFinding();
|
||||
initWeather();
|
||||
|
||||
|
||||
@@ -75,9 +84,12 @@ void setup() {
|
||||
mensch.spawn(59);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
image(img_houses, 0, 0, img_houses.width, img_houses.height);
|
||||
|
||||
//image(img_streets, 0, 0, img_houses.width, img_houses.height);
|
||||
textSize(7);
|
||||
textAlign(CENTER);
|
||||
@@ -85,6 +97,8 @@ void draw() {
|
||||
spawn.display();
|
||||
}
|
||||
|
||||
nodeDisplay();
|
||||
|
||||
mensch.display();
|
||||
|
||||
UI();
|
||||
|
||||
Reference in New Issue
Block a user