Giter VIP home page Giter VIP logo

pacman's Introduction

Pacman

in-game screenshot

This is a clone of the original pacman by Namco, as I remember, that I played for the first time on an Atari 130 XL in the early 90s.

Also, Paul Neave's pacman clone has inspired me greatly.

One of the main goals of this implementation is an SDL application with a very low CPU usage.

Install hint

You have to compile the Linux version on your own. For this, you'll need

  • libsdl2
  • sdl2-image
  • sdl2-ttf
  • and sdl2-mixer.

(make sure to take the devel packages) Then, download and extract the zip file or clone the pacman repository. Inside the pacman directory, run

./configure
make
make install

For more detailed instructions, you may also have a look at the INSTALL file.

After a successful installation, you should be able to start the game via command line: pacman

Install Fedora

sudo dnf install make gcc-c++ SDL2 SDL2-devel SDL2_image SDL2_image-devel SDL2_mixer SDL2_mixer-devel SDL2_ttf SDL2_ttf-devel

Then, download and extract the zip file or clone the pacman repository. Inside the pacman directory, run

./autogen.sh
./configure
make
make install

License

Pacman is licensed under the terms of the GNU General Public License version 2 (or any later version).

pacman's People

Contributors

borgified avatar ebuc99 avatar keithbowes avatar p-martin avatar serdarsaglam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pacman's Issues

Compilation problem in highscore.cpp

Thanks for sharing this great implementation of Pacman. I have used it to test a port of SDL2 to QNX 7 and it works really well.

I did encounter a problem while building the code, though. Line 621 in highscore.cpp is generating an error:

highscore.cpp: In member function 'void HighscoreList::load()':
highscore.cpp:621:27: error: operands to ?: have different types 'bool' and 'std::__1::basic_istream<char>'
    while (fileIsEncrypted ? readEncryptedLine(f, line) : std::getline(f, line)) {

The error can be fixed with the following patch, which wraps std::getline() with a function that returns bool:

diff --git a/src/highscore.cpp b/src/highscore.cpp
index 47baa78..a3a26da 100644
--- a/src/highscore.cpp
+++ b/src/highscore.cpp
@@ -586,6 +586,11 @@ bool HighscoreList::readEncryptedLine(std::ifstream &f, std::string &line) {
        }
 }
 
+bool HighscoreList::readLine(std::ifstream &f, std::string &line) {
+    std::getline(f, line);
+    return (line.length() > 0);
+}
+
 void HighscoreList::load() {
        if (readonly)
                return;
@@ -618,7 +623,7 @@ void HighscoreList::load() {
                if (f.is_open()) {
                        std::string line;
                        uint8_t linesRead = 0, validLines = 0;
-                       while (fileIsEncrypted ? readEncryptedLine(f, line) : std::getline(f, line)) {
+                       while (fileIsEncrypted ? readEncryptedLine(f, line) : readLine(f, line)) {
                                if (line.length() >= 1) {
                                        ++linesRead;
                                        std::string::size_type pos = line.find('|');
diff --git a/src/highscore.h b/src/highscore.h
index 8b3069f..88c26d4 100644
--- a/src/highscore.h
+++ b/src/highscore.h
@@ -49,6 +49,7 @@ class HighscoreList {
                void draw(bool nameAlterable, bool highlightLast);
                bool eventloop(bool nameAlterable, bool *redrawNeeded);
                bool readEncryptedLine(std::ifstream &f, std::string &line);
+               bool readLine(std::ifstream &f, std::string &line);
                uint8_t maxSize;
                std::vector<HighscoreEntry*> *entries;
                int idxLastInsertedEntry, idxHighlightedEntry;

I also had to remove -lpthread from Makefile.am. This is a Linux-specific library (QNX has pthread support in the C library). It may be better to enhance the configuration script to detect that.

--Elad

TODO

  • code review
  • ghost hunting mode after eating super pills
  • the bonus fruits
  • pacman life counting
  • new level after eating all pills
  • sounds
  • start screen with some configurations

add autogen.sh

add autogen.sh in root dir:

!/bin/sh

aclocal && automake --add-missing --copy && autoconf

Gamepad

hi, i want to play with gamepad, what should i do

ghosts are rendered as eyes only, no color is shown

OS: Ubuntu 18.0.4
SDL version: 2.0
gcc version: 7.4.0

The ghosts are rendered as eyes only, no ghost color is shown (see screenshot).

pacman_actual

This is because the black background on augen_0.png, augen_1.png, augen_2.png, and augen_3.png are not set to transparent. I think it is a conflict between the transparent index that you have set for the ghost images (255) and the eye images (0).

The fix I employed was:

    1. Insert the following at line 195 of src/screen.cpp: SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
  1. Modify the augen_?.png files so that alpha=0 for the background
  2. Change the last argument of lines 65-68 of src/ghost_figur.cpp from 0 to -1.

There is a similar bug affecting gfx/escaping_ghost_?.png.

I have these fixes in a branch. I'll send it to you if you are interested, or push it if you grant access to me.

This is the result of my fix:
pacman_expected

Add a .desktop file

It would be cool if a simple .desktop file could be included with the distribution. Here is the one I have now:

[Desktop Entry]
Name=Pacman (SDL)
Comment=Yet another pacman clone in C/C++ and SDL
Exec=pacman
Icon=pacman
Type=Application
Categories=Game;ArcadeGame;

And this is the icon I am using:

pacman

Different levels

Hi.
Level 1 or 2 are just the same thing and this makes the game boring.

extra life per x points

here is a simple patch for adding per 10000 points life

diff --git a/src/game.cpp b/src/game.cpp
index c8c7567..23d3376 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -325,7 +325,9 @@ bool Game::checkLastPillEaten() {
 void Game::checkScoreForExtraLife() {
 	int lastScore = currentScore;
 	currentScore = Labyrinth::getInstance()->getScore();
-	if ((lastScore<10000 && currentScore>=10000) || (lastScore<30000 && currentScore>=30000)) {
+	int target = ( ( currentScore / 10000 ) * 10000 ) ;
+
+	if (lastScore<target && currentScore>=target){
 		Pacman::getInstance()->addLives(1);
 		Sounds::getInstance()->playSingleSound(Sounds::EXTRA_MAN);
 	}

also, pacman_sdl-ebuc99-git is an AUR package for this repo

Can't build on Windows

I'm using MSYS2, and the build currently fails. The cause might be a misconfiguration of the project, leading to G++ trying to link with WinMain (it is not present in SDL2 and any of it's sub-libraries).

Here are the errors I get when trying to make : https://pastebin.com/pXzf8gnm

License for fonts

Please, can you verify license for your included fonts?
Are these fonts:

  • pacman/data/fonts/comic.ttf
  • pacman/data/fonts/comicbd.ttf

from MS? If so, they doesn't distributed under GNU GPLv2.

Thanks for your attention!

Icon not correctly handled

Hi! Thanks for providing a great Pacman game!

The icon isn't really correctly handled on Linux. The correct way of doing it is putting the icon in to /usr/share/icons and then setting the icon in the .desktop file to be just pacman. This will let icon themes that have a pacman icon use that and if the icon theme doesn't have one, then it will use your icon.

Link for more information:
https://askubuntu.com/questions/435603/desktop-files-how-to-specify-the-icon-path

Example of Qsynth where it puts it's icons:
https://dev.getsol.us/source/qsynth/browse/master/pspec_x86_64.xml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.