camera tracking, autoplay, demography files
This commit is contained in:
84
UI.pde
84
UI.pde
@@ -2,7 +2,7 @@
|
||||
int i_uiTransparency = 200;
|
||||
void initUI() {
|
||||
i_uiX = 0;
|
||||
i_uiY = 520;
|
||||
i_uiY = 518;
|
||||
i_uiW = width;
|
||||
i_uiH = height - i_uiY;
|
||||
}
|
||||
@@ -21,40 +21,65 @@ void drawUI() {
|
||||
textAlign(LEFT);
|
||||
text(String.format("%02d", hour()) + ":" + String.format("%02d", minute()) + ":" + String.format("%02d", second()), 10, 30);
|
||||
|
||||
//camera tracking
|
||||
if (b_cameraFollow) {
|
||||
if (b_mapZoom) {
|
||||
i_mapOffsetX = width/2-int(citizen[i_selectedCitizen].f_xPos)/2;
|
||||
i_mapOffsetY = height/2-int(citizen[i_selectedCitizen].f_yPos)/2;
|
||||
} else {
|
||||
i_mapOffsetX = width/2-int(citizen[i_selectedCitizen].f_xPos);
|
||||
i_mapOffsetY = height/2-int(citizen[i_selectedCitizen].f_yPos);
|
||||
}
|
||||
}
|
||||
|
||||
//debug
|
||||
String[] debug = {
|
||||
"FPS: " + int(frameRate),
|
||||
"Amount citizen: " + i_citizenAmount,
|
||||
"Amount citizen: " + i_citizenAmount,
|
||||
"Females: " + i_femaleCount + " Males: " + str(i_citizenAmount-i_femaleCount),
|
||||
" ",
|
||||
" ",
|
||||
"Selected Citizen ID: " + i_selectedCitizen,
|
||||
"Name: " + citizen[i_selectedCitizen].S_name,
|
||||
"Gender: " + citizen[i_selectedCitizen].S_gender,
|
||||
"Age: " + citizen[i_selectedCitizen].i_age,
|
||||
"x: " + citizen[i_selectedCitizen].f_xPos + " y: " + citizen[i_selectedCitizen].f_yPos,
|
||||
"Movement speed: " + citizen[i_selectedCitizen].f_movementSpeed,
|
||||
"Velocity: ",
|
||||
"Outside",
|
||||
"Mood: "
|
||||
"Gender: " + citizen[i_selectedCitizen].S_gender,
|
||||
"Age: " + citizen[i_selectedCitizen].i_age,
|
||||
"x: " + int(citizen[i_selectedCitizen].f_xPos),
|
||||
"y: " + int(citizen[i_selectedCitizen].f_yPos),
|
||||
"Movement speed: " + round(citizen[i_selectedCitizen].f_movementSpeed*100),
|
||||
"Random Run: " + citizen[i_selectedCitizen].b_randomRun,
|
||||
" ",
|
||||
"Global",
|
||||
" ",
|
||||
"Autoplay: " + b_autoPlayAfterSelect,
|
||||
"Locked Camera: " + b_cameraFollow,
|
||||
//"Velocity: ",
|
||||
//"Outside",
|
||||
//"Mood: "
|
||||
};
|
||||
int ts = i_debugTextSize;
|
||||
textSize(ts);
|
||||
int line = 0;
|
||||
int maxLinesPerColumn = i_uiH/ts;
|
||||
int columnWidth = 130;
|
||||
if (maxLinesPerColumn > 0) {
|
||||
int requiredColumns = (debug.length/maxLinesPerColumn)+1;
|
||||
for (int i = 0; i < requiredColumns; i++) {
|
||||
while (((line-(maxLinesPerColumn*i)) * ts + ts)+i_uiY<height && line < debug.length) {
|
||||
text(debug[line], 10+(150*i), i_uiY+(ts*((line-(maxLinesPerColumn*i))+1)));
|
||||
while (((line-(maxLinesPerColumn*i)) * ts + ts-1)+i_uiY<height && line < debug.length) {
|
||||
text(debug[line], 10+(columnWidth*i), i_uiY+(ts*((line-(maxLinesPerColumn*i))+1)));
|
||||
line++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//text("FPS: " + int(frameRate), 10, i_uiY + 15);
|
||||
//text("Selected Citizen: " + i_selectedCitizen, 10, i_uiY + 30);
|
||||
}
|
||||
//buttons
|
||||
fill(150, 170, 250, 80);
|
||||
rect(i_uiX+i_uiW-135, i_uiY+ts/2, 120, ts, 5);
|
||||
fill(0);
|
||||
text("Autoplay", i_uiX+i_uiW-135, i_uiY+ts/2+ts);
|
||||
fill(150, 170, 250, 80);
|
||||
rect(i_uiX+i_uiW-135, i_uiY+ts/2+1.41*ts+ts/2, 120, ts, 5);
|
||||
fill(0);
|
||||
text("Lock Camera", i_uiX+i_uiW-135, i_uiY+ts/2+1.41*ts+ts+ts/2);
|
||||
}
|
||||
|
||||
boolean b_mouseChangeMapOffset, b_mouseChangeUiHeight;
|
||||
@@ -62,12 +87,24 @@ boolean b_hoverUI;
|
||||
|
||||
void mousePressed() {
|
||||
if (mouseButton == LEFT) {
|
||||
if (mouseX >= i_uiX && mouseX <= i_uiX+i_uiW && mouseY >= i_uiY-10 && mouseY <= i_uiY+10) {
|
||||
if (mouseX >= i_uiX && mouseX <= i_uiX+i_uiW && mouseY >= i_uiY-10 && mouseY <= i_uiY+10) { //drag and drop debug window size
|
||||
b_mouseChangeUiHeight = true;
|
||||
i_uiOffsetStartY = mouseY;
|
||||
i_initUiY = i_uiY;
|
||||
} else if (mouseX >= i_uiX+i_uiW-135 && mouseX <= i_uiX+i_uiW-135+120 //autoplay button
|
||||
&& mouseY >= i_uiY+i_debugTextSize/2-5 && mouseY <= i_uiY+i_debugTextSize/2+i_debugTextSize+5) {
|
||||
//if (b_autoPlayAfterSelect) {
|
||||
// citizen[i_selectedCitizen].b_moving = false;
|
||||
// citizen[i_selectedCitizen].b_randomRun = false;
|
||||
//}
|
||||
citizen[i_selectedCitizen].b_moving = !citizen[i_selectedCitizen].b_moving;
|
||||
citizen[i_selectedCitizen].b_randomRun = !citizen[i_selectedCitizen].b_randomRun;
|
||||
b_autoPlayAfterSelect = !b_autoPlayAfterSelect;
|
||||
} else if (mouseX >= i_uiX+i_uiW-135 && mouseX <= i_uiX+i_uiW-135+120 //autoplay button
|
||||
&& mouseY >= i_uiY+i_debugTextSize/2+1.41*i_debugTextSize+i_debugTextSize/2-5 && mouseY <= i_uiY+i_debugTextSize/2+1.41*i_debugTextSize+i_debugTextSize/2+i_debugTextSize+5) {
|
||||
b_cameraFollow = !b_cameraFollow;
|
||||
} else {
|
||||
int selectedCitizen = i_selectedCitizen;
|
||||
int selectedCitizen = i_selectedCitizen; //leftclick select citizen
|
||||
for (int i = 0; i < citizen.length; i++) {
|
||||
if (selectedCitizen != i) {
|
||||
if (i_mapViewToMap(mouseX, i_mapOffsetX)+10 >= citizen[i].f_xPos - citizen[i].i_diameter/2 && i_mapViewToMap(mouseX, i_mapOffsetX)-10 <= citizen[i].f_xPos + citizen[i].i_diameter/2
|
||||
@@ -79,15 +116,20 @@ void mousePressed() {
|
||||
}
|
||||
}
|
||||
if (mouseButton == CENTER) {
|
||||
b_mouseChangeMapOffset = true;
|
||||
i_mapOffsetStartX = mouseX - i_mapOffsetX;
|
||||
i_mapOffsetStartY = mouseY - i_mapOffsetY;
|
||||
if (!b_cameraFollow) {
|
||||
b_mouseChangeMapOffset = true;
|
||||
i_mapOffsetStartX = mouseX - i_mapOffsetX;
|
||||
i_mapOffsetStartY = mouseY - i_mapOffsetY;
|
||||
}
|
||||
}
|
||||
if (mouseButton == RIGHT) {
|
||||
if (!b_autoPlayAfterSelect) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
int i_mapViewToMap(int mouse, int offset) {
|
||||
if (b_mapZoom) return (mouse-offset)*2;
|
||||
else return mouse-offset;
|
||||
|
||||
Reference in New Issue
Block a user