changed autoplay system
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import java.lang.Double;
|
import java.lang.Double;
|
||||||
int i_citizenAmount = 10;
|
int i_citizenAmount = 20;
|
||||||
int i_selectedCitizen;
|
int i_selectedCitizen;
|
||||||
int i_femaleCount;
|
int i_femaleCount;
|
||||||
|
|
||||||
@@ -42,24 +42,23 @@ void initCitizen() {
|
|||||||
citizen[i] = new Citizen(int(random(0, houses.size())), S_citizenNames[gender][int(random(0, S_citizenNames[gender].length))], gender, age);
|
citizen[i] = new Citizen(int(random(0, houses.size())), S_citizenNames[gender][int(random(0, S_citizenNames[gender].length))], gender, age);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < citizen.length; i++) {
|
for (int i = 0; i < citizen.length; i++) {
|
||||||
if (i != i_selectedCitizen)
|
if (i != i_selectedCitizen) //hacky to set citizen[0] to a specific place
|
||||||
citizen[i].spawn(citizen[i].i_home);
|
citizen[i].spawn(citizen[i].i_home);
|
||||||
|
|
||||||
else citizen[i].spawn(8, 8);
|
else citizen[i].spawn(8, 8);
|
||||||
|
|
||||||
if (citizen[i].b_randomRun) citizen[i].goTo(int(random(0, pg_map.width)), int(random(0, pg_map.height)), 10); //bad
|
//if (citizen[i].b_randomRun) citizen[i].goTo(int(random(0, pg_map.width)), int(random(0, pg_map.height)), 10); //bad
|
||||||
}
|
}
|
||||||
selectCitizen(0);
|
selectCitizen(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectCitizen(int i) {
|
void selectCitizen(int i) {
|
||||||
citizen[i_selectedCitizen].b_randomRun = true;
|
//citizen[i_selectedCitizen].b_randomRun = true;
|
||||||
citizen[i_selectedCitizen].b_moving = true;
|
//citizen[i_selectedCitizen].b_moving = true;
|
||||||
citizen[i_selectedCitizen].b_selected = false;
|
citizen[i_selectedCitizen].b_selected = false;
|
||||||
if (!b_autoPlayAfterSelect) {
|
//if (!b_autoPlayAfterSelect) {
|
||||||
citizen[i].b_randomRun = false;
|
// citizen[i].b_randomRun = false;
|
||||||
citizen[i].b_moving = false;
|
// citizen[i].b_moving = false;
|
||||||
}
|
//}
|
||||||
citizen[i].b_selected = true;
|
citizen[i].b_selected = true;
|
||||||
i_selectedCitizen = i;
|
i_selectedCitizen = i;
|
||||||
}
|
}
|
||||||
@@ -73,7 +72,7 @@ class Citizen extends Entity {
|
|||||||
float f_movementSpeed;
|
float f_movementSpeed;
|
||||||
float f_FOV = PI / 4.0;
|
float f_FOV = PI / 4.0;
|
||||||
int i_visionDistance = 60;
|
int i_visionDistance = 60;
|
||||||
boolean b_randomRun;
|
boolean b_randomRun = b_autoPlay;
|
||||||
GraphNode startNode, endNode;
|
GraphNode startNode, endNode;
|
||||||
int startNodeID, endNodeID;
|
int startNodeID, endNodeID;
|
||||||
GraphNode[] rNodes;
|
GraphNode[] rNodes;
|
||||||
@@ -97,6 +96,8 @@ class Citizen extends Entity {
|
|||||||
c_selected = color(128, 50, 50);
|
c_selected = color(128, 50, 50);
|
||||||
c_color = color(0, 0, 0);
|
c_color = color(0, 0, 0);
|
||||||
c_stroke = color(255, 255, 255);
|
c_stroke = color(255, 255, 255);
|
||||||
|
|
||||||
|
if (b_randomRun) goTo(int(random(0, pg_map.width)), int(random(0, pg_map.height)), 10); //bad
|
||||||
}
|
}
|
||||||
//citizen kann "lookat" mit 180° winkel mit bullseye förmigen gradient welches die chance etwas zu bemerken darstellt
|
//citizen kann "lookat" mit 180° winkel mit bullseye förmigen gradient welches die chance etwas zu bemerken darstellt
|
||||||
//setFocus(entity) durch geräusche auch von objekten ausserhalb des sichtfeldes aufrufbar
|
//setFocus(entity) durch geräusche auch von objekten ausserhalb des sichtfeldes aufrufbar
|
||||||
@@ -115,9 +116,9 @@ class Citizen extends Entity {
|
|||||||
void update() {
|
void update() {
|
||||||
f_angle = v2_direction.heading();
|
f_angle = v2_direction.heading();
|
||||||
|
|
||||||
|
if (b_turning) {
|
||||||
turn();
|
turn();
|
||||||
|
}
|
||||||
|
|
||||||
if (b_moving) { //if rNodes.length > 0
|
if (b_moving) { //if rNodes.length > 0
|
||||||
move();
|
move();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class Entity {
|
|||||||
void despawn() {
|
void despawn() {
|
||||||
b_linked = false;
|
b_linked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnTo(float x, float y, float speed) {
|
void turnTo(float x, float y, float speed) {
|
||||||
f_turnSpeed = speed;
|
f_turnSpeed = speed;
|
||||||
if (f_turnSpeed > 0) {
|
if (f_turnSpeed > 0) {
|
||||||
@@ -86,7 +86,7 @@ class Entity {
|
|||||||
b_turning = false;
|
b_turning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void display() {
|
void display() {
|
||||||
pg_map.stroke(c_stroke);
|
pg_map.stroke(c_stroke);
|
||||||
pg_map.fill(c_color);
|
pg_map.fill(c_color);
|
||||||
|
|||||||
@@ -19,29 +19,6 @@ void initPathFinding() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//void mousePressed() {
|
|
||||||
// startNode = gs.getNodeAt(mouseX, mouseY, 0, 10.0f);
|
|
||||||
// if (startNode != null)
|
|
||||||
// selectMode = true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void mouseDragged() {
|
|
||||||
// if (selectMode)
|
|
||||||
// endNode = gs.getNodeAt(mouseX, mouseY, 0, 10.0f);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void mouseReleased() {
|
|
||||||
// if (selectMode && endNode!= null && startNode != null && startNode != endNode) {
|
|
||||||
// start = startNode.id();
|
|
||||||
// end = endNode.id();
|
|
||||||
// usePathFinder(pathFinder);
|
|
||||||
// }
|
|
||||||
// selectMode = false;
|
|
||||||
// startNode = endNode = null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PImage img_nodes;
|
PImage img_nodes;
|
||||||
void makeGraphFromImage(Graph g, PImage map, int tilesX, int tilesY, boolean allowDiagonals) {
|
void makeGraphFromImage(Graph g, PImage map, int tilesX, int tilesY, boolean allowDiagonals) {
|
||||||
img_nodes.loadPixels();
|
img_nodes.loadPixels();
|
||||||
|
|||||||
64
UI.pde
64
UI.pde
@@ -22,7 +22,7 @@ int i_uiOffsetX, i_uiOffsetY, i_uiOffsetStartX, i_uiOffsetStartY, i_initUiY;
|
|||||||
void drawUI() {
|
void drawUI() {
|
||||||
|
|
||||||
//camera tracking
|
//camera tracking
|
||||||
if (b_cameraFollow) {
|
if (b_cameraLock) {
|
||||||
if (b_mapZoom) {
|
if (b_mapZoom) {
|
||||||
i_mapOffsetX = width/2-int(citizen[i_selectedCitizen].f_xPos)/2;
|
i_mapOffsetX = width/2-int(citizen[i_selectedCitizen].f_xPos)/2;
|
||||||
i_mapOffsetY = height/2-int(citizen[i_selectedCitizen].f_yPos)/2;
|
i_mapOffsetY = height/2-int(citizen[i_selectedCitizen].f_yPos)/2;
|
||||||
@@ -71,12 +71,12 @@ void drawUI() {
|
|||||||
"Angle: " + citizen[i_selectedCitizen].f_angle,
|
"Angle: " + citizen[i_selectedCitizen].f_angle,
|
||||||
"Movement speed: " + round(citizen[i_selectedCitizen].f_movementSpeed*100),
|
"Movement speed: " + round(citizen[i_selectedCitizen].f_movementSpeed*100),
|
||||||
"Random Run: " + citizen[i_selectedCitizen].b_randomRun,
|
"Random Run: " + citizen[i_selectedCitizen].b_randomRun,
|
||||||
"Turning: " + citizen[i_selectedCitizen].b_turning,
|
"Turning: " + citizen[i_selectedCitizen].b_turning,
|
||||||
" ",
|
" ",
|
||||||
"Sunrise: " + S_sunrise,
|
"Sunrise: " + S_sunrise,
|
||||||
"Sunset: " + S_sunset,
|
"Sunset: " + S_sunset,
|
||||||
"Autoplay: " + b_autoPlayAfterSelect,
|
"Autoplay: " + b_autoPlay,
|
||||||
"Locked Camera: " + b_cameraFollow,
|
"Locked Camera: " + b_cameraLock,
|
||||||
"Debug Mode: " + b_debug,
|
"Debug Mode: " + b_debug,
|
||||||
//"Velocity: ",
|
//"Velocity: ",
|
||||||
//"Outside",
|
//"Outside",
|
||||||
@@ -102,21 +102,41 @@ void drawUI() {
|
|||||||
void buttonFunctions(int s) {
|
void buttonFunctions(int s) {
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case(0):
|
case(0):
|
||||||
citizen[i_selectedCitizen].b_moving = !citizen[i_selectedCitizen].b_moving;
|
b_autoPlay = !b_autoPlay;
|
||||||
citizen[i_selectedCitizen].b_randomRun = !citizen[i_selectedCitizen].b_randomRun;
|
//citizen[i_selectedCitizen].b_randomRun = b_autoPlay;
|
||||||
b_autoPlayAfterSelect = !b_autoPlayAfterSelect;
|
//citizen[i_selectedCitizen].b_moving = b_autoPlay;
|
||||||
|
if (b_autoPlay) {
|
||||||
|
for (int i = 0; i < citizen.length; i++) {
|
||||||
|
if (!citizen[i].b_moving) {
|
||||||
|
if (citizen[i].nextNode == 0) {
|
||||||
|
citizen[i].goTo(int(random(0, pg_map.width)), int(random(0, pg_map.height)), 10);
|
||||||
|
} else {
|
||||||
|
citizen[i].b_moving = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!citizen[i].b_randomRun) {
|
||||||
|
citizen[i].b_randomRun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < citizen.length; i++) {
|
||||||
|
citizen[i].b_moving = false;
|
||||||
|
citizen[i].b_randomRun = false;
|
||||||
|
citizen[i].b_turning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case(1):
|
case(1):
|
||||||
b_cameraFollow = !b_cameraFollow;
|
b_cameraLock = !b_cameraLock;
|
||||||
break;
|
break;
|
||||||
case(2):
|
case(2):
|
||||||
b_debug = !b_debug;
|
b_debug = !b_debug;
|
||||||
|
|
||||||
//dirty
|
//dirty
|
||||||
for(int i = 0; i < citizen.length; i++){
|
for (int i = 0; i < citizen.length; i++) {
|
||||||
citizen[i].c_stroke = color(int(!b_debug)*255);
|
citizen[i].c_stroke = color(int(!b_debug)*255);
|
||||||
}
|
}
|
||||||
for(int i = 0; i < interactables.length; i++){
|
for (int i = 0; i < interactables.length; i++) {
|
||||||
interactables[i].c_stroke = color(int(!b_debug)*255);
|
interactables[i].c_stroke = color(int(!b_debug)*255);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -194,24 +214,32 @@ void mousePressed() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!b_cameraLock) {
|
||||||
|
b_mouseChangeMapOffset = true;
|
||||||
|
i_mapOffsetStartX = mouseX - i_mapOffsetX;
|
||||||
|
i_mapOffsetStartY = mouseY - i_mapOffsetY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mouseButton == CENTER) {
|
if (mouseButton == CENTER) {
|
||||||
if (!b_cameraFollow) {
|
if (!b_cameraLock) {
|
||||||
b_mouseChangeMapOffset = true;
|
b_mouseChangeMapOffset = true;
|
||||||
i_mapOffsetStartX = mouseX - i_mapOffsetX;
|
i_mapOffsetStartX = mouseX - i_mapOffsetX;
|
||||||
i_mapOffsetStartY = mouseY - i_mapOffsetY;
|
i_mapOffsetStartY = mouseY - i_mapOffsetY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mouseButton == RIGHT) {
|
if (mouseButton == RIGHT) {
|
||||||
// if(citizen[i_selectedCitizen].hover){
|
// if(citizen[i_selectedCitizen].hover){
|
||||||
//}
|
//}
|
||||||
if (!b_autoPlayAfterSelect) {
|
|
||||||
citizen[i_selectedCitizen].b_randomRun = false;
|
|
||||||
citizen[i_selectedCitizen].b_moving = false;
|
//if (!b_autoPlay) {
|
||||||
}
|
// citizen[i_selectedCitizen].b_randomRun = false;
|
||||||
|
// citizen[i_selectedCitizen].b_moving = false;
|
||||||
|
//}
|
||||||
|
|
||||||
citizen[i_selectedCitizen].goTo(constrain(i_mapViewToMap(mouseX, i_mapOffsetX), 0, pg_map.width), constrain(i_mapViewToMap(mouseY, i_mapOffsetY), 0, pg_map.height), 10);
|
citizen[i_selectedCitizen].goTo(constrain(i_mapViewToMap(mouseX, i_mapOffsetX), 0, pg_map.width), constrain(i_mapViewToMap(mouseY, i_mapOffsetY), 0, pg_map.height), 10);
|
||||||
citizen[i_selectedCitizen].turnTo(citizen[i_selectedCitizen].f_xPos-constrain(i_mapViewToMap(mouseX, i_mapOffsetX), 0, pg_map.width), citizen[i_selectedCitizen].f_yPos-constrain(i_mapViewToMap(mouseY, i_mapOffsetY), 0, pg_map.height),4);
|
citizen[i_selectedCitizen].turnTo(citizen[i_selectedCitizen].f_xPos-constrain(i_mapViewToMap(mouseX, i_mapOffsetX), 0, pg_map.width), citizen[i_selectedCitizen].f_yPos-constrain(i_mapViewToMap(mouseY, i_mapOffsetY), 0, pg_map.height), 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int i_mapViewToMap(int mouse, int offset) {
|
int i_mapViewToMap(int mouse, int offset) {
|
||||||
|
|||||||
10
citizen.pde
10
citizen.pde
@@ -7,11 +7,11 @@ boolean b_loadSun = false; //load sun from web-api instead of local json file (l
|
|||||||
|
|
||||||
int i_sMapReso = 8; //the higher the smaller the reso, 2 is best quality but takes some time to download
|
int i_sMapReso = 8; //the higher the smaller the reso, 2 is best quality but takes some time to download
|
||||||
|
|
||||||
float f_walkSpeedMin = .05;
|
float f_walkSpeedMin = 1;
|
||||||
float f_walkSpeedMax = .1;
|
float f_walkSpeedMax = 2;
|
||||||
|
|
||||||
boolean b_cameraFollow = true;
|
boolean b_cameraLock = false;
|
||||||
boolean b_autoPlayAfterSelect = false;
|
boolean b_autoPlay = false;
|
||||||
|
|
||||||
|
|
||||||
boolean b_controlEyeWithMouse;
|
boolean b_controlEyeWithMouse;
|
||||||
@@ -74,7 +74,7 @@ int i_mapLevelTransferC;
|
|||||||
void draw() {
|
void draw() {
|
||||||
background(127);
|
background(127);
|
||||||
|
|
||||||
clientCommunication();
|
clientCommunication();
|
||||||
|
|
||||||
pg_map.beginDraw();
|
pg_map.beginDraw();
|
||||||
pg_map.background(127);
|
pg_map.background(127);
|
||||||
|
|||||||
Reference in New Issue
Block a user