Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: A complete perl roguelike

by jwkrahn (Abbot)
on Jul 15, 2006 at 05:46 UTC ( [id://561403]=note: print w/replies, xml ) Need Help??


in reply to A complete perl roguelike

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.

Replies are listed 'Best First'.
Re^2: A complete perl roguelike
by dabreegster (Beadle) on Jul 15, 2006 at 15:06 UTC
    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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://561403]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found