Code documentation: Upgrades

This is a page that explains how upgrades work. Upgrades weren't in Classic Edition so there will be no "Scratch vs Definitive" gimmick in the page.

## Clicking upgrade

### How it affects clicking the cookie

*Directory: moving up in the world*

As always, the code will appear right now:

if (cookies >= clickUpPrice && mouseIsPressed) {

                        clickLvl \*= 2;

                        cookies -= clickUpPrice;

                        clickUpPrice \*= 10;

For the first line, that detects if you have more than the amount of cookies required to upgrade and if your mouse is pressed on the upgrade's hitbox. If that is true, then start line two (hey that rhymes)

For the second line, that multiplies the clickLvl by 2. That means that clickLvl actually adds only 1 cookie of value to clicks, and the table on the upgrades page is only possible because of that multiplication sign.

For the third line, that depletes your cookies by the price of the upgrade.

For the fourth line, that multiplies the then-current price of the upgrade by 10.

### How it looks like what it looks like

*Directory: moving up in the world*

As always, the code will app

fill(117, 61, 6);

            stroke(26, 18, 0);

            strokeWeight(4);

            rect(pointX - 25, pointY, 72, 101);

            //the upgrade's actual icon

            strokeWeight(1);

            stroke(0, 0, 0);

            fill(44, 232, 242);

            rect(pointX - 1, pointY + 55, 25, 35);

            triangle(pointX, pointY + 10, pointX, pointY + 68, pointX + 26, pointY + 58);

            if (mouseX >= clickUpHBX1 && mouseX <= clickUpHBX2 && mouseY >= clickUpHBY1 && mouseY <= clickUpHBY2) {

            //info about the upgrade

                fill(117, 61, 6);

                stroke(26, 18, 0);

                strokeWeight(4);

                rect(pointX - 27, pointY - 96, 75, 93);

                fill(255, 255, 255);

                text("Clicking upgrade", pointX - 25, pointY - 88);

                text("Clicking upgrade", pointX - 25, pointY - 88);

                text("This makes click\n-ing the cookie\n2X as effective.", pointX - 25, pointY - 72.5);

                text(clickUpPrice + "\ncookies to buy", pointX - 25, pointY - 23.3);

Wow, this is a doozy. For the first line, that makes the upgrade icon base brown like the stats page.

The second line makes the outline really dark brown, so dark that it looks black.

The third line makes the outline a bit thick.

The fourth line makes the rectangle in the place where it should be, have the width that it should have, and have the height that it should have.

The fifth line makes the upgrade icon have an outline. A thin outline, but an outline nonetheless.

The sixth line makes the upgrade icon outline black.

The seventh line makes the upgrade icon cyan, with the color ID of #2ce8f2.

The eighth line allows the palm of the hand to exist.

The ninth line allows the fingercitation needed to exist.

The tenth line detects if the upgrade hitbox has been moused over. If so, do

The eleventh line creates a rectangle above the upgrade with information that is made in the next lines.

The twelfth line makes the outline really dark brown, so dark that it looks black. Any second now.

The thirteenth line makes the outline thick enough to be seen.

The fourteenth line makes the rectangle in the right place, width, and height.

The fifteenth line makes the text white.

The sixteenth and seventeenth line are the same, summarized they make "Clicking upgrade" appear. Maybe the reason why there are two of the exact same lines is to make the message bold?

The eighteenth line is more text, in particular the description of the upgrade. I'm sure everyone knows what it looks like here.

The ninteenth line is a tiny bit more interesting as it shows the price of the upgrade.

### How it is clickable

*Directory: variables and stuff*

var clickUpHBX1 = clickX - 25;

var clickUpHBX2 = clickUpHBX1 + 72;

var clickUpHBY1 = clickY - 10;

var clickUpHBY2 = clickUpHBY1 + 101;

The first line makes the first horizontal hitbox of the clicking upgrade the same as the clickX but subtracted by 25.

The second line makes the second horizontal hitbox of the clicking upgrade the same as the first horizontal hitbox but plus 72.

The third line is the same as the first but horizontal is replaced with vertical and instead of being subtracted by 25, it's subtracted by 10.

The fourth line is the same as the second but horizontal is replaced with vertical and instead of being plused by 72, it's plused by 101.

## Cursor upgrade

*The directories are the same as in the last upgrade.*

### How it affects CpS

if (cookies >= crsrUpPrice && mouseIsPressed) {

                        crsrLvl \*= 2;

                        cookies -= crsrUpPrice;

                        crsrUpPrice \*= 10;

                    }

This is of course, similiar to the clicking upgrade. But anyway the first line detects if you have enough cookies and if your mouse has pressed on the upgrade's hitbox.

The second line multiplies the cursor level by 2.

The third line makes it so you buy the upgrade for its price and don't scam the game by not losing cookies.

The fourth line makes the upgrade 10 times pricier.

### How it looks like how it looks

fill(117, 61, 6);

                stroke(26, 18, 0);

                strokeWeight(4);

                rect(crsrUpX, clickY, 84, 101);

                //the cursor upgrade icon

                drawCrsr(crsrUpX + 40, clickY + 65, 44, 232, 242);

                if (mouseX >= crsrUpHBX1 && mouseX <= crsrUpHBX2 && mouseY >= crsrUpHBY1 && mouseY <= crsrUpHBY2) {

                    //info about the upgrade

                    fill(117, 61, 6);

                    stroke(26, 18, 0);

                    strokeWeight(4);

                    rect(crsrUpX, clickY - 96, 84, 93);

                    fill(255, 255, 255);

                    text("Cursor upgrade", crsrUpX, clickY - 88);

                    text("Cursor upgrade", crsrUpX, clickY - 88);

                    text("This makes \ncursors 2X \nas effective.", crsrUpX, clickY - 72.5);

                    text(crsrUpPrice + "\ncookies to buy", crsrUpX, clickY - 23.3);

The first line makes the box brown.

The second line makes the outline of the box really dark brown.

The third line makes the outline of the box thick enough to exist.

The fourth line makes the box existing enough to exist.

The fifth line makes the cursor in the box existing enough to be cyan and exist.

The sixth line detects if your mouse is on the upgrade. If so, do

The seventh line makes everything after it brown.

The eighth line makes the outline of the box that appeared because of the mouse being on the cursor brown.

The ninth line makes the outline of the box that appeared because of the mouse being on the cursor exist.

The tenth line makes the box that appeared because of the mouse being on the cursor's being in the right place permit exist.

The eleventh line makes the box's text that appeared because of the mouse being on the cursor's being white permit exist.

The twelfth and thirteenth line makes the box's title that appeared because of the mouse being on the cursor's being bold permit exist.

The fourteenth, fifteenth, and sixteenth line makes the box's text that appeared because of the mouse being on the cursor's existing permit exist.

The seventeenth line makes the box's price text that appeared because of the mouse being on the cursor's having the right price and existing permits exist.

### How it only appears after having a cursor

*Directory: moving up in the world*

if (cursors >= 1)

This is the most complicated code ever, I mean it must've taken years for the creator to figure out how to make this code work properly and they time travelled 5000 years into the future because technology was not advanced enough to figure out how to make this code