Shattered Islands - DevLog

DevLog#2 - Spaghettification

When you work on a project, you often have to make this choice, going fast and getting shit done, or taking hours of doing a nice clean reusable code. I know it is a very debatable subject, but I think both are good. If I am not 100% sure of the global vision of my code for some subject, I often choose the fast way to try things, then I rework directly. But as you know, we all have temporary lines of code that are sitting strong for months. In this game. I was most of the time going blind, trying things because I didn’t have a clear global picture of what I am doing. Anyway, all that speech for trying to excuse myself for writing such shitty code :stuck_out_tongue:
This week, I was supposed to look at the “deterministic” way of coding my autobattler. For that I wanted to use my PrototypingScene, but I thought it is an ugly Scene so wanted to make it an Island. But then I tried my FightingScene in the PrototypingScene but I noticed that for my FightingScene to work I had to launch my game from the start to initiate the right things. I puked a little, then I read my code and puked again. I didn’t know I could write such a spaghetti code (even worst, it was a ninja spaghetti code with hidden reference needed everywhere), but I have to admit that I fucked up there. Anyway, this week, it was rework time.

My objective: I want my Scenes to be as independent as they can be and most importantly I want to be able to test my Scenes alone using F6. Finally, I want explicit dependence with export variables when needed.

FloatingIsland
I created a new Scene that holds a Map (Visual of the Island) and a CenterPointCamera (Camera that rotate)

  • BuyingIsland
    Children of the FloatingIsland, add a BuyingArea inside
  • FightingIsland
    Children of the FloatingIsland, add a FightingArea inside

FightingScene
I made my FightingArea independent of the rest of the game, they can start a fight with FightingArea.start() function that takes an array of characters and a battle type for parameters and that’s it. The fighting area will spawn characters on the spawn points, then configure the characters so they can spawn entities and projectiles using the right spawn manager embedded in the fighting area.

PrototypingScene
My prototyping scene now use my FloatingIslands and FightingArea


SceneSwitcher
An easy Scene that reads player input to make a FloatinIsland active and all others inactive. (Make you switch camera, change UI and later change the aspect of the BuyingArea)

HeroSelector
I removed the hero selection code from the BuyingArea and made an independant Scene for it.

Characters
I changed my character scene because, even if I like the idea of being able to just drag and drop my heroes on a map to test them, I was doing the same stuff (copy pasting also) on each character scene so I factorised a little bit of logic.
I changed some logic so they don’t try too much crazy things on ready, but they need reference to the fighting_area they are on toi me able to fight, I can’t see for the moment how to make them independent of that.

By the way what I mean by dependency is that for example. Here my auto-attack module, which is responsable for triggering an auto-attack needs to know where to spawn the projectile (SpawnPoint), also it needs to know what stats to apply on the projectile (AttackManager) and finally it needs to be able to do an attack (ActionModule).

Game
I can just launch by Game Scene even with no players just to see what it looks like (not much but you can get some idea of the future visual)

I hope to be able to present better things next week. In the meantime, don’t hesitate to ask me any question about this project :slightly_smiling_face:

xoxo

Breep

1 Like