- package grid;
-
- sub new {
- my $class = shift;
- my $self = {
- _width => shift,
- _height => shift,
- _default => shift,
- _gird => {}
- };
-
- bless $self, $class;
- return $self;
- }
-
- sub get {
- my ($self, $x, $y, @rest) = @_;
- my $pos = $x + $y*$self->{_width};
-
- return defined $self->{_grid}->{$pos} ? $self->{_grid}->{$pos} : $self->{_default};
- }
-
- sub set {
- my ($self, $x, $y, $val, @rest) = @_;
- my $pos = $x + $y*$self->{_width};
-
- $self->{_grid}->{$pos} = $val;
- }
-
- sub get_height {
- my $self = shift;
- return $self->{_height};
- }
-
- sub get_width {
- my $self = shift;
- return $self->{_height};
- }
-
- 1;