See Through Sprites in PyGame

Got an idea for a game several months ago, but I realized that I need to learn and re-learn a lot of the concepts so that when I do build the 2D game in my head, it’d be as smooth and as fun as possible.

One of the idea I had in my game is being able to see through the floors — say, when the player picks up an x-ray device/glasses and therefore can scan the floor below for enemies or resources, etc.

The great thing about this feature is that I can re-use it for a different use case. Example, the player entered a room that fluctuates from light to dark, or another is transitioning from night to day (break of dawn).

Proof of Concept (POC)

I was able to make a very crude transparency effect, using multiple surfaces at different layers/levels to truly test how far I can take this idea and therefore expand its use case a lot more.

I didn’t do a voice-over on this one so let me just explain it here 🙂

I used the numbers on they keyboard to switch layers (1 to 4).

As for the transparency effect, I used the mouse wheel:

  • Scrolling up increases opacity (making the surface solid)
  • Scrolling down decreases opacity (making the surface transparent)

Other non-game (business) use cases

Of course, the other reason I’m studying games through writing one is so I can use the ideas and tech on business applications.

  • Write an app to render a digital view of the building and navigate it virtually.
  • Write a map, like Google Maps, maybe on a smaller scale and show various layers (roads, vegetation, etc.)
  • Build a digital training/tutorial on how to operate a machine/equipment
  • Represent sensor data (from IIOT devices)
  • Render a simulation
  • Others

Why Python?

I know, right… there are so many tools better at writing games.

Well, I already know Python so the learning curve to PyGame isn’t that high.

Plus, Python has tons of packages/modules for other cool things like:

  • Machine Learning (making apps smarter through data)
  • Computer Vision (for augmented reality, object detection, etc.)
  • Easy integration/access to communication protocols like MQTT, Web Sockets, ReDis Pub/Sub, HTTP, etc.
  • Data Science
  • So much more…

I’d probably have to move more to a video (VLOG) format as it’d be easier to explain and show it there, as I develop more 🙂

But I’ll still post here 🙂

Leave a Comment