Page 1 of 1

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

Posted: Sun Jul 05, 2009 2:54 pm
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.

Posted: Sun Jul 05, 2009 4:09 pm
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 :)

Posted: Sun Jul 05, 2009 5:55 pm
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 :(

Posted: Tue Jul 07, 2009 11:25 pm
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.

Posted: Wed Jul 08, 2009 8:58 am
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)

Posted: Wed Jul 08, 2009 12:01 pm
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??

Posted: Wed Jul 08, 2009 12:11 pm
by Kjell
8)

Code: Select all

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

Posted: Wed Jul 08, 2009 12:12 pm
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 :)

Posted: Wed Jul 08, 2009 12:21 pm
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

Posted: Wed Jul 08, 2009 12:31 pm
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,.

Posted: Wed Jul 08, 2009 12:49 pm
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