├── .gitignore ├── COPYING ├── ChangeLog ├── Levels ├── README ├── level01.dat ├── level02.dat ├── level03.dat ├── level04.dat ├── level05.dat ├── level06.dat ├── level07.dat ├── level08.dat ├── level09.dat └── template.dat ├── Makefile ├── README ├── README.md ├── pacman.c ├── pacman.h ├── pacmanedit.c └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | pacman 2 | pacmanedit 3 | *~ 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | Pacman for Console 2 | 3 | 2014-02-01 4 | 5 | - fixed several bugs: buffer overflow, indices out of bounds, error check 6 | - improved Makefile: notably a better parameterization allowing a non-admin 7 | installation 8 | 9 | 2006-12-12 - 1.2 10 | 11 | - added a simple level editor 12 | - fixed error messages on GCC 2.96 - Thanks to Gerald Schnabel 13 | - added introduction screen 14 | - invincibility is deactivates once level is complete 15 | 16 | 2006-12-08 - 1.1 17 | 18 | - fixed warning messages on GCC 4.1 19 | - changed background color of blue ghosts to make them more visible 20 | 21 | 2006-06-09 - 1.0 22 | 23 | - initial release 24 | 25 | 26 | Future Releases: 27 | ---------------- 28 | 1) Different sized mazes 29 | 2) Multiplayer 30 | 3) Extensive comments in code for beginner programmers 31 | 4) World domination 32 | 33 | -------------------------------------------------------------------------------- /Levels/README: -------------------------------------------------------------------------------- 1 | The included level editor (pacmanedit) isn't very difficult to learn to use, 2 | the status bar tells you everything you need to know but here are the keys 3 | 4 | UDLR or WSAD: Move cursor 5 | F: Fills all blank spaces with pellets 6 | C: Clears all pellets from board 7 | Q: Saves and quits 8 | CTRL+C: Quits WITHOUT saving 9 | 10 | Key Inserts 11 | ----------------------- 12 | 0 or space: Blank 13 | 1: Wall 14 | 2: Pellet 15 | 3: Powerup 16 | 4: Ghost/Spawning Wall 17 | 5: Blinky 18 | 6: Inkey 19 | 7: Clyde 20 | 8: Pinky 21 | 9: Pacman 22 | 23 | 24 | *) The spawning wall is a wall that the ghosts can go through but Pacman 25 | cannot. These can be used to make levels REALLY difficult. Check level 09 26 | 27 | *) Borders shouldn't need to be used, but give it a more Pacman-like feel. 28 | If a ghost or Pacman are able to reach the very edge of the board, he will 29 | be teleported to the opposite side of the level, both X and Y just like in 30 | the regular game. 31 | 32 | *) See any included level__.dat file for examples. 33 | 34 | 35 | To edit a new or existing level, type: 36 | $ pacmanedit new_or_old_level.dat 37 | 38 | 39 | To load a custom level, run pacman with the level file as the parameter: 40 | $ pacman levelfile.dat 41 | -------------------------------------------------------------------------------- /Levels/level01.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 | 1 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2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 1 2 1 1 1 1 1 1 20 | 1 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 1 21 | 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 2 1 22 | 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 2 1 23 | 1 3 2 2 1 1 2 2 2 2 2 2 2 2 9 2 2 2 2 2 2 2 1 1 2 2 3 1 24 | 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 1 25 | 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 1 26 | 1 2 2 2 2 2 2 1 1 2 2 2 2 1 1 2 2 2 2 1 1 2 2 2 2 2 2 1 27 | 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 28 | 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 30 | 1 31 | -------------------------------------------------------------------------------- /Levels/level02.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 2 | 1 2 2 2 2 2 2 3 1 0 0 0 1 2 1 0 0 0 1 3 2 2 2 2 2 2 2 1 3 | 1 2 1 1 1 1 1 2 1 0 0 0 1 2 1 0 0 0 1 2 1 1 1 1 1 1 2 1 4 | 1 2 1 0 0 0 1 2 1 1 1 1 1 2 1 1 1 1 1 2 1 0 0 0 0 1 2 1 5 | 1 2 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 2 1 6 | 1 2 2 2 2 2 2 2 1 1 1 1 1 2 1 1 1 1 1 2 2 2 2 2 2 2 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24 | 1 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 2 1 25 | 1 2 2 3 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 2 2 2 1 26 | 1 2 1 1 1 2 1 2 1 0 0 0 1 2 1 0 0 0 1 2 1 1 2 1 1 1 2 1 27 | 1 2 1 1 1 2 1 2 1 0 0 0 1 2 1 1 1 1 1 2 1 1 2 1 1 1 2 1 28 | 1 2 2 2 2 2 2 2 1 0 0 0 1 2 2 2 2 2 2 2 1 1 2 2 2 2 2 1 29 | 1 1 1 1 1 1 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 30 | 2 31 | -------------------------------------------------------------------------------- /Levels/level03.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 | 0 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 3 2 2 0 3 | 1 2 1 1 1 1 2 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 1 1 2 1 1 1 4 | 1 2 1 0 0 1 2 1 0 0 1 2 1 2 1 2 2 2 2 2 1 2 2 2 2 2 2 1 5 | 1 2 1 1 1 1 2 1 1 1 1 2 1 2 1 2 1 1 1 2 1 2 1 1 1 1 2 1 6 | 1 2 2 2 2 2 2 2 2 2 2 9 1 2 2 2 2 2 2 2 1 2 1 0 0 1 2 1 7 | 1 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 2 1 2 1 0 0 1 2 1 8 | 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 1 1 1 2 1 9 | 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 2 2 2 2 1 10 | 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 2 1 1 11 | 1 2 1 2 1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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 1 29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 30 | 3 31 | -------------------------------------------------------------------------------- /Levels/level04.dat: -------------------------------------------------------------------------------- 1 | 1 0 1 0 0 0 1 0 1 1 1 1 1 4 1 1 1 1 0 1 0 1 1 1 1 1 1 1 2 | 0 2 1 0 0 0 1 3 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 0 3 | 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 | 0 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 0 5 | 1 2 4 2 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 4 1 6 | 1 2 1 2 2 2 2 2 1 2 1 1 1 1 2 1 1 1 1 2 1 2 1 0 4 0 5 1 7 | 1 2 1 1 1 1 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 1 0 6 1 8 | 1 2 2 2 3 2 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 0 1 0 7 1 9 | 1 2 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 2 2 2 2 2 2 0 4 0 8 1 10 | 1 2 1 2 1 2 4 2 1 2 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 11 | 0 2 1 2 1 2 1 2 2 2 1 1 2 2 2 3 2 2 2 2 1 2 1 2 2 2 2 0 12 | 1 1 1 2 2 2 1 2 1 2 2 2 2 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 13 | 0 2 1 1 1 1 1 2 1 1 1 2 1 1 2 2 2 2 1 2 2 2 1 2 2 2 2 0 14 | 1 2 1 2 3 2 1 2 2 2 1 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 15 | 0 2 1 2 1 2 1 1 1 2 1 1 1 1 2 1 1 2 2 2 1 2 9 2 2 2 2 0 16 | 1 1 1 2 1 2 2 2 1 2 2 2 2 2 2 1 1 1 1 2 1 2 1 1 1 1 1 1 17 | 0 2 1 2 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2 1 2 2 2 2 2 2 0 18 | 1 2 2 2 2 2 2 2 1 0 0 0 1 2 2 2 2 2 1 2 1 1 1 1 1 1 1 1 19 | 1 1 1 2 1 1 1 1 1 1 1 0 1 2 1 1 1 2 2 2 1 0 0 1 2 2 2 1 20 | 0 2 2 2 2 2 2 2 2 2 1 0 1 2 2 2 2 1 1 1 1 1 1 1 2 1 2 0 21 | 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 2 2 2 2 2 2 2 1 1 1 22 | 0 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 1 3 1 1 1 1 1 2 1 2 0 23 | 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 2 1 2 2 2 2 2 2 2 1 2 1 24 | 0 2 2 2 2 2 1 2 1 2 2 2 2 2 2 1 2 1 2 1 1 1 1 1 2 1 2 0 25 | 1 1 1 1 1 3 1 2 2 2 1 2 1 2 1 1 2 1 2 1 2 2 2 1 2 1 1 1 26 | 0 2 2 2 2 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 2 0 27 | 1 1 1 1 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 2 1 28 | 1 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 1 2 1 2 1 2 2 2 2 2 1 29 | 1 0 1 1 1 1 1 0 1 1 1 1 1 4 1 1 1 1 0 1 0 1 1 1 1 1 1 1 30 | 4 31 | -------------------------------------------------------------------------------- /Levels/level05.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 2 | 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2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 2 1 2 1 2 1 20 | 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 21 | 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 22 | 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 23 | 1 2 2 1 1 1 2 1 2 2 2 1 2 2 1 1 1 2 1 2 2 1 2 2 1 1 1 1 24 | 1 2 1 2 2 2 2 1 2 3 2 1 2 1 2 2 2 2 1 2 1 2 2 1 0 0 0 1 25 | 1 2 2 1 1 2 2 1 2 2 2 1 2 1 2 2 2 2 1 1 2 2 2 2 1 1 0 1 26 | 1 2 2 2 2 1 2 1 2 2 2 1 2 1 2 2 2 2 1 2 1 2 2 2 2 2 1 1 27 | 0 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 1 2 0 28 | 1 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 9 2 2 2 2 2 2 3 1 29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 30 | 5 31 | -------------------------------------------------------------------------------- /Levels/level06.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 2 | 0 2 1 2 2 2 1 2 1 2 2 2 2 2 2 2 9 1 2 1 2 1 2 1 3 2 2 0 3 | 1 2 1 1 1 2 1 2 1 1 1 1 1 1 1 2 1 1 2 1 2 1 2 1 2 1 2 1 4 | 1 2 2 2 2 2 1 2 1 2 2 2 2 2 1 2 1 2 2 1 2 1 2 1 2 1 2 1 5 | 1 2 1 1 1 1 1 2 1 2 1 1 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 6 | 1 2 1 2 2 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 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1 1 2 2 2 1 2 1 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 25 | 1 1 4 4 1 1 2 1 2 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 2 1 26 | 1 1 7 8 1 1 2 1 2 1 2 2 2 3 2 2 2 1 2 1 2 2 2 3 2 2 2 1 27 | 1 1 1 1 1 2 2 1 2 1 1 2 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 1 28 | 0 2 2 2 1 2 1 2 2 2 1 2 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 0 29 | 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 30 | 6 31 | -------------------------------------------------------------------------------- /Levels/level07.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 | 1 2 2 2 2 2 2 2 2 2 2 2 2 4 4 2 2 2 2 2 2 2 2 2 2 2 2 1 3 | 1 2 1 1 1 1 2 1 1 4 1 1 2 1 1 2 1 1 4 1 1 2 1 1 1 1 2 1 4 | 1 3 1 0 0 1 2 1 1 0 1 1 2 0 0 2 1 1 0 1 1 2 1 0 0 1 3 1 5 | 1 2 1 0 0 1 2 1 1 0 1 1 2 1 1 2 1 1 0 1 1 2 1 0 0 1 2 1 6 | 1 2 1 1 1 1 2 1 1 4 1 1 2 1 1 2 1 1 4 1 1 2 1 1 1 1 2 1 7 | 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 8 | 1 2 1 4 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 4 1 2 1 9 | 1 2 1 4 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 4 1 2 1 10 | 1 2 2 2 2 2 2 1 1 2 2 2 2 1 1 2 2 2 2 1 1 2 2 2 2 2 2 1 11 | 1 1 1 1 1 1 2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 2 2 2 2 4 2 2 2 2 2 2 2 2 2 2 2 2 2 1 29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 30 | 7 31 | -------------------------------------------------------------------------------- /Levels/level08.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 0 1 2 | 0 2 2 2 2 2 2 2 2 2 2 2 4 2 4 2 4 2 2 2 2 2 2 2 2 4 2 0 3 | 1 4 1 4 1 1 1 1 1 1 1 2 1 2 1 2 1 2 1 1 1 1 1 1 1 1 4 1 4 | 1 0 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 2 2 1 1 2 2 2 1 5 | 1 0 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 6 | 1 4 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 4 2 1 2 1 7 | 1 7 4 2 1 2 2 2 1 2 2 2 1 2 1 2 4 2 1 2 1 2 1 2 2 1 2 1 8 | 1 4 1 2 1 4 1 1 1 4 1 1 1 2 1 2 1 2 1 2 1 2 1 2 4 1 2 1 9 | 1 2 2 2 2 2 2 2 2 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 2 1 2 1 10 | 1 2 1 1 1 1 1 1 1 2 1 2 1 1 1 2 1 2 1 2 1 2 1 4 2 1 2 1 11 | 1 2 2 2 2 2 2 2 2 2 2 9 2 2 2 2 1 2 1 2 1 2 1 2 2 4 2 1 12 | 1 2 1 1 1 1 1 1 1 1 1 2 1 4 1 1 1 2 1 2 1 2 1 2 1 1 2 1 13 | 1 2 1 2 2 2 2 2 2 2 1 2 1 4 1 2 2 2 1 2 1 2 1 2 1 2 2 1 14 | 1 2 1 2 1 4 1 1 1 2 1 2 1 2 2 2 1 1 1 2 1 2 2 2 1 2 1 1 15 | 1 2 1 2 1 2 2 2 1 2 1 2 1 2 1 1 1 2 2 2 1 4 1 1 1 2 1 1 16 | 1 2 1 2 2 2 1 2 1 2 4 2 1 2 2 2 1 2 1 1 1 2 2 2 1 2 2 1 17 | 1 2 1 1 1 4 1 2 1 2 1 2 1 1 1 2 1 2 1 2 2 2 1 2 2 1 2 1 18 | 1 2 2 2 2 2 2 2 1 2 1 2 2 2 2 2 1 2 1 2 1 1 1 1 2 1 2 1 19 | 1 2 1 1 1 1 1 4 1 2 1 2 1 1 1 1 1 2 1 2 1 0 0 1 2 1 2 1 20 | 1 2 2 2 2 2 2 2 2 2 1 2 4 2 2 2 2 2 1 2 1 1 1 1 2 1 2 1 21 | 1 1 1 1 1 4 1 1 1 1 1 2 1 1 1 1 1 2 1 2 2 1 2 2 2 1 2 1 22 | 0 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 2 1 2 1 2 0 23 | 1 1 1 1 1 4 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 1 24 | 0 2 2 2 2 2 2 2 2 2 1 2 1 2 1 2 1 1 2 2 2 2 2 2 2 2 2 0 25 | 1 1 1 1 1 1 1 1 1 4 1 2 1 2 1 2 1 0 1 4 4 1 1 1 1 4 1 1 26 | 1 8 4 2 2 2 2 2 2 2 2 2 4 2 4 2 1 0 1 5 6 1 2 2 2 2 2 1 27 | 1 4 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 2 1 1 1 2 1 28 | 1 2 2 2 2 2 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 0 1 30 | 8 31 | -------------------------------------------------------------------------------- /Levels/level09.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 | 1 2 2 2 2 2 2 2 2 2 9 2 2 2 2 2 2 2 2 2 2 2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 2 1 2 1 20 | 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 21 | 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 22 | 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 23 | 1 2 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 24 | 1 2 1 4 1 4 1 4 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 25 | 1 2 3 2 2 2 2 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 26 | 1 4 1 4 1 4 1 4 1 2 1 2 1 2 1 2 2 2 1 2 1 2 1 1 2 1 2 1 27 | 1 0 1 0 1 0 1 0 1 2 1 2 1 2 1 1 1 1 1 2 1 2 1 1 2 1 2 1 28 | 1 5 1 6 1 7 1 8 1 2 3 2 4 2 2 2 2 2 2 2 2 2 2 2 2 2 3 1 29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 30 | 9 31 | -------------------------------------------------------------------------------- /Levels/template.dat: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 | 1 1 3 | 1 1 4 | 1 1 5 | 1 1 6 | 1 1 7 | 1 1 8 | 1 1 9 | 1 1 10 | 1 1 11 | 1 1 12 | 1 1 13 | 1 1 14 | 1 1 15 | 1 1 16 | 1 1 17 | 1 1 18 | 1 1 19 | 1 1 20 | 1 1 21 | 1 1 22 | 1 1 23 | 1 1 24 | 1 1 25 | 1 1 26 | 1 1 27 | 1 1 28 | 1 1 29 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 30 | 1 31 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | bindir=$(prefix)/bin 3 | datarootdir=$(prefix)/share 4 | 5 | all: 6 | gcc pacman.c -o pacman -DDATAROOTDIR=\"$(datarootdir)\" $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lncurses 7 | gcc pacmanedit.c -o pacmanedit -DDATAROOTDIR=\"$(datarootdir)\" $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lncurses 8 | 9 | install: all 10 | mkdir -p $(DESTDIR)$(bindir) 11 | cp pacman $(DESTDIR)$(bindir) 12 | cp pacmanedit $(DESTDIR)$(bindir) 13 | mkdir -p $(DESTDIR)$(datarootdir)/pacman 14 | cp -fR Levels/ $(DESTDIR)$(datarootdir)/pacman/ 15 | -chown root:games $(DESTDIR)$(bindir)/pacman 16 | -chown root:games $(DESTDIR)$(datarootdir)/pacman -R 17 | chmod 750 $(DESTDIR)$(bindir)/pacman 18 | chmod 750 $(DESTDIR)$(bindir)/pacmanedit 19 | chmod 750 $(DESTDIR)$(datarootdir)/pacman/ -R 20 | 21 | uninstall: 22 | rm -f $(DESTDIR)$(bindir)/pacman 23 | rm -f $(DESTDIR)$(bindir)/pacmanedit 24 | rm -f $(DESTDIR)$(datarootdir)/pacman/Levels/level0[1-9].dat 25 | rm -f $(DESTDIR)$(datarootdir)/pacman/Levels/README 26 | rm -f $(DESTDIR)$(datarootdir)/pacman/Levels/template.dat 27 | if [ -e $(DESTDIR)$(datarootdir)/pacman/Levels/ ] ; then rmdir $(DESTDIR)$(datarootdir)/pacman/Levels/ ; fi 28 | if [ -e $(DESTDIR)$(datarootdir)/pacman/ ] ; then rmdir $(DESTDIR)$(datarootdir)/pacman/ ; fi 29 | 30 | clean: 31 | rm -f pacman 32 | rm -f pacmanedit 33 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Pacman For Console 2 | ================== 3 | Okay, so basically, I got tired of enabling flash on my browser so that I could 4 | play Pacman. That, and I was extremely bored one night. So I decided to make 5 | my own Pacman... for Console. 6 | 7 | Licensing Information 8 | --------------------- 9 | See `COPYING` for details on the GNU/GPL version 2. 10 | 11 | Compile/Install/Run 12 | ------------------- 13 | To make... gee... let's see... type `make`. 14 | To install... type `make install`. 15 | To run... type `pacman [level_#]` where \# is 1-9, for a premade level, 16 | or type `pacmac [level_file_name]` for a custom level you made. 17 | To uninstall... type `make uninstall`. 18 | i.e.: 19 | > make && su -c "make install" 20 | > pacman 3 # Start @ level 3 21 | > pacman /usr/local/share/pacman/Levels/level07.dat # Play only level 7 22 | > echo ":-( I don't like it." && make uninstall # Uninstall :-( 23 | 24 | The ASCII art 25 | ------------- 26 | 27 | + `C` - Pacman - That's you. 28 | + `&` - Ghosts - Boo. 29 | + `.` - Pellet - Yummy. Collect all of them to pass to the next level. 30 | + `*` - Power pellet - Makes you invincible for a short while. 31 | + Wall - No one can walk through it. 32 | + Blocker - A.K.A. Ghost wall. Only the Ghosts can walk through this. 33 | 34 | ![See the screenshot.](screenshot.png "Screenshot") 35 | 36 | 13 Basic Playing Rules 37 | ---------------------- 38 | In case you don't know the rules of Pacman (rules I programmed in), here are 39 | most of them: 40 | 41 | 1. Pacman must collect all the pellets of food in the maze. 1 point per pellet. 42 | 2. Big pellets make Pacman invincible for a short amount of time. 43 | 3. If Pacman touches a ghost without being invincible, you die and lose 1 life. 44 | 4. If Pacman touches a ghost while invincible, the ghost is sent back to his 45 | starting point. 46 | 5. Points are awarded for each ghost eaten in a row while invincible: 20, 40, 47 | 80, 160 (10\*2^x). 48 | 6. Pacman cannot go through the Ghost Walls (Blockers). 49 | 7. Ghosts, cannot turn completely around unless there is no other option. 50 | 8. While Pacman is invincible, Ghosts will be a bit slower and tend to stay 51 | away from him. 52 | 9. While Pacman is NOT invincible, Ghosts will tend to come toward him. 53 | 10. Pacman starts with 3 extra lives, once all three are gone, the game is 54 | over. 55 | 11. Extra lives are awarded at 1000 points, 2000, 4000, 8000... (500\*2^[x]). 56 | 12. If any character reaches a border of the maze, he will be transported to 57 | the opposite side. 58 | 13. Each character can only go in one X or Y direction at a time. 59 | 60 | The keys used are UP, DOWN, LEFT, RIGHT or W, S, A, D. 61 | 62 | To make your own levels, see `Levels/README`. 63 | 64 | Contact Information 65 | ------------------- 66 | Send comments and levels you have made to `doctormike@gmail.com`. 67 | 68 | There is a [homepage](https://sites.google.com/site/doctormike/pacman.html). 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | README -------------------------------------------------------------------------------- /pacman.c: -------------------------------------------------------------------------------- 1 | /**************************************************** 2 | * Pacman For Console V1.2 * 3 | * By: Rev. Dr. Mike Billars (doctormike@gmail.com) * 4 | * Date: 2006-12-12 * 5 | * * 6 | * Please see file COPYING for details on licensing * 7 | * and redistribution of this program * 8 | * * 9 | ****************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "pacman.h" 17 | 18 | #define EXIT_MSG "Good bye!" 19 | #define END_MSG "Game Over" 20 | #define QUIT_MSG "Bye" 21 | #define LEVEL_ERR "Cannot find level file: " 22 | 23 | void IntroScreen(); //Show introduction screen and menu 24 | void CheckCollision(); //See if Pacman and Ghosts collided 25 | void CheckScreenSize(); //Make sure resolution is at least 32x29 26 | void CreateWindows(int y, int x, int y0, int x0); //Make ncurses windows 27 | void Delay(); //Slow down game for better control 28 | void DrawWindow(); //Refresh display 29 | void ExitProgram(const char *message); //Exit and display something 30 | void GetInput(); //Get user input 31 | void InitCurses(); //Start up ncurses 32 | void LoadLevel(char *levelfile); //Load level into memory 33 | void MainLoop(); //Main program function 34 | void MoveGhosts(); //Update Ghosts' location 35 | void MovePacman(); //Update Pacman's location 36 | void PauseGame(); //Pause 37 | 38 | //For ncurses 39 | WINDOW * win; 40 | WINDOW * status; 41 | 42 | //For colors 43 | enum { Wall = 1, Normal, Pellet, PowerUp, GhostWall, Ghost1, Ghost2, Ghost3, Ghost4, BlueGhost, Pacman }; 44 | 45 | //I know global variables are bad, but it's just sooo easy! 46 | int Loc[5][2] = { 0 }; //Location of Ghosts and Pacman 47 | int Dir[5][2] = { 0 }; //Direction of Ghosts and Pacman 48 | int StartingPoints[5][2] = { 0 }; //Default location in case Pacman/Ghosts die 49 | int Invincible = 0; //Check for invincibility 50 | int Food = 0; //Number of pellets left in level 51 | int Level[29][28] = { 0 }; //Main level array 52 | int LevelNumber = 0; //What level number are we on? 53 | int GhostsInARow = 0; //Keep track of how many points to give for eating ghosts 54 | int tleft = 0; //How long left for invincibility 55 | 56 | int main(int argc, char *argv[]) { 57 | 58 | int j = 0; 59 | srand( (unsigned)time( NULL ) ); 60 | 61 | InitCurses(); 62 | CheckScreenSize(); 63 | CreateWindows(29, 28, 1, 1); 64 | 65 | //If they specified a level to load 66 | if((argc > 1) && (strlen(argv[1]) > 1)) { 67 | LoadLevel(argv[1]); 68 | MainLoop(); 69 | } 70 | 71 | //If not, display intro screen then use default levels 72 | else { 73 | //Show intro "movie" 74 | IntroScreen(); 75 | 76 | j = 1; 77 | //They want to start at a level 1-9 78 | if(argc > 1) 79 | for(LevelNumber = '1'; LevelNumber <= '9'; LevelNumber++) 80 | if(LevelNumber == argv[1][0]) j = LevelNumber - '0'; 81 | 82 | //Load 9 levels, 1 by 1, if you can beat all 9 levels in a row, you're awesome 83 | for(LevelNumber = j; LevelNumber < 10; LevelNumber++) { 84 | LevelFile[strlen(LevelFile) - 6] = '0'; 85 | LevelFile[strlen(LevelFile) - 5] = LevelNumber + '0'; 86 | LoadLevel(LevelFile); 87 | Invincible = 0; //Reset invincibility 88 | MainLoop(); 89 | } 90 | 91 | } 92 | 93 | ExitProgram(EXIT_MSG); 94 | } 95 | 96 | void CheckCollision() { 97 | int a = 0; 98 | for(a = 0; a < 4; a++) { 99 | //Collision 100 | if((Loc[a][0] == Loc[4][0]) && (Loc[a][1] == Loc[4][1])) { 101 | 102 | //Ghost dies 103 | if(Invincible == 1) { 104 | Points = Points + GhostsInARow * 20; 105 | mvwprintw(win, Loc[4][0], Loc[4][1] - 1, "%d", (GhostsInARow * 20)); 106 | GhostsInARow *= 2; 107 | wrefresh(win); 108 | 109 | usleep(1000000); 110 | 111 | Loc[a][0] = StartingPoints[a][0]; Loc[a][1] = StartingPoints[a][1]; 112 | } 113 | 114 | //Pacman dies 115 | else { 116 | wattron(win, COLOR_PAIR(Pacman)); 117 | mvwprintw(win, Loc[4][0], Loc[4][1], "X"); 118 | 119 | wrefresh(win); 120 | 121 | Lives--; 122 | usleep(1000000); 123 | 124 | if(Lives == -1) ExitProgram(END_MSG); 125 | 126 | //Reset level 127 | for(a = 0; a < 5; a++) { 128 | Loc[a][0] = StartingPoints[a][0]; 129 | Loc[a][1] = StartingPoints[a][1]; 130 | } 131 | Dir[0][0] = 1; Dir[0][1] = 0; 132 | Dir[1][0] = -1; Dir[1][1] = 0; 133 | Dir[2][0] = 0; Dir[2][1] = -1; 134 | Dir[3][0] = 0; Dir[3][1] = 1; 135 | Dir[4][0] = 0; Dir[4][1] = -1; 136 | 137 | DrawWindow(); 138 | 139 | usleep(1000000); 140 | } 141 | } 142 | } 143 | } 144 | 145 | void CheckScreenSize() { 146 | //Make sure the window is big enough 147 | int h, w; getmaxyx(stdscr, h, w); 148 | if((h < 32) || (w < 29)) { 149 | endwin(); 150 | fprintf(stderr, "\nSorry.\n"); 151 | fprintf(stderr, "To play Pacman for Console, your console window must be at least 32x29\n"); 152 | fprintf(stderr, "Please resize your window/resolution and re-run the game.\n\n"); 153 | exit(0); 154 | } 155 | } 156 | 157 | void CreateWindows(int y, int x, int y0, int x0) { 158 | win = newwin(y, x, y0, x0); 159 | status = newwin(3, 27, 29, 1); 160 | } 161 | 162 | void Delay() { 163 | 164 | struct timeb t_start, t_current; 165 | ftime(&t_start); 166 | 167 | //Slow down the game a little bit 168 | do { 169 | GetInput(); 170 | ftime(&t_current); 171 | } while (abs(t_start.millitm - t_current.millitm) < SpeedOfGame); 172 | } 173 | 174 | void DrawWindow() { 175 | int a = 0; int b = 0; 176 | char chr = ' '; 177 | int attr; 178 | 179 | //Display level array 180 | for(a = 0; a < 29; a++) for(b = 0; b < 28; b++) { 181 | switch(Level[a][b]) { 182 | case 0: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Normal)); break; 183 | case 1: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Wall)); break; 184 | case 2: chr = '.'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Pellet)); break; 185 | case 3: chr = '*'; attr = A_BOLD; wattron(win, COLOR_PAIR(PowerUp)); break; 186 | case 4: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(GhostWall)); break; 187 | } 188 | mvwaddch(win, a, b, chr | attr); 189 | } 190 | 191 | //Display number of lives, score, and level 192 | attr = A_NORMAL; 193 | wmove(status, 1, 1); 194 | wattron(status, COLOR_PAIR(Pacman)); 195 | for(a = 0; a < Lives; a++) 196 | wprintw(status, "C "); 197 | wprintw(status, " "); 198 | wattron(status, COLOR_PAIR(Normal)); 199 | mvwprintw(status, 2, 2, "Level: %d Score: %d ", LevelNumber, Points); 200 | wrefresh(status); 201 | 202 | //Display ghosts 203 | if(Invincible == 0) { 204 | wattron(win, COLOR_PAIR(Ghost1)); mvwaddch(win, Loc[0][0], Loc[0][1], '&'); 205 | wattron(win, COLOR_PAIR(Ghost2)); mvwaddch(win, Loc[1][0], Loc[1][1], '&'); 206 | wattron(win, COLOR_PAIR(Ghost3)); mvwaddch(win, Loc[2][0], Loc[2][1], '&'); 207 | wattron(win, COLOR_PAIR(Ghost4)); mvwaddch(win, Loc[3][0], Loc[3][1], '&'); 208 | } 209 | 210 | //OR display vulnerable ghosts 211 | else { 212 | wattron(win, COLOR_PAIR(BlueGhost)); 213 | mvwaddch(win, Loc[0][0], Loc[0][1], tleft + '0'); 214 | mvwaddch(win, Loc[1][0], Loc[1][1], tleft + '0'); 215 | mvwaddch(win, Loc[2][0], Loc[2][1], tleft + '0'); 216 | mvwaddch(win, Loc[3][0], Loc[3][1], tleft + '0'); 217 | } 218 | 219 | //Display Pacman 220 | wattron(win, COLOR_PAIR(Pacman)); mvwaddch(win, Loc[4][0], Loc[4][1], 'C'); 221 | 222 | wrefresh(win); 223 | } 224 | 225 | void ExitProgram(const char *message) { 226 | endwin(); 227 | printf("%s\n", message); 228 | exit(0); 229 | } 230 | 231 | void GetInput() { 232 | int ch; 233 | static int chtmp; 234 | 235 | ch = getch(); 236 | 237 | //Buffer input 238 | if(ch == ERR) ch = chtmp; 239 | chtmp = ch; 240 | 241 | switch (ch) { 242 | case KEY_UP: case 'w': case 'W': 243 | if((Level[(Loc[4][0]-1) % 29][Loc[4][1]] != 1) 244 | && (Level[(Loc[4][0]-1) % 29][Loc[4][1]] != 4)) 245 | { Dir[4][0] = -1; Dir[4][1] = 0; } 246 | break; 247 | 248 | case KEY_DOWN: case 's': case 'S': 249 | if((Level[(Loc[4][0]+1) % 29][Loc[4][1]] != 1) 250 | && (Level[(Loc[4][0]+1) % 29][Loc[4][1]] != 4)) 251 | { Dir[4][0] = 1; Dir[4][1] = 0; } 252 | break; 253 | 254 | case KEY_LEFT: case 'a': case 'A': 255 | if((Level[Loc[4][0]][(Loc[4][1]-1) % 28] != 1) 256 | && (Level[Loc[4][0]][(Loc[4][1]-1) % 28] != 4)) 257 | { Dir[4][0] = 0; Dir[4][1] = -1; } 258 | break; 259 | 260 | case KEY_RIGHT: case 'd': case 'D': 261 | if((Level[Loc[4][0]][(Loc[4][1]+1) % 28] != 1) 262 | && (Level[Loc[4][0]][(Loc[4][1]+1) % 28] != 4)) 263 | { Dir[4][0] = 0; Dir[4][1] = 1; } 264 | break; 265 | 266 | case 'p': case 'P': 267 | PauseGame(); 268 | chtmp = getch(); 269 | break; 270 | 271 | case 'q': case 'Q': 272 | ExitProgram(QUIT_MSG); 273 | break; 274 | 275 | } 276 | } 277 | 278 | void InitCurses() { 279 | initscr(); 280 | start_color(); 281 | curs_set(0); 282 | keypad(stdscr, TRUE); 283 | nodelay(stdscr, TRUE); 284 | nonl(); 285 | cbreak(); 286 | noecho(); 287 | 288 | init_pair(Normal, COLOR_WHITE, COLOR_BLACK); 289 | init_pair(Wall, COLOR_WHITE, COLOR_WHITE); 290 | init_pair(Pellet, COLOR_WHITE, COLOR_BLACK); 291 | init_pair(PowerUp, COLOR_BLUE, COLOR_BLACK); 292 | init_pair(GhostWall, COLOR_WHITE, COLOR_CYAN); 293 | init_pair(Ghost1, COLOR_RED, COLOR_BLACK); 294 | init_pair(Ghost2, COLOR_CYAN, COLOR_BLACK); 295 | init_pair(Ghost3, COLOR_MAGENTA, COLOR_BLACK); 296 | init_pair(Ghost4, COLOR_YELLOW, COLOR_BLACK); 297 | init_pair(BlueGhost, COLOR_BLUE, COLOR_RED); 298 | init_pair(Pacman, COLOR_YELLOW, COLOR_BLACK); 299 | } 300 | 301 | void IntroScreen() { 302 | int a = 0; 303 | int b = 23; 304 | 305 | a=getch(); 306 | a=getch(); 307 | a=getch(); 308 | 309 | mvwprintw(win, 20, 8, "Press any key..."); 310 | 311 | //Scroll Pacman to middle of screen 312 | for(a = 0; a < 13; a++) { 313 | if(getch()!=ERR) return; 314 | wattron(win, COLOR_PAIR(Pacman)); 315 | mvwprintw(win, 8, a, " C"); 316 | wrefresh(win); 317 | usleep(100000); 318 | } 319 | 320 | //Show "Pacman" 321 | wattron(win, COLOR_PAIR(Pacman)); 322 | mvwprintw(win, 8, 12, "PACMAN"); 323 | wrefresh(win); 324 | usleep(1000000); 325 | 326 | //Ghosts Chase Pacman 327 | for(a = 0; a < 23; a++) { 328 | if(getch()!=ERR) return; 329 | wattron(win, COLOR_PAIR(Pellet)); mvwprintw(win, 13, 23, "*"); 330 | wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, a, " C"); 331 | wattron(win, COLOR_PAIR(Ghost1)); mvwprintw(win, 13, a-3, " &"); 332 | wattron(win, COLOR_PAIR(Ghost3)); mvwprintw(win, 13, a-5, " &"); 333 | wattron(win, COLOR_PAIR(Ghost2)); mvwprintw(win, 13, a-7, " &"); 334 | wattron(win, COLOR_PAIR(Ghost4)); mvwprintw(win, 13, a-9, " &"); 335 | wrefresh(win); 336 | usleep(100000); 337 | } 338 | 339 | usleep(150000); 340 | 341 | //Pacman Chases Ghosts 342 | for(a = 25; a > 2; a--) { 343 | if(getch()!=ERR) return; 344 | wattron(win, COLOR_PAIR(Pellet)); mvwprintw(win, 13, 23, " "); 345 | 346 | //Make ghosts half as fast 347 | if(a%2) b--; 348 | 349 | wattron(win, COLOR_PAIR(BlueGhost)); mvwprintw(win, 13, b-9, "& & & &"); 350 | wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+1, " "); 351 | wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+3, " "); 352 | wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+5, " "); 353 | wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+7, " "); 354 | wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, a-3, "C "); 355 | 356 | wattron(win, COLOR_PAIR(Pellet)); mvwprintw(win, 13, 23, " "); 357 | wrefresh(win); 358 | usleep(100000); 359 | } 360 | 361 | } 362 | 363 | void LoadLevel(char *levelfile) { 364 | 365 | int a = 0; int b = 0; 366 | size_t l; 367 | char error[sizeof(LEVEL_ERR)+255] = LEVEL_ERR; 368 | FILE *fin; 369 | Food = 0; 370 | 371 | //Reset defaults 372 | Dir[0][0] = 1; Dir[0][1] = 0; 373 | Dir[1][0] = -1; Dir[1][1] = 0; 374 | Dir[2][0] = 0; Dir[2][1] = -1; 375 | Dir[3][0] = 0; Dir[3][1] = 1; 376 | Dir[4][0] = 0; Dir[4][1] = -1; 377 | 378 | //Open file 379 | fin = fopen(levelfile, "r"); 380 | 381 | //Make sure it didn't fail 382 | if(!(fin)) { 383 | l = sizeof(error)-strlen(error)-1; 384 | strncat(error, levelfile, l); 385 | if(strlen(levelfile) > l) 386 | error[sizeof(error)-2] = '.', error[sizeof(error)-3] = '.', error[sizeof(error)-4] = '.'; 387 | ExitProgram(error); 388 | } 389 | 390 | //Open file and load the level into the array 391 | for(a = 0; a < 29; a++) { 392 | for(b = 0; b < 28; b++) { 393 | fscanf(fin, "%d", &Level[a][b]); 394 | if(Level[a][b] == 2) Food++; 395 | 396 | if(Level[a][b] == 5) { Loc[0][0] = a; Loc[0][1] = b; Level[a][b] = 0; } 397 | if(Level[a][b] == 6) { Loc[1][0] = a; Loc[1][1] = b; Level[a][b] = 0; } 398 | if(Level[a][b] == 7) { Loc[2][0] = a; Loc[2][1] = b; Level[a][b] = 0; } 399 | if(Level[a][b] == 8) { Loc[3][0] = a; Loc[3][1] = b; Level[a][b] = 0; } 400 | if(Level[a][b] == 9) { Loc[4][0] = a; Loc[4][1] = b; Level[a][b] = 0; } 401 | } 402 | } 403 | 404 | fscanf(fin, "%d", &LevelNumber); 405 | 406 | //Save initial character points for if Pacman or Ghosts die 407 | for(a = 0; a < 5; a++) 408 | StartingPoints[a][0] = Loc[a][0], StartingPoints[a][1] = Loc[a][1]; 409 | 410 | } 411 | 412 | void MainLoop() { 413 | 414 | DrawWindow(); 415 | wrefresh(win); 416 | wrefresh(status); 417 | usleep(1000000); 418 | 419 | do { 420 | MovePacman(); DrawWindow(); CheckCollision(); 421 | MoveGhosts(); DrawWindow(); CheckCollision(); 422 | if(Points > FreeLife) { Lives++; FreeLife *= 2;} 423 | Delay(); 424 | 425 | } while (Food > 0); 426 | 427 | DrawWindow(); 428 | usleep(1000000); 429 | 430 | } 431 | 432 | void MoveGhosts() { 433 | int a = 0; int b = 0; int c = 0; 434 | int tmpx = 0; int tmpy = 0; 435 | int tmpdx = 0; int tmpdy = 0; 436 | int checksides[] = { 0, 0, 0, 0, 0, 0 }; 437 | static int SlowerGhosts = 0; 438 | 439 | if(Invincible == 1) { 440 | SlowerGhosts++; 441 | if(SlowerGhosts > HowSlow) 442 | SlowerGhosts = 0; 443 | } 444 | 445 | if((Invincible == 0) || SlowerGhosts < HowSlow) 446 | 447 | //Loop through each ghost 448 | for(a = 0; a < 4; a++) { 449 | 450 | //Switch sides? 451 | if((Loc[a][0] == 0) && (Dir[a][0] == -1)) Loc[a][0] = 28; 452 | else if((Loc[a][0] == 28) && (Dir[a][0] == 1)) Loc[a][0] = 0; 453 | else if((Loc[a][1] == 0) && (Dir[a][1] == -1)) Loc[a][1] = 27; 454 | else if((Loc[a][1] == 27) && (Dir[a][1] == 1)) Loc[a][1] = 0; 455 | else { 456 | 457 | //Determine which directions we can go 458 | for(b = 0; b < 4; b++) checksides[b] = 0; 459 | if(Level[Loc[a][0] + 1][Loc[a][1]] != 1) checksides[0] = 1; 460 | if(Level[Loc[a][0] - 1][Loc[a][1]] != 1) checksides[1] = 1; 461 | if(Level[Loc[a][0]][Loc[a][1] + 1] != 1) checksides[2] = 1; 462 | if(Level[Loc[a][0]][Loc[a][1] - 1] != 1) checksides[3] = 1; 463 | 464 | //Don't do 180 unless we have to 465 | c = 0; for(b = 0; b < 4; b++) if(checksides[b] == 1) c++; 466 | 467 | if(c > 1) { 468 | if(Dir[a][0] == 1) checksides[1] = 0; 469 | else if(Dir[a][0] == -1) checksides[0] = 0; 470 | else if(Dir[a][1] == 1) checksides[3] = 0; 471 | else if(Dir[a][1] == -1) checksides[2] = 0; 472 | } 473 | 474 | c = 0; 475 | do { 476 | //Decide direction 477 | b = (int)(rand() / (1625000000 / 4)); 478 | 479 | if(checksides[b] == 1) { 480 | if(b == 0) { Dir[a][0] = 1; Dir[a][1] = 0; } 481 | else if(b == 1) { Dir[a][0] = -1; Dir[a][1] = 0; } 482 | else if(b == 2) { Dir[a][0] = 0; Dir[a][1] = 1; } 483 | else if(b == 3) { Dir[a][0] = 0; Dir[a][1] = -1; } 484 | } 485 | else { 486 | if(Invincible == 0) { 487 | //Chase Pacman 488 | if((Loc[4][0] > Loc[a][0]) && (checksides[0] == 1)) { Dir[a][0] = 1; Dir[a][1] = 0; c = 1; } 489 | else if((Loc[4][0] < Loc[a][0]) && (checksides[1] == 1)) { Dir[a][0] = -1; Dir[a][1] = 0; c = 1; } 490 | else if((Loc[4][1] > Loc[a][1]) && (checksides[2] == 1)) { Dir[a][0] = 0; Dir[a][1] = 1; c = 1; } 491 | else if((Loc[4][1] < Loc[a][1]) && (checksides[3] == 1)) { Dir[a][0] = 0; Dir[a][1] = -1; c = 1; } 492 | } 493 | 494 | else { 495 | //Run away from Pacman 496 | if((Loc[4][0] > Loc[a][0]) && (checksides[1] == 1)) { Dir[a][0] = -1; Dir[a][1] = 0; c = 1; } 497 | else if((Loc[4][0] < Loc[a][0]) && (checksides[0] == 1)) { Dir[a][0] = 1; Dir[a][1] = 0; c = 1; } 498 | else if((Loc[4][1] > Loc[a][1]) && (checksides[3] == 1)) { Dir[a][0] = 0; Dir[a][1] = -1; c = 1; } 499 | else if((Loc[4][1] < Loc[a][1]) && (checksides[2] == 1)) { Dir[a][0] = 0; Dir[a][1] = 1; c = 1; } 500 | } 501 | } 502 | 503 | } while ((checksides[b] == 0) && (c == 0)); 504 | 505 | //Move Ghost 506 | Loc[a][0] += Dir[a][0]; 507 | Loc[a][1] += Dir[a][1]; 508 | } 509 | } 510 | } 511 | 512 | void MovePacman() { 513 | 514 | static int itime = 0; 515 | 516 | //Switch sides? 517 | if((Loc[4][0] == 0) && (Dir[4][0] == -1)) Loc[4][0] = 28; 518 | else if((Loc[4][0] == 28) && (Dir[4][0] == 1)) Loc[4][0] = 0; 519 | else if((Loc[4][1] == 0) && (Dir[4][1] == -1)) Loc[4][1] = 27; 520 | else if((Loc[4][1] == 27) && (Dir[4][1] == 1)) Loc[4][1] = 0; 521 | 522 | //Or 523 | else { 524 | //Move Pacman 525 | Loc[4][0] += Dir[4][0]; 526 | Loc[4][1] += Dir[4][1]; 527 | 528 | //If he hit a wall, move back 529 | if((Level[Loc[4][0]][Loc[4][1]] == 1) || (Level[Loc[4][0]][Loc[4][1]] == 4)) { 530 | Loc[4][0] -= Dir[4][0]; Loc[4][1] -= Dir[4][1]; 531 | } 532 | } 533 | 534 | //What is he eating? 535 | switch (Level[Loc[4][0]][Loc[4][1]]) { 536 | case 2: //Pellet 537 | Level[Loc[4][0]][Loc[4][1]] = 0; 538 | Points++; 539 | Food--; 540 | break; 541 | case 3: //PowerUp 542 | Level[Loc[4][0]][Loc[4][1]] = 0; 543 | Invincible = 1; 544 | if(GhostsInARow == 0) GhostsInARow = 1; 545 | itime = time(0); 546 | break; 547 | } 548 | 549 | //Is he invincible? 550 | if(Invincible == 1) tleft = (11 - LevelNumber - time(0) + itime); 551 | 552 | //Is invincibility up yet? 553 | if(tleft < 0) { Invincible = 0; GhostsInARow = 0; tleft = 0; } 554 | 555 | } 556 | 557 | void PauseGame() { 558 | int chtmp; 559 | 560 | //Display pause dialog 561 | wattron(win, COLOR_PAIR(Pacman)); 562 | mvwprintw(win, 12, 10, "********"); 563 | mvwprintw(win, 13, 10, "*PAUSED*"); 564 | mvwprintw(win, 14, 10, "********"); 565 | wrefresh(win); 566 | 567 | //And wait 568 | do { 569 | chtmp = getch(); 570 | } while (chtmp == ERR); 571 | 572 | } 573 | -------------------------------------------------------------------------------- /pacman.h: -------------------------------------------------------------------------------- 1 | // Some variables that you may want to change 2 | #ifndef DATAROOTDIR 3 | # define DATAROOTDIR "/usr/local/share" 4 | #endif 5 | #define LEVELS_FILE DATAROOTDIR "/pacman/Levels/level__.dat" 6 | char LevelFile[] = LEVELS_FILE; //Locations of default levels 7 | int FreeLife = 1000; //Starting points for free life 8 | int Points = 0; //Initial points 9 | int Lives = 3; //Number of lives you start with 10 | int HowSlow = 3; //How slow vulnerable ghost move 11 | int SpeedOfGame = 175; //How much of a delay is in the game 12 | -------------------------------------------------------------------------------- /pacmanedit.c: -------------------------------------------------------------------------------- 1 | /**************************************************** 2 | * Pacman For Console Level Editor * 3 | * By: Rev. Dr. Mike Billars (doctormike@gmail.com) * 4 | * Date: 2006-12-12 * 5 | * * 6 | * Please see file COPYING for details on licensing * 7 | * and redistribution of this program * 8 | * * 9 | ****************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "pacman.h" 17 | 18 | #define FILE_ERR "You must specify a file to use (load and save)" 19 | #define SAVE_ERR "Error while saving" 20 | 21 | void CheckScreenSize(); //Make sure resolution is at least 32x29 22 | void CreateWindows(int y, int x, int y0, int x0); //Make ncurses windows 23 | void DrawWindow(); //Refresh display 24 | void ExitProgram(const char *message); //Exit gracefully 25 | void GetInput(); //Get user input 26 | void InitCurses(); //Start up ncurses 27 | void LoadLevel(); //Load level into memory 28 | void MainLoop(); //Main loop 29 | void SaveLevel(); //Save level to specified file 30 | 31 | //For ncurses 32 | WINDOW * win; 33 | WINDOW * status; 34 | 35 | //For colors 36 | enum { Wall = 1, Normal, Pellet, PowerUp, GhostWall, Ghost1, Ghost2, Ghost3, Ghost4, BlueGhost, Pacman, Cursor}; 37 | 38 | //I know global variables are bad, but it's just sooo easy! 39 | int Level[29][28] = { 0 }; //Main level array 40 | int Loc[6][2] = { 0 }; //Ghosts, Pacman, and cursor locations 41 | int tleft = 0; //How long left for invincibility 42 | char *filename = NULL; //Name of file to load/save 43 | 44 | int main(int argc, char *argv[]) { 45 | 46 | if((argc > 1) && (strlen(argv[1]) > 1)) { 47 | filename = argv[1]; 48 | LoadLevel(); 49 | 50 | InitCurses(); 51 | CheckScreenSize(); 52 | CreateWindows(29, 28, 1, 1); 53 | 54 | DrawWindow(); 55 | Loc[5][0]=13; 56 | Loc[5][1]=13; 57 | MainLoop(); 58 | } 59 | else 60 | ExitProgram(FILE_ERR); 61 | 62 | } 63 | 64 | void CheckScreenSize() { 65 | //Make sure the window is big enough 66 | int h, w; getmaxyx(stdscr, h, w); 67 | if((h < 32) || (w < 29)) { 68 | endwin(); 69 | fprintf(stderr, "\nSorry.\n"); 70 | fprintf(stderr, "To edit levels for Pacman for Console, your console window\n"); 71 | fprintf(stderr, "must be at least 32x29 Please resize your window/resolution\n"); 72 | fprintf(stderr, "and re-run the program.\n\n"); 73 | ExitProgram(""); 74 | } 75 | } 76 | 77 | void CreateWindows(int y, int x, int y0, int x0) { 78 | win = newwin(y, x, y0, x0); 79 | status = newwin(3, 28, 29, 1); 80 | } 81 | 82 | void DrawWindow() { 83 | int a = 0; int b = 0; 84 | char chr = ' '; 85 | int attr; 86 | 87 | //Display level array 88 | for(a = 0; a < 29; a++) for(b = 0; b < 28; b++) { 89 | switch(Level[a][b]) { 90 | case 0: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Normal)); break; 91 | case 1: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Wall)); break; 92 | case 2: chr = '.'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Pellet)); break; 93 | case 3: chr = '*'; attr = A_BOLD; wattron(win, COLOR_PAIR(PowerUp)); break; 94 | case 4: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(GhostWall)); break; 95 | case 5: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost1)); break; 96 | case 6: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost2)); break; 97 | case 7: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost3)); break; 98 | case 8: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost4)); break; 99 | case 9: chr = 'C'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Pacman)); break; 100 | } 101 | mvwaddch(win, a, b, chr | attr); 102 | } 103 | 104 | //Display the cursor 105 | wattron(win,COLOR_PAIR(Cursor)); 106 | mvwaddch(win, Loc[5][0], Loc[5][1], 'X'); 107 | 108 | //Display info in status 109 | wmove(status, 1, 1); 110 | wattron(status, COLOR_PAIR(Normal)); 111 | mvwprintw(status, 1, 0, "0) 1) 2) 3)"); 112 | mvwprintw(status, 2, 0, "4) 5-8) 9) F/C/Q"); 113 | 114 | wattron(status, COLOR_PAIR(Normal)); mvwaddch(status, 1, 3, ' '); 115 | wattron(status, COLOR_PAIR(Wall)); mvwaddch(status, 1, 10, ' '); 116 | wattron(status, COLOR_PAIR(Pellet)); mvwaddch(status, 1, 19, '.'); 117 | wattron(status, COLOR_PAIR(PowerUp)); mvwaddch(status, 1, 26 , '*' | A_BOLD); 118 | wattron(status, COLOR_PAIR(GhostWall)); mvwaddch(status, 2, 3, ' '); 119 | wattron(status, COLOR_PAIR(Ghost1)); mvwaddch(status, 2, 12, '&'); 120 | wattron(status, COLOR_PAIR(Pacman)); mvwaddch(status, 2, 19, 'C'); 121 | 122 | wrefresh(status); 123 | wrefresh(win); 124 | } 125 | 126 | void ExitProgram(const char *message) { 127 | endwin(); 128 | 129 | //Must save file 130 | if(!message) 131 | printf("\n\nFile saved as: %s\n", filename); 132 | 133 | else 134 | printf("%s\n\n", message); 135 | 136 | exit(0); 137 | } 138 | 139 | void GetInput() { 140 | int ch; 141 | int a=0; 142 | int b=0; 143 | 144 | static int chtmp; 145 | 146 | ch = getch(); 147 | 148 | //Buffer input 149 | do { 150 | DrawWindow(); 151 | ch = getch(); 152 | } while (ch == ERR); 153 | 154 | switch (ch) { 155 | case KEY_UP: case 'w': case 'W': 156 | Loc[5][0]--; 157 | if(Loc[5][0]<0) { Loc[5][0]=28; } 158 | break; 159 | 160 | case KEY_DOWN: case 's': case 'S': 161 | Loc[5][0]++; 162 | if(Loc[5][0]>28) { Loc[5][0]=0; } 163 | break; 164 | 165 | case KEY_LEFT: case 'a': case 'A': 166 | Loc[5][1]--; 167 | if(Loc[5][1]<0) { Loc[5][1]=27; } 168 | break; 169 | 170 | case KEY_RIGHT: case 'd': case 'D': 171 | Loc[5][1]++; 172 | if(Loc[5][1]>27) { Loc[5][1]=0; } 173 | break; 174 | 175 | case 'q': case 'Q': 176 | //Save and exit 177 | SaveLevel(); 178 | ExitProgram(NULL); 179 | break; 180 | 181 | //Draw a blank space 182 | case '0': case ' ': 183 | Level[Loc[5][0]][Loc[5][1]]=0; 184 | break; 185 | 186 | //Draw a wall 187 | case '1': 188 | Level[Loc[5][0]][Loc[5][1]]=1; 189 | break; 190 | 191 | //Draw a pellet 192 | case '2': 193 | Level[Loc[5][0]][Loc[5][1]]=2; 194 | break; 195 | 196 | //Draw a powerup 197 | case '3': 198 | Level[Loc[5][0]][Loc[5][1]]=3; 199 | break; 200 | 201 | //Draw a ghost/spawning wall 202 | case '4': 203 | Level[Loc[5][0]][Loc[5][1]]=4; 204 | break; 205 | 206 | //Draw a ghost/pacman 207 | case '5': case '6': case '7': 208 | case '8': case '9': 209 | 210 | //Move ghost/pacman to new location 211 | Level[Loc[5][0]][Loc[5][1]]=ch-'0'; 212 | 213 | //Erase character from previous location and replace with BLANK 214 | if(Level[Loc[ch-'0'-5][0]][Loc[ch-'0'-5][1]]==ch-'0') 215 | Level[Loc[ch-'0'-5][0]][Loc[ch-'0'-5][1]]=0; 216 | 217 | //Set Loc variable to new location 218 | Loc[ch-'0'-5][0]=Loc[5][0]; 219 | Loc[ch-'0'-5][1]=Loc[5][1]; 220 | 221 | break; 222 | 223 | //Fill blank spaces with pellets 224 | case 'f': case 'F': 225 | 226 | for(a=0; a<29; a++) 227 | for(b=0; b<28; b++) 228 | if(Level[a][b]==0) Level[a][b]=2; 229 | break; 230 | 231 | //Fill pellet spaces with blanks 232 | case 'c': case 'C': 233 | 234 | for(a=0; a<29; a++) 235 | for(b=0; b<28; b++) 236 | if(Level[a][b]==2) Level[a][b]=0; 237 | break; 238 | 239 | } 240 | } 241 | 242 | void InitCurses() { 243 | initscr(); 244 | start_color(); 245 | curs_set(0); 246 | keypad(stdscr, TRUE); 247 | nodelay(stdscr, TRUE); 248 | nonl(); 249 | cbreak(); 250 | noecho(); 251 | 252 | init_pair(Normal, COLOR_WHITE, COLOR_BLACK); 253 | init_pair(Wall, COLOR_WHITE, COLOR_WHITE); 254 | init_pair(Pellet, COLOR_WHITE, COLOR_BLACK); 255 | init_pair(PowerUp, COLOR_BLUE, COLOR_BLACK); 256 | init_pair(GhostWall, COLOR_WHITE, COLOR_CYAN); 257 | init_pair(Ghost1, COLOR_RED, COLOR_BLACK); 258 | init_pair(Ghost2, COLOR_CYAN, COLOR_BLACK); 259 | init_pair(Ghost3, COLOR_MAGENTA, COLOR_BLACK); 260 | init_pair(Ghost4, COLOR_YELLOW, COLOR_BLACK); 261 | init_pair(BlueGhost, COLOR_BLUE, COLOR_RED); 262 | init_pair(Pacman, COLOR_YELLOW, COLOR_BLACK); 263 | init_pair(Cursor, COLOR_BLUE, COLOR_YELLOW); 264 | } 265 | 266 | void LoadLevel() { 267 | 268 | int a = 0; int b = 0; 269 | FILE *fin; 270 | 271 | //Open file 272 | fin = fopen(filename, "r"); 273 | 274 | //File doesn't exist, start new 275 | if(!(fin)) { 276 | for(a=0; a<28; a++) { Level[a][0]=1; Level[a][27]=1; } 277 | for(a=0; a<28; a++) { Level[0][a]=1; Level[28][a]=1; } 278 | Loc[0][0]=2; Loc[0][1]=2; Loc[1][0]=2; Loc[1][1]=4; 279 | Loc[2][0]=2; Loc[2][1]=6; Loc[3][0]=2; Loc[3][1]=8; 280 | Loc[4][0]=19; Loc[4][1]=19; 281 | Level[Loc[0][0]][Loc[0][1]]=5; 282 | Level[Loc[1][0]][Loc[1][1]]=6; 283 | Level[Loc[2][0]][Loc[2][1]]=7; 284 | Level[Loc[3][0]][Loc[3][1]]=8; 285 | Level[Loc[4][0]][Loc[4][1]]=9; 286 | } 287 | else { 288 | //Open file and load the level into the array 289 | for(a = 0; a < 29; a++) for(b = 0; b < 28; b++) { 290 | fscanf(fin, "%d", &Level[a][b]); 291 | if(Level[a][b] == 5) { Loc[0][0]=a; Loc[0][1]=b; } 292 | if(Level[a][b] == 6) { Loc[1][0]=a; Loc[1][1]=b; } 293 | if(Level[a][b] == 7) { Loc[2][0]=a; Loc[2][1]=b; } 294 | if(Level[a][b] == 8) { Loc[3][0]=a; Loc[3][1]=b; } 295 | if(Level[a][b] == 9) { Loc[4][0]=a; Loc[4][1]=b; } 296 | } 297 | } 298 | } 299 | 300 | void MainLoop() { 301 | do { 302 | GetInput(); 303 | DrawWindow(); 304 | } while (1); 305 | } 306 | 307 | void SaveLevel() { 308 | int a=0; 309 | int b=0; 310 | FILE *fout; 311 | 312 | //Open file 313 | fout = fopen(filename, "w"); 314 | if(!(fout)) ExitProgram(SAVE_ERR); 315 | 316 | for(a = 0; a < 29; a++) for(b = 0; b < 28; b++) { 317 | fprintf(fout, "%d ", Level[a][b]); 318 | fprintf(fout, "\n"); 319 | } 320 | fprintf(fout, "1"); 321 | fclose(fout); 322 | } 323 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoctoForBeaglebone/pacman4console/ddc229c3478b43b572cef4fc09bb1580f00a1e74/screenshot.png --------------------------------------------------------------------------------