Runner Game Block

soldier running in desert

Using this Block

This is a game where the player runs from left to right, jumping over obstacles that appear in the way. Jump over a set number of obstacles to win the game. If you ever played the dinosaur jumping over cactus game on Chrome when the Internet was down, yeah, it’s like that.

Making it your own

What’s in the block

Like every block, the runner block has two files in the folder:

  • An HTML file: runner.html . You should not have to change anything in this file.
  • A config file: runner_config.js – This is where you will make any changes to create your unique game.

As with most blocks, it also has an images folder. Any images used specifically in this block will be saved here. This will include the game background, player character and the obstacles.

Ideally, the beginning and end of the image will match up, as in the example. Three backgrounds are included in the block. We will have more in the future.

NOTE: The default in the demo game is a height of 576px. In this game, you have a score box and progress bar at the top so the stage and image height are set at 516px. You could change those but then this screen won’t be the same size as the rest of the blocks in your game.

There is also an audio folder that has the sounds to play when you hit an obstacle.

The config file

In the runner_config.js file you’ll see two sections. As with all blocks, there is an options object. The options include instructions on how to play the game and where to go after you have won the game.

It looks as if there are a lot of options here, and there are, but there are only a few you need to change.

const options = {
completionURL: "../next_block/next_block.html",
stage: {
width: 1000,
height: 576
},
scrolling_image: {
image_path: "images/runner_background.jpeg",
width: "7680px",
height: "600px"
},
end_of_animation: 3840, // as set in CSS
ground_level: 200,
runner: {
image: "images/boy.gif",
location: {
top: "300px",
left: "500px",
},
jump_height: "200px",
},
too_many_collisions_image: "images/runner_background.jpg",
obstacle_interval: 700, // I don't see that this is used AM
obstacle_stage_position: 1200, // position from left where new obstacle is inserted
collision_rect_inset: 10, // inset obstacle rect to make it easier to jump over
collision_counter_label: "Collisions:",
collision_limit: 10, // Game restarts if collisions reach this limit
obstacle_end_game_count: 20,
intro_text: "Get to the end of the course while treading on as few snakes as possible. If you trod on ten you will have to start over. Use the space bar to jump.",
too_many_collisions_text: "You stepped on ten snakes. You have to start over!",
exit_text: "Great! You made it to the end without stepping on too many snakes! You get a pizza!",
goal_image: {
image: "images/pizza.png",
height: "auto",
width: "150px"
},
good_sound: "../../audio/win_game.mp3",
bad_sound: "audio/hiss.mp3",
};

scrolling_image – give the path and filename for the background image.

ground_level – This is where, in pixels, your obstacles will be placed, counting the bottom of the game screen as zero. In the image below, this is where we are placing the snakes the character must jump over. I recommend just leaving it at 200, testing your game and then making the number smaller or larger, if necessary.

runner options

  • image – enter the link for the image for the character you want to use as a runner
  • location – the top and left values define the point in pixels that the game character is placed on the screen. I recommend just leaving it at as is, testing your game and then making the numbers smaller or larger, if necessary.

collision_counter_label – What do you want the label for the number of obstacles they fail to jump over?

collision_limit – How many obstacles can they run into before they lose? To make the game easier, increase this number. To make it harder, decrease the number.

obstacle_end_game_count – How many obstacles will be presented before the game ends? To make the game longer, increase this number. To make it shorter, decrease the number.

completionURL – link to go to after the game ends

intro_text – Instructions about the game. Be sure to include “Use the space bar to jump.”

too_many_collisions_text – Text to show when they lose the game.

What about all of those things you didn’t mention?

Like the obstacle_stage_position, collision_rect_insert etc.

You should leave those just as they are.

Obstacles

const obstacles = [
{
image: "images/snake.svg",
height: "auto",
width: "75px"
},
{
image: "images/snake_cartoon.svg",
height: "auto",
width: "75px"
}
];

You can have as many different obstacles as you want. We included several in the images folder, including a chicken. For each obstacle, include an image link and the width. If your image is not actually that width, it will be scaled down automatically, but it would make more sense to include an image of the size you want. The height will be computed automatically.

If you have more than one obstacle, one will be randomly select each time an obstacle is placed on the screen.

The config file should end with:

export {options, obstacles};

Similar Posts

  • Maze Game Block

    The maze game block is a 7 X 12 grid where the user starts at one cell and must travel to another cell in the same grid. The goal is to make through two screens without running out of points. The maze has items that cost the player points and that earn points.

  • Moving Targets Block

    This is a game block where players click on an item that is moving across the screen. This game can be used in two ways: “Good” targets that the player wants to hit and “bad” targets that they should not hit OR there can be just one type of “target”, the “good” target that the player hits or collects.

  • Splash Block

    Every game needs to start with a splash screen. The only requirements for the Blocks user (you!) to provide are your game title, an image for the splash screen and the link for the start of your game. Your splash screen will have an image, the title of your game and a play button. When the player clicks on the play button, they’re taken to the beginning of your game. Optionally, a sound can play as the splash screen fades out and the first screen fades in.

  • Get an Animal

    This is an assessment and game block that is very popular with young players. For each correct math question, the player gets another animal or item for their animal. Math questions can be multiplication, division, addition or subtraction. Division problems will all have a whole number quotient, with no remainder. Division can also include converting fractions to a whole number, as shown in the example below.

Leave a Reply

Your email address will not be published. Required fields are marked *