Creating a Window Based Game

In the past my jam team had worked together on a game called Window Crawler for the brackeys jam, this was a game where you go through a dungeon but every time you exit a room a new room is generated in another window. (And then rooms can disappear leaving space for another room to generate)

m2EzeQ.png

After making it me and some other team members have wanted to do another Window based game and the theme for this jam seemed like a prime opportunity for doing so. After brainstorming for a bit we settled on an incremental type game where you take care of creatures in enclosures with each enclosure being a computer window.

Working with windows ends up causing some issues since its not a common workflow people deal with for games (especially for jams where everyone wants ideally a web build). The closest thing that people make to this sort of game are desktop companions, aka things that walk around your screen such as Desktop Goose. This means that there are at least some things to look at when making window based things but for things more oriented towards creating a game based around that there's not much help.

w1D3ES.gif

The primary game engine I work in is Godot and Godot ends up simplifying things a bit by providing a Window class you can use to create and manipulate Windows. For the enclosures I would first create a scene (aka prefab for those of you who work in unity) with the type set to Window and then spawn in a new instance of that scene every time I want to spawn in a new enclosure. Windows don't like having their position set before spawning in so the first thing a window does after spawning in is adjust its position to the correct spot.

This ended up bringing me to a set of windows that looks something like this. With one main window with the UI (and that would have creatures spawn in) and some enclosure windows that are spawned in (currently from a button press but eventually from an upgrade).

Screenshot 2024-10-16 120701.png

One person who was hanging around my stream chat then had a great idea which was to make the main window be the background of everything else. This was possible through making it a borderless window the size of the screen and then lets the ui sort of float in midair with the UI on the left and the buttons on the right. I then made this have a transparent background so that you could see the computer behind it.

Screenshot 2024-10-16 121335.png

One issue that arose that I ended up spending too much time trying to fix was getting the player to be able to use their computer while the game is running even with the large transparent window covering it. There is nothing currently in Godot that allows windows to completely pass through input and instead currently it just allows you to pass input to another window in the same application. This wasn't always the case though since in Godot 3 you could pass input and it ends up being a bug caused by a recent addition in Godot 4, mousepassthroughpolygon. This is a property on the Window class where you can define a region of the window that accepts mouse clicks. For some reason the addition of this completely broke the behaviour of passing through input to other applications so to fix it I ended up downloading the source code for Godot, removing that feature entirely and then recompiling the engine (as well as build templates so that it works on export). Compiling took around an hour which left me not able to do much other than art until that finished since it was overly laggy to run the game. But once it was done the issue was fixed and you could now use the computer while the game was running.

Interacting with another application would move that to the foreground covering the game so all windows that were part of the game I set to be always on top through the alwaysontop property in the window class.

Screenshot 2024-10-16 123512.png

To allow creatures to be dragged between windows I essentially duplicated the creature to every window whenever the creature is picked up (and then removed it from all apart from one when dropped). This allows the mouse to move to any possible window and it seem like its the same creature you are holding with it never going away (especially with the large transparent window in the background to cover the space between the enclosure windows). I also created the existence of a "wild" window that creatures would spawn in to replace my main window having that behaviour.

There would be some issues with picking up and dropping creatures in windows since letting go of the mouse over a window does not count as focusing on that window and focusing on a window eats up a click to do the focus before it lets you interact with stuff on it (aka pick up creatures). This had terrible UX since you then had to select on a window before being able to start moving a creature so all windows I made detect when they started being hovered over (godot has a signal for this) and when they are they auto focus.

Screenshot 2024-10-16 123001.png

I then ran into yet another issue. Since the main background window passed through all clicks to the applications behind it you could no longer click on the UI buttons in the top right. (These were buttons to pause, quit, and open the upgrade screen). To fix that I moved them to their own small borderless window that did not pass through clicks. This ended up causing a small bug in the final version of the game where that entire region could not have interactions behind it (which was mostly a problem for trying to close out of applications since it was over top of the x button in the top right). I likely would turn that into a non-borderless window in post jam and then allow it to be moved around to wherever the player wants.

Players could also minimize windows which would cause some bugs with the game mechanics relating to creature position. (By minimize here I mean minimize to the taskbar, not make smaller) You cant outright disable minimizing behaviours but you can maximize them again when it detects its been minimized which is what I did by checking its current state every frame.

At the end of all that I had a functioning Window system and could then expand on it a bit more with the actual game mechanics to make it more of a game.

67c8b.gif


There are a couple bugs that still remain in the game that I have to figure out solutions for. One of which is the fact that the background is black instead of transparent for many people (I have no idea what causes this) which then makes it so that they cant actually use their computer in the background. A second one is the fact that you can interact with all windows at the same time. What I mean by this is you can make a giant stack of all of the windows and interact with every single one on the stack, either with picking up creatures, collecting coins, etc. This ends up causing a duplication glitch which sticks a creature to your mouse and never lets you get rid of it (and making it so you cant use the quit button to quit out of the game)

I still want to make yet another Window based game so might try that in a future Ludum Dare or in another jam I participate in with the things I learned from this one. Especially since I only had a day to code things in this jam instead of using the entire 3 days.

For people who want to play the game made for this jam it is Window Creatures

And if you want to hang out on my streams I stream over on twitch at https://twitch.tv/ategondev and multistream to youtube at https://www.youtube.com/@Ategondev (will be streaming the Ludum Dare Score Chasers tournament when that occurs on Saturday)