llusion-Z is a game I designed and programmed at the end of a 6-week introductory course in Python. I wanted to create the illusion of a 3D world within the 2D programming space of Tkinter library.
I was inspired by Shift and Monument Valley. Shift is a flash puzzle game where the player navigates a maze by changing the environment and platforms from black to white. Monument Valley is a mobile game with M.C Escher-inspired perspective illusions that bend the puzzle space, and beautiful, simple forms. I wanted to incorporate these concepts into my game.
collision detection misses
As I generated a world larger than a handful of cubes, I soon discovered a major issue in the design: image refresh rate could lag based on processor speed, even after making runtime optimizations to the rendering algorithm.
If the player gained enough speed, they would skip the area of collision detection, and land inside a solid cube. This issue would also appear if the player inverted the world while inside a cube. Embracing this constraint, I adjusted the rules so that standing inside a cube would be an essential mechanic of the gameplay.
With a mechanic that alters the play environment, I brainstormed a handful of opportunities for interesting situations of play. Perhaps they need to strategically remove blocks to get from Point A to Point B without falling off the map, or could be challenged to remove a number within a time limit, or need to uncover a specific pattern to move onto the next level.
the drawing algorithm
I achieved the illusion of perspective by rendering the front and back faces of the cube with respect to a central vanishing point, then connecting the faces by the three visible edge faces. Color choice and cast shadows added to the illusion of depth.
Another challenge faced in rendering the cubes was to display the cubes and shadows in the correct order- otherwise hidden faces of some cubes could be drawn where they should not be visible. I solved this by creating a sorting method to render based on distance from the center vanishing point.
Given the short time frame of this quick-fire demonstration of skills, I implemented the time-limited challenge to remove blocks from the screen with an easy and a hard mode. With more time, I would have loved to expand this into a narrative-driven game with various types of levels to accomplish. There is a caveat: though working with a true 3D graphics engine would make this process easier and more efficient, it would lose the elegance of this specific design solution that evolved out of the constraints of Tkinter.