If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Instructions: Timed typer

Apply functions to design a set of engaging game levels for a speed typing game.
How do games keep our attention?
Great games have just the right balance of challenge and reward. Many of them manage this pacing with levels. Levels give players an immediate goal to work toward and keep players at their edge, with each level just a bit more challenging than the last.
In this project, you’ll design the leveling system for a speed typing game.

The basic game

First, get to know the basic mechanics of the game. We’ve provided an example of a single-level game with three rounds. Each round, the player is presented with a word or phrase to type and a time limit. If they correctly spell the words within the time limit, they pass!
Take a look at the function definitions in typer.py. These are the building blocks you’ll have available to design your levels.

Gathering requirements

Start your design by thinking about your audience. Are they typing on a physical keyboard or a phone? Are they just learning to type, practicing their spelling, or looking to be entertained? Consider how your target audience might influence what the right rule set and challenge threshold is.
Then, decide how the difficulty will progress from level to level. You can vary the combination of word length, number of words, time limit, and number of rounds, or you can imagine an entirely new set of mechanics!
  • Design at least five unique game levels that increase in difficulty.
Write down your plan for each level as you go. This will guide how you organize your code.

Game over

Finally, think about how a player wins, loses, or completes the game.
  • Design a way to end the game that provides some indication of the player’s progress.
The game might end as soon as a player misses a round, printing out the number of levels they completed, or the game might continue to the end of the last level, printing out an overall accuracy score. You decide!

Function breakdown

Plan out what functions you want, what parameters they need, and what value they return. Each function should handle one specific task, like calculating a score, determining a time limit, or playing a bonus level. Then, assemble the functions to build the final game logic!
  • Add at least three new function definitions to typer.py to support your leveling system.
  • Use the functions to build your game logic in main.py.
Remember to test your game as you go, thinking through any edge cases.

More to explore

Imagine players are taken to a menu screen when they first open the game. Add a prompt that asks the user to select between multiple game options, and then use that option to adapt the gameplay. For example, players might choose between overall difficulty modes, like easy, medium, and hard, that shift the difficulty of all levels.
Playtest your game with friends and family. Observe where they’re getting stuck or which levels they’re winning too easily. How can you adjust the balance of challenge and reward in your game to better keep them motivated and engaged?

Want to join the conversation?

  • starky tree style avatar for user Solomon Bischoff
    Is it just that this course is recent that there is barely any comments here?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • cacteye blue style avatar for user 5112843
    can you teach me how to make a walking animation and flying animation and make the backdrop be smooth.
    (3 votes)
    Default Khan Academy avatar avatar for user
  • starky tree style avatar for user Solomon Bischoff
    How do you import time in the game?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user EM
    I'm having trouble with the "Challenge: Physics engine." I'm stuck on step two. My code seems to make the ball move correctly, but I'm getting this pop-up message "Modify the move() function body to stop the ball at the right wall."

    This is the ball.py that I have:

    '
    """Simulates a ball's movement and collision with the edges of a screen."""
    def maybe_bounce(position, speed, right_wall):
    """Returns the ball's new speed, which stays the same unless the ball
    bounces off of a wall.
    """
    if position >= right_wall:
    # Reverses direction and loses a bit of speed.
    speed *= -0.75
    return speed
    else:
    return speed
    def move(position, speed, right_wall):
    """Returns the ball's new position after one time step.
    The ball moves in straight line at the given speed.
    """
    ball_speed = maybe_bounce(position, speed, right_wall)
    new_position = position + ball_speed
    if new_position >=right_wall:
    return right_wall
    else:
    return new_position
    '


    The console isn't giving me an error code, and shows the ball moving to the right wall and bouncing off it several times.
    (1 vote)
    Default Khan Academy avatar avatar for user
    • leaf red style avatar for user Cavan P
      When I run your code, it looks to me like the ball almost 'dribbles' down the right wall - it's supposed to bounce all the way back to the left wall. The move function doesn't need to worry about the ball bouncing or not, it simply needs to worry about the ball stopping at the wall. It looks like you've overcomplicated the function a bit.

      We can check if the ball has reached the right wall by checking that position (which is passed in as an argument) plus the balls current speed (also an argument) is greater than the position of the right wall. If it is, then we want to return the position of the right wall - stop at the wall, don't travel past it. Similarly, we can check the left wall if the position plus speed is less than the position of the left wall, which in this case is simply 0. If neither of these are true, then we know that the ball won't be affected by anything in the next timestep and we can simply return it's future position, which will be position + speed.

      I will also note, since the syntax of Python requires whitespace, I would suggest formatting your questions/responses differently. Including your whole message in italics can make it harder to read, and you can create a codeblock by typing three backticks (`), a line break, the code you wish to share, another line break, and three more backticks. Click the 'Show Preview' option to show what your post will look like when it's shared.
      (1 vote)