Thread: Pacman game in c++

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    4

    Pacman game in c++

    ASA .

    I am a beginner in c++ & I am in 2nd Semester of Computer Science... I am studying Object Oriented Programming, & I got my Semester Project of Pacman, & i want help of you guys.

    Anyone help me in making ghosts of pac man game... I have done all other things except making ghost, anyone here please help me in making ghost logic...

    The thing which I want to know actually is that if there is a way to make two functions work in 1 time.. such as my Pac man is moving & ghost are also moving.. please tell me how I can do this..

    Thanks in advance..

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by gamingumar View Post
    Anyone help me in making ghosts of pac man game... I have done all other things except making ghost, anyone here please help me in making ghost logic...
    Read up on path finding algorithms.
    The thing which I want to know actually is that if there is a way to make two functions work in 1 time.. such as my Pac man is moving & ghost are also moving.. please tell me how I can do this..
    You can do that with threads, but it'd be unnecessarily complicating things.
    Just update all the entities serially before each frame is drawn, and if something collides, do something appropriate.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    4
    manasij7479 thanks for your reply... actually in 2nd semester of Computer Science we haven't yet studied about threads.. so I can't use threads as i don't know about them, & its looking quiet difficult to use threads. I want to know that can i run time function, ghost function & Pac-Man move function in one time,, because lets say in a function body, when i stops moving pacman the ghost & time function will also stop, so i want to know that is there any other way accept threads, which is easy to which i can use, your help will be greatly appreciated, Thanks once again

  4. #4
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by gamingumar View Post
    its looking quiet difficult to use threads.
    Don't.
    I want to know that can i run time function, ghost function & Pac-Man move function in one time,, because lets say in a function body, when i stops moving pacman the ghost & time function will also stop, so i want to know that is there any other way accept threads, which is easy to which i can use, your help will be greatly appreciated, Thanks once again
    You'll need a game loop for that, which will run once per frame and update all the entities.

  5. #5
    Registered User
    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    16
    As it has been said already, there is no need to use threads.
    Even though it might appear like the objects are all moving "at the same time", really they don't have to!
    Regarding the ghost logic: give every ghost a direction of movement and change it:
    - when the ghost hits a wall
    - randomly with a small likelihood
    - when the ghost is at a junction and it can get closer to Pacman by changing its direction

    ________________________________
    Visit my project: Derivative Calculator

  6. #6
    Registered User
    Join Date
    May 2012
    Posts
    4
    @TomasRiker i have figured out the frames thing & my pac man is moving good, firstly i am trying to make ghost which moves randomly, & my AI is not that good & it gets stuck most of the time, like games with bad AI, so can you give me something of little pseudo code type of GHOST AI. Thanks

  7. #7
    Registered User
    Join Date
    May 2012
    Posts
    4
    BY THE WAY HERE ARE MY GAME .EXE FILES

    https://skydrive.live.com/redir?resi...2E646A2A70!118

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You do not need any major path finding algorithms to implement pac-man. The original actually did not use path finding at all. All you need to do is a bump and grind type algorithm where if pacman is above the ghost the ghost constantly tries to move up - if it cant it will move up the first chance it gets. The same holds true for all other directions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to learn enough C++ to write a pacman-style game
    By m_angel in forum C++ Programming
    Replies: 1
    Last Post: 04-12-2011, 05:45 AM
  2. Help with pacman game
    By Robbe in forum C# Programming
    Replies: 2
    Last Post: 03-10-2011, 03:02 AM
  3. My Pacman Game
    By zMan in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 03:33 AM
  4. PacMan game
    By tHaPuTeR in forum Game Programming
    Replies: 0
    Last Post: 01-10-2002, 08:24 PM
  5. the smart creatures in pacman game
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 10-04-2001, 05:22 AM

Tags for this Thread