Can somebody explain this to me
Posted: 11 Jul 2008, 09:22
First of all im just new to perl. I am trying to make map viewer. in C# but i need to understand some perl codes first.
I hope someone would be kind enough to help.
What is rawmap here?
Finally, how to get the values 0-7 for the block type?
Thank you
I hope someone would be kind enough to help.
Code: Select all
my $f;
if (open($f, "<", $filename)) {
binmode($f);
local($/);
$fieldData = <$f>;
close($f);
} else {
IOException->throw("Cannot open $filename for reading.");
}
}
($width, $height) = unpack("v v", substr($fieldData, 0, 4, ''));
Questions:
What is the $fieldData? i mean its data type...
Is it a file containing binary codes of the .fld map?
sub getBlock {
my ($self, $x, $y) = @_;
if ($x < 0 || $x >= $self->{width} || $y < 0 || $y >= $self->{height}) {
return NON_WALKABLE;
} else {
return ord(substr($self->{rawMap}, ($y * $self->{width}) + $x, 1));
}
}
Finally, how to get the values 0-7 for the block type?
Thank you