Most up to Date
10/20 9P.M. , has white Chicken Sprites, balanced points, and UIunknown
plain_text
a year ago
6.4 kB
1
Indexable
Never
// Egg vars int eggX, eggY; int eggW = 160; int eggH = 215; float eggHealth = 20; // Player stats float money = 0; int clickDamage = 1; float moneyPerClick = .5; // Round vars int round = 1; int mpClickRound = 2; int dpClickRound = 2; // Shop vars float upgradeMPClickCost = 1; float upgradeDPClickCost = 1000; // Spawn points int maxSpawnPoints = 8; PVector[] spawnPoints = new PVector[maxSpawnPoints]; float distFromEgg = 30; // Chick stuff ArrayList<Chick> chicks = new ArrayList<Chick>(); boolean canSpawnChick = false; int chickDamage = 1; float chickCooldown = 60; int chickMoney = 0; // Egg Sprites PImage egg1; // Chicken Sprites PImage whiteChicken; // Font PFont blockyFont; int numChick; void setup() { frameRate(60); size(640, 640); eggX = width / 3; eggY = height / 3; //Stuff to do With Images smooth(0); egg1 = loadImage("LightBrownEgg.png"); blockyFont = createFont("BlockyFont.TTF", 16, false); whiteChicken = loadImage("WhiteChicken.png"); //Chicken Stuff for (int i = 0; i < maxSpawnPoints; i++) { float angle = TWO_PI / maxSpawnPoints * i; float x = eggX + (eggW / 2 + distFromEgg) * cos(angle); float y = eggY + (eggH / 2 + distFromEgg) * sin(angle); spawnPoints[i] = new PVector(x, y); } } void draw() { background(250); textFont(blockyFont); drawEgg(); showUI(); checkEggHealth(); drawUpgradeMPClick(); drawUpgradeDPClick(); showGizmos(); for (Chick chick : chicks) { chick.update(); // Call any update logic for the chick if needed. chick.display(); chick.damage(); } } void keyPressed() { } void mousePressed() { if (clickedEgg()) { eggHealth -= clickDamage; money += moneyPerClick; } if (upgradeMPClick()) { money = money - upgradeMPClickCost; moneyPerClick += moneyPerClick; mpClickRound +=1; upgradeMPClickCost = upgradeMPClickCost * mpClickRound; } if (upgradeDPClick()) { money = money - upgradeDPClickCost; clickDamage = clickDamage * 2; dpClickRound +=2; upgradeDPClickCost = upgradeMPClickCost * dpClickRound; } } void drawEgg() { strokeWeight(3); stroke(10); fill(#fde992); imageMode(CENTER); image(egg1, eggX, eggY, 240, 240); textAlign(CENTER, CENTER); textSize(24); fill(0); text("Egg: " + round, eggX, eggY); } void drawUpgradeMPClick() { strokeWeight(3); stroke(10); fill(4, 136, 184); rectMode(CENTER); rect(3 * width / 4, height / 6, 150, 60); strokeWeight(0); fill(3, 186, 252); stroke(3, 186, 184); rect(3 * width / 4, height / 6, 140, 50); textAlign(CENTER, CENTER); textSize(12); fill(0); text("Upgrade MPC: $" + nf(upgradeMPClickCost, 0, 0), 3 * width / 4, height / 6, 150, 60); } void drawUpgradeDPClick() { strokeWeight(3); stroke(10); fill(4, 136, 184); rectMode(CENTER); rect(3 * width / 4, 2 * height / 6, 150, 60); strokeWeight(0); fill(3, 186, 252); stroke(3, 186, 184); rect(3 * width / 4, 2 * height / 6, 140, 50); textAlign(CENTER, CENTER); textSize(12); fill(0); text("Upgrade DPC: $" + nf(upgradeDPClickCost, 0, 0), 3 * width / 4, 2 * height / 6, 150, 60); } void showUI() { textAlign(CENTER, CENTER); textSize(20); fill(3, 136, 184); stroke(0); strokeWeight(5); rect(3 * width / 4, 3 * height / 4, 250, 290); fill(3, 186, 252); stroke(3, 186, 252); rect(3 * width / 4, 3 * height / 4, 230, 270); fill(0); text("Health Left: " + nf(eggHealth, 0, 0), 3* width / 4, 3 * height / 4 - 110); text("Money: $" + nf(money, 0, 2), 3 * width / 4, 3 * height / 4 - 55); text("DPC: " + clickDamage, 3 * width / 4, 3 * height / 4); text("MPC: $" + moneyPerClick, 3 * width / 4, 3 * height / 4 + 55); text("# of Chickens: " + numChick, 3 * width / 4, 3* height / 4 + 110); } void checkEggHealth() { if (eggHealth <= 0) { chickMoney = chickMoney + 1; chickDamage = chickDamage * 2; spawnChick(); numChick += 1; nextRound(); } } void spawnChick() { PVector spawnPoint = spawnPoints[int(random(maxSpawnPoints))]; Chick newChick = new Chick(spawnPoint.x, spawnPoint.y, 25, chickDamage, chickCooldown, chickMoney); chicks.add(newChick); } //Change the "Pow" first number to change how much increase or decrease void nextRound() { round += 1; eggHealth = pow(5, round); money += money; if (round <= 3) { clickDamage += 1; } else { clickDamage += clickDamage; } } void showGizmos() { fill(255, 0, 0); // Change the fill color to red for (PVector point : spawnPoints) { ellipse(point.x, point.y, 10, 10); // Adjust size as needed } stroke(0, 255, 0); noFill(); ellipse(eggX, eggY, eggW, eggH); } class Chick { float x, y, radius; int damage; float cooldown; int _chickMoney; float cooldownCounter; Chick(float x, float y, float radius, int damage, float cooldown, int _chickMoney) { this.x = x; this.y = y; this.radius = radius; this.damage = damage; this.cooldown = cooldown; this.cooldownCounter = cooldown; this._chickMoney = _chickMoney; } void update() { cooldownCounter -= 1; } void display() { strokeWeight(3); stroke(10); fill(230, 220, 10); image(whiteChicken, x, y, radius * 1.6, radius * 2); } void damage() { if (cooldownCounter <= 0) { eggHealth -= damage; cooldownCounter = cooldown; money += _chickMoney; } } } // // [CHECK CLICK FUNCTIONS] \\ \\ boolean clickedEgg() { if (dist(mouseX, 0, eggX, 0) <= eggW / 2 && dist(0, mouseY, 0, eggY) <= eggH / 2) { return true; } return false; } boolean upgradeMPClick() { if (mouseX >= 3 * width / 4 - 75 && mouseX <= 3 * width / 4 + 75) { if (mouseY >= height/ 6 - 30 && mouseY <= height / 6 + 30) { if (money >= upgradeMPClickCost) { return true; } } } return false; } boolean upgradeDPClick() { if (mouseX >= 3 * width / 4 - 75 && mouseX <= 3 * width / 4 + 75) { if (mouseY >= 2 * height/ 6 - 30 && mouseY <= 2 * height / 6 + 30) { if (money >= upgradeDPClickCost) { return true; } } } return false; }