itch.io is community of indie game creators and players

Devlogs

Mar 16, 2024

Tower of Meowgic
A browser game made in HTML5

So, today's goal was to finally work on a random encounter system.  This actually turned out to be much easier than I thought it would be.  I'm assuming this is because of GB Studio itself.  I'd imagine this probably would've been a huge PITA back in the day (as was all gb dev probably).  

I had previously worked on the battleUI scene.  This scene would have a switch statement that basically loads a sprite based on a numeric value.  So if I want an area to have 3 possible enemies spawn in it, when that scene loads, I set the 'nextEnemyType' variable to randomly populate as 1, 2, or 3.  I have corresponding enemy sprites named 1.png, 2.png, and 3.png.  That preps the scene for the next enemy you encounter on it.

The next step is essentially figuring out WHEN to enter a battle.  To do this, I needed 2 variables.  I created a variable for counting the number of steps since my last encounter and a variable with a random number.  So my thinking was that I want players to go a maximum of 15 "steps" between battles.  So $stepCounter will increment on each step and be reset to 0 after each encounter or scene change.  $randomEncounter will receive a number between 1 and 15 with each step and will also be reset to 0 after each encounter or scene change.

Each "step" is considered a press of any direction on the dpad.  I use step in quotes because even if you tap it once to change directions, it counts that as a step.  To fix, I want to populate the player's xy coordinates before calling the script vs the player's xy coordinate when it triggers on dpad press; however, I was not seeing a reference to player position when editing the script.  I know I can do it, but am just not feeling it right now.  





Files

  • tower-of-meowgic.zip 102 kB
    Mar 16, 2024
  • Tower-of-Meowgic.gb 128 kB
    Mar 16, 2024
Download Tower of Meowgic
Read comments (3)