codex-lv2-may-2025

1. Try the Sample Game

Click here first to try this game: đź”— https://studio.code.org/courses/csd-2024/units/3/lessons/27/levels/1

Platform Jumper The game on the left is an example of a platform jumper. Press “Run” to play it. You can make the alien jump with the up arrow, and move it to the left and right with the arrow keys. You score by collecting stars, and if you score high enough, the background will change.

You already know how to use all the blocks you need to make a game just like this one, and you’ll be making your own platform jumper in this lesson.


2. Plan Your Game

Copy this doc to plan and link to it from your project README: đź”— https://docs.google.com/document/d/1FqTjwpAuFrVidZ_j6aGw895FivFCRO2CZSvhHqWuEik/view?tab=t.0

If you know how, create empty checkboxes in GitHub-flavored Markdown to check off as you go.

Build a Platform Jumper

As you build your platform jumper, you’ll be using the problem solving process.

Define The problem is clearly defined for this game, because you already looked at a sample version. However, you might want to make some changes. Make sure any new features for your game are clearly defined.

Prepare Before you start to code, you need to fill out a project guide. It will get you ready and make the coding a lot easier.

Try You’ll try out your plan when you start coding. Don’t forget all of your resources, such as the documentation and Help and Tip tab, as you begin to code.

Reflect After finishing your project, you’ll want to reflect on whether your game turned out how you planned, and ways that you could improve your process for the next time.


3. Score Variable

Now that you’ve created your backgrounds, you’ll need to choose when each background is drawn. For that, you’ll need a score variable to hold information about your player’s score.

You should always give your variables a starting value at the very beginning of the program. That way, they are available for any code that comes after.

Do This


4. Score Variable

Now that you’ve created your backgrounds, you’ll need to choose when each background is drawn. For that, you’ll need a score variable to hold information about your player’s score.

You should always give your variables a starting value at the very beginning of the program. That way, they are available for any code that comes after.

Do This


5. Choosing Your Background

đź”— Original đź”— See example in Lesson 25 Level 9

Now that you have your score variable, you can use it to choose the right background for your game.

Do This


6. Make the Scoreboard

Original

You’ll also need a scoreboard so the player can keep track of the score. There’s already a showScore function written, but it only shows the text “Score” and not the actual score. You can see an example of a working scoreboard in Lesson 25 Level 9.

Do This


7. Create a Platform Sprite

Original

Now that you have your background and your variables, it’s time to create your sprites. Usually, it will be easiest to start with the sprites that are part of the environment, such as your platforms. The sample game had two platform sprites, but you’ll make just one first, then test it before copying and pasting the code to make the second.

Do This


8. Loop the Platform Sprite

Original See an example in Lesson 21 Level 5.

Right now, your platform sprite moves down, but it doesn’t loop back up to the top of the screen.

Do This


9. Make Your Second Platform

Making a second platform will be easier than making the first, because you can copy and paste a lot of the code, then make a few small changes. This is much easier in text mode, so be sure to try it out if you haven’t already.

You’ll need to copy two parts of your code:

  1. The part at the beginning where you made the platform.
  2. The part in your loopPlatforms function where you looped the platform back to the top of the screen.

Do This


10. Create an Item

Next, you need to add the items that fall from the top of the screen. These move just like the platforms, but faster. To make the game more interesting, the items start at a random location above the screen. For the sample game:

Do This


11. Loop Your Item

Now that your item is falling, you can add code to loop it back to the top. This is similar to what you did for the platform sprite, but the item sprite will loop back to a random x and y location each time it reappears.

Do This


12. Make Your Second Item

Next, you’ll copy and paste the code for your first item to create a second item. This is also easier in text mode.

You’ll need to copy two parts of your code:

  1. The part at the beginning where you made the item.
  2. The part in your loopItems function where you looped the item back to the top of the screen.

Do This


13. Create Your Player

Now you can create your player sprite. Just like the item sprites, the player sprite will fall from the top of the screen. Unlike the items, your player sprite will get faster as it falls—just like real falling objects. This is what allows it to jump up and fall back down.

Do This


14. User Controls

Next, you should add user controls so that you can move your player around. Your player needs to:

Do This


15. Player Interactions

The last part of making your game is programming the player interactions with the other sprites. First, your player needs to land on the platforms.

Do This


16. Collect Items

Last, you’ll want your player to collect the items falling from the top of the screen.

Do This


17. Review Your Game

Look over your project guide and play your game a few times to make sure you’ve completed everything.

âś… Does the player sprite move the way it should? âś… Do all of your interactions work? âś… Are the platforms moving correctly? âś… Does the scoreboard work?


18. 🎉 Congrats!

You’re done! See the challenges on Code.org: 🔗 Lesson 27 Level 18