Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Pacman game help C++

Author
Message
Metroid Larvae
16
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 11th Nov 2008 21:10 Edited at: 12th Nov 2008 14:36
Here is my header file for my Pacman movement and I don't understand why collision detection is not working and why my Pacman does not move within the blank area and is able to move over tiles.

Basically, I need some type of algorithm for Pacman's movement in the game. Right now he moves continuously but there is no collision detection working.

SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 11th Nov 2008 21:34
I would suggest indenting this, its just awful to try to read this way.

www.Helios-Online.net
Metroid Larvae
16
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 12th Nov 2008 05:35 Edited at: 12th Nov 2008 05:37
I'll just put it under download

Attachments

Login to view attachments
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 12th Nov 2008 13:09
Use the code-tag...

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Nov 2008 14:37
@Metroid Larvae,
I've added code tags to your first post - edit that post to see how they should look.

Swordsman
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location: Wigan, England
Posted: 12th Nov 2008 18:46


Sorry, I'm new to DarkGDK and maybe I missed this, but where is SpriteID, X and Y set values before hitting this point?
Metroid Larvae
16
Years of Service
User Offline
Joined: 17th Oct 2008
Location:
Posted: 12th Nov 2008 22:49
@ swordsman

look above the function declaration
Swordsman
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location: Wigan, England
Posted: 14th Nov 2008 01:40


Those X,Y and SpriteID are what we call VERY globals, you might want to give them a prefix to stop naming clashes. For safety, you also need to check that SpriteID is equal to something in that the if statement (if Direction == Stop) as you assign it during movement. Don't ever presume that the program will work the way you want it to, it won't. Check everything, everywhere.
Off of my experience in C++ and not DGDK, two major issues always crop up with this type of game.

1. Make sure that your co-ordinates in your code and the map on the screen are actually lined up. I don't know how many times I have built a maze game and messed up the collision detection because the array wasn't correctly aligned with the co-ords I used in the code. Perhaps DGDK does this for you, maybe someone with a better knowledge of it can jump in here.

2. Look at how your program flows. How often do you call this function? It is useful to either step through the program using MSVCs debugger (click somewhere in the margin of your program, then "Start with Debugging" and Step Into to make sure that the collision is correctly being processed. Perhaps even put a std::cout message in the Direction == stop if statement to see if you are ever executing it. The results may surprise you.

Login to post a reply

Server time is: 2024-11-25 07:54:30
Your offset time is: 2024-11-25 07:54:30