Feature:   Adding Levels

imageFeatureAdding Levels
Unit Overview

Students parameterize other parts of their game, so that the experience changes as the score increases. This track delves deeper into conditionals and abstraction, offering students a chance to customize their games further while applying those concepts.

English

add translation

Product Outcomes:
  • Students add a second level (with a different background image) to NinjaCat

Standards and Evidence Statements:

Standards with prefix BS are specific to Bootstrap; others are from the Common Core. Mouse over each standard to see its corresponding evidence statements. Our Standards Document shows which units cover each standard.

  • BS-DR.4: The student can solve word problems that involve data structures

    • BS-IDE: The student is familiar with using a REPL, entering expressions properly, and interpreting error messages

      • enter and evaluate expressions on the computer

    • BS-M: The student models a problem in context and determines the data needed to describe the problem

      • identifying which quantities are fixed and which are variable

    • BS-PL.1: The student is familiar with declaring values and applying built-in functions using the programming language

      • representing (numeric, string, boolean, image, etc) values in the programming language

    • BS-PL.4: The student is familiar with the syntax for conditionals

      • BS-R: The student is able to write interactive programs using the ’Reactor’ construct

        • identify how functions work together to create and maintain a complex program

      Length: 45 Minutes
      Glossary:
      • helper function: A small function that handles a specific part of another computation, and gets called from other functions

      Materials:
        Preparation:
        • Make sure students have completed the "Scoring" feature before starting this lesson.

        Types

        Functions

        Values

        Number

        + - * / sqr sqrt expt

        1 ,4 ,44.6

        String

        string-append string-length

        "hello"

        Image

        rectangle circle triangle ellipse star scale rotate put-image

        (circle 25 "solid" "red")



        Leveling up: Adding Levels

        Overview

        Students learn how to add levels to their game

        Learning Objectives

          Evidence Statementes

            Product Outcomes

            • Students add a second level (with a different background image) to NinjaCat

            Materials

            Preparation

            • Make sure students have completed the "Scoring" feature before starting this lesson.

            Leveling up: Adding Levels (Time 45 minutes)

            • Leveling up: Adding LevelsYou can add depth to your game by adding levels. In this lesson, we’ll cover making new levels based on the game’s score. To start, we want our Ninja Cat game to have a different background image when the player progresses to the next level. We’ll say that the player reaches level two when his or her score is greater than 250.

              Where do you define the BACKGROUND-IMG image in your game? Keep your original background for the first level, but define a new variable, BACKGROUND2-IMG, that will be used for level 2. For the best results, use an image that is the same size as your original background.

              Once you have your second background image, it should be drawn into the game - but only when a certain condition is met. Think back to the helper function we wrote to change the color of the sunset animation in Unit 4, and we need to do the same thing here!
              • What must be true for the player to progress to level 2?

              • Write a function draw-bg, which consumes the score and produces the appropriate background image.

            • Now that we have our helper function, we can use it to draw of that one part of the animation. Instead of blindly putting BACKGROUND-IMG into our function, now we’ll use draw-bg(g.score):  

            • Now our Ninja Cat game has a level 2! You can add more conditions to draw-bg to have multiple levels. You can use this same technique in lots of ways:
              • Write draw-player and change draw-state so that have the Player transform if the score is above 250.

              • Change your animation functions so that your characters move faster if the score is above 250.

              • Add a special key (jumping? firing? warping?) that is only "unlocked: if the score is above 250.