Hey that’s awesome! Let me know if you need help with the monster arrays.
Putting it in a function is a good idea.
You should open the browser console and see what the error was. That will help you fix it. Really take care and time to read and understand whatever the error is. Pasting the error into a search engine will help. You can find the developer console in the developer tools menu in your browser.
The freeCells
array is only available inside the generateMap
function. You will need to make it available outside if you want to use it outside, e.g. Game.freeCells = freeCells
.
You could then pick a random cell like this: ROT.RNG.getItem(Game.freeCells)
.
Good luck!
If you do console.log(Game.alienfort)
immediately after creating it, you will see the position printed. Note that the position is a string like “5x7” not an object like {x: 5, y: 7}
.
So in your code where you say makeMonster(Game.alienfort.x + "," + Game.alienfort.y)
you probably want to change it to this: makeMonster(Game.alienfort)
because the variable is already in the correct x,y
string format.
Hey do you want to send me your code and I’ll see if I can debug what is going on. Basically what I’ll do is sprinkle console.log statements throughout the code to check that each variable holds the values I’m expecting them to hold. For example I’ll put some log statements inside monsterAct
so I can check why the monster is hitting you but not getting drawn. I suspect it is to do with an undefined/null value somewhere, so I’ll be trying to track that down.