ÖzÜ Oyun Atölyesi

< Yazı Biraz fizik >


Bazinga

Kod

import ddf.minim.*;

void setup() {
  Minim minim = new Minim(this);
  ding = minim.loadSample("ding.mp3");
  bazinga = minim.loadSample("bazinga.mp3");
  size(500, 500);
  daireX = width / 2;
  daireY = height / 2;
  fill(0, 0, 255);
  stroke(0, 0, 255);
  cursor(CROSS);
}

int daireX = 0;
int daireY = 0;
int cap = 50;
int kirmizi = 255;
int yesil = 255;
int mavi = 255;
int can = 5;
int level = 1;
AudioSample ding;
AudioSample bazinga;

void draw() {
  background(kirmizi, yesil, mavi);
  if (can > 0) {
    if (level >= 8) {
      text("Sen yaparsın!", width/2, height/2);
    } else if (level >= 4) {
      ellipse(daireX, daireY, cap, cap);
      noCursor();
      line(mouseX, 0, mouseX, 5);
      line(0, mouseY, 5, mouseY);
    } else {
      ellipse(daireX, daireY, cap, cap);
    }
  } else {
    text("Öğren de gel!", width/2, height/2);
  }
  kirmizi = kirmizi + 2;
  yesil = yesil + 2;
  mavi = mavi + 2;

  text("Can: " + can, 0, height-25);
  text("Level: " + level, 0, height-5);
}

void mousePressed() {
  if (can > 0 && level < 8) {
    if (dist(daireX, daireY, mouseX, mouseY) < cap/2) {
      daireX = int(random(cap/2, width-cap/2));
      daireY = int(random(cap/2, height-cap/2));
      cap = cap - 4;
      kirmizi = 0;
      yesil = 0;
      level = level + 1;
      ding.trigger();
    } else {
      yesil = 0;
      mavi = 0;
      can = can - 1;
      bazinga.trigger();
    }
  }
}