Sign in to follow this  

pacman, allegro, wee

This topic is 4200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, I've been playing around with my pac clone with my minimal spare time... I guess I'm progressing ok. I've been trying to move everything over to OO style with classes as opposed to my last projects all being basically one big lump of functions. :D I'm having some problems with my pac sprite. I just do a rotation on the bmp since he looks the same in all directions but for some reason the transparent pixels end up black after a rotation. But, when he goes to the right there is no rotation and the masked blit works fine. Dunno if it's an allegro bug but I thought I would mention it incase anyone else has had this issue. Other than that I've added one ghost that just runs a search around the maze, he doesn't actually look for pacman yet but I wasn't sure if I did the AI good or not. Basically he goes in a random direction, if he hits a wall he checks which ways are open and picks another direction but won't pick the direction he came from. Also, if he hits an intersection he can pick a new direction other than the way he came or can choose to go the same way if it is still a valid direction. One thing I think I did wrong with game the map is that the big dots are supposed to blink in the real pacman but mine doesn't cause the tiles are just represented by numbers in a 2d array. All this sprite animation stuff is new to me so I'm still figuring out the ways to do the animations on various things. I'm not even sure if I did my character animations right. What I did there was make a map< string, vector<int> > where the string is a sequence ("UP", "DOWN", etc) and the vector holds the tile numbers of the bitmap for that sequence and I just loop through those tiles in order. Anyways, I'm pretty happy I've made it this far so I wanted to post something about my progress. If anyone wants to take a look at what I have so far and give any feedback, that would be great. download grubba

Share this post


Link to post
Share on other sites
Nice start. [smile]

The tunnel has a bug: it seems that when you're off the screen, both you and the ghost can freely move up or down, leaving the game board entirely.

Share this post


Link to post
Share on other sites
Couple of things

1. Pacman only responds to the arrow key when I release the key, so I can't hold it down which is a tad annoying.

2. Don't disable the button on the title bar to close the window. Some of us are too stupid to press esc and resort to ctrl alt del it before realising (guilty as charged :P)

Share this post


Link to post
Share on other sites
Quote:
Original post by Fruny
Nice start. [smile]

The tunnel has a bug: it seems that when you're off the screen, both you and the ghost can freely move up or down, leaving the game board entirely.


yea, I noticed that too after posting this. Hope to get that fixed soon.

Quote:
Original post by Drazgal
Couple of things

1. Pacman only responds to the arrow key when I release the key, so I can't hold it down which is a tad annoying.

2. Don't disable the button on the title bar to close the window. Some of us are too stupid to press esc and resort to ctrl alt del it before realising (guilty as charged :P)


1. Right now it's set to when you release the key it sets the next direction to take. I suppose I could just switch it so you can hold it down. [smile]

2. As for the title bar, I suppose that is something allegro disables by default. I could try to enable it again if that is possible. I'll look into it.



Thanks for the feedback guys. Hopefully I'll finish this and then I'll be able to go back and rewrite it cleaner and better. I'll keep updating as I progress.

Share this post


Link to post
Share on other sites
Well I'm having a problem with my ghost getting stuck in the chase state I've been coding in. I'm trying to debug it in vs.net 2003. I don't have much experience using the debugger. What I'm trying to do is set a breakpoint when the ghost is stuck and try to step through code from that point. I've tried starting debugging, getting him stuck and then break all and putting a breakpoint and hitting continue(debugging) but it doesn't stop at my breakpoint. Am I doing this wrong? Can anyone point me in the right direction here?

Share this post


Link to post
Share on other sites
Well I am thinking about reworking how my map is represented. Right now it is a 2d array of ints representing a tile from my tilemap. I was thinking of switching this to a 2d array of pointers to TILE objects. These TILEs would be something like:


class CTile
{
static BITMAP *tileset;
int type; // wall, tunnel, pellet, etc

vector<int> sequence; // tiles in the animation sequence
int frame; // which tile to display
bool animating; // toggle animation on and off?

public:
int getType() const;
void nextFrame();

};


I'm not sure if this is the best way to handle this because only the power pellets animate but I guess it would make it possible to animate other tiles if I wanted to. If I do go with something like this do I need a new timer for the animations or do I use some sort of global timer for all of my timing? Also, I'm not quite sure the best way to load in the tile information.

I haven't had a chance to experiment with this yet but wanted to see if I was on the right track here or if I'm making it more complex than necessary. Any feedback is appreciated.

Share this post


Link to post
Share on other sites
Well ofcourse it depends on how you have written your game so far but this is how I would implement it.

Have a 2D array for the maze, this is all static so each struct needs only record its tile graphic to draw, its position and if it can be traversed or not.

Then store all the pills in a second array which are rendered after the mae is draw. If you seperate the pill data from the pill animation (hmm not a very good description there, Ill write some psuedo code instead)


class PillGraphic
{
public:
LoadPill();
Render(int X, int Y);

private:
int Frame;
BITMAP* Graphic:
}

class Pill
{
public:
void Render()
{
if(Active)
{
Graphics.Render(X,Y);
}
private:
POINT Position;
bool Active; // True for existing false its already being eaten
static PillGraphic Graphic;
}



Something like that, of course wiht a simple pacman you could throw out the pillgraphic class alltogether and just have a static BITMAP and static frame counter for the pills instead.

If you really want to keep the pills as tiles then you can use inheritance and make a specialized subset of CTile, CTilePill with the pill animation code there. Which would keep your Tile class nice and clean for the none animating tiles.
[/source]

[Edited by - Drazgal on June 17, 2006 8:42:40 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Drazgal
Well ofcourse it depends on how you have written your game so far but this is how I would implement it.

Have a 2D array for the maze, this is all static so each struct needs only record its tile graphic to draw, its position and if it can be traversed or not.

Then store all the pills in a second array which are rendered after the mae is draw. If you seperate the pill data from the pill animation (hmm not a very good description there, Ill write some psuedo code instead)

*** Source Snippet Removed ***


I will most likely start from scratch. I may be able to use bits and pieces of what I have already but as I progress I keep thinking I should of done something differently so it makes me want to go back and try new things.

If I understand you correctly you are saying to simplify my CTile class and have a static 2d array of these CTiles. Inherit from CTile a pill class for the animation of those. Say I've done this but I'm still confused on how to create a map with this new setup. It was easy enough using a 2d array of ints but this is new to me and I'm unsure of what is normally done to handle this. Will I need to create some kind of map editor to work this out? Also any tips on timing the frame changing?

Thank you for your input Drazgal.

Share this post


Link to post
Share on other sites

This topic is 4200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this