mbkarle / mind-the-fog

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

fixed #10 #64

Closed akarle closed 7 years ago

akarle commented 7 years ago

In this branch, the way that the world map updates is edited such that it doesn't change nearly as much of the html.

Basically, what happens is that we leverage existing code:

getValidNeighbors currently returns the Locations of every location that is updated on a regular move (due to fog removal). We leverage this code and use jQuery's functionality to find the ID of each world element (now written as # row x col ) and change its html to be the symbol it should be.

This eliminates need to rebuild all 1000some locations each time.

Note that buildRoomHTML now takes in a boolean as its third parameter for if its a full rebuild. Full rebuilds should happen whenever something affects the whole floor's html (descent, fog removal,etc).

akarle commented 7 years ago

Ok I made this even better by only updating those positions which had fog, removing the fog, and then replacing their html!

This makes the removeFog function almost worthless.... but thats ok! its still used in buildRoomHTML.

Note that now buildRoomHTML should be used for a total build (no boolean needed) and updateRoomHTML should be used for an update (in the case of a move), and this takes in the old position of the character [x,y] and the new position.

Cheers, Alex