PageRenderTime 23ms CodeModel.GetById 13ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/t_backcompat/MoP/lib/SDL/Tutorial/MoP/Models.pm

http://github.com/PerlGameDev/SDL
Perl | 46 lines | 40 code | 5 blank | 1 comment | 1 complexity | cf8a564df513ebfa18bc8cba4bf3a243 MD5 | raw file
 1package SDL::Tutorial::MoP::Models;
 2use strict;
 3use File::ShareDir qw(module_file);
 4use Cwd qw(abs_path);
 5use Data::Dumper;
 6
 7BEGIN {
 8	use Exporter ();
 9	use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
10	$VERSION = '0.01';
11	@ISA     = qw(Exporter);
12
13	#Give a hoot don't pollute, do not export more than needed by default
14	@EXPORT      = qw(map);
15	@EXPORT_OK   = qw(map);
16	%EXPORT_TAGS = ();
17}
18
19my @map    = ();                            # bool values where we can go
20my @frame  = ();                            # tile gfx definitions
21my $avatar = { x => 0, y => 0, face => 0 }; # player pos
22
23sub new {
24	my ( $class, %parameters ) = @_;
25	my $self = bless( {}, ref($class) || $class );
26
27	load_map() or die("Can't load map.");
28
29	return $self;
30}
31
32sub load_map {
33	my $path = module_file( 'SDL::Tutorial::MoP', 'data/main.map' );
34	open( FH, $path ) || die "Can not open file $path: $!";
35	while (<FH>) {
36		my @row = split( //, $_ );
37		push( @map, \@row );
38	}
39	close(FH);
40}
41
42sub map {
43	return @map;
44}
45
461;