jordanlrothwell / missile_command

Assignment 3 - COSC101 T1 2024
MIT License
0 stars 0 forks source link

Main #11

Open deklinedcode opened 1 month ago

deklinedcode commented 1 month ago

Terrain terrain; City[] cities = new City[6]; float[] citySpacing = {0.10, 0.20, 0.30, 0.65, 0.75, 0.85}; // Array to set spacing of cities boolean[] hitMarker = new boolean[6]; // Array to store if city is hit or safe

void setup() { size(1000, 500); // Initialise the terrain object terrain = new Terrain(); // Initialise the cities and set hitMarker to no cities hit for (int i = 0; i < cities.length; i++) { cities[i] = new City(citySpacing[i]); hitMarker[i] = false; } }

void draw() { background(0); terrain.drawTerrain(); terrain.drawMissileBase();

for (int i = 0; i < cities.length; i++) { if (cities[i].cityHitDetection(mouseX, mouseY) || hitMarker[i]) { // replace mouseX/mouseY with bomb coordinates hitMarker[i] = true; // city hit cities[i].cityHit(); // draw hit city } else { cities[i].citySafe(); // draw safe city } }

// Grid lines if need to use remove comments /* for (int x = 50; x <= width; x += 50) { stroke(255); line(x, 0, x, height);

for (int y = 50; y <= width; y += 50) { stroke(255); line(0, y, width, y); } } */ }