better bictcle

better bictcle // Here’s an example of how you could use a simple story template (story 7952, or see the “Better bicycle” link above) and turn it into a more complicated game.

VAR frame = 0 VAR wheels = 0 VAR accessories = 0

VAR money = 300 VAR payment = 0 VAR speed = 0 VAR style = 0

You’re banging around in the garage, and find an old bicycle. It’s not much to look at yet, but you can tell it has potential. -> describe -> choose_upgrade

=== choose_upgrade === You have ${money}. What do you want to upgrade on your bike?

  • {money >= upgrade_cost(frame)} [The frame (${upgrade_cost(frame)})]   ~ money -= upgrade_cost(frame)   ~ frame += 1   You decide to put some money into the frame.   -> describe -> choose_upgrade
  • {money >= upgrade_cost(wheels)} [The wheels (${upgrade_cost(wheels)})]   ~ money -= upgrade_cost(wheels)   ~ wheels += 1   You could use a new set of wheels.   -> describe -> choose_upgrade
  • {money >= upgrade_cost(accessories)} [The accessories (${upgrade_cost(accessories)})]   ~ money -= upgrade_cost(accessories)   ~ accessories += 1   You know what this bike needs? Accessories!   -> describe -> choose_upgrade
  • No upgrades right now. I want to earn some money!   -> earn_money

// This knot just tunnels into descriptions of all the parts of the bike. === describe === -> describe_frame -> describe_wheels -> describe_accessories ->->

=== describe_frame === {   - frame == 0:     The bike’s frame is rusty and all dinged up. Nobody would steal this hunk of junk.   - frame == 1:     The bike has a steel tube frame, kind of a weird lime green color. It definitely says “1980’s”, but at least it’s in good shape.   - frame == 2:     The bike’s frame is modern aluminum, with nice smooth welds at all the joints. It’s a bright silver color. Nothing fancy, but this is a nice bike.   - else:     The bike has a sleek carbon fiber frame with smooth curves at all the joints. It’s painted in yellow streaks with plenty of glistening epoxy that shows off the woven carbon fiber. It’s incredibly light. } ->->

=== describe_wheels === <> {   - wheels == 0:     The wheels both have broken spokes, so that they wobble constantly. You can never get up much speed because they hit the brakes every time they go around.   - wheels == 1:      The wheels are old and clunky, with threadbare tires, but at least they’re true. Unfortunately, the tires are pretty leaky so you have to pump them up every couple of days.   - wheels == 2:     The wheels are sparkling, high-quality, light, and new. You also have nice fast rubber tires on them.   - else:     The wheels are really fancy, with flattened aerodynamic spokes. They’re made from fancy aluminum, and you have the fastest racing tires on them. } ->->

=== describe_accessories === <> {   - accessories == 0:     The accessories are all old and broken–an ancient kickstand that doesn’t work, and a rack that’s broken and missing a screw so it leans to the side if you put anything on it. The handlebars are also so wobbly that it’s hard to steer.   - accessories == 1:     The bike has some basic accessories. There’s a good solid rack on the back that you can use to carry stuff.   - accessories == 2:     The bike has a few nice touches. The handlebars have soft spongy tape on them to make your hands more comfortable. You also have lights on the wheels that flash in a star pattern when you’re riding.   - else:     The bike has all the latest technology. Integrated shifters, lights, even a bicycle computer that shows you a map and tracks your routes and stats. } ->->

=== earn_money === You have ${money}. What do you want to do?

  • [Bicycle messenger]   -> messenger
  • {money >= 60} Enter a bike race (Entry fee: $60)   -> bike_race
  • Actually, I want to upgrade my bike   -> choose_upgrade === messenger === ~ payment = random_integer(10, 40) ~ money += payment You spend the afternoon as a bicycle messenger. You deliver {groceries|three live rabbits|an important document|a framed photograph} to {a mansion in the hills|a museum downtown|a run-down shack|a laundromat} and are paid ${payment}. -> earn_money

=== bike_race === ~ speed = frame * 3 + wheels * 4 + random_integer(10, 50) You pay your entry fee and pull up to the starting line. {   - speed > 60:     The wind whips through your hair. You feel on fire. The world goes by in a blur.     You are awarded the top prize, $400!     ~ money += 400     -> earn_money   - speed > 50:     Your bike feels like part of you, all working smoothly together to zoom along. You’re neck-and-neck with another racer, but in the end you get second place. You are awarded $100.     ~ money += 100     -> earn_money   - else:     You try your best, but the others are too fast for you. Maybe you should upgrade your bike? } -> earn_money

=== function upgrade_cost(level) === ~ return 100 + level * 25