Posted: Mon Jul 18, 2005 6:22 pm Post subject: Perl/Tk Tilebased Maze Game
A couple weeks back when I was without Internet for a week, I got to messing around with Perl/Tk again and experimented with a tile-based maze game.
This maze game isn't fully playable. There's a first level which cannot be beaten, and the only way to "quit" the level is to get yourself killed just to start the level over.
Screenshots:
And of course, it has its bugs. One bug that I don't particularly care to fix, as this was just an experiment, is something I call the "Dead Zone". Here's a screenshot of that:
This area, when the player walks into it, the map on-screen stops updating until you exit the area, when the map will suddenly update to show your new position.
Bug List:
- The "Dead Zone"
- Blue spheres don't disappear when gotten (so you can get negative spheres remaining)
- Red door doesn't disappear when opened
- Goal says congrats on beating the level, then nothing.
- On the first step after the level is loaded, it takes longer to process the tiles to be shown than taking steps after that.
You'll probably need to install Tk::StatusBar from CPAN to test this.
I'm posting this so you can play around with it, get ideas, learn, etc. but since this was just an experiment there's not a whole lot of documentation for it.
Customization:
Quote:
sprites.dat contains sprite data, i.e. walls, spheres, doors, water, etc.
First you define the sprites by a symbol, and then define its name and functions below. All the supported functions are exampled. Below that part you define images, going by the names of each tile.
The tile named void is a reserved tile which must be there. On the screenshots, the void tiles are the black ones. These tiles are used when you get to a point on the stage where the boundaries are visible. All the tiles that aren't part of the level ("void" tiles) are shown using the graphic you had as "void"
The tile named man is also reserved. This tile is the game's internal representation of the player--the stickman. I don't know how the program would react to this one (or the void one) being deleted, if anyone wants to play around with that feel free.
001.map is the map for level 1. The level maps are just a bunch of symbols representing different objects (the one-character symbols defined in sprites.dat), and then information for where the player starts, how many spheres to collect, hint message, etc.
And of course you can just edit Maze.pl to make any additional changes you want.
Controls:
- Arrow keys to move stickman around.
What I intend to do is make a module for this, possibly along the lines of Tk::Games::TileBased[::Maze] which will be more object-oriented (not in module objects, but as each sprite being its own object, that would make it easier to for example have the blue spheres turn into normal floor tiles when contacted by the player).
And don't comment on the graphics, either, this was just an experiment and I didn't put the most time into them.
Great job Cer - looking forward to more TK games and products from others, as well as you. I might even venture into the unknown myself =] _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Yeah, I loved Chip's Challenge. I had a level editor for it too.
Something else I want to try with Perl/Tk is having like a scrollable canvas without the scrollbar, so instead of going through and just popping tiles in, it would scroll from tile to tile smoothly... cuz the bad thing with Chip's Challenge was the frame-by-frameness of it, it can get pretty crazy sometimes. _________________ Current Site (2008) http://www.cuvou.com/