in reply to Re: Re: OT: Tile maps
in thread OT: Tile maps

Again talking about your area of "view", and tilesets. Lets say you define a 100x100 area as being forest. Heres what I am thinking.

Now what you can do with this is start testing if present_pos <= some_val_from_next_area then start mapping that area before they actually encounter it. Also with this approach you can generate "random" dungeons of differing sizes to explore, and they should all have a slightly different look and feel, depending on how many tiles you add to each tileset. Also you can gen an area once, print out the map to a file, then tweak to add doors, etc via a simple editor which you can create to work with this data structure. Then save again, in edited form. That way if you have say a main castle, which is pivitol in your quest, all that needs to be done, is to map the def to tiles, and print, as opposed to generating the area then mapping then printing. {l2kashe}.o O ( maybe even do the mapping via the editor to avoid the mapping cost completly at run time?)

Hope this helps and that the readmore tag works like I hope it does :P
#HEADER FILE # define start and end points for x and y, and assign a # tileset # Note completely off the cuff Ideas following # Area => { name => 'something', tiles => 'forest', world => '50,75->150,175',# anchor it in the world X => 100, Y => 100, }; # CODE # How big do we need to gen? # @mask = gen_area( $area->{X}, $area->{Y}, number_of_tiles_in_selected_set ); # # Make it purty # @output = draw_area(\@mask, $area->{tiles}); $handle = print_it(\@output); # later if ($move) { # # X or Y will be constant here, so we only need width or # or height not both # @mask = gen_area(0, $area->{Y}, forest); @output = draw_area(\@mask); # # here we would append to the appropriate range on our main # output matrix then print it # } sub gen_area { # # This is horribly innefficient the larger your area becomes # but it show the basic Idea # ($x,$y,$num) = @_; for ( 0 .. $x ) { for ( o .. $y ) { $return[$x][$y] = int(rand($num)) + 1; } } return(@return); } # END gen_area sub draw_area { # # Again horribly inefficient, again off the cuff code to # display idea as opposed to how to do it right # ($ref,$set) = @_; @data = @{$ref}; # # @tiles could either be populated with actual filenames, # or simply references to structures in memory who know # where to find the files, or piece together the fabric of # your map # @tiles = get_tiles($set); # # So we build another AoA which takes the values in the # matrix as an offset to pull the approriate tile name, from # the tile array, which is a mapping we can use when # sending it back to the player. # for ($f = 0; $f <= @data; $f++) { @line = @{$data[$f]}; for ($s = 0; $s <= $#line; $s++) { $return[$f][$s] = $tiles[$lines[$s]]; } } return(@return); }


/* And the Creator, against his better judgement, wrote man.c */