Map Generation Demo

jaynabonne
Attached is a little demo showing some of what's possible with Quest's new mapping feature. By setting the exit grid length to 0 and varying the "grid_bordersides" attribute (north = 8, east = 4, south = 2, west = 1, added together), you can create a more-or-less traditonal looking map.

This demo code is integrated with a freely available Javascript library called "rot.js", which is used to make "Rogue-like" games (thanks to Scott Greig for pointing me to this). It's available here: http://ondras.github.com/rot.js/hp/ This code is just used to generate a random map.

The basic idea behind the map generator is that it takes a character-based map description and generates Quest connected rooms from it.

An example is this:
    <mymap type="stringlist">
<value>11111111111</value>
<value>10001000111</value>
<value>10011000101</value>
<value>10111000101</value>
<value>10110000101</value>
<value>10110000101</value>
<value>10111110101</value>
<value>10000000001</value>
<value>11110111111</value>
<value>10010100001</value>
<value>10010100001</value>
<value>10000000001</value>
<value>10010100001</value>
<value>11110111111</value>
</mymap>


where "1" is a wall and "0" is empty space.

The files provided in the zip are:

GenerateMap.aslx - The core map generation code. Feel free to use this. Take it, embrace it, modify it, love it (as you see fit).
rot_test.aslx - The test program. This is what you load in Quest to run the demo.
rot.js - The freely available JS library. I did make one minor change to have the DIgger cells reported in row-major order instead of column-major order. Besides that, it's untouched.
rotglue.js - A small JS glue layer between Quest and rot.js.

There is one coding ugliness, which is the dependency (for this demo) on a "launch room" that the generated map gets attached to. I found that if the player has already entered a room and a new exit gets added, the map code does not see it, and things get really confused. So I had to add another room one step away which could remain clean for the map to be attached to. This is an area of the map code I need to figure out stil.

Now if we could have icons on the room cells... (Well you can have labels.)

A natural extension to this is to have the map strings include other symbols as well, which could be used (for example) to look up in a dictionary to provide things like room names, etc. Right now the rooms are bare bones. But... it is just a demo. :)

sgreig
Still no replies to this thread? I think you broke everyone's brain, Jay. :D

jaynabonne
Well auto-generation has some interesting challenges. If you're using the map and arrows, it's great. If you want room descriptions and a more traditional IF look and feel, then it's something else entirely.

Entropic Pen
jaynabonne wrote:Well auto-generation has some interesting challenges. If you're using the map and arrows, it's great. If you want room descriptions and a more traditional IF look and feel, then it's something else entirely.


So I made this little number:

http://textadventures.co.uk/games/view/bs4x2ipkz0aloe_vwxyx0g/entropic-time-killer

I found a small crevice of code in the GenerateMap_GetRoom function which I exploited for fun and profit:
- A number of casinos, arenas, and trade outposts in random locations highlighted with either green, red, and blue
-- Casinos
--- Have a random assortment of games from Blackjack, Slots, Craps, Big 6 Wheel, and Lunar Hold 'em
- Traveling merchants that wander around the map
- A totally re-designed combat system

Entropic Pen
Hey Jay, I've been working on "Entropic Time Killer" for some time and I was wondering if it is possible to generate multiple maps and have them on different layers?

For example in my game I have "surface" map as the base map, and I wanted to create an "Ethereal" dimension that is
randomly generated and connected to the surface world via a portal... how would I do that?

BTW, thanks for all the coding libraries like the Path Library and 2nd Inventory Pane library.

jaynabonne
Let me take a look at it. It should be possible, just joining two different maps with an up/down. But I have to look at the code again to work out how. It might not be before the weekend, but I will get back to you.

Entropic Pen
I reproduced the combination of the Random Map Gen with the MyGrid libraries in the attachment.

It is a bare-bones example of everything I did to generate the map environment.

Omega
Pretty neat stuff Jay.
Now if only we can change the damn player icon on the map. that would be awesome.


I actually liked that game of yours entropic. compared to what everyone else had made and the 10 downloads i choose.

Entropic Pen
Omega wrote:Pretty neat stuff Jay.
Now if only we can change the damn player icon on the map. that would be awesome.

I actually liked that game of yours entropic. compared to what everyone else had made and the 10 downloads i choose.


Thanks Omega. Big things are coming in the next update, and not just the prospect of new worlds, but little details that'll make the game seem more lively: towns and environments will have descriptions along with a new re-design of the combat system... and more!

jaynabonne
Omega wrote:Pretty neat stuff Jay.
Now if only we can change the damn player icon on the map. that would be awesome.


Check out my other map work (if you have Quest 5.4):

viewtopic.php?f=18&t=3886

Actually EP's sample shows it integrated.

jaynabonne
Pen, attached is a try. It has some things I don't like that need to be fixed, but it illustrates a first step.

What I did was get rid of that ugly LaunchRoom business by passing in the launch room to GenerateMap. I added a fourth parameter and got rid of the global reference in the function. That means you can call it multiple times and pass in different launch/root rooms. I then just added some rooms to hook the lower launch room to the upper one. It still has the problem that the wall leading in shows solid, which is not good. Perhaps you have overcome that. :)

Entropic Pen
Okay, now I gotta ask about how to implement some of the other map algorithms from rot.js into Quest.

I got the Cellular generation figured out for the Overworld so now it looks more natural, and I'm still using the digger function for the Underworld, buuuut... I need one more function for a third (super secret) level.

This function is Eller's Perfect Maze, but when I try to implement it, it always seems to not load properly.

Here is the link to the rot.js interactive manual for quick reference:
http://ondras.github.io/rot.js/manual/#map/maze

I have not changed anything having to do with the Map generation functions on Quest's part, nor rot.js so the "To Pen from Jay" files still apply.

Also... how do I change the player icon?

jaynabonne
For the first part, it seems I set you up to fail by modifying the Digger code to output in a different way. The map generators dump the result maze in column-major order (one column after another) instead of row-major. For our maze needs, it was easier to have it come back in rows. So I had modified the Digger code to do that, and the glue code assumes the info comes back that way.

Eller is still sending the data back in column-major order, which really confused the glue code.

What you can do is go into the Eller code, around line 1851 and replace this:

	for (var i=0;i<this._width;i++) {
for (var j=0;j<this._height;j++) {
callback(i, j, map[i][j]);
}
}

with this:

    for (var j=0;j<this._height;j++) {
for (var i=0;i<this._width;i++) {
callback(i, j, map[i][j]);
}
}

Then it should work. I've also added the file (zipped) as an attachment, if that's easier.

For the other question, there is a function in myGrid.js called myGridApi.drawPlayer. This creates the drawing path for the player. You can modify that. (If you have trouble, ask. It's going to have to be a vector thing - one made with lines and arcs.)

Unfortunately, the code doesn't work with Quest 5.5, as some things have changed, so I can't run it myself yet. If this ends up carrying on, I will have to get it working.

Entropic Pen
It works! The Eller Maze anyway. Still figuring out how to change the player icon.

jaynabonne
What do you want it to be?

m4u
I'm interesting too. I'd like to be a happy face :D . And I have a question: is it possible to asign the arrow keys to move north, south, east and west without typing the direction?

jaynabonne
You can hook the arrow keys, but keep in mind that if you have a standard command line, it might be a bit confusing. You'll lose the up/down history functionality (which probably isn't too bad), but people won't be able to use the arrows to edit within a line.

As far as the happy face, I'll have to see if I can get it working with 5.5 so I can try it out.

m4u
I see, and how exactly can I hook it?

jaynabonne
Here's one way to do it.

m4u
Thanks Jay but I think I'm slow. I don't know how this works, where is that number coming from? and how can asign the north command to the key?

m4u
Jay, "why have you abandon me?" :(

jaynabonne
Not abandoned... just sometimes life gets in the way of "play". :) (But a reminder never hurts!)

The values are key codes that the keyboard generates. They are the more raw values. For example, hitting the "m" key always returns 77, regardless of whether caps lock is on, shift is held down, ctrl is held down, etc. You can also directly use things like shift, ctrl, and alt keys for what you want - they generate codes as well.

Attached is an updated version. I added some handlers for the up/down/left/right cases, mapping them to the right directions. Only the aslx file has changed, but I packaged the full set needed.

I hope that helps.

m4u
Jay, after a while the keyboard start "reacting" as if pressing the enter key, and the arrow keys start doing the two jobs, the one before and the direction. But I could'nt reproduce it in the test file, so maybe it has something to do with the game where I included it?

Omega
m4u. Im sure if you wait long enough you Quest will have an update to do simple things like that. For now deal with what you got going for yourself now and finish the game. By the time that happens, I bet you will have the opportunity to change that.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums