On this page:
6.1 Background Kata (difficulty = 1)
6.2 Background Kata (difficulty = 1)
6.3 Background Kata (difficulty = 1)
6.4 Level Design Kata (difficulty = 1)
6.5 Level Design Kata (difficulty = 2)

6 Level Design

6.1 Background Kata (difficulty = 1)

read
Code a game with a custom background.
code
#lang survival
 
(survival-game #:bg (basic-bg))

6.2 Background Kata (difficulty = 1)

read
Code a game with a desert background.
code
#lang survival
 
(survival-game #:bg (basic-bg #:image DESERT-BG))

6.3 Background Kata (difficulty = 1)

read
Code a game with a lava background with a 2 by 2 grid.
code
#lang survival
 
(define (my-bg)
   (basic-bg
    #:image LAVA-BG
    #:rows 2
    #:columns 2))
 
(survival-game #:bg (my-bg))

6.4 Level Design Kata (difficulty = 1)

Tip: make-world-objects works best with houses or trees and must only take two types. See the Assets Library for more options.

read
Code a game with a pink background filled with random color candy-cane-trees and snow-pine-trees.
code
#lang survival
 
(survival-game
  #:bg (basic-bg #:image PINK-BG)
  #:other-entities (make-world-objects
   candy-cane-tree
   snow-pine-tree
   #:hd? #t
   #:random-color? #t))

6.5 Level Design Kata (difficulty = 2)

Tip: With a 3x3 bg, the posn x value can be between 0 and 480 and the y between 0 and 360. Hue is any value between 0 and 360.

read
Code a game with 3 world objects with customized position, tile, size, and/or hue.
code
#lang survival
 
(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)))