ZGameEditor forum Forum Index ZGameEditor forum
The rapid development solution with a tiny footprint. ZGE Wiki homepage.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    ZGameEditor forum Forum Index -> Tips'n'Tricks
View previous topic :: View next topic  
Author Message
jph_wacheski



Joined: 16 Feb 2008
Posts: 983
Location: Canada

PostPosted: Sun Jul 05, 2009 2:54 pm    Post subject: a (very) basic setup to explore "RogueLike" system Reply with quote

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.



maze_test_000.zip
 Description:
.zgeproj

Download
 Filename:  maze_test_000.zip
 Filesize:  1.07 KB
 Downloaded:  153 Time(s)


_________________
iterationGAMES.com


Last edited by jph_wacheski on Sun Jul 05, 2009 5:57 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
VilleK
Site Admin


Joined: 15 Jan 2007
Posts: 1548
Location: Stockholm, Sweden

PostPosted: Sun Jul 05, 2009 4:09 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Visit poster's website
jph_wacheski



Joined: 16 Feb 2008
Posts: 983
Location: Canada

PostPosted: Sun Jul 05, 2009 5:55 pm    Post subject: Reply with quote

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



maze_test_002.zip
 Description:
.zgeproj

Download
 Filename:  maze_test_002.zip
 Filesize:  1.46 KB
 Downloaded:  158 Time(s)


_________________
iterationGAMES.com
Back to top
View user's profile Send private message Visit poster's website
jph_wacheski



Joined: 16 Feb 2008
Posts: 983
Location: Canada

PostPosted: Tue Jul 07, 2009 11:25 pm    Post subject: Reply with quote

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.



gridbased_generator__001.zip
 Description:
.zgeproj

Download
 Filename:  gridbased_generator__001.zip
 Filesize:  1.84 KB
 Downloaded:  197 Time(s)


_________________
iterationGAMES.com
Back to top
View user's profile Send private message Visit poster's website
kattle87



Joined: 26 Sep 2007
Posts: 399
Location: Italy

PostPosted: Wed Jul 08, 2009 8:58 am    Post subject: Reply with quote

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 Very Happy
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=-
Back to top
View user's profile Send private message
jph_wacheski



Joined: 16 Feb 2008
Posts: 983
Location: Canada

PostPosted: Wed Jul 08, 2009 12:01 pm    Post subject: Reply with quote

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.., Wink


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
Back to top
View user's profile Send private message Visit poster's website
Kjell



Joined: 23 Feb 2008
Posts: 1392

PostPosted: Wed Jul 08, 2009 12:11 pm    Post subject: Reply with quote

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

K
Back to top
View user's profile Send private message
VilleK
Site Admin


Joined: 15 Jan 2007
Posts: 1548
Location: Stockholm, Sweden

PostPosted: Wed Jul 08, 2009 12:12 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Visit poster's website
Kjell



Joined: 23 Feb 2008
Posts: 1392

PostPosted: Wed Jul 08, 2009 12:21 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
jph_wacheski



Joined: 16 Feb 2008
Posts: 983
Location: Canada

PostPosted: Wed Jul 08, 2009 12:31 pm    Post subject: Reply with quote

thanks guys, I knew there was a nicer solution,. Smile

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
Back to top
View user's profile Send private message Visit poster's website
Kjell



Joined: 23 Feb 2008
Posts: 1392

PostPosted: Wed Jul 08, 2009 12:49 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ZGameEditor forum Forum Index -> Tips'n'Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group