123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 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 = 10;
- int i_nameSize = 12;
- color c_selected = color(128, 50, 50);
- color c_color = color(50, 200, 80);
- color c_stroke = color(255, 255, 255);
- PVector v2_direction = new PVector(0, 0);
-
- 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;
- }
-
-
-
- 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;
- }
- 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() {
- 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;
- }
- }
-
- void display() {
- pg_map.stroke(c_stroke);
- pg_map.fill(c_color);
- if (b_selected) pg_map.fill(c_selected);
- pg_map.ellipse(f_xPos, f_yPos, i_diameter, i_diameter);
- pg_map.fill(c_stroke);
- pg_map.textAlign(CENTER);
- pg_map.textSize(i_nameSize);
- pg_map.text(s_name, f_xPos, f_yPos-10);
- }
- }
-
-
- class Interactable extends Entity {
-
- Interactable(String name, String description) {
- s_name = name;
- }
-
- void update() {
- }
- }
|