Python

Python: PyWeek 32: Lil Miss Vampire

TL;DR A world that scrolls infinitely in any direction, an RPG-like UI, and simple, real-time fighting.


My younger kids and I built this entry for PyWeek 32 based on the theme “Neverending”.

The key innovations are:

  • It has a neverending world. As the player walks along, it picks up tiles and places new ones invisibly. It uses an LRUDict to remember the last million tiles you’ve seen. This matches real life in that if you go back to a place after 20 years, it’ll look different than when you first saw it.
  • The user interface was inspired by Super Mario RPG, but the fighting mechanics are purposely realtime. It’s a lot like if you were playing Street Fighter, but all you were allowed to do was use a fast punch, a slow punch, or block. It’s a little bit like roshambo.

The code:

  • The code is pretty pleasant. I made use of lots of new features in the latest Python, and I built a pretty decent developer experience.
  • It’s built on the excellent arcade library which has exceptionally good documentation, tutorials, and examples.
  • I used type annotations everywhere, and I enforced them via mypy. I made extensive use of `typing.NamedTuple` which gives it a nice, immutable, well-typed flavor.
  • I used black to format the code during check-in.
  • There are extensive unit tests for the models. And there are git hooks to keep everything sane.
  • Running `make iterate` will reformat the code, run mypy to enforce types, run the unit tests, and then launch the game.

Here’s the GitHub page with more details.

Published on Web Code Geeks with permission by Shannon Behrens, partner at our WCG program. See the original article here: Python: PyWeek 32: Lil Miss Vampire

Opinions expressed by Web Code Geeks contributors are their own.

Shannon Behrens

Catholic, father of eight, open source enthusiast, Python, JavaScript, Ruby, Scala, Go, etc. programmer.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button