My very first Python project!

It's very basic, of course, but I'm so excited because it's the first time I code something outside a game engine. I wanted to make something not game-related, but I ended up making a text-based game anyway. Sorry, not sorry.
It's called "La venganza de Loki", which translates as "Loki's Revenge".



Loki is actually a cute little Yorkshire dog who's home alone and moves in the house as shown in the map in the corner. You can choose one of three actions in every room of the house. Every answer gives you a certain amount of points; your final score determines the ending of the story.


The project only has four files. 

I stored all the text in a file to keep it tidy. The second one has a class called Room with five instances that store the content of the different rooms (texts, map and an ID). I then did the same with the endings: a file with a class and three instances. The main file manages both the tkinter interface and the game.




The interface is a simple frame with multiple labels and three buttons that I organized using .grid()

The buttons use the function ChangeRoomText() that updates the current score, sums +1 to the room ID and calls another function according to the current room ID:

  • If the room ID is smaller than the number of rooms in the game, the function UpdateRoom() changes all text content to the next room. The first text shown in the window is variable, depending on the previous choice; the second one is a presentation of the new room. All the instances of the Room class are stored in a list so the function can return the correct texts with a simple loop.
  • When Loki completes the game, ChangeRoomText() calls the function Ending() which kind of explains itself, I think.

For the map, I used images from Freepik (here and here) with some Photoshop editing.