Code documentation: The Big Cookie and The Price Board

This page is a page about how the big cookie and price board works.

Start cookie click SFX

Change cookies and all-time cookies by 1 times golden cookie effect

Switch sprite to (clicked cookie)

When loop done:

Switch sprite to (non-clicked cookie)

### The price board

The code for price board, or rather, the things *on* the price board is quite simple.

The code looks like this:

(We'll use the Grandma as an example.)

When Grandma price shower hovered over:

Say "(Grandma price) Cookies".

### A video example

This is both to give more information on this stuff and also to fulfill one of the tasks on the task manager thing admins have.

### The Big Cookie

The big cookie's code in Definitive Edition is incredibly complex compared to its Scratch brother.

#### Variables

The code setting up the big cookie ~~looks like~~ is this:

(setting up its location)

var cookieSize = 135

var cookieX = 75

var cookieY = 300

var cookieHitboxX1 = cookieX - 45;

var cookieHitboxX2 = cookieHitboxX1 + cookieSize;

var cookieHitboxY1 = cookieY - (cookieSize / 2);

var cookieHitboxY2 = cookieY + (cookieSize / 2);

(variables for the chips)

var chipX = 20;

var chipY = 35;

var chipRad = 120;

(detects if you clicked the cookie)

if (mouseIsPressed && mouseX > cookieHitboxX1 && mouseX < cookieHitboxX2 && mouseY > cookieHitboxY1 && mouseY < cookieHitboxY2)

        cookieSize = 135; (makes the cookie its normal size)

        (setting stuff with the chips to normal)

        chipRad = 120;

        chipX = 30;

        chipY = 35;

//the base of the cookie

    fill(173, 151, 26);

    ellipse(cookieX, cookieY, cookieSize, cookieSize);

   (the chips in the cookie)

    fill(135, 76, 10);

    ellipse(cookieX - chipX, cookieY - chipY, cookieSize - chipRad, cookieSize - chipRad);

    ellipse(cookieX, cookieY, cookieSize - (chipRad - 21), cookieSize - (chipRad - 21));

    ellipse(cookieX + chipX, cookieY - 25, cookieSize - (chipRad - 16), cookieSize - (chipRad - 16));

### Stats

*Directory: much stats very wow*

Since the price board doesn't exist in definitive edition, this part is about the code for the stats instead. There will be the code at the left, and an explanation right after it in brackets.

//stats screen

            strokeWeight(3); (The outline of the stats screen.)

            var statX = 140; (How far right the stats screen is to the left edge of the screen.)

            var statY = 1; (This is literally just here to trigger people, there is no need for the stats screen to be uncentered by 1 pixel but it is.)

            fill(179, 118, 6); (This makes the base of the stats screen brown.)

            rect(statX, statY, 255, height - 1); (This makes the base of the stats screen exist. In more detail, the 1st and 2nd variables are where the stats screen is, the third thing is the width and the fourth one is unsurprisingly the height.)

            fill(255, 255, 255); (This makes the text white.)

            //title

            textSize(25); (This is how big the title is.)

            text("Stats", statX + 30, statY + 30); (This is how existing the title is because if it wasn't for this code, the title wouldn't exist. In more detail, the first thing is the actual message, the second and third things are where the message is)

            //actual stats text

            textSize(10); (This is how big the text below the title is.)

            text(cookies + " cookie(s) in bank", statX + 10, statY + 72); //cookies in bank (I'm not explaining what text does again, refer to the second last comment.)

            text(allTimeCookies + " cookie(s) baked (all time)", statX + 10, statY + 97); //all time cookie(s) (/|\)

            text("CpS: " + CpS, statX + 10, statY + 118);  //CpS (|)

            text("Buildings: " + buildings, statX + 10, statY + 139); //buildings (|)