Making with Code

Platformer Game Lab #

In this lab you explore a platformer game and designing tileset.

๐Ÿ“– You can find the offical documentation HERE.


[0] Setup #

๐Ÿ’ป Start by going into your unit02_games folder.

cd ~/desktop/making_with_code/unit02_games

๐Ÿ’ป Clone the repo. Be sure to change YOUR-GITHUB-USERNAME to your actual Github username.

git clone https://github.com/the-isf-academy/lab_pyxel_platformer_YOUR-GITHUB-USERNAME
๐Ÿ’ป cd into the lab
cd lab_pyxel_platformer_YOUR-GITHUB-USERNAME
๐Ÿ’ป Enter the Poetry shell and install the requirements:
poetry shell
poetry install

This repo includes these key files:

  • game.py
  • sprite.py
  • player.py
  • coin.py
  • helpers.py
  • assets.pyxres

[1] Tilesets #

๐Ÿ’ป First, play the game python game.py. Use the arrows < > to move sideways and space to jump. Note the gravity and note the walls. There are multiple different tiles that are registered as walls.


Edit the Map #

๐Ÿ’ป Open the resource editor

pyxel edit assets.pyxres 

๐Ÿ‘€ Go to the map editor. Notice, the purple and blue tiles are all solid walls. You can select the tiles on the bottom right. Then, draw with that selection in the map editor.

๐Ÿ’ป Add some new walls to the map. Then save, and replay the game.


Add Your Own Tiles #

๐Ÿ’ป Open the editer and draw your own wall asset. Be sure to draw it near the other wall tiles.

๐Ÿ’ป Then add your new tile into the map.


๐Ÿ‘พ ๐Ÿ’ฌ Setting New Tiles as WALLS

When new WALL tiles are added, you must update the code accordingly.

๐Ÿ‘€ โœ๏ธ Find the new x,y cordinate range of the WALL tiles. By hovering over the tile on the bottom left, it displays the x,y cordinate on the top.

In the screenshot, the new tile is located at (0,5)

๐Ÿ’ป In helpers.py, update the x,y range accordingly to your new tile range. Remember, in for i in range(start, stop) the stop value is not inclusive. So your stop value must be +1 above your desired number.

33
34
35
36
37
WALL_TILE_POSITIONS = []
# SET RANGES BASED ON X,Y IN MAP EDITOR
for x in range(0,5):   
    for y in range(2,6):  
        WALL_TILE_POSITIONS.append((x,y))

๐Ÿ’ป Experiment and customize your own tileset! Feel free to google tileset pixel example to reference


[2] Camera/Gravity #

๐Ÿ’ป Experiment with gravity by customizing the attributes in the Player class.

๐Ÿ’ป Experiment with the camera by customizing the scroll_border_X and scroll_border_Y in the Game class.


[3] Deliverables #

โšกโœจ

๐Ÿ’ป Push your work to Github:

  • git status
  • git add -A
  • git status
  • git commit -m “describe your changes here”

    be sure to customize this message, do not copy and paste this line

  • git push
  • remote