Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Cookie Clicker: the bakery, its store and golden cookies
Mason36353354d91371f
diff --git a/games/cookieclicker/.gitignore b/games/cookieclicker/.gitignorenew file mode 100644index 00000000..ea1472ec--- /dev/null+++ b/games/cookieclicker/.gitignore@@ -0,0 +1 @@+output/diff --git a/games/cookieclicker/Makefile b/games/cookieclicker/Makefilenew file mode 100644index 00000000..9047511a--- /dev/null+++ b/games/cookieclicker/Makefile@@ -0,0 +1,79 @@+# Cookie Clicker — click the big cookie, buy buildings and upgrades, catch golden cookies.+# make build output/cookieclicker.nwa+# make check link the app like the calculator does (output/cookieclicker.bin)+# make data src/data.h from tools/data.py (the names, news and pictures; needs zopfli)+#+# In NumPlay the game draws with the launcher's strips, shapes and fonts, unpacks its texts with its+# DEFLATE decoder and saves through its file functions (module.o leaves them to the launcher); on its+# own it brings them along.+Q ?= @+CC = arm-none-eabi-gcc+NWLINK ?= npx --yes -- [email protected]+BUILD_DIR = output+SRC = src/main.c+HEADERS = src/data.h ../common/epsilon_app.h ../common/epsilon_files.h ../common/np_text.h \+ ../../launcher/src/gfx.h ../../launcher/src/np.h ../../launcher/src/font.h ../../launcher/src/inflate.h++# (its numbers are doubles, written exactly: no -fsingle-precision-constant, except for the launcher's drawing)+CFLAGS = -std=c11 $(shell $(NWLINK) eadk-cflags-device)+CFLAGS += -Os -Wall -Wextra -Wno-unused-parameter -fno-math-errno+CFLAGS += -fno-tree-loop-distribute-patterns -flto -fno-fat-lto-objects -fwhole-program -fvisibility=internal+LIBFLAGS = $(CFLAGS) -fsingle-precision-constant+LDFLAGS = -Wl,--relocatable -nostartfiles --specs=nano.specs+LDFLAGS += -Wl,-e,main -Wl,-u,eadk_app_name -Wl,-u,eadk_app_icon -Wl,-u,eadk_api_level+LDFLAGS += -Wl,--gc-sections -flinker-output=nolto-rel++.PHONY: build check clean data+build: $(BUILD_DIR)/cookieclicker.nwa++check: $(BUILD_DIR)/cookieclicker.nwa+ $(Q) $(NWLINK) nwa-bin $< $(BUILD_DIR)/cookieclicker.bin+ @echo "BIN $(BUILD_DIR)/cookieclicker.bin: $$(wc -c < $(BUILD_DIR)/cookieclicker.bin) bytes"++data:+ python3 tools/data.py++# compiled, then linked (the link options would upset the compiler)+$(BUILD_DIR)/main.o: $(SRC) $(HEADERS) | $(BUILD_DIR)+ @echo "CC $<"+ $(Q) $(CC) $(CFLAGS) -c $(SRC) -o $@+$(BUILD_DIR)/gfx.o: ../../launcher/src/gfx.c $(HEADERS) | $(BUILD_DIR)+ $(Q) $(CC) $(LIBFLAGS) -c $< -o $@+$(BUILD_DIR)/font_data.o: ../../launcher/src/font_data.c ../../launcher/src/font.h | $(BUILD_DIR)+ $(Q) $(CC) $(LIBFLAGS) -c $< -o $@+$(BUILD_DIR)/xfont.o: ../../launcher/src/xfont.c ../../launcher/src/np_xfont.h $(HEADERS) | $(BUILD_DIR)+ $(Q) $(CC) $(LIBFLAGS) -c $< -o $@+$(BUILD_DIR)/inflate.o: ../../launcher/src/inflate.c ../../launcher/src/inflate.h | $(BUILD_DIR)+ $(Q) $(CC) $(LIBFLAGS) -c $< -o $@++$(BUILD_DIR)/cookieclicker.nwa: $(BUILD_DIR)/main.o $(BUILD_DIR)/gfx.o $(BUILD_DIR)/font_data.o $(BUILD_DIR)/xfont.o \+ $(BUILD_DIR)/inflate.o $(BUILD_DIR)/icon.o+ @echo "LD $@"+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $^ -lm -o $@+ $(Q) arm-none-eabi-strip --strip-unneeded $@++$(BUILD_DIR)/icon.o: src/icon.png | $(BUILD_DIR)+ @echo "ICON $<"+ $(Q) $(NWLINK) png-icon-o $< $@++$(BUILD_DIR):+ $(Q) mkdir -p $@++clean:+ $(Q) rm -rf $(BUILD_DIR)++# NumPlay launcher: the app as a module (see ../../tools/npmodule.py) for the+# calculator, and as a relocatable object for the simulator build.+.PHONY: module sim-module+module: $(BUILD_DIR)/module.o+$(BUILD_DIR)/module-main.o: $(SRC) $(HEADERS) | $(BUILD_DIR)+ $(Q) $(CC) $(CFLAGS) -DNP_MODULE=1 -c $(SRC) -o $@+$(BUILD_DIR)/module.o: $(BUILD_DIR)/module-main.o+ $(Q) $(CC) $(CFLAGS) -Wl,--relocatable -nostartfiles -nostdlib -Wl,-e,main -flinker-output=nolto-rel $< -o $@++sim-module: $(BUILD_DIR)/sim-module.o+$(BUILD_DIR)/sim-module.o: $(SRC) $(HEADERS) | $(BUILD_DIR)+ $(Q) mkdir -p $(BUILD_DIR)/sim+ $(Q) cc -std=c11 -O2 -fPIC $(shell $(NWLINK) eadk-cflags-simulator) -DNP_MODULE=1 -Dmain=np_cookieclicker_main \+ -c $(SRC) -o $(BUILD_DIR)/sim/main.o+ $(Q) ld -r $(BUILD_DIR)/sim/main.o -exported_symbol _np_cookieclicker_main -o $@diff --git a/games/cookieclicker/src/data.h b/games/cookieclicker/src/data.hnew file mode 100644index 00000000..604f62df--- /dev/null+++ b/games/cookieclicker/src/data.h@@ -0,0 +1,163 @@+/* Generated by tools/data.py: Cookie Clicker's names, news and the store's pictures. */+#define TIER_N 5+#define ACH_TIERS 1+/* the upgrades, in the order of the save */+#define N_CURSOR 10+#define U_MOUSE N_CURSOR+#define N_MOUSE 8+#define U_KITTEN (U_MOUSE + N_MOUSE)+#define N_KITTEN 3+#define U_GOLD (U_KITTEN + N_KITTEN)+#define U_GRANDMA (U_GOLD + 3)+#define U_COOKIE (U_GRANDMA + 18)+#define N_COOKIE 16+#define U_TIER (U_COOKIE + N_COOKIE)+#define N_UP (U_TIER + 19 * TIER_N)+/* the achievements, in the order of the save */+#define N_BANK 16+#define A_CPS N_BANK+#define N_CPS 12+#define A_CLICK (A_CPS + N_CPS)+#define N_CLICK 6+#define A_BUILD (A_CLICK + N_CLICK) /* the cursor's, then ACH_TIERS for each other building */+#define N_CURSOR_ACH 3+#define A_GOLDEN (A_BUILD + N_CURSOR_ACH + 19 * ACH_TIERS)+#define N_GOLDEN 4+#define A_OWNED (A_GOLDEN + N_GOLDEN)+#define A_UPGRADED (A_OWNED + 2)+#define A_MISC (A_UPGRADED + 2)+#define N_ACH (A_MISC + 5)+/* the texts: the upgrades' names, the achievements', the news, the other achievements'+ descriptions, the milks */+#define X_ACH N_UP+#define X_NEWS (X_ACH + N_ACH)+#define N_LORE 15+#define X_MDESC (X_NEWS + N_LORE)+#define X_MILK (X_MDESC + 5)+#define N_MILK 3+#define N_TEXT 245+#define TEXT_SIZE 4886+static const uint8_t cookie_up[N_COOKIE] = {33, 49, 34, 82, 67, 83, 67, 84, 69, 85, 166, 166, 86, 71, 87, 72};+enum { IC_CURSOR, IC_GRANDMA, IC_FARM, IC_MINE, IC_FACTORY, IC_BANK, IC_TEMPLE, IC_WIZARD, IC_SHIPMENT, IC_ALCHEMY, IC_PORTAL, IC_TIME, IC_ANTIMATTER, IC_PRISM, IC_CHANCE, IC_FRACTAL, IC_CONSOLE, IC_IDLEVERSE, IC_CORTEX, IC_YOU, IC_MOUSE, IC_KITTEN };+static const uint8_t icons[22][18] = {+ {1, 48, 0, 7, 240, 0, 31, 240, 3, 127, 240, 15, 31, 176, 3, 49, 0, 6},+ {240, 128, 31, 254, 103, 96, 154, 101, 102, 2, 36, 79, 4, 130, 31, 156, 227, 127},+ {96, 128, 22, 252, 35, 79, 252, 131, 22, 96, 192, 54, 248, 1, 6, 96, 240, 255},+ {252, 227, 127, 99, 28, 134, 96, 0, 6, 96, 0, 6, 96, 0, 6, 96, 0, 6},+ {6, 96, 0, 6, 96, 34, 54, 227, 59, 255, 191, 237, 219, 254, 255, 255, 255, 255},+ {96, 128, 31, 254, 247, 255, 0, 96, 219, 182, 109, 219, 182, 13, 0, 255, 255, 255},+ {96, 0, 15, 144, 128, 31, 248, 193, 63, 156, 227, 121, 254, 247, 255, 255, 15, 0},+ {192, 0, 14, 224, 1, 23, 176, 129, 63, 216, 195, 111, 252, 247, 255, 254, 7, 0},+ {96, 0, 15, 240, 128, 25, 152, 129, 31, 248, 193, 63, 254, 183, 223, 145, 8, 9},+ {240, 0, 6, 96, 0, 6, 144, 128, 16, 4, 162, 95, 253, 219, 191, 253, 235, 127},+ {248, 193, 48, 102, 54, 201, 9, 153, 144, 9, 153, 144, 147, 108, 102, 12, 131, 31},+ {255, 47, 64, 6, 198, 63, 248, 1, 15, 144, 128, 16, 100, 162, 95, 254, 247, 255},+ {96, 192, 54, 146, 164, 80, 108, 115, 239, 247, 206, 54, 10, 37, 73, 108, 3, 6},+ {96, 0, 6, 240, 0, 15, 152, 129, 25, 12, 195, 48, 6, 102, 96, 255, 255, 255},+ {156, 227, 123, 254, 199, 63, 159, 255, 240, 15, 255, 249, 252, 227, 127, 222, 199, 56},+ {96, 0, 15, 144, 128, 31, 12, 195, 57, 146, 228, 127, 3, 124, 224, 9, 249, 255},+ {255, 31, 128, 5, 152, 128, 17, 152, 128, 5, 24, 188, 1, 248, 255, 0, 0, 0},+ {240, 192, 63, 254, 231, 127, 255, 15, 0, 255, 239, 127, 254, 199, 63, 240, 0, 0},+ {216, 192, 63, 182, 247, 237, 251, 251, 246, 254, 199, 30, 96, 0, 6, 0, 0, 0},+ {240, 128, 31, 248, 129, 31, 240, 0, 0, 252, 227, 127, 255, 255, 255, 255, 15, 0},+ {240, 128, 22, 100, 66, 38, 252, 67, 32, 4, 66, 32, 4, 130, 16, 240, 0, 0},+ {1, 56, 192, 7, 254, 255, 255, 63, 207, 243, 252, 255, 159, 239, 127, 252, 3, 0},+};+static const uint8_t text_z[2298] = {+ 141, 88, 7, 147, 220, 58, 108, 214, 79, 65, 234, 171, 231, 244, 54, 221, 221, 78, 220, 207, 126, 109, 42, 68,+ 98, 87, 204, 81, 128, 30, 8, 221, 90, 249, 245, 33, 200, 209, 237, 186, 101, 226, 42, 128, 16, 58, 62, 80,+ 247, 142, 18, 31, 68, 3, 69, 72, 28, 233, 35, 28, 18, 31, 73, 135, 135, 168, 11, 102, 176, 149, 153, 50,+ 44, 74, 183, 196, 150, 132, 33, 40, 225, 60, 220, 159, 199, 84, 165, 77, 101, 45, 195, 251, 169, 254, 139, 28,+ 161, 191, 91, 134, 151, 41, 103, 151, 221, 233, 7, 159, 209, 239, 245, 51, 198, 219, 21, 227, 151, 188, 196, 246,+ 25, 239, 154, 62, 126, 206, 122, 147, 177, 88, 10, 48, 203, 90, 104, 120, 174, 194, 208, 31, 223, 39, 67, 78,+ 235, 12, 157, 188, 31, 113, 70, 182, 51, 227, 3, 203, 104, 152, 46, 68, 30, 231, 53, 158, 169, 95, 83, 153,+ 48, 103, 217, 160, 211, 79, 144, 13, 139, 17, 101, 232, 140, 255, 74, 102, 196, 48, 81, 94, 72, 203, 78, 158,+ 68, 111, 46, 72, 226, 99, 98, 114, 198, 139, 53, 220, 108, 16, 113, 171, 81, 40, 113, 76, 75, 178, 109, 120,+ 74, 6, 217, 79, 170, 126, 157, 73, 225, 168, 200, 113, 70, 79, 34, 95, 146, 191, 54, 189, 103, 250, 1, 242,+ 39, 244, 27, 77, 84, 140, 74, 185, 120, 37, 89, 152, 206, 228, 67, 41, 115, 10, 103, 250, 189, 34, 151, 121,+ 53, 138, 103, 222, 253, 108, 164, 151, 140, 167, 218, 31, 190, 187, 144, 97, 75, 119, 196, 59, 76, 60, 202, 233,+ 124, 218, 195, 60, 71, 65, 134, 103, 159, 19, 163, 110, 159, 89, 99, 52, 186, 8, 75, 49, 241, 118, 225, 116,+ 22, 62, 31, 123, 181, 19, 67, 16, 185, 73, 84, 219, 97, 61, 162, 222, 81, 175, 209, 102, 194, 12, 138, 169,+ 92, 8, 189, 33, 228, 213, 96, 92, 205, 104, 23, 246, 100, 4, 113, 246, 78, 255, 58, 37, 35, 8, 83, 101,+ 103, 119, 104, 231, 191, 196, 128, 17, 231, 132, 112, 41, 253, 72, 214, 49, 211, 85, 152, 210, 242, 77, 13, 243,+ 87, 223, 188, 159, 243, 213, 151, 86, 30, 161, 222, 156, 95, 189, 10, 130, 70, 241, 235, 154, 191, 60, 126, 28,+ 114, 90, 202, 89, 217, 31, 52, 42, 158, 115, 196, 41, 220, 144, 70, 145, 152, 157, 52, 21, 89, 78, 120, 160,+ 92, 134, 39, 162, 39, 212, 88, 224, 160, 50, 239, 73, 174, 34, 68, 249, 106, 201, 205, 136, 74, 206, 137, 143,+ 176, 36, 246, 218, 142, 154, 66, 227, 71, 98, 91, 213, 211, 171, 43, 19, 252, 247, 154, 2, 237, 105, 177, 169,+ 154, 132, 99, 198, 82, 60, 211, 19, 225, 2, 147, 80, 181, 71, 106, 41, 167, 255, 113, 124, 105, 238, 129, 41,+ 81, 109, 50, 98, 178, 20, 48, 231, 237, 106, 150, 152, 14, 233, 34, 188, 167, 109, 208, 71, 37, 140, 80, 2,+ 42, 5, 149, 211, 94, 251, 99, 107, 177, 99, 71, 143, 225, 67, 54, 61, 63, 166, 25, 251, 243, 179, 171, 81,+ 230, 17, 230, 196, 85, 85, 13, 111, 213, 152, 90, 43, 240, 45, 109, 162, 48, 82, 54, 247, 51, 229, 8, 25,+ 71, 209, 225, 250, 68, 104, 101, 146, 165, 246, 119, 131, 4, 37, 12, 38, 90, 251, 157, 66, 213, 37, 227, 154,+ 177, 209, 239, 49, 103, 82, 48, 202, 185, 1, 84, 72, 165, 136, 94, 41, 149, 84, 12, 217, 28, 47, 99, 50,+ 8, 158, 231, 225, 126, 72, 241, 106, 81, 145, 3, 220, 226, 218, 173, 158, 123, 193, 83, 252, 248, 227, 34, 236,+ 80, 139, 25, 18, 27, 41, 21, 3, 69, 243, 68, 72, 142, 196, 144, 162, 228, 106, 8, 131, 214, 60, 5, 111,+ 30, 202, 41, 36, 89, 11, 140, 153, 74, 105, 49, 174, 12, 7, 42, 150, 110, 49, 15, 143, 57, 163, 30, 41,+ 194, 130, 108, 19, 9, 15, 111, 36, 177, 121, 10, 38, 180, 58, 114, 132, 26, 179, 147, 35, 117, 47, 57, 36,+ 98, 131, 163, 166, 89, 146, 82, 3, 179, 48, 17, 67, 88, 181, 144, 71, 57, 137, 100, 144, 3, 20, 95, 29,+ 186, 13, 191, 32, 167, 156, 17, 152, 60, 51, 228, 104, 53, 79, 146, 189, 230, 74, 127, 174, 174, 237, 144, 55,+ 210, 225, 87, 212, 5, 162, 166, 91, 186, 8, 125, 22, 150, 156, 108, 234, 216, 82, 169, 109, 120, 92, 10, 113,+ 32, 183, 17, 101, 61, 78, 21, 173, 214, 139, 25, 240, 5, 164, 82, 18, 14, 247, 255, 92, 17, 130, 174, 197,+ 154, 225, 221, 119, 195, 49, 147, 13, 207, 185, 32, 19, 8, 90, 235, 226, 29, 156, 175, 101, 205, 48, 10, 199,+ 154, 71, 78, 230, 176, 204, 129, 28, 124, 152, 192, 28, 23, 151, 140, 108, 195, 147, 188, 126, 132, 128, 11, 134,+ 212, 171, 157, 102, 130, 5, 21, 163, 124, 4, 165, 34, 249, 150, 212, 183, 23, 219, 58, 131, 35, 10, 71, 93,+ 231, 186, 61, 215, 130, 217, 21, 83, 223, 174, 58, 252, 238, 232, 172, 179, 168, 202, 169, 74, 206, 174, 197, 68,+ 247, 70, 30, 165, 8, 183, 241, 116, 63, 189, 76, 53, 171, 47, 188, 110, 13, 72, 212, 55, 175, 143, 98, 36,+ 173, 48, 122, 132, 17, 217, 255, 185, 161, 218, 145, 213, 7, 31, 255, 45, 100, 49, 21, 246, 121, 154, 97, 145,+ 156, 202, 52, 252, 135, 77, 254, 162, 232, 69, 186, 115, 58, 78, 230, 200, 222, 160, 123, 120, 179, 42, 65, 232,+ 203, 161, 31, 253, 46, 171, 246, 173, 212, 167, 144, 134, 191, 172, 184, 5, 15, 200, 10, 220, 87, 130, 215, 135,+ 195, 95, 194, 140, 199, 20, 90, 215, 214, 69, 195, 236, 110, 103, 113, 140, 221, 192, 28, 114, 106, 246, 100, 213,+ 171, 76, 120, 128, 144, 165, 58, 9, 135, 68, 57, 14, 247, 65, 41, 164, 133, 96, 172, 186, 1, 71, 89, 173,+ 61, 246, 101, 225, 49, 105, 71, 94, 142, 148, 71, 149, 19, 67, 241, 28, 213, 86, 242, 33, 76, 177, 12, 175,+ 60, 153, 17, 86, 78, 45, 246, 61, 95, 47, 201, 161, 2, 202, 34, 245, 127, 8, 158, 157, 247, 19, 193, 127,+ 226, 45, 94, 7, 77, 139, 121, 137, 138, 100, 130, 131, 40, 196, 117, 158, 221, 208, 191, 254, 243, 152, 12, 80,+ 21, 55, 47, 0, 86, 236, 114, 111, 15, 185, 230, 230, 177, 143, 224, 162, 169, 80, 171, 89, 202, 84, 193, 97,+ 227, 42, 100, 41, 116, 183, 220, 209, 228, 195, 6, 209, 39, 142, 183, 102, 115, 94, 179, 117, 231, 32, 49, 180,+ 29, 80, 38, 202, 185, 47, 0, 97, 63, 74, 194, 195, 203, 179, 28, 30, 137, 173, 212, 206, 15, 184, 16, 120,+ 3, 250, 82, 231, 154, 170, 76, 17, 152, 86, 197, 12, 101, 170, 254, 101, 223, 118, 35, 109, 53, 149, 101, 209,+ 196, 149, 225, 131, 146, 84, 209, 146, 112, 235, 188, 154, 45, 97, 3, 228, 8, 163, 135, 52, 209, 156, 202, 50,+ 145, 146, 167, 175, 233, 98, 50, 31, 8, 7, 12, 95, 179, 94, 193, 91, 116, 15, 152, 244, 88, 81, 58, 186,+ 215, 154, 220, 43, 71, 77, 54, 136, 13, 224, 247, 173, 172, 228, 61, 215, 182, 67, 159, 22, 37, 186, 82, 108,+ 185, 207, 194, 190, 185, 106, 9, 186, 11, 94, 139, 151, 232, 182, 160, 200, 76, 208, 135, 250, 90, 218, 73, 4,+ 245, 190, 3, 150, 83, 29, 57, 138, 71, 87, 218, 78, 180, 198, 120, 56, 228, 6, 32, 157, 118, 104, 201, 241,+ 234, 128, 126, 9, 219, 121, 253, 106, 179, 83, 79, 49, 99, 176, 51, 253, 161, 183, 9, 230, 157, 225, 99, 236,+ 80, 185, 211, 207, 249, 144, 56, 25, 221, 209, 243, 44, 106, 103, 249, 71, 194, 223, 25, 20, 147, 5, 102, 114,+ 47, 125, 66, 32, 32, 119, 158, 51, 250, 62, 43, 128, 57, 123, 55, 194, 9, 55, 136, 114, 226, 225, 117, 53,+ 29, 165, 80, 197, 132, 178, 118, 149, 158, 240, 103, 168, 49, 136, 210, 78, 95, 27, 97, 220, 192, 176, 216, 6,+ 197, 148, 112, 238, 58, 27, 58, 22, 35, 239, 179, 82, 96, 81, 137, 107, 56, 47, 208, 91, 81, 163, 143, 59,+ 181, 172, 185, 160, 238, 84, 69, 70, 167, 94, 79, 48, 209, 246, 51, 108, 178, 126, 167, 4, 197, 82, 206, 224,+ 141, 48, 188, 32, 251, 174, 0, 59, 128, 184, 31, 222, 130, 152, 184, 118, 213, 201, 115, 12, 135, 148, 189, 243,+ 78, 201, 166, 139, 187, 8, 49, 216, 148, 60, 119, 227, 6, 83, 178, 2, 255, 244, 175, 110, 106, 191, 192, 239,+ 162, 176, 248, 130, 145, 181, 186, 147, 43, 30, 120, 100, 41, 244, 103, 180, 41, 11, 247, 103, 201, 219, 188, 164,+ 80, 58, 37, 138, 51, 246, 71, 44, 243, 157, 252, 145, 98, 220, 95, 184, 187, 124, 53, 226, 165, 172, 133, 224,+ 52, 17, 229, 253, 174, 90, 67, 218, 189, 125, 224, 93, 102, 173, 32, 7, 212, 185, 149, 237, 134, 229, 212, 56,+ 253, 114, 240, 166, 37, 212, 154, 227, 19, 38, 159, 57, 50, 219, 96, 33, 230, 173, 35, 161, 57, 234, 155, 64,+ 153, 52, 113, 221, 18, 116, 106, 235, 48, 250, 178, 166, 152, 252, 221, 187, 203, 52, 58, 229, 25, 244, 237, 7,+ 76, 167, 158, 203, 190, 57, 78, 168, 75, 91, 113, 35, 154, 87, 244, 133, 79, 209, 50, 137, 9, 183, 123, 51,+ 69, 144, 213, 134, 107, 202, 7, 199, 8, 195, 196, 213, 202, 147, 127, 248, 71, 135, 148, 237, 187, 156, 123, 173,+ 122, 8, 167, 9, 205, 243, 15, 223, 209, 60, 60, 247, 66, 142, 190, 23, 28, 213, 155, 199, 195, 203, 13, 228,+ 196, 125, 20, 247, 203, 67, 79, 140, 27, 59, 99, 251, 125, 239, 55, 185, 105, 16, 226, 160, 239, 215, 66, 91,+ 61, 208, 53, 101, 223, 55, 247, 53, 84, 59, 20, 172, 34, 195, 132, 28, 156, 181, 30, 103, 98, 143, 225, 53,+ 83, 239, 16, 247, 108, 179, 201, 155, 249, 149, 63, 247, 250, 124, 224, 128, 204, 27, 52, 170, 138, 63, 70, 205,+ 27, 140, 73, 107, 246, 92, 121, 43, 201, 129, 40, 67, 78, 213, 133, 185, 77, 195, 94, 191, 123, 240, 96, 117,+ 84, 24, 37, 110, 112, 66, 182, 226, 101, 32, 52, 239, 101, 189, 147, 234, 85, 58, 36, 45, 14, 18, 237, 155,+ 71, 200, 69, 91, 153, 77, 177, 76, 247, 192, 65, 153, 169, 194, 204, 40, 58, 137, 68, 80, 12, 65, 132, 97,+ 68, 165, 188, 129, 201, 26, 38, 42, 144, 108, 215, 135, 115, 170, 124, 60, 42, 81, 87, 166, 91, 199, 46, 57,+ 124, 97, 255, 76, 1, 42, 193, 34, 203, 154, 81, 193, 75, 241, 153, 221, 175, 72, 27, 102, 47, 125, 223, 132,+ 190, 153, 170, 225, 118, 36, 43, 127, 46, 63, 170, 231, 103, 71, 153, 81, 182, 187, 56, 55, 212, 175, 41, 63,+ 137, 218, 4, 232, 187, 217, 29, 159, 133, 105, 187, 55, 188, 33, 89, 114, 219, 105, 212, 47, 255, 94, 60, 159,+ 17, 64, 71, 46, 19, 56, 146, 1, 54, 60, 250, 50, 96, 111, 71, 165, 166, 222, 59, 113, 94, 11, 173, 115,+ 129, 72, 177, 127, 29, 128, 201, 255, 149, 161, 9, 111, 9, 70, 34, 6, 198, 217, 3, 135, 5, 181, 121, 231,+ 113, 116, 236, 57, 9, 71, 210, 111, 191, 185, 100, 12, 20, 97, 117, 41, 56, 250, 190, 102, 111, 72, 40, 171,+ 222, 82, 202, 217, 219, 244, 158, 95, 167, 250, 58, 82, 194, 246, 185, 210, 131, 221, 235, 177, 175, 46, 178, 2,+ 167, 84, 166, 189, 202, 159, 250, 254, 128, 170, 92, 127, 19, 196, 38, 82, 136, 105, 38, 246, 245, 93, 32, 227,+ 210, 86, 188, 247, 229, 199, 84, 140, 56, 248, 215, 80, 177, 255, 79, 14, 207, 23, 152, 9, 75, 75, 165, 173,+ 202, 20, 187, 190, 46, 217, 55, 229, 207, 123, 149, 103, 201, 20, 90, 111, 101, 186, 165, 124, 175, 78, 111, 150,+ 128, 217, 161, 166, 64, 233, 248, 3, 186, 114, 1, 132, 127, 248, 251, 171, 57, 241, 106, 4, 133, 218, 188, 246,+ 30, 251, 212, 17, 184, 94, 67, 160, 82, 254, 2, 190, 175, 124, 56, 181, 235, 74, 63, 252, 97, 120, 230, 9,+ 71, 131, 76, 88, 12, 254, 193, 163, 160, 214, 42, 163, 99, 67, 205, 203, 61, 223, 234, 84, 79, 230, 207, 208,+ 127, 220, 64, 56, 111, 94, 50, 79, 115, 159, 255, 8, 255, 240, 47, 14, 78, 30, 127, 3, 115, 80, 194, 156,+ 183, 159, 251, 255, 222, 129, 197, 246, 35, 132, 227, 37, 104, 65, 219, 216, 54, 33, 87, 107, 133, 130, 112, 4,+ 60, 24, 41, 36, 131, 178, 224, 137, 171, 210, 215, 39, 62, 187, 251, 111, 251, 39, 45, 216, 182, 184, 201, 246,+ 211, 3, 247, 244, 230, 124, 27, 238, 228, 59, 44, 203, 72, 170, 91, 39, 255, 23,+};diff --git a/games/cookieclicker/src/icon.png b/games/cookieclicker/src/icon.pngnew file mode 100644index 00000000..ddcb7bd3Binary files /dev/null and b/games/cookieclicker/src/icon.png differdiff --git a/games/cookieclicker/src/main.c b/games/cookieclicker/src/main.cnew file mode 100644index 00000000..f20cd2e5--- /dev/null+++ b/games/cookieclicker/src/main.c@@ -0,0 +1,661 @@+/* Cookie Clicker: Orteil's idle game, for the NumWorks calculator.+ *+ * Click the big cookie, buy buildings that bake for you, then upgrades that make them bake more,+ * and catch the golden cookies. The numbers are the game's own (version 2.05): its 20 buildings+ * with their prices and cookies per second, each one 15% dearer than the last, the tiered+ * upgrades that double a building, the cursor's thousand fingers, the mice, flavored cookies,+ * grandma types, kittens that turn milk (achievements) into cookies, golden cookies with Frenzy,+ * Lucky and Click frenzy, and ascension, which trades the bakery for prestige levels: +1%+ * cookies per second each.+ *+ * The bank is counted in doubles, as the game does; prices and rates in floats, whose 7 digits+ * are more than the game shows (1.234 million). Inside NumPlay it draws with the launcher's+ * strips, shapes and fonts and unpacks its names and news with the launcher's DEFLATE decoder;+ * on its own (CookieClicker.nwa) it brings them along. */+#include <eadk.h>+#include "../../../launcher/src/gfx.h"+#include "../../../launcher/src/inflate.h"+#include "../../common/np_text.h"++#if NP_MODULE /* (np_file_read and np_file_write: NumPlay's, launcher/src/np.h) */+#define np_app_begin()+#define np_app_end() 0+#else+#include "../../common/epsilon_app.h"+#include "../../common/epsilon_files.h"+#define np_file_read ef_read+#define np_file_write ef_write+const char eadk_app_name[] __attribute__((section(".rodata.eadk_app_name"))) = "Cookie Clicker";+const uint32_t eadk_api_level __attribute__((section(".rodata.eadk_api_level"))) = 0;+void np_push(int x, int y, int w, int h, const color_t *px) {+ eadk_display_push_rect((eadk_rect_t){(uint16_t)x, (uint16_t)y, (uint16_t)w, (uint16_t)h}, px);+}+#endif+#include "data.h"++/* the keys, in 32 bits: those from 36 on come down 23 */+#define K(k) (1u << ((k) < 32 ? (k) : (k) - 23))+static uint32_t keys(void) {+ uint64_t s = eadk_keyboard_scan();+ return ((uint32_t)s & 0x80001FFFu) | ((uint32_t)(s >> 32) & 0x1FFFF0u) << 9;+}+#define WHITE 0xFFFF+#define CREAM HEX(0xEDE3D3)+#define GOLD HEX(0xFFD966)+#define WOOD HEX(0x3A2716)+#define DARK HEX(0x24170C)+#define NB 20+#define LW 144 /* the left panel, the cookie's; the store is right of it */+#define SX (LW + 2)+#define CX 72 /* the big cookie */+#define CY 128+#define INFO 190 /* what the selected thing does */++static const char *const bname[NB] = {+ T("Cursor"), T("Grandma"), T("Farm"), T("Mine"), T("Factory"), T("Bank"), T("Temple"), T("Wizard tower"),+ T("Shipment"), T("Alchemy lab"), T("Portal"), T("Time machine"), T("Antimatter condenser"), T("Prism"),+ T("Chancemaker"), T("Fractal engine"), T("Javascript console"), T("Idleverse"), T("Cortex baker"), T("You")};+/* each building's price and cookies per second, as two digits and a power of ten */+static const int8_t bdata[NB][4] = {+ {15, 0, 10, -2}, {10, 1, 10, -1}, {11, 2, 80, -1}, {12, 3, 47, 0}, {13, 4, 26, 1}, {14, 5, 14, 2},+ {20, 6, 78, 2}, {33, 7, 44, 3}, {51, 8, 26, 4}, {75, 9, 16, 5}, {10, 11, 10, 6}, {14, 12, 65, 6},+ {17, 13, 43, 7}, {21, 14, 29, 8}, {26, 15, 21, 9}, {31, 16, 15, 10}, {71, 18, 11, 11}, {12, 21, 83, 11},+ {19, 23, 64, 12}, {54, 25, 51, 13}};+/* the upgrade tiers' colours (Plain, Berrylium, Blueberrylium...), the milks' */+static const uint32_t tier_rgb[10] = {0xCCB3AC, 0xFF89E7, 0x00DEFF, 0xFFCC2F, 0xE9D673,+ 0xA8BF91, 0x60FF50, 0xF01700, 0x9AB834, 0x7E7AB9};+static const uint32_t milk_rgb[N_MILK] = {0xF4F1EA, 0x8B5A33, 0xF06C93};++/* ------------------------------------------------------------ the bakery (cookieclicker.sav) */+static struct {+ uint8_t magic, version, flags, mode; /* flags: 1 the guide was read; mode: buy 1, 10 or 100 (0-2) */+ uint16_t amount[NB];+ uint32_t clicks, golden;+ uint32_t gc_t, frenzy, cfrenzy; /* ms since the last golden cookie; what is left of each effect */+ double cookies, earned, handmade;+ uint8_t up[(N_UP + 7) / 8], unl[(N_UP + 7) / 8], ach[(N_ACH + 7) / 8];+} sv;+#define SAVE_NAME "cookieclicker.sav"++static union { /* the inflater's tables while the texts are unpacked, the strip after */+ color_t strip[SCREEN_W * STRIP_H];+ uint8_t tables[3400];+} ram;+static char text[TEXT_SIZE], buf[160], pop[48];+static uint16_t text_at[N_TEXT];+static uint8_t list[N_UP];+static float cps, raw_cps, cpc, each[NB], milk;+static int nach, nup, owned, nlist, tab = 1, sel[3], top[3], ov, osel, toast = -1, gc_x, gc_y, news_x, news_w;+static uint32_t now, seed, toast_t, news_n, clicks_t, clicks_n, gc_life, gc_dur, pop_t, bounce_t;+static struct {+ int16_t x, y;+ uint32_t t;+ char s[32];+} rises[4];++static uint32_t rnd(void) {+ seed ^= seed << 13;+ seed ^= seed >> 17;+ return seed ^= seed << 5;+}+static bool has(const uint8_t *bits, int i) { return bits[i >> 3] >> (i & 7) & 1; }+static void set(uint8_t *bits, int i) { bits[i >> 3] |= (uint8_t)(1 << (i & 7)); }+static const char *txt(int i) { return text + text_at[i]; }+static float powi(float x, int n) {+ float r = 1;+ for (; n; n >>= 1, x *= x)+ if (n & 1) r *= x;+ return r;+}+static float p10(int e) { return e < 0 ? 1 / powi(10, -e) : powi(10, e); }+static float base_price(int b) { return bdata[b][0] * p10(bdata[b][1]); }+static int many(void) { return sv.mode == 2 ? 100 : sv.mode * 9 + 1; }+/* the price of n more buildings b: 15% more for each one owned, rounded up */+static float price(int b, int n) {+ float p = base_price(b) * powi(1.15f, sv.amount[b]);+ return __builtin_ceilf(n > 1 ? p * (powi(1.15f, n) - 1) / 0.15f : p * 0.99999f);+}++/* ------------------------------------------------------------ numbers, as the game writes them */+static const char *const units[12] = {+ T(" million"), T(" billion"), T(" trillion"), T(" quadrillion"), T(" quintillion"), T(" sextillion"),+ T(" septillion"), T(" octillion"), T(" nonillion"), T(" decillion"), T(" undecillion"), T(" duodecillion")};+static char *cpy(char *o, const char *s) {+ while ((*o = *s++)) o++;+ return o;+}+static char *num(char *o, uint32_t v) { /* with commas: 1,234,567 */+ char t[14];+ int n = 0;+ do {+ if (n % 4 == 3) t[n++] = ',';+ t[n++] = (char)('0' + v % 10);+ } while (v /= 10);+ while (n) *o++ = t[--n];+ *o = 0;+ return o;+}+/* 0.1 and 12.3 (a decimal when there is one, below 1,000), 123,456, then 1.234 million, 12.5 billion... */+static char *big(char *o, double v) {+ int u = 0;+ if (!(v > 0)) v = 0;+ if (v < 1e6) {+ uint32_t t = (uint32_t)(v * 10 + .5);+ if (v >= 1000 || t % 10 == 0) return num(o, v >= 1000 ? (uint32_t)v : t / 10);+ o = num(o, t / 10);+ *o++ = '.', *o++ = (char)('0' + t % 10), *o = 0;+ return o;+ }+ for (v /= 1e6; v >= 999.9995 && u < 11; u++) v /= 1000;+ uint32_t m = (uint32_t)(v * 1000 + .5);+ o = num(o, m / 1000);+ if ((m %= 1000)) {+ *o++ = '.';+ for (int d = 100; m; d /= 10) *o++ = (char)('0' + m / d), m %= d;+ }+ return cpy(o, units[u]);+}+static char *cat(char *o, const char *a, double v, const char *b) { return cpy(big(cpy(o, a), v), b); }++/* ------------------------------------------------------------ cookies per second */+static int bought(int from, int n) {+ int k = 0;+ while (n--) k += has(sv.up, from++);+ return k;+}+/* the cursor's thousand fingers: what each building that isn't a cursor adds to it and to a click */+static float fingers(void) {+ float add = has(sv.up, 3) ? 0.1f : 0;+ for (int t = 4; t < N_CURSOR; t++)+ if (has(sv.up, t)) add *= t == 4 ? 5 : t == 5 ? 10 : 20;+ return add * (float)(owned - sv.amount[0]);+}+static void compute(void) {+ owned = 0, nup = bought(0, N_UP), nach = 0;+ for (int b = 0; b < NB; b++) owned += sv.amount[b];+ for (int i = 0; i < N_ACH; i++) nach += has(sv.ach, i);+ milk = (float)nach / 25;+ float mult = 1, total = 0, clicks = (float)(1 << bought(0, 3)), frenzy = sv.frenzy ? 7 : 1;+ for (int i = 0; i < N_COOKIE; i++)+ if (has(sv.up, U_COOKIE + i)) mult *= 1 + (float)(cookie_up[i] >> 5) / 100;+ for (int i = 0; i < N_KITTEN; i++) /* +10%, 12.5%, 15% of the milk */+ if (has(sv.up, U_KITTEN + i)) mult *= 1 + milk * (float)(4 + i) / 40;+ for (int b = 0; b < NB; b++) {+ float c = bdata[b][2] * p10(bdata[b][3]);+ if (b == 0) c = c * clicks + fingers();+ else c *= (float)(1 << bought(U_TIER + (b - 1) * TIER_N, TIER_N));+ if (b == 1) c *= (float)(1 << bought(U_GRANDMA, 18));+ if (b > 1 && has(sv.up, U_GRANDMA + b - 2)) c *= 1 + sv.amount[1] / 100.f / (float)(b - 1);+ each[b] = c * mult * frenzy;+ total += sv.amount[b] * c;+ }+ raw_cps = total * mult, cps = raw_cps * frenzy;+ cpc = (clicks + fingers() + (float)bought(U_MOUSE, N_MOUSE) * cps / 100) * (sv.cfrenzy ? 777 : 1);+}++/* ------------------------------------------------------------ upgrades */+static const uint16_t cursor_at[10] = {1, 1, 10, 25, 50, 100, 150, 200, 250, 300};+static const uint8_t cursor_e[10] = {2, 2, 4, 5, 7, 8, 9, 10, 13, 16}, kitten_e[3] = {6, 9, 13};+static const uint8_t tier_e[TIER_N] = {1, 1, 2, 4, 6}, tier_at[TIER_N] = {1, 5, 25, 50, 100}, golden_at[3] = {7, 27, 77};++static float up_price(int u) {+ if (u < U_MOUSE) return (u == 1 ? 5 : 1) * p10(cursor_e[u]);+ if (u < U_KITTEN) return 5 * p10(4 + 2 * (u - U_MOUSE));+ if (u < U_GOLD) return 9 * p10(kitten_e[u - U_KITTEN]);+ if (u < U_GRANDMA) return 7 * (p10(9 + 2 * (u - U_GOLD) + (u == U_GOLD + 2)) - 1) / 9; /* 777,777,777... */+ if (u < U_COOKIE) return 50 * base_price(u - U_GRANDMA + 2);+ if (u < U_TIER) { /* 999,999 or 4,999,995... */+ int c = cookie_up[u - U_COOKIE];+ return (p10((c & 15) + 5) - 1) * (c & 16 ? 5 : 1);+ }+ int t = (u - U_TIER) % TIER_N; /* 10, 50, 500, 50,000... times its building's price */+ return base_price(1 + (u - U_TIER) / TIER_N) * p10(tier_e[t]) * (t ? 5 : 1);+}+static bool up_ready(int u) { /* unlocked by what the bakery has done */+ if (u < U_MOUSE) return sv.amount[0] >= cursor_at[u];+ if (u < U_KITTEN) return sv.handmade >= p10(3 + 2 * (u - U_MOUSE));+ if (u < U_GOLD) return milk >= (u == U_KITTEN ? 0.5f : (float)(u - U_KITTEN));+ if (u < U_GRANDMA) return sv.golden >= golden_at[u - U_GOLD];+ if (u < U_COOKIE) return sv.amount[u - U_GRANDMA + 2] >= 15 && sv.amount[1];+ if (u < U_TIER) return sv.earned * 20 >= up_price(u);+ return sv.amount[1 + (u - U_TIER) / TIER_N] >= tier_at[(u - U_TIER) % TIER_N];+}+static void up_desc(int u) { /* what it does, in buf */+ int b = u - U_GRANDMA + 2;+ if (u < 3) cpy(buf, T("The mouse and cursors are twice as efficient."));+ else if (u == 3) cpy(buf, T("The mouse and cursors gain +0.1 cookies for each non-cursor building owned."));+ else if (u < U_MOUSE) cat(buf, T("Multiplies the gain from Thousand fingers by "), u == 4 ? 5 : u == 5 ? 10 : 20, ".");+ else if (u < U_KITTEN) cpy(buf, T("Clicking gains +1% of your CpS."));+ else if (u < U_GOLD) cpy(buf, T("You gain more CpS the more milk you have."));+ else if (u < U_GRANDMA) cpy(buf, u < U_GOLD + 2 ? T("Golden cookies appear twice as often and stay twice as long.")+ : T("Golden cookie effects last twice as long."));+ else if (u < U_COOKIE)+ cat(cpy(cpy(buf, T("Grandmas are twice as efficient. ")), bname[b]), T(": +1% CpS per "), b - 1, T(" grandmas."));+ else if (u < U_TIER) cat(buf, T("Cookie production multiplier +"), cookie_up[u - U_COOKIE] >> 5, "%.");+ else cpy(cpy(buf, bname[1 + (u - U_TIER) / TIER_N]), T(": twice as efficient."));+}+static void sort_list(void) { /* the store's upgrades: unlocked, not bought yet, cheapest first */+ nlist = 0;+ for (int u = 0; u < N_UP; u++) {+ if (!has(sv.unl, u) || has(sv.up, u)) continue;+ int i = nlist++;+ float p = up_price(u);+ while (i && up_price(list[i - 1]) > p) list[i] = list[i - 1], i--;+ list[i] = (uint8_t)u;+ }+}++/* ------------------------------------------------------------ achievements */+/* their kind: baked, per second, from clicking, buildings, golden cookies, owned, upgrades, or one of+ their own (7); where each kind starts; the counts they ask for */+static const uint8_t kinds[7] = {A_CPS, A_CLICK, A_BUILD, A_GOLDEN, A_OWNED, A_UPGRADED, A_MISC};+static const uint16_t counts[] = {1, 2, 50, 1, 7, 27, 77, 100, 500, 20, 50};+static int threshold(int a, float *v) {+ static const uint8_t first[7] = {0, 0, 0, 0, 3, 7, 9}; /* (in counts) */+ int k = 0, i;+ while (k < 7 && a >= kinds[k]) k++;+ i = a - (k ? kinds[k - 1] : 0);+ *v = k == 0 ? (a ? p10(3 * a / 2 + 2) : 1) : k == 1 ? p10(6 * i / 5) : k == 2 ? p10(3 + 2 * i)+ : k == 3 ? counts[i < N_CURSOR_ACH ? i : 0] : k < 7 ? counts[first[k] + i] : 0;+ return k;+}+static int ach_building(int a) { return a - A_BUILD < N_CURSOR_ACH ? 0 : a - A_BUILD - N_CURSOR_ACH + 1; }+static bool ach_won(int a) {+ float v;+ int k = threshold(a, &v), least = 65535;+ switch (k) {+ case 0: return sv.earned >= v;+ case 1: return raw_cps >= v;+ case 2: return sv.handmade >= v;+ case 3: return sv.amount[ach_building(a)] >= v;+ case 4: return sv.golden >= v;+ case 5: return owned >= v;+ case 6: return nup >= v;+ }+ for (int b = 0; b < NB; b++) least = sv.amount[b] < least ? sv.amount[b] : least;+ switch (a - A_MISC) {+ case 0: return least; /* one with everything */+ case 1: return sv.earned >= 1e6 && sv.clicks <= 15; /* neverclick */+ case 4: return bought(U_GRANDMA, 18) >= 7; /* elder */+ }+ return false; /* the others are won as they happen */+}+static void win(int a) {+ if (has(sv.ach, a)) return;+ set(sv.ach, a);+ toast = a, toast_t = now;+}+static void ach_desc(int a) { /* what it takes, in buf */+ static const char *const pre[7] = {T("Bake "), T("Bake "), T("Make "), T("Have "), T("Click "), T("Own "), T("Purchase ")};+ static const char *const post[7] = {T(" cookies in one ascension."), T(" cookies per second."),+ T(" cookies from clicking."), " x ", T(" golden cookies."), T(" buildings."),+ T(" upgrades.")};+ float v;+ int k = threshold(a, &v);+ if (k > 6) cpy(buf, txt(X_MDESC + a - A_MISC));+ else cpy(cat(buf, pre[k], v, post[k]), k == 3 ? bname[ach_building(a)] : "");+}++static void check(void) { /* once a second, and after a purchase: what unlocks, what is won */+ compute();+ for (int a = 0; a < N_ACH; a++)+ if (ach_won(a)) win(a);+ compute();+ for (int u = 0; u < N_UP; u++)+ if (!has(sv.unl, u) && up_ready(u)) set(sv.unl, u), nlist = -1;+ if (nlist < 0) sort_list();+}+static void save(void) {+ sv.magic = 'C', sv.version = 1;+ np_file_write(SAVE_NAME, &sv, sizeof sv);+}++/* ------------------------------------------------------------ playing */+static void earn(double v) { sv.cookies += v, sv.earned += v; }+static void click(void) {+ int i = sv.clicks++ & 3;+ earn(cpc);+ sv.handmade += cpc, bounce_t = now;+ if (now - clicks_t > 1000) clicks_t = now, clicks_n = 0;+ if (++clicks_n >= 10) win(A_MISC + 2); /* uncanny clicker */+ rises[i].x = (int16_t)(CX - 30 + rnd() % 60), rises[i].y = (int16_t)(CY - 24 - rnd() % 24), rises[i].t = now;+ big(cpy(rises[i].s, "+"), cpc);+}+static void buy(void) {+ int s = sel[tab];+ float p = tab ? price(s, many()) : up_price(list[s]);+ if (sv.cookies < p) return;+ sv.cookies -= p;+ if (tab) sv.amount[s] = (uint16_t)(sv.amount[s] + many());+ else set(sv.up, list[s]), sort_list();+ check();+ save();+}++/* the golden cookie: once 5 to 15 minutes have gone by (half that with Lucky day, half again with+ Serendipity), it shows for 13 seconds (twice as long with each); then Frenzy or Lucky, sometimes+ Click frenzy */+static int luck(void) { return has(sv.up, U_GOLD) + has(sv.up, U_GOLD + 1); }+static void golden_pop(void) {+ uint32_t dur = has(sv.up, U_GOLD + 2) + 1, e = rnd() % 20;+ sv.golden++, sv.gc_t = 0;+ if (gc_life > gc_dur - 1000) win(A_MISC + 3); /* early bird */+ gc_life = 0;+ if (e < 2) sv.cfrenzy = 13000 * dur, cpy(pop, T("Click frenzy! x777"));+ else if (e < 11) sv.frenzy = 77000 * dur, cpy(pop, T("Frenzy! Production x7"));+ else {+ double v = sv.cookies * 0.15 < cps * 900.0 ? sv.cookies * 0.15 : cps * 900.0;+ earn(v + 13);+ cat(pop, T("Lucky! +"), v + 13, "");+ }+ pop_t = now;+ check();+ save();+}++/* ------------------------------------------------------------ drawing */+#define VIS(y, h) ((y) < gfx_y1 && (y) + (h) > gfx_y0)+static void say(const np_font_t *f, int x, int y, const char *s, color_t c) { gfx_text(f, x, y, s, c, 256); }+static void mid(const np_font_t *f, int x, int y, const char *s, color_t c) { gfx_text_center(f, x, y, s, c, 256); }+static int para(int y, const char *s, color_t c) { return gfx_paragraph(&np_font_small, SX + 87, y, 166, 12, s, c, 256); }+/* a cookie, r pixels round: golden or not */+static void cookie(int x, int y, int r, bool gold) {+ static const int8_t chips[9][3] = {{-22, -24, 9}, {14, -30, 7}, {30, -2, 9}, {-34, 6, 7}, {-8, 4, 10},+ {18, 22, 8}, {-16, 30, 8}, {2, -12, 5}, {34, 24, 5}};+ if (!VIS(y - r, 2 * r)) return;+ gfx_circle(x, y, r, gold ? HEX(0xC48A1C) : HEX(0x9C5B26), 256);+ gfx_circle(x, y, r - 1 - r / 16, gold ? HEX(0xF2C33C) : HEX(0xD9A25E), 256);+ gfx_circle(x - r / 4, y - r / 4, r / 2, WHITE, 40);+ for (int i = 0; i < 9; i++) {+ int cx = x + chips[i][0] * r / 52, cy = y + chips[i][1] * r / 52, cr = chips[i][2] * r / 52 + 1;+ gfx_circle(cx, cy, cr, gold ? HEX(0xB07A12) : HEX(0x4B2611), 256);+ gfx_circle(cx - cr / 3, cy - cr / 3, cr / 3, WHITE, 50);+ }+}++static void left(void) {+ gfx_vgrad(0, 16, LW, SCREEN_H - 16, 0x2E5480, 0x14263F);+ /* light turning slowly behind the big cookie */+ for (int y = gfx_y0; y < gfx_y1; y++)+ for (int x = 0; x < LW; x++) {+ int dx = x - CX, dy = y - CY, d = dx * dx + dy * dy, ax = dx < 0 ? -dx : dx, ay = dy < 0 ? -dy : dy;+ if (d > 74 * 74 || d < 900) continue;+ int q = ay * 256 / (ax + ay); /* an angle, 0 to 1023 around */+ q = dx < 0 ? (dy < 0 ? 512 + q : 511 - q) : (dy < 0 ? 1023 - q : q);+ color_t *p = gfx_buf + (y - gfx_y0) * SCREEN_W + x;+ if (((q + (int)(now / 12)) & 127) < 64) *p = gfx_mix(*p, WHITE, (74 * 74 - d) * 9 / (74 * 74));+ }+ uint32_t b = now - bounce_t; /* a little smaller for a moment when clicked */+ cookie(CX, CY, b < 240 ? 48 + (int)b / 60 : 52, false);+ /* the milk, which rises with the achievements and changes flavor every 25 */+ int h = 10 + (int)((milk > 1 ? 1 : milk) * 20), rank = nach / 25 < N_MILK ? nach / 25 : N_MILK - 1;+ for (int x = 0; x < LW; x++) {+ int w = (int)(now / 40 + x) % 48, top = SCREEN_H - h + (w < 24 ? w : 48 - w) / 6;+ gfx_fill(x, top, 1, h + 8, gfx_rgb(milk_rgb[rank]));+ gfx_fill(x, top, 1, 2, WHITE);+ }+ /* the cookies: "1.234 million", the number on its own line, "million cookies" under it; per second */+ if (VIS(16, 56)) {+ char *name = NULL, *line2 = buf + 80;+ big(buf, sv.cookies);+ for (char *s = buf; *s && !name; s++)+ if (*s == ' ') *s = 0, name = s + 1;+ mid(&np_font_title, CX + 1, 41, buf, 0);+ mid(&np_font_title, CX, 40, buf, WHITE);+ cpy(name ? cpy(cpy(line2, name), " ") : line2, T("cookies"));+ mid(&np_font_body, CX, 54, line2, WHITE);+ cat(buf, T("per second: "), cps, "");+ mid(&np_font_small, CX, 67, buf, CREAM);+ }+ /* the effects going on, what the golden cookie did, +1 rising from the cookie */+ for (int i = 0; i < 2; i++) {+ uint32_t ms = i ? sv.cfrenzy : sv.frenzy;+ if (ms) num(cpy(buf, i ? T("Click frenzy ") : T("Frenzy ")), (ms + 999) / 1000), say(&np_font_small, 4, 84 + 11 * i, buf, GOLD);+ }+ if (now - pop_t < 2500) mid(&np_font_small, CX, 196, pop, GOLD);+ for (int i = 0; i < 4; i++) {+ uint32_t t = now - rises[i].t;+ if (rises[i].t && t < 900)+ gfx_text_center(&np_font_body, rises[i].x, rises[i].y - (int)t / 20, rises[i].s, WHITE, 256 - (int)t * 2 / 7);+ }+ if (gc_life) { /* the golden cookie, fading in and out */+ float k = (float)gc_life / (float)gc_dur * 2 - 1;+ int a = (int)((1 - k * k * k * k) * 256);+ gfx_circle(gc_x, gc_y, 20, HEX(0xFFE680), a / 3);+ cookie(gc_x, gc_y, 14, true);+ gfx_text_center(&np_font_small, gc_x, gc_y + 26, "shift", WHITE, a);+ }+ if (toast >= 0 && now - toast_t < 3500) {+ gfx_rrect(4, 206, LW - 8, 30, 6, DARK, 230);+ mid(&np_font_small, CX, 218, T("Achievement unlocked"), HEX(0xC9B79C));+ mid(&np_font_small, CX, 231, txt(X_ACH + toast), WHITE);+ }+}++/* ------------------------------------------------------------ the store */+static void fit(const np_font_t *f, const char *s, int w) { /* s in buf, cut to w pixels */+ char *e = cpy(buf, s);+ while (gfx_text_width(f, buf) > w && e > buf + 4) cpy(--e, "...");+}+/* a picture: a building's (or a mouse, a kitten, a cookie) on its tier's colour */+static void picture(int u, int x, int y) {+ int t = u, k = IC_CURSOR;+ if (u >= U_MOUSE) t = u - U_MOUSE, k = IC_MOUSE;+ if (u >= U_KITTEN) t = u - U_KITTEN, k = IC_KITTEN;+ if (u >= U_GRANDMA) t = 1, k = IC_GRANDMA;+ if (u >= U_TIER) t = (u - U_TIER) % TIER_N, k = 1 + (u - U_TIER) / TIER_N;+ if (u < 0) t = 3, k = -1 - u; /* (a building) */+ gfx_rrect(x, y, 18, 18, 4, gfx_rgb(tier_rgb[t]), 256);+ if ((u >= U_GOLD && u < U_GRANDMA) || (u >= U_COOKIE && u < U_TIER)) cookie(x + 9, y + 9, 7, u < U_GRANDMA);+ else+ for (int i = 0; i < 144; i++)+ if (icons[k][i >> 3] >> (i & 7) & 1) gfx_fill(x + 3 + i % 12, y + 3 + i / 12, 1, 1, DARK);+}+static bool locked(int b) { return !sv.amount[b] && sv.earned < base_price(b); }+static int rows(void) {+ int n = 2;+ for (int b = 0; b < NB; b++)+ if (!locked(b)) n = b + 3; /* the next two buildings show as ??? */+ return tab == 0 ? nlist : tab == 1 ? (n < NB ? n : NB) : N_ACH;+}++static void store(void) {+ static const char *const tabs[3] = {T("Upgrades"), T("Buildings"), T("Stats")};+ gfx_fill(LW, 16, SCREEN_W - LW, SCREEN_H - 16, WOOD);+ /* the tabs; how many are bought at once, how many achievements are won */+ if (VIS(16, 30)) {+ for (int i = 0; i < 3; i++) {+ if (i == tab) gfx_rrect(SX + 1 + i * 58, 18, 56, 14, 5, HEX(0x8A6238), 256);+ mid(&np_font_small, SX + 29 + i * 58, 29, tabs[i], i == tab ? WHITE : HEX(0xB79C7C));+ }+ if (tab == 1) num(cpy(buf, T("Buy x")), (uint32_t)many());+ else if (tab == 0) cpy(num(buf, (uint32_t)nlist), T(" upgrades"));+ else cpy(num(cpy(num(buf, (uint32_t)nach), " / "), N_ACH), T(" achievements"));+ mid(&np_font_small, SX + 87, 42, buf, HEX(0x9CF29C));+ }+ /* the list */+ int n = rows(), h = tab == 2 ? 12 : 24, s = sel[tab];+ for (int r = 0; r < 144 / h && top[tab] + r < n; r++) {+ int i = top[tab] + r, y = 46 + r * h;+ if (!VIS(y, h)) continue;+ gfx_fill(SX, y, SCREEN_W - SX, h - 1, i == s ? HEX(0x6E4D2E) : tab == 2 ? WOOD : HEX(0x4C331E));+ if (tab == 2) {+ fit(&np_font_small, txt(X_ACH + i), 166);+ say(&np_font_small, SX + 4, y + 9, buf, has(sv.ach, i) ? WHITE : HEX(0x8C7A66));+ continue;+ }+ float p;+ if (tab == 1) {+ if (sv.amount[i]) num(buf, sv.amount[i]), gfx_text_right(&np_font_title, SCREEN_W - 4, y + 20, buf, WHITE, 70);+ if (!locked(i)) picture(-1 - i, SX + 3, y + 3);+ cpy(buf, locked(i) ? "???" : bname[i]);+ p = price(i, many());+ } else {+ picture(list[i], SX + 3, y + 3);+ fit(&np_font_body, txt(list[i]), SCREEN_W - SX - 30);+ p = up_price(list[i]);+ }+ say(&np_font_body, SX + 26, y + 12, buf, 0);+ say(&np_font_body, SX + 25, y + 11, buf, WHITE);+ big(buf, p);+ say(&np_font_small, SX + 25, y + 21, buf, sv.cookies >= p ? HEX(0x6CF26C) : HEX(0xFF6B6B));+ }+ /* what the selected one does */+ if (!VIS(INFO, SCREEN_H - INFO)) return;+ gfx_fill(SX, INFO, SCREEN_W - SX, SCREEN_H - INFO, DARK);+ int y = INFO + 14;+ *buf = 0;+ if (tab == 1) {+ if (locked(s)) return;+ char *o = cat(buf, T("Each makes "), each[s], T(" cookies per second."));+ o = cat(num(cpy(o, "\n"), sv.amount[s]), T(" make "), each[s] * sv.amount[s], "");+ if (cps > 0) cat(o, " (", each[s] * sv.amount[s] * 100 / cps, "%)");+ } else if (s >= n) cpy(buf, T("Upgrades show up here as your bakery grows."));+ else if (tab == 0) y = para(y, txt(list[s]), GOLD), up_desc(list[s]);+ else y = para(y, txt(X_ACH + s), GOLD), ach_desc(s);+ para(y, buf, CREAM);+}++/* ------------------------------------------------------------ the news, and the menus */+static void next_news(void) { /* how far the bakery's fame has gone: the digits of a tenth of all it baked */+ int l = 0;+ for (double e = sv.earned / 10; e >= 1 && l < N_LORE - 1; e /= 10) l++;+ news_n = (uint32_t)(X_NEWS + l);+ news_x = SCREEN_W, news_w = gfx_text_width(&np_font_small, txt(news_n));+}++enum { OV_NONE, OV_MENU, OV_HELP, OV_QUIT };+static const char *const menu_items[3] = {T("Resume"), T("How to play"), T("Quit game")};+static const char *const help_keys[12] = {+ "OK", T("click the cookie"), "shift", T("catch a golden cookie"), T("Arrows"), T("choose, change tabs"),+ "EXE", T("buy"), "x", T("buy 1, 10 or 100"), T("Back"), T("menu")};+static void button(int y, const char *s, bool on) {+ gfx_rrect(98, y, 124, 24, 12, on ? GOLD : HEX(0x6B4A2C), 256);+ mid(&np_font_body, 160, y + 17, s, on ? WOOD : WHITE);+}+static void overlay(void) {+ static const char *const titles[4] = {0, "Cookie Clicker", T("How to play"), T("Quit the game?")};+ gfx_fill_alpha(0, 0, SCREEN_W, SCREEN_H, 0, 130);+ gfx_rrect(40, 22, 240, 204, 14, WOOD, 256);+ gfx_rrect_outline(40, 22, 240, 204, 14, 2, HEX(0xC8A27A), 256);+ mid(&np_font_title, 160, 52, titles[ov], WHITE);+ if (ov == OV_HELP) {+ for (int i = 0; i < 6; i++) {+ gfx_text_right(&np_font_small, 128, 76 + 16 * i, help_keys[2 * i], GOLD, 256);+ say(&np_font_small, 136, 76 + 16 * i, help_keys[2 * i + 1], WHITE);+ }+ mid(&np_font_small, 160, 182, T("Your bakery only bakes while the game is open."), HEX(0xC9B79C));+ button(192, T("Play"), true);+ return;+ }+ int n = ov == OV_MENU ? 3 : 2;+ for (int i = 0; i < n; i++) button(196 - 32 * (n - i), ov == OV_MENU ? menu_items[i] : i ? T("No") : T("Yes"), osel == i);+ if (ov == OV_QUIT) mid(&np_font_small, 160, 96, T("Your bakery is saved."), WHITE);+}++static void scene(void *ctx) {+ if (VIS(0, 16)) { /* the news */+ gfx_fill(0, 0, SCREEN_W, 16, HEX(0x150D06));+ say(&np_font_small, news_x, 12, txt(news_n), HEX(0xE8DCC8));+ }+ left();+ store();+ if (ov) overlay();+}++/* ------------------------------------------------------------ the game */+static void load(void) {+ uint32_t len = 0;+ const uint8_t *d = np_file_read(SAVE_NAME, &len);+ uint8_t *v = (uint8_t *)&sv;+ bool ok = d && len == sizeof sv && d[0] == 'C' && d[1] == 1;+ for (uint32_t i = 0; i < sizeof sv; i++) v[i] = ok ? d[i] : 0;+ /* whatever it holds, a bakery this game could have saved */+ double *dv[3] = {&sv.cookies, &sv.earned, &sv.handmade};+ for (int i = 0; i < 3; i++)+ if (!(*dv[i] >= 0 && *dv[i] < 1e300)) *dv[i] = 0;+ if (sv.mode > 2) sv.mode = 0;+}+static void move(int d) {+ int n = rows(), shown = tab == 2 ? 12 : 6, *s = &sel[tab], *t = &top[tab];+ *s += d;+ if (*s >= n) *s = n - 1;+ if (*s < 0) *s = 0;+ if (*s < *t) *t = *s;+ if (*s >= *t + shown) *t = *s - shown + 1;+}++int main(void) {+ np_app_begin();+ /* the names and the news, unpacked once */+ if (np_inflate_tables_size() <= sizeof ram.tables)+ np_inflate((uint8_t *)text, TEXT_SIZE, text_z, sizeof text_z, (np_inflate_tables_t *)(void *)ram.tables);+ for (int i = 0, at = 0; i < N_TEXT; i++) {+ text_at[i] = (uint16_t)at;+ while (at < TEXT_SIZE - 1 && text[at]) at++;+ at++;+ }+ color_t *their_strip = gfx_buf;+ gfx_buf = ram.strip;+ now = (uint32_t)eadk_timing_millis();+ seed = eadk_random() ^ now;+ if (!seed) seed = 1;+ load();+ sort_list();+ check();+ next_news();+ if (!(sv.flags & 1)) ov = OV_HELP, sv.flags |= 1;+ uint32_t held = keys(), stale = held; /* keys still down from the launcher wait to be let go */+ uint32_t repeat_at = 0, last = now, second = now, saved = now;+ for (;;) {+ now = (uint32_t)eadk_timing_millis();+ uint32_t dt = now - last > 250 ? 250 : now - last, k = keys(), hit = k & ~held;+ const uint32_t ud = K(eadk_key_up) | K(eadk_key_down) | K(eadk_key_eight) | K(eadk_key_two);+ last = now, stale &= k;+ if (hit & ud) repeat_at = now + 300;+ else if ((k & ud & ~stale) && (int32_t)(now - repeat_at) >= 0) hit |= k & ud & ~stale, repeat_at = now + 60;+ held = k;+ if (k & (K(eadk_key_home) | K(eadk_key_on_off))) break;+ bool ok = hit & (K(eadk_key_ok) | K(eadk_key_five)), exe = hit & K(eadk_key_exe);+ int dx = !!(hit & (K(eadk_key_right) | K(eadk_key_six))) - !!(hit & (K(eadk_key_left) | K(eadk_key_four)));+ int dy = !!(hit & (K(eadk_key_down) | K(eadk_key_two))) - !!(hit & (K(eadk_key_up) | K(eadk_key_eight)));+ if (ov) {+ int n = ov == OV_MENU ? 3 : 2, was = ov, c = osel = (osel + dy + n) % n;+ if (hit & K(eadk_key_back)) ov = OV_NONE;+ else if (ok || exe) { /* (Quit game asks first, No chosen) */+ ov = was == OV_MENU && c ? OV_MENU + c : OV_NONE, osel = 1;+ if (was == OV_QUIT && !c) break;+ }+ } else {+ if (ok) click();+ if ((hit & K(eadk_key_shift)) && gc_life) golden_pop();+ if (hit & K(eadk_key_back)) ov = OV_MENU, osel = 0, save();+ if (hit & K(eadk_key_multiplication)) sv.mode = (uint8_t)((sv.mode + 1) % 3);+ tab = (tab + dx + 3) % 3;+ move(dy);+ if (exe && tab < 2 && sel[tab] < rows()) buy();+ }+ /* time goes by: baking, the golden cookie and its effects */+ earn((double)cps * dt / 1000);+ for (uint32_t *t = &sv.frenzy; t <= &sv.cfrenzy; t++)+ if (*t && !(*t = *t > dt ? *t - dt : 0)) compute();+ if (gc_life) gc_life = gc_life > dt ? gc_life - dt : 0;+ else if ((sv.gc_t += dt) >= 300000u >> luck()) {+ uint32_t lo = 300000u >> luck();+ float f = (float)(sv.gc_t - lo) / (float)(2 * lo);+ if (f > 1 || (float)(rnd() & 0xFFFF) < f * f * f * f * f * 65536)+ gc_dur = gc_life = 13000u << luck(), gc_x = 20 + (int)(rnd() % (LW - 40)), gc_y = 84 + (int)(rnd() % 100);+ }+ if (now - second >= 1000) second = now, check();+ if (now - saved >= 10000) saved = now, save();+ news_x -= (int)(dt * 45 / 1000) + 1;+ if (news_x < -news_w) next_news();+ eadk_display_wait_for_vblank();+ gfx_render(scene, 0, 0, SCREEN_H);+ uint32_t spent = (uint32_t)eadk_timing_millis() - now;+ if (spent < 30) eadk_timing_msleep(30 - spent);+ }+ save();+ gfx_buf = their_strip;+ return np_app_end();+}diff --git a/games/cookieclicker/tools/data.py b/games/cookieclicker/tools/data.pynew file mode 100644index 00000000..e470ddba--- /dev/null+++ b/games/cookieclicker/tools/data.py@@ -0,0 +1,594 @@+#!/usr/bin/env python3+"""Cookie Clicker's data for the calculator: src/data.h.++The names of the upgrades, the achievements and the news are Orteil's, as the game has them+(version 2.05). They go into one block of text packed with DEFLATE (zopfli), which the game+unpacks once when it starts (NumPlay's own decoder, launcher/src/inflate.c), so they take about+half their size in flash. The pictures of the store are 12 x 12 masks drawn below.++Usage: data.py [OUT] (src/data.h by default; needs the zopfli module)+"""+import os+import sys++import zopfli.zlib++HERE = os.path.dirname(os.path.abspath(__file__))+OUT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(HERE, "..", "src", "data.h")++TIER_N = 5 # tiered upgrades for each building (the game has 15)+ACH_TIERS = 1 # building achievements for each (have 1)++# ------------------------------------------------------------------ upgrades, in the order of the save+CURSOR = ["Reinforced index finger", "Carpal tunnel prevention cream", "Ambidextrous", "Thousand fingers"] + \+ [n + " fingers" for n in ["Million", "Billion", "Trillion", "Quadrillion", "Quintillion", "Sextillion", "Septillion",+ "Octillion", "Nonillion", "Decillion", "Undecillion"]]+MOUSE = [n + " mouse" for n in ["Plastic", "Iron", "Titanium", "Adamantium", "Unobtainium", "Eludium", "Wishalloy",+ "Fantasteel", "Nevercrack", "Armythril", "Technobsidian", "Plasmarble", "Miraculite",+ "Aetherice", "Omniplast"]]+KITTEN = ["Kitten " + n for n in ["helpers", "workers", "engineers", "overseers", "managers", "accountants"]]+GOLD = ["Lucky day", "Serendipity", "Get lucky"]+GRANDMA = ["Farmer grandmas", "Miner grandmas", "Worker grandmas", "Banker grandmas", "Priestess grandmas",+ "Witch grandmas", "Cosmic grandmas", "Transmuted grandmas", "Altered grandmas", "Grandmas' grandmas",+ "Antigrandmas", "Rainbow grandmas", "Lucky grandmas", "Metagrandmas", "Binary grandmas", "Alternate grandmas",+ "Brainy grandmas", "Clone grandmas"]+# (name, % more CpS, price: so many nines, times 5 or not)+COOKIES = [+ ("Plain cookies", 1, 6, 0), ("Sugar cookies", 1, 6, 1), ("Oatmeal raisin cookies", 1, 7, 0),+ ("Peanut butter cookies", 2, 7, 1), ("Coconut cookies", 2, 8, 0), ("White chocolate cookies", 2, 8, 1),+ ("Macadamia nut cookies", 2, 8, 0), ("Double-chip cookies", 2, 9, 1),+ ("White chocolate macadamia nut cookies", 2, 10, 0), ("All-chocolate cookies", 2, 10, 1),+ ("Dark chocolate-coated cookies", 5, 11, 0), ("White chocolate-coated cookies", 5, 11, 0),+ ("Eclipse cookies", 2, 11, 1), ("Zebra cookies", 2, 12, 0), ("Snickerdoodles", 2, 12, 1),+ ("Stroopwafels", 2, 13, 0), ("Macaroons", 2, 13, 1), ("Empire biscuits", 2, 14, 0),+ ("British tea biscuits", 2, 14, 0), ("Madeleines", 2, 14, 1), ("Palmiers", 2, 14, 1), ("Palets", 2, 15, 0),+ ("Sables", 2, 15, 0), ("Caramoas", 3, 16, 0), ("Sagalongs", 3, 16, 0), ("Shortfoils", 3, 16, 0),+ ("Win mints", 3, 16, 0), ("Gingerbread men", 2, 16, 0), ("Gingerbread trees", 2, 16, 0),+ ("Pure black chocolate cookies", 5, 16, 1), ("Pure white chocolate cookies", 5, 16, 1),+ ("Ladyfingers", 3, 17, 0), ("Tuiles", 3, 17, 1), ("Chocolate-stuffed biscuits", 3, 18, 0),+ ("Checker cookies", 3, 18, 1), ("Butter cookies", 3, 19, 0), ("Cream cookies", 3, 19, 1),+]+TIERED = { # each building's upgrades, tier 1 first+ "Grandma": ["Forwards from grandma", "Steel-plated rolling pins", "Lubricated dentures", "Prune juice",+ "Double-thick glasses", "Aging agents", "Xtreme walkers", "The Unbridling", "Reverse dementia",+ "Timeproof hair dyes"],+ "Farm": ["Cheap hoes", "Fertilizer", "Cookie trees", "Genetically-modified cookies", "Gingerbread scarecrows",+ "Pulsar sprinklers", "Fudge fungus", "Wheat triffids", "Humane pesticides", "Barnstars"],+ "Mine": ["Sugar gas", "Megadrill", "Ultradrill", "Ultimadrill", "H-bomb mining", "Coreforge", "Planetsplitters",+ "Canola oil wells", "Mole people", "Mine canaries"],+ "Factory": ["Sturdier conveyor belts", "Child labor", "Sweatshop", "Radium reactors", "Recombobulators",+ "Deep-bake process", "Cyborg workforce", "78-hour days", "Machine learning", "Brownie point system"],+ "Bank": ["Taller tellers", "Scissor-resistant credit cards", "Acid-proof vaults", "Chocolate coins",+ "Exponential interest rates", "Financial zen", "Way of the wallet", "The stuff rationale", "Edible money",+ "Grand supercycles"],+ "Temple": ["Golden idols", "Sacrifices", "Delicious blessing", "Sun festival", "Enlarged pantheon",+ "Great Baker in the sky", "Creation myth", "Theocracy", "Sick rap prayers", "Psalm-reading"],+ "Wizard tower": ["Pointier hats", "Beardlier beards", "Ancient grimoires", "Kitchen curses", "School of sorcery",+ "Dark formulas", "Cookiemancy", "Rabbit trick", "Deluxe tailored wands", "Immobile spellcasting"],+ "Shipment": ["Vanilla nebulae", "Wormholes", "Frequent flyer", "Warp drive", "Chocolate monoliths",+ "Generation ship", "Dyson sphere", "The final frontier", "Autopilot",+ "Restaurants at the end of the universe"],+ "Alchemy lab": ["Antimony", "Essence of dough", "True chocolate", "Ambrosia", "Aqua crustulae", "Origin crucible",+ "Theory of atomic fluidity", "Beige goo", "The advent of chemistry", "On second thought"],+ "Portal": ["Ancient tablet", "Insane oatling workers", "Soul bond", "Sanity dance", "Brane transplant",+ "Deity-sized portals", "End of times back-up plan", "Maddening chants", "The real world",+ "Dimensional garbage gulper"],+ "Time machine": ["Flux capacitors", "Time paradox resolver", "Quantum conundrum", "Causality enforcer",+ "Yestermorrow comparators", "Far future enactment", "Great loop hypothesis",+ "Cookietopian moments of maybe", "Second seconds", "Additional clock hands"],+ "Antimatter condenser": ["Sugar bosons", "String theory", "Large macaron collider", "Big bang bake",+ "Reverse cyclotrons", "Nanocosmics", "The Pulse",+ "Some other super-tiny fundamental particle? Probably?", "Quantum comb",+ "Baking Nobel prize"],+ "Prism": ["Gem polish", "9th color", "Chocolate light", "Grainbow", "Pure cosmic light", "Glow-in-the-dark",+ "Lux sanctorum", "Reverse shadows", "Crystal mirrors", "Reverse theory of light"],+ "Chancemaker": ["Your lucky cookie", "\"All Bets Are Off\" magic coin", "Winning lottery ticket",+ "Four-leaf clover field", "A recipe book about books", "Leprechaun village", "Improbability drive",+ "Antisuperstistronics", "Bunnypedes", "Revised probabilistics"],+ "Fractal engine": ["Metabakeries", "Mandelbrown sugar", "Fractoids", "Nested universe theory",+ "Menger sponge cake", "One particularly good-humored cow", "Chocolate ouroboros", "Nested",+ "Space-filling fibers", "Endless book of prose"],+ "Javascript console": ["The JavaScript console for dummies", "64bit arrays", "Stack overflow",+ "Enterprise compiler", "Syntactic sugar", "A nice cup of coffee", "Just-in-time baking",+ "cookies++", "Software updates", "Game.Loop"],+ "Idleverse": ["Manifest destiny", "The multiverse in a nutshell", "All-conversion", "Multiverse agents",+ "Escape plan", "Game design", "Sandbox universes", "Multiverse wars", "Mobile ports",+ "Encapsulated realities"],+ "Cortex baker": ["Principled neural shackles", "Obey", "A sprinkle of irrationality", "Front and back hemispheres",+ "Neural networking", "Cosmic brainstorms", "Megatherapy", "Synaptic lubricant", "Psychokinesis",+ "Spines"],+ "You": ["Cloning vats", "Energized nutrients", "Stunt doubles", "Clone recycling plant", "Free-range clones",+ "Genetic tailoring", "Power in diversity", "Self-betterment", "Source control", "United workforce"],+}+BUILDINGS = ["Cursor", "Grandma", "Farm", "Mine", "Factory", "Bank", "Temple", "Wizard tower", "Shipment",+ "Alchemy lab", "Portal", "Time machine", "Antimatter condenser", "Prism", "Chancemaker", "Fractal engine",+ "Javascript console", "Idleverse", "Cortex baker", "You"]+# the golden cookie's building special, for each building+SPECIAL = ["High-five", "Congregation", "Luxuriant harvest", "Ore vein", "Oiled-up", "Juicy profits",+ "Fervent adoration", "Manabloom", "Delicious lifeforms", "Breakthrough", "Righteous cataclysm",+ "Golden ages", "Extra cycles", "Solar flare", "Winning streak", "Macrocosm", "Refactoring",+ "Cosmic nursery", "Brainstorm", "Deduplication"]++# ------------------------------------------------------------------ achievements, in the order of the save+BANK = ["Wake and bake", "Making some dough", "So baked right now", "Fledgling bakery", "Affluent bakery",+ "World-famous bakery", "Cosmic bakery", "Galactic bakery", "Universal bakery", "Timeless bakery",+ "Infinite bakery", "Immortal bakery", "Don't stop me now", "You can stop now", "Cookies all the way down",+ "Overdose", "How?", "The land of milk and cookies", "He who controls the cookies controls the universe",+ "Tonight on Hoarders", "Are you gonna eat all that?", "We're gonna need a bigger bakery",+ "In the mouth of madness"]+CPS = ["Casual baking", "Hardcore baking", "Steady tasty stream", "Cookie monster", "Mass producer", "Cookie vortex",+ "Cookie pulsar", "Cookie quasar", "Oh hey, you're still here", "Let's never bake again",+ "A world filled with cookies", "When this baby hits 36 quadrillion cookies per hour", "Fast and delicious",+ "Cookiehertz : a really, really tasty hertz", "Woops, you solved world hunger", "Turbopuns", "Faster menner",+ "And yet you're still hungry", "The Abakening"]+CLICK = ["Clicktastic", "Clickathlon", "Clickolympics", "Clickorama", "Clickasmic", "Clickageddon", "Clicknarok",+ "Clickastrophe", "Clickataclysm", "The ultimate clickdown"]+CURSOR_ACH = ["Click", "Double-click", "Mouse wheel", "Of Mice and Men", "The Digital"]+BUILDING_ACH = {+ "Grandma": ["Grandma's cookies", "Sloppy kisses", "Retirement home"],+ "Farm": ["Bought the farm", "Reap what you sow", "Farm ill"],+ "Mine": ["You know the drill", "Excavation site", "Hollow the planet"],+ "Factory": ["Production chain", "Industrial revolution", "Global warming"],+ "Bank": ["Pretty penny", "Fit the bill", "A loan in the dark"],+ "Temple": ["Your time to shrine", "Shady sect", "New-age cult"],+ "Wizard tower": ["Bewitched", "The sorcerer's apprentice", "Charms and enchantments"],+ "Shipment": ["Expedition", "Galactic highway", "Far far away"],+ "Alchemy lab": ["Transmutation", "Transmogrification", "Gold member"],+ "Portal": ["A whole new world", "Now you're thinking", "Dimensional shift"],+ "Time machine": ["Time warp", "Alternate timeline", "Rewriting history"],+ "Antimatter condenser": ["Antibatter", "Quirky quarks", "It does matter!"],+ "Prism": ["Lone photon", "Dazzling glimmer", "Blinding flash"],+ "Chancemaker": ["Lucked out", "What are the odds", "Grandma needs a new pair of shoes"],+ "Fractal engine": ["Self-contained", "Threw you for a loop", "The sum of its parts"],+ "Javascript console": ["F12", "Variable success", "No comments"],+ "Idleverse": ["They'll never know what hit 'em", "Well-versed", "Ripe for the picking"],+ "Cortex baker": ["It's big brain time", "Just my imagination", "Now there's an idea"],+ "You": ["My own clone", "Multiplicity", "Born for this job"],+}+GOLDEN = ["Golden cookie", "Lucky cookie", "A stroke of luck", "Fortune", "Leprechaun", "Black cat's paw"]+OWNED = ["Builder", "Architect", "Engineer", "Lord of Constructs"]+UPGRADED = ["Enhancer", "Augmenter", "Upgrader", "Lord of Progress"]+# (their conditions are in the game, in this order)+MISC = ["One with everything", "Centennial", "Just wrong", "Neverclick", "True Neverclick", "Uncanny clicker",+ "Early bird", "Fading luck", "Elder", "Rebirth", "Sacrifice", "Oblivion", "From scratch", "You win a cookie"]+MISC_DESC = ["Have at least 1 of every building.", "Have at least 100 of everything.", "Sell a grandma.",+ "Make 1 million cookies by only having clicked 15 times.",+ "Make 1 million cookies with no cookie clicks.", "Click really, really fast.",+ "Click a golden cookie less than 1 second after it spawns.",+ "Click a golden cookie less than 1 second before it dies.", "Own at least 7 grandma types.",+ "Ascend at least once.", "Ascend with 1 million cookies baked.", "Ascend with 1 billion cookies baked.",+ "Ascend with 1 trillion cookies baked.",+ "This is for baking 100 trillion cookies and making it on the local news."]+MILK = ["Plain milk", "Chocolate milk", "Raspberry milk", "Orange milk", "Caramel milk", "Banana milk", "Lime milk"]++# ------------------------------------------------------------------ the news+LORE = [ # as the bakery grows: two for each power of ten from 1,000 cookies on+ "You feel like making cookies. But nobody wants to eat your cookies.",+ "Your first batch goes to the trash. The neighborhood raccoon barely touches it.",+ "Your family agrees to try some of your cookies.",+ "Your cookies are popular in the neighborhood.", "People are starting to talk about your cookies.",+ "Your cookies are talked about for miles around.", "Your cookies are renowned in the whole town!",+ "Your cookies bring all the boys to the yard.", "Your cookies now have their own website!",+ "Your cookies are worth a lot of money.", "Your cookies sell very well in distant countries.",+ "People come from very far away to get a taste of your cookies.",+ "Kings and queens from all over the world are enjoying your cookies.",+ "There are now museums dedicated to your cookies.", "A national day has been created in honor of your cookies.",+ "Your cookies have been named a part of the world wonders.",+ "History books now include a whole chapter about your cookies.",+ "Your cookies have been placed under government surveillance.", "The whole planet is enjoying your cookies!",+ "Strange creatures from neighboring planets wish to try your cookies.",+ "Elder gods from the whole cosmos have awoken to taste your cookies.",+ "Beings from other dimensions lapse into existence just to get a taste of your cookies.",+ "Your cookies have achieved sentience.", "The universe has now turned into cookie dough, to the molecular level.",+ "Your cookies are rewriting the fundamental laws of the universe.",+ "A local news station runs a 10-minute segment about your cookies. Success! (you win a cookie)",+ "it's time to stop playing",+]+GRANNY = ["\"Moist cookies.\" - grandma", "\"We're nice grandmas.\" - grandma", "\"Indentured servitude.\" - grandma",+ "\"Come give grandma a kiss.\" - grandma", "\"Why don't you visit more often?\" - grandma",+ "\"Call me...\" - grandma"]+BUILDING_NEWS = { # one for each building from the farm on+ "Farm": "News : cookie farms suspected of employing undeclared elderly workforce!",+ "Mine": "News : chocolate mines found to cause earthquakes and sinkholes!",+ "Factory": "News : cookie factories linked to global warming!",+ "Bank": "News : cookie loans on the rise as people can no longer afford them with regular money.",+ "Temple": "News : theists of the world discover new cookie religion - \"Oh boy, guess we were wrong all along!\"",+ "Wizard tower": "News : get your new charms and curses at the yearly National Spellcrafting Fair! Exclusive prices "+ "on runes and spellbooks.",+ "Shipment": "News : new chocolate planet found, becomes target of cookie-trading spaceships!",+ "Alchemy lab": "News : national gold reserves dwindle as more and more of the precious mineral is turned to "+ "cookies!",+ "Portal": "News : nation worried as more and more unsettling creatures emerge from dimensional portals!",+ "Time machine": "News : time machines involved in history-rewriting scandal! Or are they?",+ "Antimatter condenser": "News : first antimatter condenser successfully turned on, doesn't rip apart reality!",+ "Prism": "News : cookies now being baked at the literal speed of light thanks to new prismatic contraptions.",+ "Chancemaker": "News : strange statistical anomalies continue as weather forecast proves accurate an "+ "unprecedented 3 days in a row!",+ "Fractal engine": "News : local man sails around the world to find himself - right where he left it.",+ "Javascript console": "News : nation holds breath as nested ifs about to hatch.",+ "Idleverse": "News : is another you living out their dreams in an alternate universe? Probably, you lazy bum!",+ "Cortex baker": "News : are you smarter than a cortex baker? New game show deemed \"unfair\" by contestants.",+ "You": "News : the person of the year is, this year again, you! How unexpected!",+}+MISC_NEWS = [ # once the bakery has made 10,000 cookies+ "News : man robs bank, buys cookies.",+ "News : doctors recommend twice-daily consumption of fresh cookies.",+ "News : \"all-you-can-eat\" cookie restaurant opens in big city; waiters trampled in minutes.",+ "News : cookie shortage strikes town, people forced to eat cupcakes; \"just not the same\", concedes mayor.",+ "News : \"Ook\", says interviewed orangutan.",+ "News : new cookie-based religion sweeps the nation.",+ "News : what do golden cookies taste like? Study reveals a flavor \"somewhere between spearmint and liquorice\".",+ "News : 97-year-old baker still makes cookies the old-fashioned way!",+]+KITTEN_NEWS = "News : faint meowing heard around local cookie facilities; suggests new ingredient being tested."++# ------------------------------------------------------------------ the store's pictures, 12 x 12+ICONS = {+ "cursor": """+X...........+XX..........+XXX.........+XXXX........+XXXXX.......+XXXXXX......+XXXXXXX.....+XXXXXXXX....+XXXXX.......+XX.XXX......+X...XX......+.....XX.....""",+ "grandma": """+....XXXX....+...XXXXXX...+.XXXXXXXXXX.+.XX......XX.+.X.XX..XX.X.+.XX..XX..XX.+.X........X.+.X..XXXX..X.+..X......X..+...XXXXXX...+..XXX..XXX..+.XXXXXXXXXX.""",+ "farm": """+.....XX.....+...X.XX.X...+..XXXXXXXX..+.X..XXXX..X.+..XXXXXXXX..+...X.XX.X...+.....XX.....+..XX.XX.XX..+...XXXXXX...+.....XX.....+.....XX.....+XXXXXXXXXXXX""",+ "mine": """+..XXXXXXXX..+.XXXXXXXXXX.+XX...XX...XX+X....XX....X+.....XX.....+.....XX.....+.....XX.....+.....XX.....+.....XX.....+.....XX.....+.....XX.....+.....XX.....""",+ "factory": """+.XX.........+.XX.........+.XX.........+.XX..X...X..+.XX.XX..XX..+.XXXXX.XXX..+XXXXXXXXXXXX+XX.XX.XX.XXX+XX.XX.XX.XXX+XXXXXXXXXXXX+XXXXXXXXXXXX+XXXXXXXXXXXX""",+ "bank": """+.....XX.....+...XXXXXX...+.XXXXXXXXXX.+XXXXXXXXXXXX+............+.XX.XX.XX.XX+.XX.XX.XX.XX+.XX.XX.XX.XX+.XX.XX.XX.XX+............+XXXXXXXXXXXX+XXXXXXXXXXXX""",+ "temple": """+.....XX.....+....XXXX....+....X..X....+...XXXXXX...+...XXXXXX...+..XXXXXXXX..+..XXX..XXX..+.XXXX..XXXX.+.XXXXXXXXXX.+XXXXXXXXXXXX+XXXXXXXXXXXX+............""",+ "wizard": """+......XX....+.....XXX....+.....XXXX...+....XXX.X...+....XX.XX...+...XXXXXXX..+...XX.XXXX..+..XXXXXX.XX.+..XXXXXXXXX.+XXXXXXXXXXXX+.XXXXXXXXXX.+............""",+ "shipment": """+.....XX.....+....XXXX....+....XXXX....+...XX..XX...+...XX..XX...+...XXXXXX...+...XXXXXX...+..XXXXXXXX..+.XXXXXXXXXX.+XX.XXXXXX.XX+X...X..X...X+....X..X....""",+ "alchemy": """+....XXXX....+.....XX.....+.....XX.....+.....XX.....+....X..X....+...X....X...+..X......X..+.X.XXXXXX.X.+X.XXXXXXXX.X+X.XXXXXXXX.X+X.XXXXXXXX.X+.XXXXXXXXXX.""",+ "portal": """+...XXXXXX...+..XX....XX..+.XX..XX..XX.+XX..X..X..XX+X..X....X..X+X..X....X..X+X..X....X..X+X..X....X..X+XX..X..X..XX+.XX..XX..XX.+..XX....XX..+...XXXXXX...""",+ "time": """+XXXXXXXXXXXX+.X........X.+.XX......XX.+..XXXXXXXX..+...XXXXXX...+....XXXX....+....X..X....+...X....X...+..X..XX..X..+.X.XXXXXX.X.+.XXXXXXXXXX.+XXXXXXXXXXXX""",+ "antimatter": """+.....XX.....+..XX.XX.XX..+.X..X..X..X.+.X.X....X.X.+..XX.XX.XX..+XXX.XXXX.XXX+XXX.XXXX.XXX+..XX.XX.XX..+.X.X....X.X.+.X..X..X..X.+..XX.XX.XX..+.....XX.....""",+ "prism": """+.....XX.....+.....XX.....+....XXXX....+....XXXX....+...XX..XX...+...XX..XX...+..XX....XX..+..XX....XX..+.XX......XX.+.XX......XX.+XXXXXXXXXXXX+XXXXXXXXXXXX""",+ "chance": """+..XXX..XXX..+.XXXXX.XXXX.+.XXXXXXXXXX.+..XXXXXXXX..+XXXXX..XXXXX+XXXX....XXXX+XXXX....XXXX+XXXXX..XXXXX+..XXXXXXXX..+.XXXXXXXXXX.+.XXXX.XXXXX.+..XX...XXX..""",+ "fractal": """+.....XX.....+....XXXX....+....X..X....+...XXXXXX...+..XX....XX..+..XXX..XXX..+.X..X..X..X.+.XXXXXXXXXX.+XX........XX+XXX......XXX+X..X....X..X+XXXXXXXXXXXX""",+ "console": """+XXXXXXXXXXXX+X..........X+X.X........X+X..X.......X+X...X......X+X..X.......X+X.X........X+X.....XXXX.X+X..........X+XXXXXXXXXXXX+............+............""",+ "idleverse": """+....XXXX....+..XXXXXXXX..+.XXXXXXXXXX.+.XXXXXXXXXX.+XXXXXXXXXXXX+............+XXXXXXXXXXXX+.XXXXXXXXXX.+.XXXXXXXXXX.+..XXXXXXXX..+....XXXX....+............""",+ "cortex": """+...XX.XX....+..XXXXXXXX..+.XX.XX.XXXX.+XXXXX.XX.XXX+XX.XXXXXXX.X+XXXX.XX.XXXX+.XXXXXXXXXX.+..XX.XXXX...+.....XX.....+.....XX.....+............+............""",+ "you": """+....XXXX....+...XXXXXX...+...XXXXXX...+...XXXXXX...+....XXXX....+............+..XXXXXXXX..+.XXXXXXXXXX.+XXXXXXXXXXXX+XXXXXXXXXXXX+XXXXXXXXXXXX+............""",+ "mouse": """+....XXXX....+...X.XX.X...+..X..XX..X..+..X..XX..X..+..XXXXXXXX..+..X......X..+..X......X..+..X......X..+..X......X..+...X....X...+....XXXX....+............""",+ "kitten": """+X..........X+XX........XX+XXX......XXX+XXXXXXXXXXXX+XXXXXXXXXXXX+XX..XXXX..XX+XX..XXXX..XX+XXXXXXXXXXXX+XXXXX..XXXXX+.XXXXXXXXXX.+..XXXXXXXX..+............""",+}+++def icon_bytes(art):+ rows = art.strip().split("\n")+ assert len(rows) == 12 and all(len(r) == 12 for r in rows), art+ bits = [c == "X" for r in rows for c in r]+ out = []+ for i in range(0, 144, 8): # lowest bit first+ out.append(sum(1 << k for k in range(8) if bits[i + k]))+ return out+++# How much of the game fits in NumPlay (13 KB): the upgrades, achievements and news that come first, so+# far that milk (an achievement is 4%) takes the kittens to the engineers+N = dict(cursor=10, mouse=8, kitten=3, cookie=16, bank=16, cps=12, click=6, cursor_ach=3, golden=4, owned=2,+ upgraded=2, milk=3)+MISC_KEPT = [0, 3, 5, 6, 8] # one with everything, neverclick, uncanny clicker, early bird, elder+++def main():+ order = [b for b in BUILDINGS[1:]]+ cookies = COOKIES[:N["cookie"]]+ misc = [MISC[i] for i in MISC_KEPT]+ ups = CURSOR[:N["cursor"]] + MOUSE[:N["mouse"]] + KITTEN[:N["kitten"]] + GOLD + GRANDMA + [c[0] for c in cookies]+ for b in order:+ ups += TIERED[b][:TIER_N]+ achs = BANK[:N["bank"]] + CPS[:N["cps"]] + CLICK[:N["click"]] + CURSOR_ACH[:N["cursor_ach"]]+ for b in order:+ achs += BUILDING_ACH[b][:ACH_TIERS]+ achs += GOLDEN[:N["golden"]] + OWNED[:N["owned"]] + UPGRADED[:N["upgraded"]] + misc+ news = [LORE[i] for i in [0, 1, 2] + list(range(3, 27, 2))] # a line for each power of ten+ assert len(MISC_DESC) == len(MISC)+ strings = ups + achs + news + [MISC_DESC[i] for i in MISC_KEPT] + MILK[:N["milk"]]+ text = "\0".join(strings).encode("ascii") + b"\0"+ z = zopfli.zlib.compress(text, numiterations=100)[2:-4]+ raw = len(text)+ L = ["/* Generated by tools/data.py: Cookie Clicker's names, news and the store's pictures. */",+ "#define TIER_N %d" % TIER_N, "#define ACH_TIERS %d" % ACH_TIERS,+ "/* the upgrades, in the order of the save */",+ "#define N_CURSOR %d" % N["cursor"], "#define U_MOUSE N_CURSOR", "#define N_MOUSE %d" % N["mouse"],+ "#define U_KITTEN (U_MOUSE + N_MOUSE)", "#define N_KITTEN %d" % N["kitten"],+ "#define U_GOLD (U_KITTEN + N_KITTEN)", "#define U_GRANDMA (U_GOLD + 3)",+ "#define U_COOKIE (U_GRANDMA + 18)", "#define N_COOKIE %d" % len(cookies),+ "#define U_TIER (U_COOKIE + N_COOKIE)", "#define N_UP (U_TIER + 19 * TIER_N)",+ "/* the achievements, in the order of the save */",+ "#define N_BANK %d" % N["bank"], "#define A_CPS N_BANK", "#define N_CPS %d" % N["cps"],+ "#define A_CLICK (A_CPS + N_CPS)", "#define N_CLICK %d" % N["click"],+ "#define A_BUILD (A_CLICK + N_CLICK) /* the cursor's, then ACH_TIERS for each other building */",+ "#define N_CURSOR_ACH %d" % N["cursor_ach"],+ "#define A_GOLDEN (A_BUILD + N_CURSOR_ACH + 19 * ACH_TIERS)", "#define N_GOLDEN %d" % N["golden"],+ "#define A_OWNED (A_GOLDEN + N_GOLDEN)", "#define A_UPGRADED (A_OWNED + %d)" % N["owned"],+ "#define A_MISC (A_UPGRADED + %d)" % N["upgraded"], "#define N_ACH (A_MISC + %d)" % len(misc),+ "/* the texts: the upgrades' names, the achievements', the news, the other achievements'",+ " descriptions, the milks */",+ "#define X_ACH N_UP", "#define X_NEWS (X_ACH + N_ACH)",+ "#define N_LORE 15",+ "#define X_MDESC (X_NEWS + N_LORE)", "#define X_MILK (X_MDESC + %d)" % len(misc),+ "#define N_MILK %d" % N["milk"], "#define N_TEXT %d" % len(strings), "#define TEXT_SIZE %d" % raw]+ COOKIES[:] = cookies+ # a cookie upgrade: its % in the top 3 bits, then 5 if it is so many nines times 5, then the nines+ L.append("static const uint8_t cookie_up[N_COOKIE] = {%s};" %+ ", ".join(str(p << 5 | x5 << 4 | (n - 5)) for _, p, n, x5 in COOKIES))+ assert all(1 <= p <= 7 and 5 <= n < 21 for _, p, n, _ in COOKIES)+ names = list(ICONS)+ L.append("enum { %s };" % ", ".join("IC_" + n.upper() for n in names))+ data = [b for n in names for b in icon_bytes(ICONS[n])]+ L.append("static const uint8_t icons[%d][18] = {" % len(names))+ for i in range(len(names)):+ L.append(" {%s}," % ", ".join(str(b) for b in data[18 * i:18 * i + 18]))+ L.append("};")+ L.append("static const uint8_t text_z[%d] = {" % len(z))+ for i in range(0, len(z), 24):+ L.append(" " + ", ".join(str(b) for b in z[i:i + 24]) + ",")+ L.append("};")+ open(OUT, "w").write("\n".join(L) + "\n")+ print(f"data.h: {len(ups)} upgrades, {len(achs)} achievements, {len(news)} news; "+ f"text {raw} bytes, packed {len(z)}; icons {len(data)} bytes")+++if __name__ == "__main__":+ main()diff --git a/games/cookieclicker/tools/icon.py b/games/cookieclicker/tools/icon.pynew file mode 100644index 00000000..e3badbcd--- /dev/null+++ b/games/cookieclicker/tools/icon.py@@ -0,0 +1,30 @@+#!/usr/bin/env python3+"""src/icon.png: the big cookie on Cookie Clicker's blue, as the calculator's home screen shows apps."""+import os++from PIL import Image, ImageDraw++S = 8 # drawn 8 times larger, then scaled down smoothly+W, H = 55, 56+img = Image.new("RGBA", (W * S, H * S), (0, 0, 0, 0))+d = ImageDraw.Draw(img)+d.rounded_rectangle([0, 0, W * S - 1, H * S - 1], radius=12 * S, fill=(38, 74, 116, 255))+d.rounded_rectangle([0, 0, W * S - 1, H * S // 2], radius=12 * S, fill=(52, 96, 146, 255))+d.rectangle([0, H * S // 4, W * S - 1, H * S // 2], fill=(52, 96, 146, 255))+cx, cy, r = 27.5 * S, 28 * S, 22 * S+++def disc(x, y, rr, fill):+ d.ellipse([x - rr, y - rr, x + rr, y + rr], fill=fill)+++disc(cx, cy + 1.5 * S, r, (60, 32, 12, 120)) # its shadow+disc(cx, cy, r, (156, 91, 38, 255))+disc(cx - 0.5 * S, cy - 0.5 * S, r - 1.6 * S, (217, 162, 94, 255))+disc(cx - 5 * S, cy - 5 * S, r * 0.5, (232, 186, 124, 255))+for x, y, rr in [(-10, -11, 4.2), (6, -14, 3.2), (14, -1, 4.2), (-15, 3, 3.2), (-3, 2, 4.6), (8, 10, 3.6),+ (-7, 13, 3.6), (1, -6, 2.4)]:+ disc(cx + x * S, cy + y * S, rr * S, (75, 38, 17, 255))+ disc(cx + (x - rr / 3) * S, cy + (y - rr / 3) * S, rr * S / 3, (120, 72, 40, 255))+img = img.resize((W, H), Image.LANCZOS)+img.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "src", "icon.png"))