122 lines
2.9 KiB
Plaintext
122 lines
2.9 KiB
Plaintext
int i_interactableAmount = 10;
|
|
|
|
//entitiy-subklassen: papier .. computer .. mobiles ... books ... lamps ... tables ...
|
|
Interactable[] interactables = new Interactable[10];
|
|
|
|
|
|
void initInteractables() {
|
|
for (int i = 0; i < interactables.length; i++) {
|
|
interactables[i] = new Interactable("Interactable", "Content");
|
|
}
|
|
for (int i = 0; i < interactables.length; i++) {
|
|
interactables[i].spawn(citizen[(int)random(0, citizen.length)].i_home);
|
|
}
|
|
}
|
|
|
|
|
|
class Entity {
|
|
String s_name;
|
|
boolean b_linked;
|
|
int i(int x) {
|
|
return (x);
|
|
};
|
|
boolean b_selected;
|
|
boolean b_moving;
|
|
boolean b_turning;
|
|
PVector v2_turnBuffer = new PVector(0, 0);
|
|
float f_turnSpeed;
|
|
|
|
int i_turning;
|
|
|
|
float f_xPos, f_yPos, f_xSpawn, f_ySpawn;
|
|
float f_angle;
|
|
int i_diameter = 20;
|
|
int i_collBoundX, i_collBoundY, i_collBoundW, i_collBoundH;
|
|
int i_nameSize = 24;
|
|
|
|
int i_location; //0: at home. 1: outside. 2: at work. 3: in church. 4: at a friends place .. etc
|
|
|
|
color c_selected = color(128, 50, 50);
|
|
color c_color = color(50, 200, 80);
|
|
color c_initialColor;
|
|
color c_stroke = color(255, 255, 255);
|
|
PVector v2_direction = new PVector(0, 0);
|
|
|
|
Entity(){
|
|
}
|
|
|
|
void spawn(int house) { //generic spawn
|
|
PVector v2_spawnPoint = houses.get(house).v2_randomSpawnPoint();
|
|
f_xSpawn = v2_spawnPoint.x;
|
|
f_ySpawn = v2_spawnPoint.y;
|
|
f_xPos = f_xSpawn;
|
|
f_yPos = f_ySpawn;
|
|
turnTo(0, 10, 0);
|
|
f_angle = 0;
|
|
b_linked = true;
|
|
i_collBoundX = (int)f_xPos - (i_diameter/2);
|
|
i_collBoundY = (int)f_yPos - (i_diameter/2);
|
|
i_collBoundW = i_diameter;
|
|
i_collBoundH = i_diameter;
|
|
i_location = 0;
|
|
}
|
|
|
|
|
|
|
|
void spawn(int x, int y) { //specific spawn
|
|
f_xSpawn = x;
|
|
f_ySpawn = y;
|
|
f_xPos = f_xSpawn;
|
|
f_yPos = f_ySpawn;
|
|
turnTo(0, 10, 0);
|
|
b_linked = true;
|
|
i_collBoundX = (int)f_xPos - (i_diameter/2);
|
|
i_collBoundY = (int)f_yPos - (i_diameter/2);
|
|
i_collBoundW = i_diameter;
|
|
i_collBoundH = i_diameter;
|
|
i_location = 1;
|
|
}
|
|
void despawn() {
|
|
b_linked = false;
|
|
}
|
|
|
|
void turnTo(float x, float y, float speed) {
|
|
f_turnSpeed = speed;
|
|
if (f_turnSpeed > 0) {
|
|
b_turning = true;
|
|
v2_turnBuffer.x = x;
|
|
v2_turnBuffer.y = y;
|
|
float difference = v2_direction.heading() - v2_turnBuffer.heading();
|
|
if (difference < -PI) difference += TWO_PI;
|
|
if (difference > PI) difference -= TWO_PI;
|
|
if (difference > 0.0) i_turning = -1;
|
|
if (difference < 0.0) i_turning = 1;
|
|
f_turnSpeed*=4*abs(difference);
|
|
} else {
|
|
v2_direction.x = x;
|
|
v2_direction.y = y;
|
|
}
|
|
}
|
|
|
|
void turn() {
|
|
f_angle = v2_direction.heading();
|
|
if (!(abs(int(v2_direction.heading() * 1000) - int(v2_turnBuffer.heading()*1000)) < 100)) {
|
|
v2_direction = v2_direction.rotate(i_turning*PI/180*f_turnSpeed);
|
|
} else {
|
|
b_turning = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
class Interactable extends Entity {
|
|
|
|
Interactable(String name, String description) {
|
|
s_name = name;
|
|
}
|
|
|
|
void update() {
|
|
}
|
|
}
|