Orkn's Pulp Devlog

Bumping this with some Resonant Tale progress!

resonant_tale_pot_boss

This is a sub-boss in the first dungeon. There are a few different mechanics going on:

  • When you step into the room the door slams shut behind you, trapping you in.
  • When you approach the key it disappears, triggering the sub-boss. I trigger both this and the door slam with an item tile that is identical to the floor in appearance but on collect calls an event to say it has been collected on the room. That makes the item tile reusable and keeps the room specific logic inside the room script.
  • I made quite a bit of use of both play ... then and wait ... then for timing events.
  • The boss requires the player to attack the correct (non-jiggling) pot. The others explode which damages the player - I have a generic event for an explosion happening at some coordinates that will trigger an "explode" event on the adjacent tiles as well as damaging the player and I re-use it for the player's bomb item they get later in the game.
  • Once the boss encounter starts it is on a timer to re-randomise the pot locations (I called each randomisation a "round" of the boss). I had to account for the round being ended by the player attacking the correct pot and make sure the timer didn't prematurely end a new round that had just been started manually by the player.
  • The pot locations are randomised! This is the big one. I wanted the pots to appear randomly anywhere in the room each round, but never in the same location as each other or the player. This isn't as simple as it sounds given Pulp's limitations!

All pulpscript has is a random function that returns a random integer between some min and max values (inclusive). After a bit of thinking what I realised is that, if you have a room where the possible x coordinates go between x_min and x_max, and the player is somewhere in the room, you can use the random function to randomly get an x coordinate that isn't the player's by getting a random number between x_min and x_max - 1, then comparing it to the player's x coordinate and adding 1 if it is equal to or greater than the player's x coordinate.

Like this:

min_x = 9
max_x = 15

tile_x = random 9,14
if tile_x>=event.px then
  tile_x++
end

Maybe this is obvious, but it was an "aha!" moment for me!

Unfortunately with three different pot locations to randomise it got a little more complicated. For each subsequent location I had to reduce the max in the random range (essentially you reduce it by however many values you already have occupied), but I also had to recursively check if my random value was equal to or greater than each of the already occupied coordinates. So the first pot has just the one conditional, the second pot has a top-level if/elseif with a nested if in each, and the third pot has a top level if/elseif/elseif each with a if/elseif in turn each with a nested if. I can just about accept that, but randomising the locations of more than 3 objects and some kind of refactor would be necessary - exactly how I don't know!

Anyway I hope some of that was interesting and I will endeavour to actually get the game finished!

3 Likes