{"id":13392973,"url":"https://github.com/jmoon018/PacVim","last_synced_at":"2025-03-13T19:31:17.064Z","repository":{"id":23623322,"uuid":"26992831","full_name":"jmoon018/PacVim","owner":"jmoon018","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-23T18:15:25.000Z","size":3272,"stargazers_count":3267,"open_issues_count":21,"forks_count":194,"subscribers_count":57,"default_branch":"master","last_synced_at":"2025-03-08T21:34:53.001Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmoon018.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-22T08:05:10.000Z","updated_at":"2025-03-08T16:02:14.000Z","dependencies_parsed_at":"2024-10-25T09:23:31.964Z","dependency_job_id":"a4518986-8617-46dc-88c8-925a9f015d4b","html_url":"https://github.com/jmoon018/PacVim","commit_stats":{"total_commits":114,"total_committers":10,"mean_commits":11.4,"dds":0.1842105263157895,"last_synced_commit":"ca7c8833c22c5fe97974ba5247ef1fcc00cedb8e"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoon018%2FPacVim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoon018%2FPacVim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoon018%2FPacVim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmoon018%2FPacVim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmoon018","download_url":"https://codeload.github.com/jmoon018/PacVim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243469138,"owners_count":20295694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:00:40.348Z","updated_at":"2025-03-13T19:31:17.053Z","avatar_url":"https://github.com/jmoon018.png","language":"C++","readme":"# PacVim\n\nPacVim is a game that teaches you vim commands.\nYou must move pacman (the green cursor) to highlight each word on the gameboard while avoiding the ghosts (in red).\n\n![my image](https://raw.githubusercontent.com/jmoon018/PacVim/master/gifs/all.gif)\n# Building and running\n\nVim is a great tool to write and edit code, but many \npeople, including me, struggled with the steep learning curve. \nI did not find a fun, free way to learn about the vim commands\nin-depth, and thus, PacVim was born. Inspired by the classic,\nPacMan, \u003cb\u003ePacVim\u003c/b\u003e is a game that'll give anyone plenty of\npractice with the vim commands while being a ton of fun to play.\n\nDownload and build the game with:\n\n## Mac OS X\n`brew install pacvim`\n\n## Linux (and Mac OS X alternative)\n\n1. Download and install Curses (graphics library) \u003cbr\u003e\n\t-\u003e For Ubuntu (in terminal): `sudo apt-get install libncurses5-dev` \u003cbr\u003e\n\t\n\t-\u003e OR [This tutorial](http://geeksww.com/tutorials/operating_systems/linux/tools/how_to_download_compile_and_install_gnu_ncurses_on_debianubuntu_linux.php) may help (have not confirmed)\n\t\n\t-\u003e OR build from source: [Curses source files](http://ftp.gnu.org/pub/gnu/ncurses/)\n\n\t-\u003e Mac OS X should come with Curses installed, so skip this step. \n\t\n\u003c!--\t-\u003e For Mac OS X: Install Homebrew (brew.sh), then use `brew install ncurses \u0026\u0026 brew link ncurses --force`. If you get errors, type `brew tap homebrew/dupes` and try again.--\u003e\n\n\n```\n2. git clone https://github.com/jmoon018/PacVim.git\n3. cd PacVim\n4. [sudo] make install\n```\n\n## Using Docker\n\nIf you have docker installed already, you can just:\n\n```sh\ndocker run -it freedomben/pacvim [LEVEL_NUMBER] [MODE]\n```\n\n### Building the docker image from source\n\nFrom the project root, build the image:\n\n```sh\ndocker build -t freedomben/pacvim .\n```\n\nPush to docker hub:\n\n```sh\ndocker push freedomben/pacvim\n```\n\nTo play, run (from anywhere):\n```\n$ pacvim [LEVEL_NUMBER] [MODE]\n```\nYou may specify the starting level and mode (`n` and `h` for normal/hard). Default mode is hard:\n```\n$ pacvim 8 n\n```\n\nTo Uninstall, navigate to the folder where you cloned this repo, and type `make uninstall` \u003cbr\u003e\nNote: this game may not install/compile properly without gcc version 4.8.X or higher\n\n# How To Play\n\nThe objective of PacVim is very similar to PacMan.\nYou must run over all the characters on the screen while avoiding the ghosts (red `G`).\nPacVim has two special obstacles:\n\n1. You cannot move into the walls (yellow color).  You must use vim motions to jump over them.\n\n2. If you step on a tilde character (cyan `~`), you lose!\n\nYou are given three lives. You gain a life each time you beat\nlevel 0, 3, 6, 9, etc. There are 10 levels, 0 through 9. After\nbeating the 9th level, the game is reset to the 0th level, but\nthe ghosts move faster.\n\n\u003cb\u003eWinning conditions:\u003c/b\u003e Use vim commands to move the cursor\nover the letters and highlight them. After all letters are\nhighlighted, you win and proceed to the next level.\n\n\u003cb\u003eLosing conditions:\u003c/b\u003e If you touch a ghost (indicated\nby a red `G`) or a tilde character, you lose a life. If you\nhave less than 0 lives, you lose the entire game.\n\n\u003ch4\u003eList of Implemented Commands\u003c/h4\u003e\n\n| key | what it does |\n| --- | --- |\n| q   | quit the game |\n| h   | move left |\n| j   | move down |\n| k   | move up |\n| l   | move right |\n| w   | move forward to next word beginning |\n| W   | move forward to next WORD beginning |\n| e   | move forward to next word ending |\n| E   | move forward to next WORD ending |\n| b   | move backward to next word beginning |\n| B   | move backward to next WORD beginning |\n| $   | move to the end of the line |\n| 0   | move to the beginning of the line |\n| gg/1G | move to the beginning of the first line |\n| *number*G | move to the beginning of the line given by *number* |\n| G   | move to the beginning of the last line |\n| ^   | move to the first word at the current line |\n| \u0026   | 1337 cheatz (beat current level)\n\n\n# Create Your Own Map! \n\nThe maps for \u003cb\u003ePacVim\u003c/b\u003e are loaded from text files from\nthe \u003ci\u003e/usr/local/share/pacvim-maps\u003c/i\u003e folder. After installing, you may, instead, use the *maps* folder (where you installed\nthe game) by calling `make MAPDIR=maps`.\n\nThe name of each text file must be\nin a format such as: `map#.txt`, where `#` represents a number like\n0, 1, 9, 14, etc. The numbers must be consecutive (can't have map0.txt,\nmap1.txt, and then map3.txt). \u003cb\u003eMAKE SURE YOU CHANGE THE NUM_OF_LEVELS \nIN GLOBALS.CPP OR ELSE YOUR NEW MAPS WON'T LOAD\u003c/b\u003e. It should be equal\nto the highest map number.\n\nIn the map text file, the walls are denoted by ampersands `#`, and the\ntildes come just from the tilde key. Maps must be bounded and closed,\nso the player is trapped within 4 walls. Make sure walls block the top\nand left of the terminal (or else the player goes offscreen). Any\nshape, height, and width, within these constraints, should work\n\n\u003cb\u003eCreating Ghosts and Players\u003c/b\u003e\u003cbr\u003e\nAt the bottom of each map text file, parameters about the Ghost(s)\nand Players are specified\n\n\u003cb\u003eGhost:\u003c/b\u003e\u003cbr\u003e\n`/# X Y` ... EG: `/0.5 1 1`\u003cbr\u003e\nThe forward slash denotes that this information describes a Ghost (instead of player).\u003cbr\u003e\nThe # denotes the time, in seconds, it takes for the Ghost to move. (#=0.5 means 2 moves/sec)\u003cbr\u003e\nX and Y denote the starting x- and y-position of the Ghost\u003cbr\u003e\n\n\u003cb\u003ePlayer:\u003c/b\u003e \u003cbr\u003e\n`pX Y` ... EG: `p15 7`\nThe 'p' denotes that this information describes a Player (instead of Ghost).\u003cbr\u003e\nThe X and Y denote the starting x- and y-position of the Player. \u003cbr\u003e\n\u003cb\u003eThis is optional\u003c/b\u003e, the player spawns in the middle of the map otherwise\u003cbr\u003e\n\u003cb\u003eThis should be the last line of the file\u003c/b\u003e\u003cbr\u003e\n \n\u003ch2\u003eCode Overview\u003c/h2\u003e\n\n\u003ch4\u003eavatar.cpp\u003c/h4\u003e\nContains the \u003cb\u003e`avatar`\u003c/b\u003e class, which contains information about\nthe player, such as his/her x position, y position, etc. It\nalso contains methods that allow the player to move and correspond\nto the keystrokes. For example, the \u003cb\u003e`avatar`\u003c/b\u003e class contains the method\ncalled \u003cb\u003e`parseWordForward(bool)`\u003c/b\u003e which implements the functionality\nfor the \"w\" (or \"W\" if true) vim command.\n\n\u003ch4\u003eghost1.cpp\u003c/h4\u003e\nContains the \u003cb\u003eGhost1\u003c/b\u003e class, derived from the \u003cb\u003e`avatar`\u003c/b\u003e class. It is\njust like the avatar class, but it requires an extra paremeter\nupon initialization, called `sleepTime`, a double value that\ndetermines how quickly a ghost moves. It refers to the time, in\nseconds, the ghost must wait to move. A `sleepTime` of 0.5 means\nthe ghost moves 2 times a second. `sleepTime` = 0.33 is 3 moves per second, etc.\n\u003cbr\u003e\nThe `Ghost1` class also contains a method called \u003cb\u003e`spawnGhost`\u003c/b\u003e which\ncreates the ghost at the location based on its initialization parameters.\nThe ghost will appear when `READY` (global bool) is true (this means the player\nis ready), and it will call \u003cb\u003e`ghost.think()`\u003c/b\u003e one second afterwards.\n\u003cbr\u003e\n`think` is a recursive method that simply moves the ghost. It uses \na basic greedy algorithm based on the distance of the ghost's potential\nmoves (up, down, right, left) and the player.\n\u003cbr\u003e\n\nEach ghost contains its own thread. A global mutex, called `mtx`, is\nused (in `think`) to ensure that resources are shared properly.\n\n`helperFns.cpp`\nContains methods that allow easy changes of the screen. A few of them:\n\n* `chtype charAt(int x, int y)` returns the chtype at the (x,y) location\n* `bool writeAt(int x, int y, chtype letter)` writes the 'letter' at location (x,y). Returns false if location is invalid.\n* `void printAtBottom(string msg)`  writes a message one line below the last line\n\n\u003ch4\u003egame.cpp\u003c/h4\u003e\nThis contains the \u003ci\u003emain()\u003c/i\u003e method among many other important ones\n\n\u003cb\u003emain\u003c/b\u003e - contains a loop that breaks when `LIVES` \u003c 0. In the loop,\nthe proper map name is determined and loaded. Data is reset (such as as the pointers,\nthe ghost AI, etc). The level is incremented.\n\u003cbr\u003e\n\u003cb\u003einit(const char*)\u003c/b\u003e - called by \u003cb\u003e`main`\u003c/b\u003e. Calls \u003cb\u003e`drawScreen(str map)`\u003c/b\u003e, creates and\nspawns player and ghosts threads. Then calls \u003cb\u003e`playGame`\u003c/b\u003e. After \u003cb\u003e`playGame`\u003c/b\u003e\nends, all the ghost threads are deleted, and then we go back to the \u003cb\u003e`main`\u003c/b\u003e method.\n\u003cbr\u003e\n\u003cb\u003edrawScreen(char* map)\u003c/b\u003e - called by \u003cb\u003e`init`\u003c/b\u003e. Reads from text file given\nby parameter. Loads everything onto the screen with the proper color and gets\ninformation from the ghost and player so that they spawn in the proper place in \u003cb\u003e`init`\u003c/b\u003e.\n\u003cbr\u003e\n\u003cb\u003eplayGame(time_t, avatar player)\u003c/b\u003e - called by \u003cb\u003e`init`\u003c/b\u003e. This contains two loops,\none that consumes everything in the input buffer (which is then deleted), the second\nloop allows the player to continuously input keystrokes. When a keystroke is input,\n\u003cb\u003e`onKeystroke`\u003c/b\u003e is called\n\u003cbr\u003e\n\n\n\u003ch2\u003e\u003ca name=\"ToDoBugsTag\"\u003eTo-dos / Bugs\u003c/a\u003e\u003c/h2\u003e\n\u003cul\u003e\n\t\u003cli\u003eMore testing on `#G` and `G` commands\u003c/li\u003e\n\t\u003cli\u003eG can go out of bounds on Map 8 with the boxes. #G (between boxes)\u003c/li\u003e\n\t\u003cli\u003eG won't move to proper line, it can hit the last wall rather than the last word (map2)\u003c/li\u003e\n\t\u003cli\u003eRefactor code, more comments\u003c/li\u003e\n\u003c/ul\u003e\n\n\n\u003ch2\u003eLICENSE\u003c/h2\u003e\nPacVim is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License (LGPL) as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nPacVim is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","funding_links":[],"categories":["C++","Uncategorized","Learning Vim"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmoon018%2FPacVim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmoon018%2FPacVim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmoon018%2FPacVim/lists"}