a (very) basic setup to explore "RogueLike" system

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

a (very) basic setup to explore "RogueLike" system

Post by jph_wacheski »

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.
Attachments
maze_test_000.zip
.zgeproj
(1.07 KiB) Downloaded 514 times
Last edited by jph_wacheski on Sun Jul 05, 2009 5:57 pm, edited 1 time in total.
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Every game where the player is represented by a single box reminds me about the game "Adventure" on Atari 2600 where the sword looks like an arrow and the evil dragon looks like a duck. And still it was a incredibly captivating and fun game for its time :)
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

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;

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
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 :(
Attachments
maze_test_002.zip
.zgeproj
(1.46 KiB) Downloaded 551 times
iterationGAMES.com
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

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.
Attachments
gridbased_generator__001.zip
.zgeproj
(1.84 KiB) Downloaded 585 times
iterationGAMES.com
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

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 :D
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=-
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

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??
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

8)

Code: Select all

if(maze_data[x+r,y+c] == 1 && (r != 0 || c != 0))
{
  srv+=1;
}
K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Seems to be a problem with the expression parser.

This works:

if ( (maze_data[x+r,y+c]==1) && (r!=0 || c!=0) ) srv+=1;

The dungeons looks great btw! Every time I press Z it comes up with something nice and playable.

edit: Kjell was quicker :)
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

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 :wink:

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
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

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,.
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

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 :wink:

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
Post Reply