Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

A complete perl roguelike

by dabreegster (Beadle)
on Jul 15, 2006 at 01:28 UTC ( #561379=sourcecode: print w/replies, xml ) Need Help??
Category: Fun Stuff
Author/Contact Info Da-Breegster ( thebreegster on AIM dabreegster on freenode
Description: My main project for the past year has been a Perl roguelike engine. I finally produced the first game with the engine, and I'd like to hear feedback on the game and, if anybody's brave, the code. The game consists of quite a few modules, data files, and such, so I've packaged it together: Who knows? You might enjoy it!
// None, the game is at
Replies are listed 'Best First'.
Re: A complete perl roguelike
by jwkrahn (Monsignor) on Jul 15, 2006 at 05:46 UTC
    I had a cursory look at the Roguelike::UI module. A lot of places in the code you are pushing a scalar onto an array inside a foreach statement modifier when you could simply push the list directly onto the array. In the following examples the lines with the line numbers are from your module and the lines following them are without the foreach statement modifier:
    159 push @rows, $_ foreach ($start .. $y); push @rows, $start .. $y; 165 push @rows, $_ foreach ($y + 1 .. $end); push @rows, $y + 1 .. $end; 193 push @cols, $_ foreach ($start2 .. $x); push @cols, $start2 .. $x; 199 push @cols, $_ foreach ($x + 1 .. $end2); push @cols, $x + 1 .. $end2; 257 push @msgs, $Game->{Messages}[-5 + $_] foreach 0 .. 4; push @msgs, @{ $Game->{Messages} }[ -5 .. -1 ]; 288 shift @{ $Game->{MsgLog} } foreach 1 .. $times; splice @{ $Game->{MsgLog} }, 0, $times; 356 push @draw, $lines[$_] foreach $y1 .. $y2; push @draw, @lines[ $y1 .. $y2 ];
    The block:
    265 if (scalar @lines > 5) { 266 @sayme = map { $lines[-$_] } (1 .. 5); 267 @sayme = reverse @sayme; 268 } else {
    Could be simpified with an array slice to:
    if (@lines > 5) { @sayme = @lines[ -5 .. -1 ]; } else {
    In a lot of places you use an ASCII ESC character which shows up in my editor as "^[". Perl provides an escape sequence for the ASCII ESC character: "\e" which is more readable.

      Thank you very much for all of the suggestions! I wrote that bit of the UI nearly a year ago, so there are bound to be many more mistakes.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://561379]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-09-30 05:14 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (159 votes). Check out past polls.