Untitled
unknown
plain_text
a year ago
4.7 kB
2
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 clickRound = 2; // Shop vars float upgradeClickCost = 1; // 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; // Font PFont blockyFont; void setup() { frameRate(60); size(640, 640); eggX = width / 3; eggY = height / 3; smooth(0); egg1 = loadImage("Light Brown Egg.png"); blockyFont = createFont("BlockyFont.TTF", 16, false); 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(); drawUpgradeClick(); 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 (upgradeClick()) { money = money - upgradeClickCost; moneyPerClick += .5; clickRound +=2; upgradeClickCost = upgradeClickCost * clickRound; } } 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 drawUpgradeClick() { strokeWeight(3); stroke(10); fill(4, 136, 184); rectMode(CENTER); rect(13 * width / 16, height / 6, 150, 60); strokeWeight(0); fill(3, 186, 252); rect(13 * width / 16, height / 6, 140, 50); textAlign(CENTER, CENTER); textSize(12); fill(0); text("Upgrade Click: $" + nf(upgradeClickCost, 0, 0), 13 * width / 16, height / 6, 150, 60); } void showUI() { textAlign(CENTER); textSize(24); fill(0); text("Left: " + nf(eggHealth, 0, 0), eggX, eggY - 150); text("Money: $" + nf(money, 0, 2), eggX, eggY - 120); text("DPC: " + clickDamage, eggX, eggY +300); text("MPC: $" + moneyPerClick, eggX, eggY - 180); } void checkEggHealth() { if (eggHealth <= 0) { chickMoney = chickMoney + 1; chickDamage = chickDamage * 2; spawnChick(); 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(10, round); money = money + pow(5, round); clickDamage += 1; } 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); ellipse(x, y, radius * 2, 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 upgradeClick() { if (mouseX >= 13 * width / 16 - 61.5 && mouseX <= 13 * width / 16 + 61.5) { if (mouseY >= height/ 6 - 30 && mouseY <= height / 6 + 30) { if (money >= upgradeClickCost) { return true; } } } return false; }