mbkarle / mind-the-fog

Roguelike JavaScript game--mind the fog!
2 stars 1 forks source link

Torch and other Fog Fun #53

Closed akarle closed 7 years ago

akarle commented 7 years ago

So late night thoughts--I think that it would be really fun to mess around with fog functionality now that I've moved all related functions to Room.js.

From the introduction of my fog removal system (with getValidNeighbors(avX,avY, flashlight) ) there has been the possibility for a flashlight / torch.

I think it would be a really cool game feature:

Torches

  1. Map the 't' key to triggering a torchOn flag, which will be passed to removeFog.
  2. Create a row in the inventory specifically for torches, and display a 't' for each torch (I'm thinking right above the XP hr)
  3. When a torch is active, it will remove more fog per move for the next X seconds, which creates a nice sense of urgency / rush to explore so as not to waste the torch
  4. Make a special torch item for the chests to be picked up (shouldn't be a mob drop...)
  5. Iterate on this idea...

Other fog fun

akarle commented 7 years ago

Serious progress in the above commit!

Torches are now held by the Hero object! Pressing t will activate the torch and expand the visibility of the character for 10 seconds. Basic functionality is there: you can't spam t, can't press it with no torches left, and torches show up in the inventory!

TODO:

akarle commented 7 years ago

Added torch item... still need to implement restrictions on having too many torches in your inventory (I'm thinking cap at 10).

akarle commented 7 years ago

Ok so a lot went down... First, in 50b5b86 I created a nice function which would basically remove the fog around the player as you went. It was optimized to only update the squares you've never seen before (and the square you are on, to move the 'x'), and it worked well!

But then in the shower I had this idea.. what if we could have a tail on the fog being removed? The idea seemed simple.. just add a setTimeout before you call the function of before.

But it was a flawed, half-baked, commit, and it led to #71, which was a bad bug because you could even remove yourself from the screen!

The solution here was to make each Timeout a property of each Location, such that when you moved (call to updateRoomHTML, all the squares visible to the hero have any existing fogTimeout's cleared, and all positions no longer visible have a fogTimeout set such that in a certain amount of time (determined by the room's tier) the fog creeps back in.

I like the idea a lot as a sort of "you lose your mind and memory as you go deeper".

But I'm closing this issue for now and leaving it to @mbkarle to work on scaling the fog tail to gameplay. Pretty proud of the code I generated by the final commit (01513ed) :) :)

Cheers, Alex