added collision bounds, moved display to citizen.display()

This commit is contained in:
2019-01-30 13:29:30 +01:00
parent a1913cd70f
commit 14941c1b2e

View File

@@ -31,12 +31,20 @@ class Entity {
float f_xPos, f_yPos, f_xSpawn, f_ySpawn;
float f_angle;
int i_diameter = 10;
int i_collBoundX, i_collBoundY, i_collBoundW, i_collBoundH;
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);
Entity() {
}
void spawn(int house) { //generic spawn
PVector v2_spawnPoint = houses.get(house).v2_randomSpawnPoint();
f_xSpawn = v2_spawnPoint.x;
@@ -46,6 +54,10 @@ class Entity {
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;
}
@@ -57,6 +69,10 @@ class Entity {
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;
}
void despawn() {
b_linked = false;
@@ -88,14 +104,7 @@ class Entity {
}
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);
}
}