### Copyright (C) The Holy Ghost 2017 ###This program is released under the GPL 3.0 and artistic license 2.0. use lib "../../HollyGame"; use Sprite; package Wycadia::Aldhebrand; our @ISA = "HollyGame::Player"; sub Aldhebrand { my $class = shift; my $self = {}; bless $self, $class; my $self = $self->SUPER::Player; $self->$app = shift; my $image1 = new SDL::Surface(-name=>"./images/player.jpg"); $self->{leftimagelibrary}->push{$image1}; my $image2 = new SDL::Surface(-name=>"./images/player2.jpg"); $self->{rightimagelibrary}->push{$image2}; my $image3 = new SDL::Surface(-name=>"./images/player3.jpg"); $self->{upimagelibrary}->push{$image3}; my $image4 = new SDL::Surface(-name=>"./images/player3.jpg"); $self->{downimagelibrary}->push{$image4}; return $self; } sub update { my $self = shift; } sub draw { my $self = shift; my $image = $imagelibrary->get; $image->blit($screenrect, $self->{app}, $screenrect); } ### Copyright (C) The Holy Ghost 2017 ###This program is released under the GPL 3.0 and artistic license 2.0. use lib "../../HollyGame"; use Sprite; package Wycadia::ButterflySprite; our @ISA = "Sprite"; sub ButterflySprite { my $class = shift; my $self = {}; bless $self, $class; my $self = $self->SUPER::Sprite(shift,shift,shift,shift); $self->$app = shift; my $image1 = new SDL::Surface(-name=>"./images/butterflysprite1.png"); $self->{imagelibrary}->push{$image1}; my $image2 = new SDL::Surface(-name=>"./images/butterflysprite2.png"); $self->{imagelibrary}->push{$image1}; $self->{screenrect} = new SDL::Rect -width => $self->{box}->{w}, -height => $self->{box}->{h}; return $self; } sub update { my $self = shift; $self->{x}++; } sub draw { my $self = shift; my $image = $imagelibrary->get; $image->blit($self->{screenrect}, $self->{app}, $self->{screenrect}); } ### Copyright (C) The Holy Ghost 2017 ###This program is released under the GPL 3.0 and artistic license 2.0. use lib "../../HollyGame"; use Maproom; package Wycadia::MapRoom; our @ISA = "MapRoom"; sub MapRoom { my $class = shift; my $self = {}; bless $self, $class; $self = $self->SUPER::MapRoom; $self->{exits} = (); my $self->{app} = shift; $self->{background} = new SDL::Surface(-name=>"./images/morningglory-800x600-1.jpg"); push ($self->{sprites}, ButterFlySprite($self->{app})); return bless $self, $class; } sub draw { my ($self, $app) = shift; $self->{background}->blit($screenrect, $app, $screenrect); $self->SUPER::draw; } ### Copyright (C) The Holy Ghost 2017 ###This program is released under the GPL 3.0 and artistic license 2.0. use SDL; ###use SDL::TTFont; use SDL::Surface; use SDL::Rect; use SDLx::App; use lib "../../HollyGame"; use Game; package Wycadia::WycadiaGame; our @ISA = "Game"; sub Game { my $class = shift; my $self = {}; bless $self, $class; my $app = new SDLx::App( -title => "Perl Game", ###-icon => "", -width => 800, -height => 600); $self = $self->SUPER::Game(shift,$app); $self->{screenrect} = new SDL::Rect -width => 800, -height => 600; $self->{room} = MapRoomMorningGlory->MapRoomMorningGlory($app); $self->{Aldhebrand} = Aldhebrand->Aldhebrand($app); $self->{font} = new SDL::TTFont ( -proto => $proto, -name => "Times New Roman", -size => 12 ); } sub gameloop { my ($self) = shift; ### subclass responsability my $gameover = 0; while (!$gameover) { $event = SDL::Event->new(); $event->wait(); if ($event->type() == SDL_KEYDOWN) { if ($event->key_sym == SDLK_ESCAPE) { $gameover = 1; } if ($event->key_sym == SDLK_LEFT) { $self->{Aldhebrand}->move(-1,0,0); } if ($event->key_sym == SDLK_RIGHT) { $self->{Aldhebrand}->move(1,0,0); } if ($event->key_sym == SDLK_UP) { $self->{Aldhebrand}->move(0,-1,0); } if ($event->key_sym == SDLK_DOWN) { $self->{Aldhebrand}->move(0,1,0); } $self->{room}->update(); $self->{room}->draw($self->{app}, $self->{screenrect}); $self->{app}->flip; } } }