Games::Roguelike::World - Roguelike World
package myWorld; use base 'Games::Roguelike::World'; $r = myWorld->new(w=>80,h=>50,dispw=>40,disph=>18); # creates a world with specified width/height & map display width/height $r->area(new Games::Roguelike::Area(name=>'1')); # create a new area in this world called "1" $r->area->genmaze2(); # make a cavelike maze $char = Games::Roguelike::Mob->new($r->area, sym=>'@', pov=>8); # add a mobile object with symbol '@' $r->setvp($char); # set viewpoint to be from $char's perspective $r->drawmap(); # draw the active area map from the current perspective while (!((my $c = $r->getch()) eq 'q')) { $char->kbdmove($c); $r->drawmap(); }
General pupose object which pulls together field of view, item, mob handling and map drawing code.
* contains a hash of Games::Roguelike::Area's for each "level" or "region" in the game * uses the Games::Roguelike::Console library to draw the current area * assumes the user will be using overridden Games::Roguelike::Mob's as characters in the game * assumes the user will be using overridden Games::Roguelike::Item's as items in the game
Options can also all be set/get as class accessors:
vp => undef # Games::Roguelike::Mob that is the 'viewpoint' dispx, dispy => (0,1) # x/y location, of the map dispw, disph => (60,24) # width & height of the map msgx, msgy => (0,0) # x/y location of the "scrolling message box" msgw, msgh => (60, 1) # width & height of the "scrolling message box" maxlog => 80, # maximum number of rows stored message log msgoldcolor => 'gray', # color of non-curent messages (if left blank, color is left alone) wsym => '#', # default wall symbol fsym => '.', # default floor symbol dsym => '+', # default door symbol debugmap => 0, # turn on map coordinate display debug => 0, # debug level (higher = more) noview => '#+', # list of symbols that block view nomove => '#', # list of symbols that block movement area => undef, # Games::Roguelike::Area that contains the currrent map
None of these features have to be used, and can be easily ignored or overridden.
No arguments: returns the current area
Specify a scalar name: returns an area with that name
Specify an Games::Roguelike::Area object: stores that object in the area hash, overwriting any with the same name, then makes it the active area
Debug print messages
For now, hard coded to far right side of screen, at col 82, past most terminal game widths
Read one character, blocks until a char is pressed.
Calls getch repeatedly, optionally echoing characters to the active console. If "empty" is not set to true, it will not return empty strings.
Refreshes the console display.
Read one character, nonblocking, returns undef if none are available.
searches "map feature list" for the given symbol, returns coordinates if found
Erases the "display world", and resets the "display line" (used by dispstr)
Useful for displaying an in-game menu, inventory, ability or skill list, etc.
Draws a tagged string at the "displine" position and increments the "displine".
Return value: 0 (offscreen, did not draw), 1 (ok), 2 (ok, but next call will be offscreen).
Draws the map, usually do this after each move
Same as showmsg, but also shows the cursor, and gets a character response, optionally waiting until it matches.
Turn on/off display of cursor for next operation.
Shows a message and pushes it into the log. Use of color argument is deprecated. Prefer to use "<$color>$msg" tagged strings.
Shows a message at msgx, msgy coorinates and optionally logs it. Also displays up to (msgh-1) old messages.
Saves the world (!), optionally specify filename which defaults to "rll.world".
Loads a world, optionally specify filename, returns a reference to the new world.
Console is not initialized, and is, instead, copied from the current world.
Games::Roguelike::Area, Games::Roguelike::Mob, Games::Roguelike::Console
Erik Aronesty earonesty@cpan.org
earonesty@cpan.org
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html or the included LICENSE file.
To install Games::Roguelike::Mob, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Roguelike::Mob
CPAN shell
perl -MCPAN -e shell install Games::Roguelike::Mob
For more information on module installation, please visit the detailed CPAN module installation guide.