b0VIM 7.0 +4ZGy M nick nick-laptop ~nick/Projects/perlman/perlman
3210#"! U tp
x h y e v a u e f b ad x z y m a ` O F 8 & d W I ; ,
Z
5
} Z < 9 8 ! W
N
3 o R ; $
u ^ G , D } K C B 1 H E e D $ 14, 92, 1, 1, 0, 1, # 1 114, 92, 1, 1, 1, 1, # 1, 3 172, 92, 0, 1, 1, 1, # 3, 17 230, 92, 1, 0, 1, 1, # 17, 5 232, 16, 0, 1, 1, 0, # 5 114, 14, 0, 1, 1, 1, # 2 14, 16, 0, 1, 0, 1, # 0 my @intersections = ( ## ## ( 498, 552, 1, 0, 1, 0 ) ## ## corner of the screen, you can go up and left: ## directions are available, up, down, left, right. Example, the lower right ## The format of this is the upper left corner coordinate, (x, y) and which ## ## is chasing pacman. ## it reaches an intersection, unless the ghost has a high agression level and ## to determine which way to move. So a ghost will move in one direction until ## When they hit an intersection they will be given which directions they can go ## These intersections are for a method I am trying out with the ghosts ## intersections ); { x => 298, y => 265, color => 'orange' }, { x => 222, y => 265, color => 'cyan' }, { x => 260, y => 265, color => 'pink' }, my @ghostStart = ( { x => 260, y => 207, color => 'red' }, 'apple', 'pear', 'banana' ); my @levelFruits = ( 'cherry', 'strawberry', 'orange', 'pretzel', my %ghostAggressions = ( 'red' => 90, 'cyan' => 70, 'pink' => 50, 'orange' => 30 ); my @ghostColors = ( 'red', 'cyan', 'pink', 'orange' ); # in order of agression my %ghosts; # ghost data my $eattenPellets = 0; my $baseSpeed = 0.3; my $fullscreen = 0; my $directionNext = 0; my $directionOld = $direction; my $direction = $LEFT; my $perlManAnim = 0; my $perlManAnimSpeed = 7; my $perlManSpeed = 0; my $ghostSpeed = 1; my $revdFreeLife = 0; my $freeLife = $FREE_LIFE; my $players = 0; my $lives = 0; my $highScore = 0; my $score = 0; my $redraw_all = 0; my $gameOver = 0; my $playing = 0; #0 Are we playing the game? default to '0' till game starts my $level = 0; # keep track of the level, we default to '0' till the game begins my $pelletOffsetY = 0; my $pelletOffsetX = 13; my $boardOffsetY = 0; my $boardOffsetX = 5; ## End of debug vars my $drawGrid = 1; # draw path grid my $drawIntersections = 1; # draw intersections my $drawWarpGates = 1; # draw the actual gates that warp pacman my $drawWarps = 1; # draw warp collision rectangles my $collisionDebugOn = 1; # Collision data is printed to STDOUT my $numOnly = 1; # this will draw ONLY the number labels and no grey rectangles my $labelRects = 1; # this numerically labels each one my $drawPoints = 1; # this will draw the collision rectangles my $DEBUG = 1; # This will turn off ALL debugging, including the variables below ## Debugging variables ); -size => 1024 -channels => 2, -frequency => 44100, my $mixer = new SDL::Mixer( ); -flags => SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWACCEL, -depth => 32, -height => 600, -width => 800, -title => 'PerlMan', my $app = new SDL::App( my $CHASE = 1; my $PATROL = 0; my $UP_RIGHT = 8; my $DOWN_RIGHT = 7; my $DOWN_LEFT = 6; my $UP_LEFT = 5; my $RIGHT = 4; my $LEFT = 3; my $DOWN = 2; my $UP = 1; my $FREE_LIFE = 200; #should be 10000 my $LIVES = 3; ## Some 'static' variable declarations use SDL::OpenGL; use SDL::TTFont; use SDL::Sound; use SDL::Mixer; use SDL::Event; use SDL::Cursor; use SDL::Surface; use SDL::App; use SDL; ## SDL Libraries use Switch; use strict; =cut =end comment info Version : $Id: .perlman.swn,v 1.1 2009/03/28 03:35:34 nick Exp $ PerlMan -- PacMan clone written using the Perl::SDL =begin comment info #!/usr/bin/perl -w ad f y v b L 4 ! ~ K H F E D C #
w
i
e
d
G
+
y ] N ? 0 r H
l
P
4
~ p b ^ ] @ 0 } $app->fill ( $rect, $color ); ); -y => $y + $boardOffsetY, -x => $x + $boardOffsetX, -width => 1, -height => 1, my $rect = SDL::Rect->new ( ); -b => 0x00, -g => 0x00, -r => 0xff, my $color = SDL::Color->new ( my ( $x, $y ) = @_; sub drawPixel { } $app->fill ( $rect, $color ); ); -y => $y1 + $boardOffsetY, -x => $x1 + $boardOffsetX, -width => ( $x2 - $x1 ), -height => ( $y2 - $y1 ), my $rect = SDL::Rect->new ( ); -b => 0x00, -g => 0xff, -r => 0x00, my $color = SDL::Color->new ( my ( $x1, $y1, $x2, $y2, $num ) = @_; sub drawRectI { } } $font->print ( $app, $rect->x, $rect->y, $num ); -bg=>$color, -fg=>$fontColor ); my $font = new SDL::TTFont ( -name=>"./fonts/CourierNew-Bold.ttf", -size=>10, ); -b => 0x00, -g => 0x00, -r => 0xff, my $fontColor = new SDL::Color ( ) if ( $numOnly ); -b => 0x00, -g => 0x00, -r => 0x00, $color = new SDL::Color ( $num /= 4; if ( $labelRects ) { $app->fill ( $rect, $color ) if ( ! $numOnly ); ); -y => $y1 + $boardOffsetY, -x => $x1 + $boardOffsetX, -width => ( $x2 - $x1 ), -height => ( $y2 - $y1 ), my $rect = SDL::Rect->new ( ); -b => 0xff, -g => 0xff, -r => 0xff, my $color = SDL::Color->new ( my ( $x1, $y1, $x2, $y2, $num ) = @_; sub drawRect { ############################### #### Temporary fucntions ############################### } } $app->grab_input ( SDL_GRAB_OFF ); SDL::Cursor::show ( undef, 1 ); $fullscreen = 0; else { } $app->grab_input ( SDL_GRAB_ON ); SDL::Cursor::show ( undef, 0 ); $fullscreen = 1; if ( ! $fullscreen ) { $app->fullscreen (); sub setFullScreen { ## ## Switch between fullscreen and windowed. Take away our mouse cursor in fullscreen ## } return $hit; # returns non-zero for a hit
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>