a (very) basic setup to explore "RogueLike" system
Moderator: Moderators
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
a (very) basic setup to explore "RogueLike" system
I was reading about some maze generation ideas,. [ http://pcg.wikidot.com/category-pcg-algorithms ] and wanted to try some of my own ideas in this area,.
So I knocked out a rough setup, for playeing around with these ideas in ZGE. It is a simple setup that has an array generated from noise2() and a little player can move around in the open spaces (0 in the array, walls are 1s) I don't normaly build my games in abstracted setups, just create objects (models in ZGE) for all the logical 'objects' but as soon as I started with this the concept of abstraction and having the data stored in a nice array for easy access and manipulation,. this became more appealing to me. Anyway,. just posted this for the kids interested in messing with these ideas,. and in the hopes that ppl will expand on the idea of a little framework for trying this type of level generating in ZGE. i.e. please improve/replace this setup!
I suppose the items should be sotred in an array as with mosters and such and then drawn in a loop like the maze is,. . but this is just a start.
peace.
So I knocked out a rough setup, for playeing around with these ideas in ZGE. It is a simple setup that has an array generated from noise2() and a little player can move around in the open spaces (0 in the array, walls are 1s) I don't normaly build my games in abstracted setups, just create objects (models in ZGE) for all the logical 'objects' but as soon as I started with this the concept of abstraction and having the data stored in a nice array for easy access and manipulation,. this became more appealing to me. Anyway,. just posted this for the kids interested in messing with these ideas,. and in the hopes that ppl will expand on the idea of a little framework for trying this type of level generating in ZGE. i.e. please improve/replace this setup!
I suppose the items should be sotred in an array as with mosters and such and then drawn in a loop like the maze is,. . but this is just a start.
peace.
- Attachments
-
- maze_test_000.zip
- .zgeproj
- (1.07 KiB) Downloaded 698 times
Last edited by jph_wacheski on Sun Jul 05, 2009 5:57 pm, edited 1 time in total.
iterationGAMES.com
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
Ha! true that, . I have a half finnished Adventure remake somewhere I'll dig it out later,. we (I was working with grahm lacky on it) had a very cool system for sword/item holding with two hands, two keys, 4 directions,. I may bring that system back in here!
Anyway I did a bit more and got a decent cave system generation going,. used this idea here: http://pixelenvy.ca/wa/ca_cave.html
I have not figured out the cavern conecting bit yet but this already looks good and will work for my idea,. I just had a look at his actual code and found a much nicer adjacent counting method,. in python;
Much cleaner than my hackery, I will try to emulate that next ver. and find a way to connect the caverns,. then perhaps add a little monster to avoid.
for now pressing space re-gens the level. However does not yet move the player out of the walls
Anyway I did a bit more and got a decent cave system generation going,. used this idea here: http://pixelenvy.ca/wa/ca_cave.html
I have not figured out the cavern conecting bit yet but this already looks good and will work for my idea,. I just had a look at his actual code and found a much nicer adjacent counting method,. in python;
Code: Select all
def __adj_wall_count(self,sr,sc):
count = 0
for r in (-1,0,1):
for c in (-1,0,1):
if self.__map[(sr + r)][sc + c] != FLOOR and not(r == 0 and c == 0):
count += 1
return count
for now pressing space re-gens the level. However does not yet move the player out of the walls

- Attachments
-
- maze_test_002.zip
- .zgeproj
- (1.46 KiB) Downloaded 716 times
iterationGAMES.com
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
ok I optomized that convolution part as the above,. much nicer looking!
I added a basic 'monster' that just chases the player,. and does a screwy random dance that starts to help get around the corners. I am thinking to figure out some pathfinding now,. may try to invent my own, or build a ver. of A* or whatever I can find that I can figure out. . next thing is to do something to have the objects spawn in open areas,. currently they often get born in solid matter, no fun that. Just press SPACE or Z till you get a decent playable layout (or fix my codes),. .
oh, I tweeked the convolution, 7 passes and it gets nice and rounded with a decent rate of fully connected levels,. perhaps I don't have to work out a way to garantee access to all the map, may do a limited dig-ability?
peace.
I added a basic 'monster' that just chases the player,. and does a screwy random dance that starts to help get around the corners. I am thinking to figure out some pathfinding now,. may try to invent my own, or build a ver. of A* or whatever I can find that I can figure out. . next thing is to do something to have the objects spawn in open areas,. currently they often get born in solid matter, no fun that. Just press SPACE or Z till you get a decent playable layout (or fix my codes),. .
oh, I tweeked the convolution, 7 passes and it gets nice and rounded with a decent rate of fully connected levels,. perhaps I don't have to work out a way to garantee access to all the map, may do a limited dig-ability?
peace.
- Attachments
-
- gridbased_generator__001.zip
- .zgeproj
- (1.84 KiB) Downloaded 758 times
iterationGAMES.com
really nice work!
For what concerns path finding... I only know recursive algorithms (quite computational intensive) but if the place you are exploring is that little, I guess we ca figure something out
Passed one exam yesterday, but there's a mandatory oral part for this exam too, and HELP MY I'M GONNA DIE ON MONDAY!!! (yes is quite a difficult one)
For what concerns path finding... I only know recursive algorithms (quite computational intensive) but if the place you are exploring is that little, I guess we ca figure something out

Passed one exam yesterday, but there's a mandatory oral part for this exam too, and HELP MY I'M GONNA DIE ON MONDAY!!! (yes is quite a difficult one)
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
-=Hugo Rossi=-
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
Well be sure to do some studying, .or go and get real drunk the night before! I have had some success with both methods of preperation.., 
I forgot to ask I had a question with this line;
if (maze_data[x+r,y+c]==1) {if (r==0 && c==0) srv*=1; else srv+=1;}
it is a weird backwards if statment there,. I want to say something like;
if (maze_data[x+r,y+c]==1) && !(r==0 && c==0) srv+=1;
however that did not seem to work, so I resorted to the what we have,. ( srv*=1 dose nothing and the else is what we want) is there a more logical way of saying this??

I forgot to ask I had a question with this line;
if (maze_data[x+r,y+c]==1) {if (r==0 && c==0) srv*=1; else srv+=1;}
it is a weird backwards if statment there,. I want to say something like;
if (maze_data[x+r,y+c]==1) && !(r==0 && c==0) srv+=1;
however that did not seem to work, so I resorted to the what we have,. ( srv*=1 dose nothing and the else is what we want) is there a more logical way of saying this??
iterationGAMES.com

Code: Select all
if(maze_data[x+r,y+c] == 1 && (r != 0 || c != 0))
{
srv+=1;
}
Haha,
Funny, as you can see in my example you don't need the brackets around the maze_data statement, but as seen in Ville's example, you don't need the brackets around the assignment because it's a single line
By the way, why don't you render the map into a bitmap? Must be a whole lot faster then looping through the entire array and rendering a quad per cell each frame. In fact, since you're not moving the camera, you can just disable clearscreen and only render the dungeon once.
K
Funny, as you can see in my example you don't need the brackets around the maze_data statement, but as seen in Ville's example, you don't need the brackets around the assignment because it's a single line

By the way, why don't you render the map into a bitmap? Must be a whole lot faster then looping through the entire array and rendering a quad per cell each frame. In fact, since you're not moving the camera, you can just disable clearscreen and only render the dungeon once.
K
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
thanks guys, I knew there was a nicer solution,. 
Kj- yeah those are good ideas,. That is one reson to post this, I like to hear what you guys can think of,. also to try to get more ppl to do simple games with ZGE. You do like your rendering trickery these days eh,. w/ no clearscreen perhaps a nice digging game could be done,. I am partial to The Pit (search Mame!!) It will depend on what the rest of the game will need to do of course,.

Kj- yeah those are good ideas,. That is one reson to post this, I like to hear what you guys can think of,. also to try to get more ppl to do simple games with ZGE. You do like your rendering trickery these days eh,. w/ no clearscreen perhaps a nice digging game could be done,. I am partial to The Pit (search Mame!!) It will depend on what the rest of the game will need to do of course,.
iterationGAMES.com
Hi jph,
During the 8-bit / C64 days only updating the pixels that had changed was the way to go .. these days you have plenty of power to do about anything, so it doesn't matter as much .. but I guess its legacy still lingers on
Additional remark, use either a ZLibrary or a global trigger ( condition looking at global variable ) to prevent duplicate code such as the maze generation expression. It's a absolute time killer when you have to change code in multiple places for a single modification.
K
During the 8-bit / C64 days only updating the pixels that had changed was the way to go .. these days you have plenty of power to do about anything, so it doesn't matter as much .. but I guess its legacy still lingers on

Additional remark, use either a ZLibrary or a global trigger ( condition looking at global variable ) to prevent duplicate code such as the maze generation expression. It's a absolute time killer when you have to change code in multiple places for a single modification.
K