Python Forum
[PyGame] [In Progress] - Rogue-Like Game Tutorial
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] [In Progress] - Rogue-Like Game Tutorial
#1
There's a community on Reddit (https://www.reddit.com/r/roguelikedev) which is putting a roguelike game together, a piece at a time, on a weekly basis. It's not the first time they've done it, so we know it'll take 13 weeks. It sounds like fun, but I'm not interested in using the libtcod library to have a game running in the console, so I'm adapting it to work with pygame. Since all the tutorials are followed along with discussions, notes, and q&a, I'll try to keep the same pace as them, and link to their discussions. Likewise, I'll try to keep the project as close to the tutorial as possible, so you can read through it and have it work with very minimal changes.

github repository: https://github.com/nilamo/roguelike

Section 0, basic setup
Tutorial: http://rogueliketutorials.com/tutorials/tcod/part-0/
Code: https://github.com/nilamo/roguelike/tree/section-00
Notes:
  • After installing python, I recommend setting up a virtual environment (it helps to keep track of which dependencies are used for each project, which can help make distribution issues easier to solve). In this case, inside the repository, I ran python -m venv . to create a new environment in the folder I was currently in.
  • At the root of the repository, I also created a batch file which will open a new console window inside the virtual environment, so it's easier to activate. This is completely optional, but I'm lazy and did it for my benefit.
  • The virtual environment's Lib folder is not included in the repository, because it's fairly large, but also unrelated to the project. Creating the environment, and then running pip install pygame from within the environment will accomplish the same thing for you.

Section 1, basic pygame use, event loops, input handling, displaying a sprite, and moving the sprite
Tutorial: http://rogueliketutorials.com/tutorials/tcod/part-1/
Discussion: https://www.reddit.com/r/roguelikedev/co..._tutorial/
Code: https://github.com/nilamo/roguelike/tree/section-01
Notes:
  • The original tutorial is based on a console, where 1 "unit" is a character. Since we're using pixels instead of characters, I added the concept of a Block Size, which scales the units up to the appropriate pixel. This way, most of the tutorial stays the same (you still move one unit at a time, for example).
  • Furthermore, using fonts and drawing characters to screen is weird, so instead I created a transparent png for the character. Same outcome, different path.

Section 2, Entity class, render functions, and a basic map
Tutorial: http://rogueliketutorials.com/tutorials/tcod/part-2/
Discussion: https://www.reddit.com/r/roguelikedev/co..._tutorial/
Code: https://github.com/nilamo/roguelike/tree/section-02
Notes:
  • The concept of "colors" doesn't make as much sense since we're not using a terminal. Because we're using actual images, and coloring them outside of the engine (Paint.net, photoshop, the gimp, etc), naming things based on their color isn't significant. If that isn't factored out of the tutorial soon (maybe around map generation), I'll remove/rename the color variables to something that more accurately represents what they are. "block_type" perhaps.

Section 3, Map Generation
Tutorial: http://rogueliketutorials.com/tutorials/tcod/part-3/
Discussion: https://www.reddit.com/r/roguelikedev/co..._tutorial/
Code: https://github.com/nilamo/roguelike/tree/section-03


Section 4, Field of Vision
Tutorial: http://rogueliketutorials.com/tutorials/tcod/part-4/
Discussion: https://www.reddit.com/r/roguelikedev/co..._tutorial/
Code: https://github.com/nilamo/roguelike/tree/section-04
Notes:
  • The tutorial relies on libtcod to handle field of vision, and keeping the fov map updated, and thus mostly focuses on how to represent that information to the player. Since we're not using libtcod, I wrote a couple functions to do that using some trig. It's fast (well, fast enough that you won't notice it slowing anything down), but not perfect. libtcod has several different algorithms to try to give the "feeling" that you want, I just went with basic ray-casting because honestly that's good enough lol.



...this section to be expanded upon over time...
Reply


Messages In This Thread
[In Progress] - Rogue-Like Game Tutorial - by nilamo - Jun-20-2019, 03:15 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020