Skip to content

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.

16.5 KB
Raw Blame
/* The game's facts: its plants, zombies and Adventure's 50 levels. */
#include "game.h"

/* cost in sun, recharge in ticks (7.5 s, 30 s or 50 s), health */
const PlantDef plant_defs[N_PLANTS] = {
  {"Peashooter", 100, 750, 300, 0, 0},
  {"Sunflower", 50, 750, 300, 0, 0},
  {"Cherry Bomb", 150, 5000, 300, 0, 0},
  {"Wall-nut", 50, 3000, 4000, 0, 0},
  {"Potato Mine", 25, 3000, 300, 0, 0},
  {"Snow Pea", 175, 750, 300, 0, 0},
  {"Chomper", 150, 750, 300, 0, 0},
  {"Repeater", 200, 750, 300, 0, 0},
  {"Puff-shroom", 0, 750, 300, 1, 0},
  {"Sun-shroom", 25, 750, 300, 1, 0},
  {"Fume-shroom", 75, 750, 300, 1, 0},
  {"Grave Buster", 75, 750, 300, 0, 0},
  {"Hypno-shroom", 75, 3000, 300, 1, 0},
  {"Scaredy-shroom", 25, 750, 300, 1, 0},
  {"Ice-shroom", 75, 5000, 300, 1, 0},
  {"Doom-shroom", 125, 5000, 300, 1, 0},
  {"Lily Pad", 25, 750, 300, 0, 0},
  {"Squash", 50, 3000, 300, 0, 0},
  {"Threepeater", 325, 750, 300, 0, 0},
  {"Tangle Kelp", 25, 3000, 300, 0, 0},
  {"Jalapeno", 125, 5000, 300, 0, 0},
  {"Spikeweed", 100, 750, 300, 0, 0},
  {"Torchwood", 175, 750, 300, 0, 0},
  {"Tall-nut", 125, 3000, 8000, 0, 0},
  {"Sea-shroom", 0, 3000, 300, 1, 0},
  {"Plantern", 25, 3000, 300, 0, 0},
  {"Cactus", 125, 750, 300, 0, 0},
  {"Blover", 100, 750, 300, 0, 0},
  {"Split Pea", 125, 750, 300, 0, 0},
  {"Starfruit", 125, 750, 300, 0, 0},
  {"Pumpkin", 125, 3000, 4000, 0, 0},
  {"Magnet-shroom", 100, 750, 300, 1, 0},
  {"Cabbage-pult", 100, 750, 300, 0, 0},
  {"Flower Pot", 25, 750, 300, 0, 0},
  {"Kernel-pult", 100, 750, 300, 0, 0},
  {"Coffee Bean", 75, 750, 300, 0, 0},
  {"Garlic", 50, 750, 400, 0, 0},
  {"Umbrella Leaf", 100, 750, 300, 0, 0},
  {"Marigold", 50, 3000, 300, 0, 0},
  {"Melon-pult", 300, 750, 300, 0, 0},
  {"Explode-o-nut", 0, 0, 4000, 0, 0},
};

const char *const plant_blurbs[N_SEEDS] = {
  "Peashooters are your first line of defense. They shoot peas at attacking zombies.",
  "Sunflowers are essential for you to produce extra sun. Try planting as many as you can!",
  "Cherry Bombs can blow up all zombies in an area. They have a short fuse so plant them near zombies.",
  "Wall-nuts have hard shells which you can use to protect other plants.",
  "Potato Mines pack a powerful punch, but they need a while to arm themselves. Plant them ahead of zombies: "
  "they explode on contact.",
  "Snow Peas shoot frozen peas that damage and slow the enemy.",
  "Chompers can devour a zombie whole, but they are vulnerable while chewing.",
  "Repeaters fire two peas at a time.",
  "Puff-shrooms are cheap, but can only fire a short distance.",
  "Sun-shrooms give small sun at first and normal sun later.",
  "Fume-shrooms shoot fumes that can pass through screen doors.",
  "Plant Grave Busters on graves to remove the graves.",
  "When eaten, Hypno-shrooms will make a zombie turn around and fight for you.",
  "Scaredy-shrooms are long-ranged shooters that hide when enemies get near them.",
  "Ice-shrooms temporarily immobilize all zombies on the screen.",
  "Doom-shrooms destroy everything in a large area and leave a crater that can't be planted on.",
  "Lily pads let you plant non-aquatic plants on top of them.",
  "Squashes will smash the first zombie that gets close to it.",
  "Threepeaters shoot peas in three lanes.",
  "Tangle Kelp are aquatic plants that pull the first zombie that nears them underwater.",
  "Jalapenos destroy an entire lane of zombies.",
  "Spikeweeds pop tires and hurt any zombies that step on them.",
  "Torchwoods turn peas that pass through them into fireballs that deal twice as much damage.",
  "Tall-nuts are heavy-duty wall plants that can't be jumped over.",
  "Sea-shrooms are aquatic plants that shoot short ranged spores.",
  "Planterns light up an area, letting you see through fog.",
  "Cacti shoot spikes that can pop balloons.",
  "Blovers can blow away all balloon zombies and fog.",
  "Split Peas shoot forward and backwards.",
  "Starfruits shoot stars in five directions.",
  "Pumpkins protect plants that are within their shells.",
  "Magnet-shrooms remove helmets and other metal objects from zombies.",
  "Cabbage-pults hurl cabbages at the enemy.",
  "Flower Pots let you plant on roofs.",
  "Kernel-pults fling corn kernels and butter at zombies.",
  "Plant Coffee Beans on sleeping mushrooms to wake them up.",
  "Garlic diverts zombies into other lanes.",
  "Umbrella Leaves protect nearby plants from bungees and catapults.",
  "Marigolds give you silver and gold coins.",
  "Melon-pults do heavy damage to groups of zombies.",
};

const char *const plant_stats[N_SEEDS] = {
  "Damage: normal",
  "Sun production: normal",
  "Damage: massive\nRange: all zombies in a medium area\nUsage: single use, instant",
  "Toughness: high",
  "Damage: massive\nRange: all zombies in a small area\nUsage: single use, delayed activation",
  "Damage: normal, slows zombies",
  "Damage: massive\nRange: very short\nUsage: long delay between chomps",
  "Damage: normal (for each pea)\nFiring speed: 2x",
  "Damage: normal\nRange: short\nSleeps during the day",
  "Sun production: low, then normal\nSleeps during the day",
  "Damage: normal, penetrates screen doors\nRange: all zombies in the fume cloud\nSleeps during the day",
  "Range: plant it on a grave to remove the grave\nUsage: single use, instant\nCan only be planted on graves",
  "Usage: single use, on contact\nSleeps during the day",
  "Damage: normal\nRange: long\nSleeps during the day",
  "Damage: very light, immobilizes zombies\nRange: all zombies on the screen\nUsage: single use, instant\n"
  "Sleeps during the day",
  "Damage: massive\nRange: all zombies in a large area\nUsage: single use, instant\nSleeps during the day",
  "Must be planted in water",
  "Damage: massive\nRange: short, hits all zombies it lands on\nUsage: single use",
  "Damage: normal\nRange: three lanes",
  "Damage: massive\nUsage: single use, on contact\nMust be planted in water",
  "Damage: massive\nRange: all zombies in a lane\nUsage: single use, instant",
  "Damage: normal\nRange: all zombies that walk over it\nCan't be eaten by zombies",
  "Damage: doubles the damage of peas that pass through it",
  "Toughness: very high\nCan't be jumped over",
  "Damage: normal\nRange: short\nMust be planted in water\nSleeps during the day",
  "Range: lights up a large area through the fog",
  "Damage: normal\nRange: ground and air",
  "Range: all balloon zombies, and the fog\nUsage: single use, instant",
  "Damage: normal\nRange: forward and backward\nFiring speed: 1x forward, 2x backward",
  "Damage: normal\nRange: five directions",
  "Toughness: high",
  "Range: nearby zombies\nUsage: one piece of metal at a time\nSleeps during the day",
  "Damage: normal\nRange: lobbed",
  "Must be planted on roofs",
  "Damage: light (kernel), normal (butter)\nRange: lobbed\nButter immobilizes zombies",
  "Wakes up a sleeping mushroom\nUsage: single use, instant",
  "Range: diverts zombies that bite it\nToughness: medium",
  "Range: protects the plants around it",
  "Makes coins",
  "Damage: heavy\nRange: lobbed, hits a group of zombies",
};

/* value (a wave's budget), first level, first wave, how often, and the levels it may come in (bit n: level n + 1),
 * as the game's own table */
const ZombieDef zombie_defs[N_ZOMBIES] = {
  {"Zombie", 1, 1, 1, 4000, 0x3FFFFFFFFFFFFull},
  {"Flag Zombie", 1, 1, 1, 0, 0x3FFFFFFFFFFFFull},
  {"Conehead Zombie", 2, 3, 1, 4000, 0x3FFFFFFFFFBFCull},
  {"Pole Vaulting Zombie", 2, 6, 5, 2000, 0x0020010806360ull},
  {"Buckethead Zombie", 4, 8, 1, 3000, 0x312D034A04B80ull},
  {"Newspaper Zombie", 2, 11, 1, 1000, 0x0000000A04C00ull},
  {"Screen Door Zombie", 4, 13, 5, 3500, 0x00000000D3000ull},
  {"Football Zombie", 7, 16, 5, 2000, 0x0080081298000ull},
  {"Dancing Zombie", 5, 18, 5, 1000, 0x00000000E0000ull},
  {"Backup Dancer", 1, 18, 1, 0, 0x00000000E0000ull},
  {"Ducky Tube Zombie", 1, 21, 5, 0, 0x0000000000000ull},
  {"Snorkel Zombie", 3, 23, 10, 2000, 0x0000025C00000ull},
  {"Zomboni", 7, 26, 10, 2000, 0x0000036000000ull},
  {"Zombie Bobsled Team", 3, 26, 10, 2000, 0x0000036000000ull},
  {"Dolphin Rider Zombie", 3, 28, 10, 1500, 0x0000238000000ull},
  {"Jack-in-the-Box Zombie", 3, 31, 10, 1000, 0x30090C0000000ull},
  {"Balloon Zombie", 2, 33, 10, 2000, 0x000C300000000ull},
  {"Digger Zombie", 4, 36, 10, 1000, 0x0009800000000ull},
  {"Pogo Zombie", 4, 38, 10, 1000, 0x008E000000000ull},
  {"Bungee Zombie", 3, 41, 10, 1000, 0x3430000000000ull},
  {"Ladder Zombie", 4, 43, 10, 1000, 0x35C0000000000ull},
  {"Catapult Zombie", 5, 46, 10, 1500, 0x3600000000000ull},
  {"Gargantuar", 10, 48, 15, 1500, 0x3800000000000ull},
  {"Imp", 10, 48, 1, 0, 0x3800000000000ull},
};

const char *const zombie_blurbs[N_ZOMBIES] = {
  "Regular garden-variety zombie.",
  "Flag Zombie marks the arrival of a huge pile, or \"horde,\" of zombies.",
  "His traffic cone headpiece makes him twice as tough as normal zombies.",
  "Pole Vaulting Zombie vaults with a pole.",
  "His bucket hat makes him extremely resistant to damage.",
  "His newspaper provides limited defense.",
  "His screen door is an effective shield.",
  "Football Zombie is very tough and fast.",
  "Dancing Zombie summons backup dancers.",
  "Backup Dancers are summoned by Dancing Zombie.",
  "Ducky Tube allows Zombie to float in water.",
  "Snorkel Zombie can swim underwater.",
  "Zomboni crushes plants and leaves an ice trail.",
  "Zombie Bobsled Team rides a bobsled down the Zomboni's ice.",
  "Dolphin Rider Zombies exploit your pool's weakness.",
  "This zombie carries an explosive surprise.",
  "Balloon Zombie floats above the fray, immune to most attacks.",
  "This zombie digs to bypass your defenses.",
  "Pogo Zombie hops to bypass your defenses.",
  "Bungee Zombie attacks from above.",
  "Ladder Zombie climbs over obstacles.",
  "Catapult Zombie operates heavy machinery.",
  "Gargantuar is a gigantic zombie.",
  "Imps are tiny zombies hurled by Gargantuar deep into your defenses.",
};

const char *const zombie_stats[N_ZOMBIES] = {
  "Toughness: low",
  "Toughness: low",
  "Toughness: medium",
  "Toughness: medium\nSpeed: fast, then normal (after jump)\nSpecial: jumps the first plant he runs into",
  "Toughness: medium\nWeakness: magnet-shroom",
  "Toughness: low\nNewspaper toughness: low\nSpeed: normal, then fast (after losing newspaper)",
  "Toughness: low\nScreen door toughness: high\nWeakness: fume-shrooms and magnet-shrooms",
  "Toughness: high\nSpeed: fast\nWeakness: magnet-shroom",
  "Toughness: medium\nSpecial: summons backup dancers",
  "Toughness: low",
  "Special: can only appear in the pool",
  "Toughness: low\nSpecial: swims underwater\nSpecial: can only appear in the pool",
  "Toughness: high\nSpecial: crushes plants\nSpecial: leaves an ice trail\nWeakness: spikeweed",
  "Toughness: low\nSpecial: can only appear on ice",
  "Toughness: medium\nSpeed: fast, then normal (after jump)\nSpecial: jumps the first plant he runs into\n"
  "Special: can only appear in the pool",
  "Toughness: medium\nSpeed: fast\nSpecial: jack-in-the-box explodes",
  "Toughness: medium\nSpecial: flying\nWeakness: cactus and blover",
  "Toughness: medium\nSpeed: fast, then slow\nSpecial: digs, bypassing your defenses\nSpecial: appears behind "
  "your plants\nWeakness: split pea and magnet-shroom",
  "Toughness: medium\nSpeed: fast\nSpecial: hops over the first plant he runs into\nWeakness: magnet-shroom",
  "Toughness: medium\nSpecial: steals your plants from above",
  "Toughness: medium\nSpeed: fast, then slow\nSpecial: puts a ladder on wall-nuts\nWeakness: magnet-shroom",
  "Toughness: medium\nSpecial: lobs basketballs at your plants",
  "Toughness: extremely high\nSpecial: smashes plants, throws his imp",
  "Toughness: low",
};

/* environment, mode, rows (bits), sun at the start, waves, reward, seeds (and the conveyor's weights) */
#define ALL5 0x1F
#define ALL6 0x3F
const LevelDef level_defs[N_LEVELS] = {
  /* the day */
  {ENV_DAY, MODE_LAWN, 1 << 2, 150, 4, P_SUNFLOWER, 1, {P_PEASHOOTER}, {0}},
  {ENV_DAY, MODE_LAWN, 0x0E, 50, 6, P_CHERRYBOMB, 2, {P_PEASHOOTER, P_SUNFLOWER}, {0}},
  {ENV_DAY, MODE_LAWN, 0x0E, 50, 8, P_WALLNUT, 3, {P_PEASHOOTER, P_SUNFLOWER, P_CHERRYBOMB}, {0}},
  {ENV_DAY, MODE_LAWN, ALL5, 50, 10, REWARD_SHOVEL, 4, {P_PEASHOOTER, P_SUNFLOWER, P_CHERRYBOMB, P_WALLNUT}, {0}},
  {ENV_DAY, MODE_BOWLING, ALL5, 0, 8, P_POTATOMINE, 2, {P_WALLNUT, P_EXPLODENUT}, {0}},
  {ENV_DAY, MODE_LAWN, ALL5, 50, 10, P_SNOWPEA, 5,
   {P_PEASHOOTER, P_SUNFLOWER, P_CHERRYBOMB, P_WALLNUT, P_POTATOMINE}, {0}},
  {ENV_DAY, MODE_LAWN, ALL5, 50, 20, P_CHOMPER, 6,
   {P_PEASHOOTER, P_SUNFLOWER, P_CHERRYBOMB, P_WALLNUT, P_POTATOMINE, P_SNOWPEA}, {0}},
  {ENV_DAY, MODE_LAWN, ALL5, 50, 10, P_REPEATER, 0, {0}, {0}},
  {ENV_DAY, MODE_LAWN, ALL5, 50, 20, REWARD_MONEY, 0, {0}, {0}},
  {ENV_DAY, MODE_CONVEYOR, ALL5, 0, 20, P_PUFFSHROOM, 7,
   {P_PEASHOOTER, P_CHERRYBOMB, P_WALLNUT, P_REPEATER, P_SNOWPEA, P_CHOMPER, P_POTATOMINE},
   {20, 20, 15, 20, 10, 5, 10}},
  /* the night */
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 10, P_SUNSHROOM, 0, {0}, {0}},
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 20, P_FUMESHROOM, 0, {0}, {0}},
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 10, P_GRAVEBUSTER, 0, {0}, {0}},
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 20, REWARD_ALMANAC, 0, {0}, {0}},
  {ENV_NIGHT, MODE_WHACK, ALL5, 0, 8, P_HYPNOSHROOM, 3, {P_POTATOMINE, P_GRAVEBUSTER, P_CHERRYBOMB}, {0}},
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 10, P_SCAREDYSHROOM, 0, {0}, {0}},
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 20, P_ICESHROOM, 0, {0}, {0}},
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 10, P_DOOMSHROOM, 0, {0}, {0}},
  {ENV_NIGHT, MODE_LAWN, ALL5, 50, 20, REWARD_MONEY, 0, {0}, {0}},
  {ENV_NIGHT, MODE_CONVEYOR, ALL5, 0, 20, P_LILYPAD, 7,
   {P_GRAVEBUSTER, P_ICESHROOM, P_DOOMSHROOM, P_HYPNOSHROOM, P_SCAREDYSHROOM, P_FUMESHROOM, P_PUFFSHROOM},
   {20, 15, 15, 10, 15, 15, 10}},
  /* the pool */
  {ENV_POOL, MODE_LAWN, ALL6, 50, 10, P_SQUASH, 0, {0}, {0}},
  {ENV_POOL, MODE_LAWN, ALL6, 50, 20, P_THREEPEATER, 0, {0}, {0}},
  {ENV_POOL, MODE_LAWN, ALL6, 50, 20, P_TANGLEKELP, 0, {0}, {0}},
  {ENV_POOL, MODE_LAWN, ALL6, 50, 30, REWARD_KEYS, 0, {0}, {0}},
  {ENV_POOL, MODE_CONVEYOR, ALL6, 0, 20, P_JALAPENO, 4, {P_LILYPAD, P_WALLNUT, P_PEASHOOTER, P_CHERRYBOMB},
   {25, 15, 25, 35}},
  {ENV_POOL, MODE_LAWN, ALL6, 50, 20, P_SPIKEWEED, 0, {0}, {0}},
  {ENV_POOL, MODE_LAWN, ALL6, 50, 30, P_TORCHWOOD, 0, {0}, {0}},
  {ENV_POOL, MODE_LAWN, ALL6, 50, 20, P_TALLNUT, 0, {0}, {0}},
  {ENV_POOL, MODE_LAWN, ALL6, 50, 30, REWARD_MONEY, 0, {0}, {0}},
  {ENV_POOL, MODE_CONVEYOR, ALL6, 0, 30, P_SEASHROOM, 8,
   {P_LILYPAD, P_SQUASH, P_THREEPEATER, P_TANGLEKELP, P_JALAPENO, P_SPIKEWEED, P_TORCHWOOD, P_TALLNUT},
   {25, 5, 25, 5, 10, 10, 10, 10}},
  /* the fog */
  {ENV_FOG, MODE_LAWN, ALL6, 50, 10, P_PLANTERN, 0, {0}, {0}},
  {ENV_FOG, MODE_LAWN, ALL6, 50, 20, P_CACTUS, 0, {0}, {0}},
  {ENV_FOG, MODE_LAWN, ALL6, 50, 10, P_BLOVER, 0, {0}, {0}},
  {ENV_FOG, MODE_LAWN, ALL6, 50, 20, REWARD_MONEY, 0, {0}, {0}},
  {ENV_NIGHT, MODE_VASE, ALL5, 0, 3, P_SPLITPEA, 4, {P_PEASHOOTER, P_SNOWPEA, P_SQUASH, P_HYPNOSHROOM}, {0}},
  {ENV_FOG, MODE_LAWN, ALL6, 50, 10, P_STARFRUIT, 0, {0}, {0}},
  {ENV_FOG, MODE_LAWN, ALL6, 50, 20, P_PUMPKIN, 0, {0}, {0}},
  {ENV_FOG, MODE_LAWN, ALL6, 50, 10, P_MAGNETSHROOM, 0, {0}, {0}},
  {ENV_FOG, MODE_LAWN, ALL6, 50, 20, REWARD_MONEY, 0, {0}, {0}},
  {ENV_FOG, MODE_CONVEYOR, ALL6, 0, 20, P_CABBAGEPULT, 8,
   {P_LILYPAD, P_SEASHROOM, P_MAGNETSHROOM, P_BLOVER, P_CACTUS, P_STARFRUIT, P_SPLITPEA, P_PUMPKIN},
   {25, 10, 5, 5, 15, 25, 5, 10}},
  /* the roof */
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 10, P_FLOWERPOT, 0, {0}, {0}},
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 20, P_KERNELPULT, 0, {0}, {0}},
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 20, P_COFFEEBEAN, 0, {0}, {0}},
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 30, REWARD_MONEY, 0, {0}, {0}},
  {ENV_ROOF, MODE_CONVEYOR, ALL5, 0, 20, P_GARLIC, 4, {P_FLOWERPOT, P_CHOMPER, P_PUMPKIN, P_CHERRYBOMB},
   {50, 25, 15, 10}},
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 20, P_UMBRELLA, 0, {0}, {0}},
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 30, P_MARIGOLD, 0, {0}, {0}},
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 20, P_MELONPULT, 0, {0}, {0}},
  {ENV_ROOF, MODE_LAWN, ALL5, 50, 30, REWARD_MONEY, 0, {0}, {0}},
  {ENV_ROOF, MODE_CONVEYOR, ALL5, 0, 0, REWARD_TROPHY, 6,
   {P_FLOWERPOT, P_MELONPULT, P_JALAPENO, P_CABBAGEPULT, P_KERNELPULT, P_ICESHROOM}, {55, 10, 12, 10, 5, 8}},
};

/* the graves already on the lawn at night: (column, how many) */
const uint8_t grave_columns[N_LEVELS][6][2] = {
  [10] = {{6, 1}, {7, 1}, {8, 2}},
  [11] = {{6, 1}, {7, 1}, {8, 2}},
  [12] = {{6, 1}, {7, 1}, {8, 2}},
  [13] = {{5, 1}, {6, 1}, {7, 2}, {8, 3}},
  [15] = {{5, 1}, {6, 1}, {7, 2}, {8, 3}},
  [16] = {{4, 1}, {5, 2}, {6, 2}, {7, 3}, {8, 3}},
  [17] = {{4, 1}, {5, 2}, {6, 2}, {7, 3}, {8, 3}},
  [18] = {{4, 1}, {5, 2}, {6, 2}, {7, 3}, {8, 3}},
  [19] = {{3, 1}, {4, 2}, {5, 2}, {6, 2}, {7, 3}, {8, 3}},
};