Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Pacman with SFML  (Read 12810 times)

0 Members and 1 Guest are viewing this topic.

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
Pacman with SFML
« on: July 03, 2014, 05:27:43 pm »
Hello, I'm really new to SFML and I don't know if it's the best idea to start game programming with pacman :D The only thing left is the AI for the ghosts but I don't really know how to realize that... So maybe I start AI programming with tic-tac-toe or so... If somebody of you has an Idea how to realize an AI for Pacman-ghosts (it doesn't care if the behavior of the ghosts (blinky, pinky, inky and clyde) is different), please tell me :) I'd really appreciate it because if I have that, my first game is (almost) done...

I realized that the ghosts and pacman use more than one tile, in my version they only use one tile... Is it even possible to realize an AI for the ghosts that way (maybe somebody of you knows that)?

You can compile the code on windows and linux, on mac it isn't tested

Sorry for my bad english I'm Swiss

Edit:
New Download Link
http://download.lima-city.de/hazeler/Pacman.rar

Edit:
I still haven't done an AI, but I have some ideas how to do it. I learned alot about OOP last week and I really begin to understand the whole objectorientation rather than just watching tutorials without all of the technical terms... Books for ever :D
« Last Edit: August 18, 2014, 10:02:49 pm by Dubmosphere »

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: Pacman with SFML
« Reply #1 on: July 03, 2014, 05:32:25 pm »
I tried it but it seems to be a bit buggy  :-\



You can see my version i made months ago here

http://en.sfml-dev.org/forums/index.php?topic=12939

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Pacman with SFML
« Reply #2 on: July 03, 2014, 05:34:05 pm »
I tried it but it seems to be a bit buggy  :-\



You can see my version i made months ago here

http://en.sfml-dev.org/forums/index.php?topic=12939

ooh I have to recompile the windows version... I've changed the Spritesheet^^

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Pacman with SFML
« Reply #3 on: July 03, 2014, 05:52:56 pm »
Oh look another Swiss person! :D

There are full blown articles on the internet that describe how the AI of each ghost works. Implementing it is a different thing though. With same Finite State Machines it should still be fairly easy.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: AW: Pacman with SFML
« Reply #4 on: July 03, 2014, 11:06:28 pm »
Oh look another Swiss person! :D

There are full blown articles on the internet that describe how the AI of each ghost works. Implementing it is a different thing though. With same Finite State Machines it should still be fairly easy.

I know there are many articles about the bahavior of the ghosts but the point is I have no plan how to realize that in code^^... I'll try to implement clyde first because he moves randomly^^ I have absolutely no idea how to implement the other ones maybe I should try to do some simpler games first^^

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: Pacman with SFML
« Reply #5 on: July 03, 2014, 11:13:47 pm »
The first you need is a pathfinding function/method, then you can start making the AI

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Pacman with SFML
« Reply #6 on: July 03, 2014, 11:34:17 pm »
The ghosts have a set target they want to reach and at every intersection they choose to enter tile that is closer in straight line to target, it's very dumb pathing and can even lead to wrong results:
http://home.comcast.net/~jpittman2/pacman/pacmandossier.html#CH3_Intersections

I have a somewhat badly written pacman that implements that from over a year ago:
https://github.com/FRex/Man/blob/master/src/PacEngine.cpp#L377
Back to C++ gamedev with SFML in May 2023

JuDelCo

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • JuDelCo's Twitter
Re: Pacman with SFML
« Reply #7 on: July 03, 2014, 11:46:09 pm »
I dont recommend you to see my code, because my ghosts behaviours are a bit more advanced/complex, but ill put the line where is the code, just in case other person needs it

https://github.com/JuDelCo/SFML2-Game/blob/master/Game/pacman/PacmanController.cpp#L267

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Pacman with SFML
« Reply #8 on: July 03, 2014, 11:48:33 pm »
The first you need is a pathfinding function/method, then you can start making the AI

I'll take a look on the sourcecode of your pacman... i think it's really cool and is really similar to the original :D it's really interesting how you've done that :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Pacman with SFML
« Reply #9 on: July 03, 2014, 11:53:40 pm »
A quick search for "pacman ai" yields also this:
http://gameinternals.com/post/2072558330/understanding-pac-man-ghost-behavior

Don't hesitate to research further, it's crucial to progress as a game developer :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Pacman with SFML
« Reply #10 on: July 04, 2014, 12:52:03 am »
I made a Pacman-style game as my first game and I used the information found in The Pacman Dossier, which is where information that Nexus linked to originally came from (it's listed in its sources).

I'd recommend starting with Blinky as that ghost takes the simplest route and is easiest to understand. Then, the technique used to make the ghost find its way to where it wants to go can be used for the other ghosts too.

You can visualise the map as a single-width path with double-width walls, rather than a double-width path. This helped me immensely.

I think it it's the only game that I made (complete) so I'd be happy to discuss the innards of it, but I didn't exactly implement everything perfectly (I had no "ghost home") so don't expect too much from me  ;D I spent most of my time with the game adding features to learn more about things, especially SFML, which is why I added a music player and volume controls, language files, etc.. Also, my code is terrible in it; the main() function is about 1700 lines long  :-[
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Pacman with SFML
« Reply #11 on: July 06, 2014, 03:55:17 am »
I made a Pacman-style game as my first game and I used the information found in The Pacman Dossier, which is where information that Nexus linked to originally came from (it's listed in its sources).

I'd recommend starting with Blinky as that ghost takes the simplest route and is easiest to understand. Then, the technique used to make the ghost find its way to where it wants to go can be used for the other ghosts too.

You can visualise the map as a single-width path with double-width walls, rather than a double-width path. This helped me immensely.

I think it it's the only game that I made (complete) so I'd be happy to discuss the innards of it, but I didn't exactly implement everything perfectly (I had no "ghost home") so don't expect too much from me  ;D I spent most of my time with the game adding features to learn more about things, especially SFML, which is why I added a music player and volume controls, language files, etc.. Also, my code is terrible in it; the main() function is about 1700 lines long  :-[

What do you mean with single-width-paths? Sorry if it's a dumb question but I don't really understand... Do you mean the width of the "ways"?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Pacman with SFML
« Reply #12 on: July 07, 2014, 12:50:50 am »
What do you mean with single-width-paths? Sorry if it's a dumb question but I don't really understand... Do you mean the width of the "ways"?
No need to quote the entire post; just quote the part you want to talk about (remove the rest) ;)

You said that your Pacman and ghosts were only the width of a single tile. In your map, you had paths/ways/allowed-tiles as single-width tiles. I was saying that I found that keeping the path/way as single-width, making the walls double-width (that's in the map but actually draw them only filling half of those tiles), and increasing the draw-size of Pacman and the ghosts, even though they are still following the map where the path has is only one tile-width.

I found that it worked for me and I think that it was a bit of a milestone of realisation  8)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*