Code documentation: Other

This page is about code that didn't fit into any other pages but are still existent nonetheless.

## Fake Cookie Clicker

### README

This is basically the notepad of Fake Cookie Clicker. It used to look like this:

But now it looks like this:

### Save/Load System

#### Save

When S key pressed:

Say: (All-Time Cookies) + "-" + (cookies) + "-"... You get the idea, this repeats for nearly every stat in the game.

#### Load

When L key pressed:

Ask: "What was the first part of the code?"

If: (The answer contains letters), then

Ask it again.

Else,

Set (stat) to answer.

That if/else statement is essentially copied 7 times for every stat in the save code, so it'd be redundant to write all of the code.

## Fake Cookie Clicker Definitive Edition

### Title screen

*Directory: None*

Due to the education-oriented stigma of Khan Academy, you can see the code when trying to play a game. However, this can be put to more creative use as the creator of Fake Cookie Clicker Definitive Edition does with these pretty long 167 lines of code, so if you have a short attention span don't read on:

/\*

            this effect doesn't work properly on mobile devices, sorry mobile players:

              \_\_\_\_\_\_\_

             /       \

             \\_\_\_\_\_\_\_/

        \_\_     \_\_\_           \_\_

       |\_\_   /     \   | /  |\_\_

        \_\_   \_\_\_    \_\_\_         \_\_ \_\_    \_\_

        \_\_         \_\_ \_\_   \_\_          \_\_    \_\_

    A JAYDAR STUDIOS GAME

    FAKE COOKIE CLICKER DEFINITIVE EDITION, COPYRIGHT 2022, JAYDAR STUDIOS, INC.

\*/

/\*\*

    PATCH NOTES:

        V0.0000521: Fixed a bug with the cursor.

        V0.000052: Added a lot more achievements (more specifically 5), along with a bit more clarification to the "Achievs" object.

        V0.0000513: Added a "Speedrunner's Guide"

        V0.000512: Fixed a bug with the "Won't Budge" achievement where you could get it multiple times and fixed a bug where you might not get cookie achievements if you ran the game in the background.

        V0.000511: Fixed an extremely small bug with the "Can We Fix It?" Achievement.

        V0.00051: Fixed the Grandma (in multiple ways).

        V0.0005: Added Grandma and an extra Achieveeement.

        V0.00045: Added acheivements.

        V0.00044: Added upgrades for cursors.

        V0.00043: Added the fist upgrade of many to come, that upgrade being an upgrade to the cookie clicks.

        V0.000421: Added graphics for a prototype upgrade for cookie clicks

        V0.00042: Added the info board (kinda)

        V0.00041: Made cursors appear underneath the big cookie

        V0.0004: FINALLY FINISHED THE CURSOR (kinda, I need to add it underneath the cookie and add info when the buy icon is hovered over, but still!)

        V0.00031: Added more graphics for when I actually implement the cursor and changed to a version number rather than a prototype number

        V0.00030 (prototype 3): Tried to do more work, ended up doing about nothing

        V0.00025 (prototype 2.5): Added a rectangle

        V0.00020 (prototype 2): Finished the chips

        V0.00010 (prototype 1): Original prototype release

\*/

/\*

    To do (most important to least important):

    Add saving

    Fix the big cookie's hitbox to make it a circle

    Add SFX

    Once the info board is added, I need to make sure the cookie count text doesn't overlap with the info board.

    Add the news ticker

    Add particles

    Add bulk buying

    Add debug features

    Maybe create a seperate website for this game????? (I'm kinda limited in Khan Academy)

\*/

/\*

    DONE (oldest to latest):

    Finish the Cursor

    Add the info board (sorta)

    Added an upgrade for clicking the cookie! (HERE COMES THE HYPE TRAIN!!!!!!!!!!!!!!)

    Added an upgrade for the cursor (THOMAS THE HYPE TRAIN LEVELS OF HYPE)

\*/

/\*\*

    And now, the offical speedrunner's guide to DE speedruns, made by Jaydar:

        SPEEDRUN CATEGORIES:

    10K cookies (earn 10 thousand cookies all-time w/o messing with the code.)

    1M cookies (earn 1 million cookies all-time w/o messing with the code.)

    All Achievements (Earn every achievement in the game w/o messing with the code.)

        SUBCATEGORIES:

    Any% (beating that category in any way, while still obeying the main category's rules)

    Low click% (beating that category while clicking the cookie the least amount of times)

        CATEGORY EXSTENSIONS:

    ACE (Messing with the game's code to get to 1 Million cookies. Cookie clicks are NOT ALLOWED!)

    short% (An extremely short run where you have to get these achievements: "Bakeginner", "Nice try", and "Won't Budge!")

    timetravel% (A run where you have to get 10 cookies in every version of the game.)

    That's it; enjoy running these categories soon!

    NOTE: Speedrun leaderboards on speedrun.com aren't ready yet, but you can still record speedruns in advance.

\*\*/

/\*\*

        FEATURES:

    - A big cookie

    - Buyable Cursors and Grandmas

    - Upgrades

    - Stats

    - Achievements

    - Cookies

    - And soon enough, speedrun.com leaderboards!

/\*\*

                CREDITS:

Cookie clicker is by Orteil, I have his thanks for this project, as it's his concept.

Fake Cookie clicker and Fake Cookie Clicker: Definitive Edition by me, copyright 2021 - 2022.

Code is by me, unless I say "This code is by (so and so)."

Graphics are by me

\*/

This should be self explanatory except for the first few lines of code, in Khan Academy those would look like big art of the words "FAKE COOKIE CLICKER" but here they just seem like a randomly generated maze with only faint signs of the words.

### Frame cap

*Directory: variables and stuff*

Here's the code:

var fpsCap = 30;

frameRate(fpsCap);

This is super complicated stuff that no one understands. Since this wiki is mostly for casuals and not Albert Einstein, we will move on so as to not bend your brains even further.

### Default values

*Directory: variables and stuff*

//cookie count setup

    var cookies = 0;

    //all time cookies setup

    var allTimeCookies = 0;

    //cookies per second setup

    var CpS = 0;

    var buildings = 0;

This code sets the cookies, all time cookies, buildings, and CpS to zero when you start the game, and if you're wondering the numbers don't change with the amount of cookies you get, buildings or cookies you have gotten, or cookies you get per second.

### Buy icon

Here's one paragraph of code, and then there will be another.

*Directory: variables and stuff*

#### First paragraph

var buyX = 395;

var buyY = 265;

var buyW = 205;

var buyH = 75;

This is the first proper one, so of course it'll be met with proper documentation. The first line sets the buy icon horizontal value to 395 pixels from the left side of the screen.

The second line sets the buy icon's vertical value to 265 pixels from the top side of the screen.

The third line sets the buy icon's width to 205 pixels wide.

The fourth line sets the buy icon's height to 75 pixels high.

The next paragraph of code is coming now!

#### Second paragraph

var buyHBX1 = buyX;

var buyHBX2 = buyHBX1 + buyW;

var buyHBY1 = buyY;

var buyHBY2 = buyHBY1 + buyH;

The first line makes the buy icon's first horizontal hitbox equal the same as buyX, which is 395 pixels away from the left side of the screen.

The second line makes the buy icon's second horizontal hitbox equal the first horizontal hitbox plus the width of the buy icon, which is 205 pixels wide.

The third line and fourth line are the same as the first and second line except horizontal was replaced by vertical.

#### Third paragraph?

This paragraph is shorter as it's not really a paragraph.

var font1 = createFont("monospace", 18);

This makes the font of the buy icon the monospace font and makes the size of the font 18.

#### Fourth paragraph??

*Directory: where the magic happens*

fill(61, 155, 255);

    rect(buyX, buyY, 204, buyH);

    fill(255, 255, 255);

The first line makes the base of the buy icon blue.

The second line makes the base of the buy icon exist where it's supposed to exist.

The third line makes the price text white.

#### FIFTH PARAGRAPH???

*Directory: where the magic happens*

textFont(font1);

    text("Cursors", buyX + 31, buyY + 14.3);

    textSize(28);

    text(cursors, buyX + 9, buyY + 36);

This text makes the title of the cursor exist where it's supposed to and also makes the font and size and text and horizontal and vertical values what they're supposed to be.

### Cookie count text

*Directory: variables and stuff*

var font2 = createFont("sans-serif", 10);

This is super complicated stuff even after reading the last section and no one knows what it does.

### Price text

*Directory: where the magic happens*

textFont(font1);

    text(cursorPrice + " Cookies", buyX + 15, buyY + 65);

The first line makes the font the font it's supposed to be, monospace.

The second line makes the text what it's supposed to be, or the price of the cursor.

### Achievements

*Directory: variables and stuff*

var achievs = [];

//an object that stores achievments

var achieved = {

    bakeginner: "false",

    rollDough: "false",

    toFeed: "false",

    fixIt: "false",

    nicetry: "false"

};

//this just plays the SFX for achievments

var playChiev = function() {

    var snd = getSound("retro/coin");

    snd.audio.volume = 0.095;

    playSound(snd);

};

var unlocknicetry = function() {

    achieved.nicetry = "true";

    achievs.push("\nNice Try (Right-click the cookie)");

    playChiev();

};

The first line basically makes the achievement variable a list.

The second to sixth line makes an actual list that says "All these achievements aren't unlocked yet!"

The seventh line makes a function called playChiev.

The sixth line makes a variable that plays a retro coin sound.

The seventh line makes the volume of the sound 0.495.

The eighth line makes the sound play.

The ninth line makes a function.

The tenth line checks if you've achieved the achievement "Nice Try".

The eleventh line pushes the message "Nice Try (Right-click the cookie)"

The twelfth line calls the function from the seventh line.

*Directory: gold stars*

if (allTimeCookies === 1 && achieved.bakeginner === "false") {

                achieved.bakeginner = "true";

                achievs.push("Bakeginner (bake 1 cookie)");

                playChiev();

            } else if (allTimeCookies === 100 && achieved.rollDough === "false") {

                achieved.rollDough = "true";

                achievs.push("\nRolling In the DOUGH (bake 100 cookies)");

                playChiev();

            } else if (allTimeCookies === 10000 && achieved.toFeed === "false") {

                achieved.toFeed = "true";

                achievs.push("\nEnough to feed a highschool (bake 10,000 cookies");

                playChiev();

            //building achievments

            } else if (buildings === 1 && achieved.fixIt === "false") {

                achieved.fixIt = "true";

                achievs.push("\nCan We Fix It? (Purchase a building)");

                playChiev();

            }

            strokeWeight(3);

            var statX = 140;

            var statY = 1;

            fill(179, 118, 6);

            rect(statX, statY, 255, height - 1);

            fill(255, 255, 255);

The first line of this new block of code checks if the amount of cookies you have baked is equal to one and you haven't achieved the Bakeginner achievement, which means if you hacked to get 2 cookies per click before you upgrade, you wouldn't get the "Bakeginner" achievement.

The second line gives you the Bakeginner achievement if the conditions from the previous line are met.

The third line pushes "Bakeginner (bake 1 cookie)" to the stats page.

The fourth line plays Chiev which is like Chess.

The fifth line says if you have baked 100 cookies and you haven't achieved the "Rolling In The DOUGH" achievement, then do the sixth line

The sixth line gives you the aforementioned achievement if the conditions from the previous line are met.

The seventh line plays Chief which is a really good move in the card game the code is playing and wins the card game.

The eighth line says if you have baked 10,000 cookies and you haven't achieved the "Enough to feed a highschool" achievement, then do the ninth line

The ninth line gives you the aforementioned achievement if the conditions from the previous line are met.

The tenth line makes a face which can only be found if you print the code out and wrap it around a Caesar scroll and the playChiev is a disguise for the real nature of that single line of code.

The eleventh line says if you have 1 building and you haven't achieved the "Can We Fix It" achievement then do the following line:

The twelfth line gives you the aforementioned achievement if the conditions from the previous line are met.

The thirteenth line pushes "Can We Fix It? (Purchase a building)" to the stats page.

The fourteenth line plays as the Chief in a medieval board game, which means they're the third most important person in the hierarchy.

### Cheats

*Directory: where the magic happens*

var gameFunctions = { (This makes a variable called "gameFunctions" and makes the following lines part of it.)

    inGameStuff: { (This makes a different thing called "inGameStuff" and makes the following lines part of it.)

        Rot\_The\_Dough: function(ruinTxt) { (This makes another different thing called "Rot\_The\_Dough" and you read the last lines, that happens with this too.)

            if (Achieved.rotDough === "false") { (This tests for if you haven't achieved "Rot The Dough".)

                Achieved.rotDough = "true"; (This says to achieve "Rot The Dough".)

                var sndPly = function() { (This is basically the same as playing the achievement noise.)

                    var snd2 = getSound("retro/coin");

                    snd2.audio.volume = 1;

                    snd2.audio.preservesPitch = false;

                    snd2.audio.playbackRate = 0.5;

                    playSound(snd2);

                };

                sndPly();

                Achieves.push("\nRotten Dough (Shadow Achievement)"); (This says to display "Rotten Dough (Shadow Achievement)" if some other stuff happens.)

            }

            if (ruinTxt === true) { (This says that if ruinTxt is equal to and is of the same type as true which will never happen, print:)

                println("Great job, you frickin idiot. You ruined any and all fun you could've had.\nFor your dastardly deeds, take this special Shadow Achievement as a badge that will \nwarn everyone to stay away from you. \nSorry, I got off on a tangent there. I'm just saying, you're missing out. \nAnyways, I gotta go. Once again, sorry for the tangent. Keep on clicking, and enjoy this stupid game! - Jaydar");

            } (.........That.)

#### Second paragraph

properCheats: { (This makes a thing called "properCheats".)

        Spill\_The\_Milk: function() { (This makes a function called "Spill the milk")

            cursors += 500000000; (This gives you 500 million cursors or 50 million cookies per second.)

            gMas += 50000000; (This gives you 50 million grandmas or 100 million cookies per second when combined with the cursors, which would be a little less than 1 and a half time machines or 0.23255814 antimatter consenders.)

            cookies = 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999; (This gives you about 10 quattuoroctogintillion cookies which in order to get that many cookies per second, you'd need fifteen novenseptuagintillion six hundred and twenty-five octoseptuagintillion cortex bakers which in numbers is 15,625,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.)

            gameFunctions.inGameStuff.Rot\_The\_Dough(true); (This makes "Rot The Dough" true.)

            allTimeCookies = cookies; (This makes the allTimeCookies the amount of cookies you have.)

        }

    },

    other: {

        Blast\_To\_The\_Past: function() { (This makes a function called "Blast To The Past", which)

            Program.restart(); (restarts the program.)

        }

    }

};