Games Another Long Night

Discussion in 'Projects In Progress' started by tacosontitan, Jul 14, 2021.

1. tacosontitan

Joined:
Feb 16, 2021
Posts:
8
I finally started working on my puzzle game after years of putting it off. While it's just getting started, I just completed a major chunk of logic, game object connections.

In my game, game objects can be connected to, and impact one another in different ways. The quote-unquote physical effects of game objects are applied recursively while the visual effects are limited to direct connections.

With that, the following screenshot demonstrates testing of an infinitely connected series of game objects, which, in play, is technically allowed:

I've always thought there was something beautiful about recursion. Frustrating, but beautiful.

2. AiKodex

Joined:
Jan 21, 2021
Posts:
254
Looks really interesting. Could you explain a little bit about the recursive physical effects. Could the visual effects also be applied recursively?
Also, do the colors of the connections hold any valuable information or is it just from an artistic perspective as of now?

MoonJellyGames and tacosontitan like this.
3. tacosontitan

Joined:
Feb 16, 2021
Posts:
8
I'll answer your questions in reverse as it'll be clearer that way.

Do the colors mean anything?
Yes. The color of a cube represents a specific object type in code and allows me to visually determine which object I'm tinkering with. The color of the connections represent the object at the opposing end of the connection. For example, if the red cube is connected to the green cube, then a line is created that is red at the green cube, and green at the red cube. This helps the player determine what connection they're following in game, which will be very important later on.

Could the visual effects also be applied recursively?
Yes, and in-fact, they originally were. I might, bring it back, depending on how things begin to look once I start testing multi-effects. I've already implemented the code to support infinitely many effects per game object, but I have not tested the actual application of more than one yet.

Could you explain a little bit about the recursive physical effects?

To begin, game effects in my game define how the health, power, defense, and many other statistics of an object, change within an interaction, and each game effect is responsible for defining how it applies physical and, if any are involved, visual effects.

So for a simple example, let's say we create a new effect called simply "Reduction Effect", and we want this effect to limit the power output of any connected red cubes by 50%. The effect would apply it's power reduction to any directly connected red cubes.

Now the recursion comes into play to expand on this. Let's say that when a red cube is connected to a white cube, the white cube gets an automatic power boost of 20%, no effects required. Let's also say that the current connection tree is Green -> Red -> White.

With this, let's define some variables to display the impact:
• Green Cube
• Power: 100%
• Reduction Effect: -50% Power (Red Cubes Only)
• Red Cube
• Power: 100%
• Amplification Effect: +20% Power (White Cubes Only)
• White Cube
• Power: 100%
To visualize the impact, let's say the connection tree is simply Green -> Red -> White. Because of the recursive application of the effects, the state of each cube after application is:

• Green Cube
• Power: 100%
• Red Cube
• Power: 50%
• White Cube
• Power: 110%
So instead of the white cube getting the entirety of it's 20% boost in power from the red cube, it only gets half of that due to the reduction effect the green cube has on the red one.

This applies all the way through the connection tree, no matter how far down it goes. The recursion stops once it gets back to the initiating game object, so it can lead to some pretty interesting results. For example, if the tree is:

• Green Cube 1
• Red Cube 1
• White Cube 1
• Blue Cube 1
• Green Cube 1
• Red Cube 2
• White Cube 2
This series is allowed, and technically creates a circular reference. However, it is safeguarded by the fact that the application stops once it returns to the origin. If a circular reference is detected, the effect is instead applied beginning with the last object in the circular reference, while retaining the first object as the starting point, which allows the entirety of the desired output to be achieved.

Note: The concept of circular connections may not be supported in the final product, but it isn't off the table yet.