#lang survival

About this Language

Use this language to create your own survival-style game!

  • Customize your avatar!
  • Add food to help your avatar battle hunger!
  • Add enemies for extra challenges!
  • Customize recipies and craft new foods and weapons in game!
  • Dabble in level design!
To Install

Package Source: survival

Need a reminder how to install a package? Check out this video tutorial.


Hello World 1

Code the basic survival game.

(survival-game)

Avatar 1

Code a game with a basic avatar.

(survival-game
#:avatar (basic-avatar))

Avatar 2

Code a game with an avatar that has a custom sprite.

(survival-game
#:avatar (basic-avatar
          #:sprite wizard-sprite))

Avatar 3

Code a game with an avatar that has a custom sprite and speed.

(define (my-avatar)
 (basic-avatar #:sprite pirate-sprite
               #:speed 20))

(survival-game
#:avatar (my-avatar))

Avatar 4

Code a game with an avatar that has a custom sprite, speed and WASD key-mode.

(define (my-avatar)
 (basic-avatar #:sprite monk-sprite
               #:speed 20
               #:key-mode 'wasd))

(survival-game
#:avatar (my-avatar))

Avatar 5

Code a game with an avatar that has a custom sprite, speed, WASD key-mode, and 200 health and max-health.

(define (my-avatar)
 (basic-avatar #:sprite wizard-sprite
               #:speed 20
               #:key-mode 'wasd
               #:health 200
               #:max-health 200))

(survival-game
#:avatar (my-avatar))

Background 1

Code a game with a custom background.

(survival-game
#:bg (basic-bg))

Background 2

Code a game with a desert background.

(survival-game
#:bg (basic-bg
      #:image DESERT-BG))

Background 3

Code a game with a lava background with a 2 by 2 grid.

(define (my-bg)
 (basic-bg
  #:image LAVA-BG
  #:rows 2
  #:columns 2))

(survival-game
#:bg (my-bg))

Background 4

Code a game with a lava background with a 2 by 2 grid that starts on tile 3.

(define (my-bg)
 (basic-bg #:image LAVA-BG
           #:rows 2
           #:columns 2
           #:start-tile 3
           #:hd? #t))

(survival-game #:bg (my-bg))

Coin 1

Code a game with collectible coins.

(survival-game
#:coin-list  (list (basic-coin)))

Coin 2

Code a game with very valuable collectible coins.

(define (my-coin)
 (basic-coin #:value 500))

(survival-game
#:coin-list  (list (my-coin)))

Coin 3

Code a game with many valuable silver coins.

(define (my-coin)
 (basic-coin #:sprite          silvercoin-sprite
             #:name            "Silver Coin"
             #:value           100
             #:amount-in-world 20))

(survival-game
#:coin-list  (list (my-coin)))

Coin 4

Code a game with a silver coin, and a single, extremely valuable gold coin that only appears once.

(define (my-coin)
 (basic-coin #:sprite silvercoin-sprite
             #:name   "Silver Coin"))

(define (my-special-coin)
 (basic-coin #:sprite          goldcoin-sprite
             #:name            "Gold Coin"
             #:value           1000
             #:amount-in-world 1
             #:respawn?        #f))

(survival-game
#:coin-list  (list (my-coin)
                   (my-special-coin)))

Coin 5

Code a game with 3 collectible coins: a basic coin; a rarer, more valuable silver coin; and an extremely rare and valuable gold coin.

(define (silver-coin)
 (basic-coin #:sprite silvercoin-sprite
             #:name   "Silver Coin"
             #:value  500
             #:amount-in-world 5))

(define (gold-coin)
 (basic-coin #:sprite          goldcoin-sprite
             #:name            "Gold Coin"
             #:value           1000
             #:amount-in-world 1
             #:respawn?        #f))

(survival-game
#:coin-list  (list (basic-coin)
                   (silver-coin)
                   (gold-coin)))

Crafter 1

Code a game with a basic crafter.

(survival-game
#:crafter-list (list
                (basic-crafter
                 #:sprite cauldron-sprite
                 #:position (posn 200 200)
                 #:tile 2)))

Crafter 2

Code a game with carrots, and a crafter that makes carrot stew from carrots.

(survival-game
#:food-list (list
             (carrot
              #:name "Carrot"
              #:amount-in-world 10))
#:crafter-list (list
                (basic-crafter
                 #:recipe-list (list
                                carrot-stew-recipe))))

Crafter 3

Code a game with fish, and a crafter that makes fish stew with high-healing power.

(define (fish-stew)
 (basic-product #:name "Fish Stew"
                #:sprite fishstew-sprite
                #:heals-by 50))

(define fish-stew-recipe
 (recipe #:product (fish-stew)
         #:ingredients (list "Fish")))

(survival-game
#:food-list (list (fish))
#:crafter-list (list
                (basic-crafter
                 #:recipe-list (list
                                fish-stew-recipe))))

Crafter 4

Code a game with carrots, fish, and a crafter that makes both carrot-stew and fish-stew.

(define (fish-stew)
 (basic-product #:name "Fish Stew"
                #:sprite fishstew-sprite
                #:heals-by 50))

(define fish-stew-recipe
 (recipe #:product (fish-stew)
         #:ingredients (list "Fish")))

(define (my-cauldron)
 (basic-crafter
  #:recipe-list (list
                 carrot-stew-recipe
                 fish-stew-recipe)))

(survival-game
#:food-list (list
             (carrot #:amount-in-world 10)
             (fish #:amount-in-world 10))
#:crafter-list (list
                (my-cauldron)))

Enemy 1

Code a game with an enemy.

(survival-game
#:enemy-list (list
              (basic-enemy)))

Enemy 2

Code a game with 10 random enemies.

(survival-game
#:enemy-list (list
              (basic-enemy
               #:amount-in-world 10)))

Enemy 3

Code a game with 5 bat enemies with medium AI.

(define (my-enemy)
 (basic-enemy #:ai 'medium
              #:sprite bat-sprite
              #:amount-in-world 5))

(survival-game
#:enemy-list (list
              (my-enemy)))

Enemy 4

Code a game with 10 total mobs: half are not-smart slime, and half are smarter bats who only appear at night.

(define (easy-enemy)
 (basic-enemy #:ai 'easy
              #:sprite slime-sprite
              #:amount-in-world 5))

(define (medium-enemy)
 (basic-enemy #:ai 'medium
              #:sprite bat-sprite
              #:amount-in-world 5
              #:night-only? #t))

(survival-game
#:enemy-list (list
              (easy-enemy)
              (medium-enemy)))

Enemy 5

Code a game with 5 hard bat enemies that spit acid with 50 damage.

(define (hard-enemy)
 (basic-enemy #:ai 'hard
              #:sprite snake-sprite
              #:amount-in-world 5
              #:weapon (acid-spitter
                        #:damage 50)))

(survival-game
#:enemy-list (list
              (hard-enemy)))

Enemy 6

Code a game with 5 slimes with 'easy ai, 3 snakes with 'medium ai, and 1 bat with 'hard ai that only shows up at night and does 50 damage.

(define (easy-enemy)
 (basic-enemy #:ai 'easy
              #:sprite slime-sprite
              #:amount-in-world 5))

(define (medium-enemy)
 (basic-enemy #:ai 'medium
              #:sprite snake-sprite
              #:amount-in-world 3))

(define (hard-enemy)
 (basic-enemy #:ai 'hard
              #:sprite bat-sprite
              #:amount-in-world 1
              #:night-only? #t
              #:weapon (acid-spitter
                        #:damage 50)))

(survival-game
#:enemy-list (list (easy-enemy)
                   (medium-enemy)
                   (hard-enemy)))

Food 1

Code a game with 10 food items in the world.

(survival-game
#:food-list (list
             (basic-food
              #:amount-in-world 10)))

Food 2

Code a game with exactly 2 custom foods that heal you by 20.

(define (my-food)
 (basic-food #:amount-in-world 2
             #:heals-by 20))

(survival-game
#:food-list (list
             (my-food)))

Food 3

Code a game with a couple of apples with extra healing power.

(define (my-food)
 (basic-food #:sprite apples-sprite
             #:name "Apples"
             #:amount-in-world 2
             #:heals-by 20))

(survival-game
#:food-list (list
             (my-food)))

Food 4

Code a game with 2 different food types: common apples with low-healing power and one very rare cherry with high-healing power.

(define (my-food)
 (basic-food #:sprite apples-sprite
             #:name "Apples"
             #:amount-in-world 15
             #:heals-by 5))

(define (special-food)
 (basic-food #:sprite cherry-sprite
             #:name "Cherry"
             #:amount-in-world 1
             #:heals-by 50
             #:respawn? #f))

(survival-game
#:food-list (list (my-food)
                  (special-food)))

Food 5

Code a game with a very fast starvation rate and lots of cherries with high-healing power.

(define (my-food)
 (basic-food #:sprite cherry-sprite
             #:name "Cherries"
             #:amount-in-world 20
             #:heals-by 50))

(survival-game
#:food-list (list
             (my-food))
#:starvation-rate 100)

Food 6

Code a game with 3 food types: common cherries, trick smores that deplete your health, and a single high-healing carrot that spawns, only once, on a specific tile.

(define (basic-cherry)
 (basic-food #:sprite          cherry-sprite
             #:name            "Cherries"
             #:amount-in-world 15))

(define (basic-smores)
 (basic-food #:sprite          smores-sprite
             #:name            "Smores"
             #:heals-by        -10))

(define (special-carrot)
 (basic-food #:sprite   carrot-sprite
             #:name     "Carrots"
             #:tile     4
             #:amount-in-world 1
             #:heals-by 50
             #:respawn? #f))

(survival-game
#:food-list       (list (basic-cherry)
                        (basic-smores)
                        (special-carrot)))

Game Jam 1

????

(survival-game
#:avatar       (basic-avatar)
#:coin-list    (list (basic-coin))
#:food-list    (list (basic-food #:amount-in-world 10))
#:enemy-list   (list (basic-enemy))
#:crafter-list (list (basic-crafter)))

Game Jam 2

????

(define (my-avatar)
 (basic-avatar #:sprite wizard-sprite))

(define (gold-coin)
 (basic-coin #:sprite goldcoin-sprite
             #:name "gold coin"
             #:amount-in-world 4
             #:value 40))

(define (toasted-marshmallow)
 (basic-food #:sprite          toastedmarshmallow-sprite
             #:name            "toasted marshmallow"
             #:heals-by        5
             #:amount-in-world 5))

(define (cherry)
 (basic-food #:sprite          cherry-sprite
             #:name            "cherry"
             #:heals-by        50
             #:respawn?        #f))

(define (carrot)
 (basic-food #:sprite          carrot-sprite
             #:name            "carrot"
             #:amount-in-world 5))

(define (bowl)
 (basic-food #:sprite          bowl-sprite
             #:name            "bowl"
             #:heals-by        0
             #:amount-in-world 2))

(define (my-enemy-1)
 (basic-enemy #:ai              'easy
              #:sprite          snake-sprite
              #:amount-in-world 5))

(define (my-enemy-2)
 (basic-enemy #:ai              'medium
              #:sprite          bat-sprite
              #:amount-in-world 2
              #:night-only?     #t))

(define (smores)
 (basic-food #:sprite smores-sprite
             #:name "smores"
             #:heals-by 40))

(define (steak)
 (basic-food #:sprite  steak-sprite
             #:name    "steak"
             #:heals-by 50))

(define (carrot-stew)
 (basic-food #:sprite   carrotstew-sprite
             #:name     "carrot-stew"
             #:heals-by 60))

(define smores-recipe
 (recipe #:product     (smores)
         #:build-time  10
         #:ingredients (list "toasted marshmallow")))

(define steak-recipe
 (recipe #:product     (steak)
         #:build-time  5
         #:ingredients (list "cherry" "toasted marshmallow")))

(define carrot-stew-recipe
 (recipe #:product     (carrot-stew)
         #:build-time  15
         #:ingredients (list "carrot" "bowl")))

(define (campfire)
 (basic-crafter #:sprite      campfire-sprite
                #:position    (posn 200 200)
                #:tile        2
                #:recipe-list (list smores-recipe
                                    steak-recipe)))

(define (cauldron)
 (basic-crafter #:sprite      cauldron-sprite
                #:position    (posn 200 200)
                #:tile        3
                #:recipe-list (list carrot-stew-recipe)))

(survival-game
#:avatar       (my-avatar)
#:coin-list    (list


                (gold-coin))
#:food-list    (list (toasted-marshmallow)
                     (cherry)
                     (carrot)
                     (bowl))
#:enemy-list   (list (my-enemy-1)
                     (my-enemy-2))
#:crafter-list (list (cauldron)
                     (campfire)))

Hello World 1

Code the basic survival game.

(survival-game)

Level Design 1

Code a game with a forest background with world objects.

(survival-game
#:bg (basic-bg
      #:image FOREST-BG)
#:enable-world-objects? #t)

Level Design 2

Code a game with a forest background filled with high definition trees.

(survival-game
#:bg (basic-bg
      #:image FOREST-BG)
#:other-entities
(make-world-objects
 round-tree
 pine-tree
 #:hd? #t))

Level Design 3

Code a game with a pink background filled with random color candy-cane-trees and snow-pine-trees.

(survival-game
#:bg (basic-bg
      #:image PINK-BG)
#:other-entities (make-world-objects
                  candy-cane-tree
                  snow-pine-tree
                  #:hd? #t
                  #:random-color? #t))

Level Design 4

Code a game with 3 world objects with customized position, tile, size, and/or hue.

(survival-game
#:other-entities
(pine-tree (posn 100 200)
           #:tile 0)
(wood-house (posn 100 200)
            #:tile 1
            #:size 0.5)
(brick-house (posn 100 200)
             #:tile 2
             #:hue (random 360)))

Npc 1

Code a game with a basic NPC.

(survival-game
#:npc-list (list (basic-npc)))

Npc 2

Code a game with a named witch NPC.

(define (my-npc)
 (basic-npc
  #:sprite witch-sprite
  #:name   "Witch"))

(survival-game
#:npc-list (list (my-npc)))

Npc 3

Code a game with an NPC with custom dialog.

(define (my-npc)
 (basic-npc
  #:dialog (list "Woah, who are you??"
                 "Nevermind -- I'm too busy."
                 "Move along, now!")))

(survival-game
#:npc-list (list (my-npc)))

Npc 4

Code a game with a witch NPC who follows you. Give them a name and a specific start tile.

(define (my-npc)
 (basic-npc
  #:sprite witch-sprite
  #:name   "Witch"
  #:tile   3
  #:mode   'follow))

(survival-game
#:npc-list (list (my-npc)))

Npc 5

Code a game with 2 NPCs with custom dialog and two additional customizations each.

(define (my-npc)
 (basic-npc
  #:name   "Francis"
  #:tile   4
  #:dialog (list "Greetings!"
                 "You better find some food soon...")))

(define (another-npc)
 (basic-npc
  #:sprite witch-sprite
  #:mode   'pace
  #:dialog (list "Now where did I put it..."
                 "Have you seen an eye of newt?"
                 "Oh, I think I see it!")))

(survival-game
#:npc-list (list (my-npc) (another-npc)))

Sky 1

Code a game with a very long day/night cycle.

(survival-game
#:sky    (basic-sky #:length-of-day 5000))

Sky 2

Code a game with a custom-colored night sky.

(survival-game
#:sky (basic-sky #:night-sky-color  'darkmagenta))

Sky 3

Code a game with a short day/night cycle where it gets pitch-black at midnight.

(survival-game
#:sky    (basic-sky #:length-of-day 500
                    #:max-darkness  255))

Sky 4

Code a game with a short night, and many nocturnal enemies.

(survival-game
#:enemy-list   (list (basic-enemy #:amount-in-world 20
                                  #:night-only? #t))
#:sky          (basic-sky #:length-of-day    2400
                          #:start-of-daytime 200
                          #:end-of-daytime   2200))

Weapon Crafter 1

Code a game with a crafter that builds swords.

(define my-sword-recipe
 (recipe #:product (sword)
         #:build-time 20))

(survival-game
#:crafter-list (list
                (basic-crafter
                 #:sprite woodtable-sprite
                 #:recipe-list (list
                                my-sword-recipe))))

Weapon Crafter 2

Code a game with a wood table crafter that slowly builds a high-damage sword.

(define my-sword-recipe
 (recipe #:product (sword #:damage 100)
         #:build-time 100))

(survival-game
#:crafter-list (list (basic-crafter
                      #:sprite woodtable-sprite
                      #:recipe-list (list my-sword-recipe))))

Weapon Crafter 3

Code a game with coins, and a wood table crafter that instantly builds fast-moving fire-magic for 100 gold.

(define my-fire-magic-recipe
 (recipe #:product (fire-magic
                    #:name "Fast Flame"
                    #:speed 7)
         #:cost 100))

(survival-game
#:coin-list (list
             (basic-coin))
#:crafter-list (list
                (basic-crafter
                 #:sprite woodtable-sprite
                 #:recipe-list (list
                                my-fire-magic-recipe))))