Mar 16, 2024
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
Get Tower of Meowgic
Tower of Meowgic
Just playing with gb studio. this is not intended for actual playing. just sharing the url with friends.
Status | Prototype |
Author | PestoRavioli |
More posts
- New animation8 days ago
- And we're back!8 days ago
- Stepping away for a while...Jul 11, 2024
- June 26, 2024Jun 26, 2024
- June 19, 2024Jun 19, 2024
- May 30, 2024May 30, 2024
- May 28, 2024May 28, 2024
- May 23, 2024 - It's been awhileMay 23, 2024
- May 7, 2024 - NOT GAME RELATEDMay 07, 2024
- April 24, 2024Apr 24, 2024
Comments
Log in with itch.io to leave a comment.
Great tutorial! Worked really well for me. Thank you.
I know you commented over on reddit thanking me(I think it was you!), but i just saw this comment here. I'm just glad that while I learn things here that others can benefit as well. There's probably better and more efficient ways to do the things I've done, but I'm glad to know my way works for others!
Yes, it was me. I have been struggling to find efficient ways to do the same thing and spent too much time playing with triggers. This ended up working perfectly for me. Now, if there ever comes a time where I feel like it can be adjusted or improved on, I will be sure to share it here.