Jump to content

Random Map Generation for Roguelikes in Phaser?


Muckluck
 Share

Recommended Posts

Hi,

 

I'm starting work on a little project to make a roguelike in Phaser and after a ton of Googling, I still can't figure out for the life of me how to assign tiles from a spritesheet to a dungeon generating algorithm (something simple like cellular automata).

 

I could always try and implement something like rot.js to do the generating, but even still I'm not sure how to take some simple sprites and display them as a tile in the map.

 

If anyone could help me out I'd be truly grateful. I've probably missed something really obvious but I'll be damned if I can figure it out!

Many thanks.

Link to comment
Share on other sites

I'm starting work on a little project to make a roguelike in Phaser and after a ton of Googling, I still can't figure out for the life of me how to assign tiles from a spritesheet to a dungeon generating algorithm (something simple like cellular automata).

 

You create a 'model' for the dungeon (most likely a javascript object containing a two dimensional array of integer values, with each integer representing a specific tile type). You model wouldn't contain any display logic, it would simply be a representation of your dungeon. This object would also contain a method that would populate the arrays with dungeon data using whatever algorithm you see fit.

 

Then, you create a 'view' that renders your model (by iterating through your model array, and drawing a tile for each location in the array). So, it would look at location 0x0, see that it contains the integer 5 (which might be rock), it would look up the integer '5' in either some sort of array lookup table, or a switch statement, and find the image of a rock defined there, and then draw it.

 

Is that what you are asking?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...