xxxxxxxxxx
407
var num = 1;
var t = 0;
var R = 0;
var F = [];
var wdepth = 0;
var water = 0;
var pay = 0;
var dosh = 0;
var drain = 1;
var slow = 1;
var big = 1;
var net = 1;
var C = 0;
var img;
let playMode = 'sustain';
let hit;
let boop;
let smack;
function preload(){
img = loadImage('sto.png');
hit = loadSound('assets/hit.mp3');
boop = loadSound('assets/boop.mp3');
smack = loadSound('assets/smack.mp3');
}
function setup() {
createCanvas(900, 900);
fill(0);
noStroke();
textSize(40);
water = color(150, 0, 0);
water.setAlpha(200);
for (var i = 0; i < 20; i++) F.push(new food(random(-450, 450), random(-450, 450), random(big * 5, 20 * big) + 1));
cursor('none');
soundFormats('mp3', 'ogg');
}
var noButt = true;
function death() {
// death goes here
fill(0);
background(200, 100, 0);
image(img, 0, 0);
if (noButt) {
cursor('pointer');
dosh += pay;
var Y = 610;
var X = 0;
let button1 = createButton('❦');
button1.position(X, Y);
button1.id('Drain');
button1.mousePressed(drainAdd);
let button2 = createButton('⛛');
button2.id('Slow');
button2.position(X += width / 4, Y);
button2.mousePressed(slowAdd);
let button3 = createButton('⛰');
button3.id('Big');
button3.position(X += width / 4, Y);
button3.mousePressed(bigAdd);
let button4 = createButton('🕸');
button4.mousePressed(netAdd);
button4.position(X += width / 4, Y);
button4.id('Bank');
noButt = false;
let button5 = createButton('↵');
button5.id('Leave');
button5.position(X, 20);
button5.mousePressed(leave);
}
textSize(40);
textAlign(LEFT);
text("It is dead", 100, 100);
text("you feel bad", 100, 200);
text("but somehow relieved", 100, 300);
text("you are paid " + pay, 100, 400);
text("you have " + dosh, 100, 500);
textAlign(CENTER);
rectMode(CENTER)
textSize(20);
var Y = 600;
var X = width / 8;
fill(250, 250, 250);
rect(X, Y + 120, 130, 300, 15);
fill(0);
text("Drain" + Roman(drain), X, Y + 263);
text("cost:" + drain, X, Y);
fill(250, 250, 250);
rect(X += width / 4, Y + 120, 130, 300, 15);
fill(0);
text("Slow Drops" + Roman(slow), X, Y + 263);
text("cost:" + slow, X, Y);
fill(250, 250, 250);
rect(X += width / 4, Y + 120, 130, 300, 15);
fill(0);
text("Big Drops" + Roman(big), X, Y + 263);
text("cost:" + big, X, Y);
fill(250, 250, 250);
rect(X += width / 4, Y + 120, 130, 300, 15);
fill(0);
text("Net" + Roman(net), X, Y + 263);
text("cost:" + net, X, Y);
//stop time
frameRate(0);
}
function drainAdd() {
if (drain <= dosh) {
dosh -= drain;
drain++;
death();
}
}
function slowAdd() {
if (slow <= dosh) {
dosh -= drain;
slow++;
death();
}
}
function bigAdd() {
if (big <= dosh) {
dosh -= big;
big++;
death();
}
}
function netAdd() {
if (net <= dosh) {
dosh -= net;
net++;
death();
}
}
function leave() {
wdepth = 0;
num = 1;
//kill buttons
Drain.remove();
Slow.remove();
Big.remove();
Bank.remove();
Leave.remove();
noButt = true;
//restart time
cursor('none');
frameRate(50);
}
function draw() {
if (wdepth > 900) {
if (num > -100) num--;
if (num >= 0) num *= 0.9;
}
if (num < 0) {
death();
} else {
translate(450, 450);
t += 0.0125;
if (mouseY > 900 - wdepth) {
wdepth /= 1 + (sqrt(drain - 1) / 100);
if (wdepth < 1) wdepth = 0;
}
background(200, 200, 0);
R = lim((PI * sqrt(num)) % 500 + 10, 180);
noFill()
stroke(200, 200, 200);
circle(mouseX - 450, mouseY - 450, 10);
noStroke();
fill(0);
if (C > 35) body(0, R, R);
fill(0);
Circle(0, 0, R);
//the satalites
C = int(sqrt(num) / 10); //How many times the black Circle has reached the edge
fill(0);
// text(C+":"+int(num)+":"+R,-400,-400);
if (pay < C) pay = C;
for (var i = 0; i < C; i++) {
if (i < 10) {
fill(0);
Circle(sin(t + i * TAU / lim(C, 10)) * R / 2, cos(t + i * TAU / lim(C, 10)) * R / 2, R / 2);
} else if (i < 15) {
fill(200, 200, 180)
Circle(sin(t + (i * 2 - 10) * TAU / 10) * R / 2, cos(t + (i * 2 - 10) * TAU / 10) * R / 2, R / 2.5);
fill(0);
Circle(sin(i + t * 10) * R / 10 + sin(t + (i * 2 - 10) * TAU / 10) * R / 2, cos(i * 2 + t * 11) * R / 10 + cos(t + (i * 2 - 10) * TAU / 10) * R / 2, R / 20);
} else if (i < 25) {
var L = (100 - ((t + i / 5) * 100) % 100) / 50;
spike(sin(t + (i * 2 + 1) * TAU / 20) * R / 1.4, cos(t + (i * 2 + 1) * TAU / 20) * R / 1.4,
sin(t + (i * 2 + 1) * TAU / 20) * (R + L * R / 3), cos(t + (i * 2 + 1) * TAU / 20) * (R + L * R / 3),
R / 10);
} else if (i < 30) {
var L = (100 - ((t + i) * 200) % 100) / 50;
fill(0);
spike(sin(t + (i * 4) * TAU / 20) * R / 1.4, cos(t + (i * 4) * TAU / 20) * R / 1.4,
sin(t + (i * 4) * TAU / 20) * (R - L * R / 3), cos(t + (i * 4) * TAU / 20) * (R - L * R / 3),
R / 100);
spike(sin(t + (i * 4) * TAU / 20 + TAU / 100) * R / 1.4, cos(t + (i * 4) * TAU / 20 + TAU / 100) * R / 1.4,
sin(t + (i * 4) * TAU / 20 + TAU / 100) * (R - L * R / 3), cos(t + (i * 4) * TAU / 20 + TAU / 100) * (R - L * R / 3),
R / 100);
spike(sin(t + (i * 4) * TAU / 20 - TAU / 100) * R / 1.4, cos(t + (i * 4) * TAU / 20 - TAU / 100) * R / 1.4,
sin(t + (i * 4) * TAU / 20 - TAU / 100) * (R - L * R / 3), cos(t + (i * 4) * TAU / 20 - TAU / 100) * (R - L * R / 3),
R / 100);
} else if (i < 35) {
fill(200, 0, 0);
var Ax = sin(t + (1 + i * 4) * TAU / lim(C, 10)) * R / 1.4;
var Ay = cos(t + (1 + i * 4) * TAU / lim(C, 10)) * R / 1.4;
Circle(Ax, Ay, R / 20);
var Bx = Ax * random(1, 1.5)
var By = Ay * random(1, 1.5)
tentacle(Ax, Ay, Bx, By, R / 10)
}
//arm(0,0,100);
}
for (var f of F) f.show();
fill(0, 200, 200);
stroke(0);
strokeWeight(net * abs(sin(t)));
circle(mouseX - 450, mouseY - 450, net * 10)
fill(water);
rectMode(CORNER);
rect(-450, 450 - wdepth, 900, wdepth);
}
// the help button
noStroke();
fill(244, 67, 54)
square(-450, -450, 20);
fill(255, 255, 255);
textSize(20);
textAlign(LEFT);
text("?", -446, -432)
if (mouseX < 20 && mouseY < 20 && mouseIsPressed) {
square(-430, -430, 860);
fill(0);
textAlign(LEFT);
textSize(35);
text("1) don't touch the black one", -400, -360);
text("2) click the red ones", -400, -320);
text("3) if they get to the bottom things speed up", -400, -280);
text("4) between tries upgrade things ", -400, -240);
textSize(12);
text("5) there maybe secrect dynamics ", -400, -200);
}
}
function lim(A, B) {
if (A < B) return A
return B
}
var dam = 0;
function Circle(x, y, s) {
circle(x, y, s);
if (dist(mouseX, mouseY, x + 450, y + 450) < s / 2) {
fill(200, 200, 200);
circle(mouseX - 450, mouseY - 450, random(net + 10, (net + 10) * 3));
if (num > 0) {num *= 0.9;num--;}
if (dam % 5 == 0) {
hit.play();
}
dam++;
}
}
function tentacle(sx, sy, ex, ey, girth) {
var S = createVector(sx, sy);
var E = createVector(ex, ey);
var G = S.copy().sub(E).rotate(TAU / 4).normalize().mult(girth);
S1 = S.copy().add(G); //.mult(R/2);
S2 = S.copy().sub(G); //.mult(R/2);
stroke(200, 0, 0);
bezier(S.x, S.y, S1.x, S1.y, S.x, S.y, E.x, E.y);
bezier(S.x, S.y, S2.x, S2.y, S.x, S.y, E.x, E.y)
noStroke();
}
function spike(sx, sy, ex, ey, girth) {
var S = createVector(sx, sy);
var E = createVector(ex, ey);
var G = S.copy().sub(E).rotate(TAU / 4).normalize().mult(girth);
S1 = S.copy().add(G);
S2 = S.copy().sub(G);
triangle(S1.x, S1.y, S2.x, S2.y, E.x, E.y)
Circle(E.x, E.y, girth)
}
function sgn(A) {
return abs(A) / A;
}
function food(x, y, s) {
this.x = x;
this.y = y;
this.s = s;
var et = false;
this.show = function () {
fill(200, 0, 0);
circle(this.x, this.y, sqrt(this.s * 5));
if (dist(mouseX, mouseY, this.x + 450, this.y + 450) < sqrt(this.s * 5) + net) {
et = true;
//boop.rate(10 + random(1));
boop.play();
}
if (et) {
this.x *= 0.9;
this.y *= 0.9;
if (dist(this.x, this.y, 0, 0) < 2) {
num += this.s;
this.y = -450;
et = false;
this.x = random(-450, 450);
this.s = random(big * 5, 20 * big) + 5;
}
} else {
//avoid the core
if (dist(this.x, this.y, 0, 0) < R / 2) this.x += sgn(this.x);
//fall
this.y += (C + 1) * (10 + wdepth) / (this.s * slow);
if (this.y > 450 - wdepth) {
this.y = -450
this.x = random(-450, 450);
this.s = random(big * 5, 20 * big) + 5;
wdepth += this.s / 10;
if (smacks < 20) {
smack.amp(.1);
smack.rate(10 / s);
smack.play();
smacks++;
} else smacks -= .1;
}
}
}
}
var smacks = 0;
function body(x, y, s) {
fill(175, 150, 176);
circle(x, y, s);
bezier(x, y - s / 2, x - s * 2, y + 2 * s, x + s * 2, y + 2 * s, x, y - s / 2);
//nips
fill(200, 200, 0)
Circle(x + s / 4, y, s / 8);
Circle(x - s / 4, y, s / 8);
Circle(x + s / 5, y + s / 4, s / 9);
Circle(x - s / 5, y + s / 4, s / 9);
fill(0);
Circle(x + s / 4, y, s / 10);
Circle(x - s / 4, y, s / 10);
Circle(x + s / 5, y + s / 4, s / 12);
Circle(x - s / 5, y + s / 4, s / 12);
Circle(x, y * 2, s / random(5, 12));
}
function arm(x, y, s) {
fill(175, 150, 176);
curve(x, y, x + 73, x + 24, x + 73, x + 61, x, y);
}
function Roman(A) {
if (A < 2) return ('');
const map = [
["M", 1000],
["CM", 900],
["D", 500],
["CD", 400],
["C", 100],
["XC", 90],
["L", 50],
["XL", 40],
["X", 10],
["IX", 9],
["V", 5],
["IV", 4],
["I", 1],
];
let res = " ";
for (const [roman, val] of map) {
while (A >= val) {
res += roman;
A -= val;
}
}
return res;
}