From 58679d012f14aa274f4532d0f922d6a24dbbe574 Mon Sep 17 00:00:00 2001 From: Matthew Mondor Date: Tue, 11 Apr 2023 22:31:00 +0000 Subject: [PATCH] Initial import of pacman-1.3 from http://archive.ubuntu.com/ubuntu/ubuntu/pool/universe/p/pacman4console/ --- COPYING | 339 ++++++++++++++++++++++++ ChangeLog | 32 +++ Levels/README | 40 +++ Levels/level01.dat | 30 +++ Levels/level02.dat | 30 +++ Levels/level03.dat | 30 +++ Levels/level04.dat | 30 +++ Levels/level05.dat | 30 +++ Levels/level06.dat | 30 +++ Levels/level07.dat | 30 +++ Levels/level08.dat | 30 +++ Levels/level09.dat | 30 +++ Levels/template.dat | 30 +++ Makefile | 30 +++ README | 56 ++++ pacman | Bin 0 -> 24196 bytes pacman.c | 750 ++++++++++++++++++++++++++++++++++++++++++++++++++++ pacman.h | 12 + pacmanedit | Bin 0 -> 18792 bytes pacmanedit.c | 406 ++++++++++++++++++++++++++++ screenshot.png | Bin 0 -> 3505 bytes 21 files changed, 1965 insertions(+) create mode 100755 COPYING create mode 100755 ChangeLog create mode 100755 Levels/README create mode 100755 Levels/level01.dat create mode 100755 Levels/level02.dat create mode 100755 Levels/level03.dat create mode 100755 Levels/level04.dat create mode 100755 Levels/level05.dat create mode 100755 Levels/level06.dat create mode 100755 Levels/level07.dat create mode 100755 Levels/level08.dat create mode 100755 Levels/level09.dat create mode 100755 Levels/template.dat create mode 100755 Makefile create mode 100755 README create mode 100755 pacman create mode 100755 pacman.c create mode 100755 pacman.h create mode 100755 pacmanedit create mode 100755 pacmanedit.c create mode 100755 screenshot.png diff --git a/COPYING b/COPYING new file mode 100755 index 0000000..d511905 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100755 index 0000000..c47665f --- /dev/null +++ b/ChangeLog @@ -0,0 +1,32 @@ +Pacman for Console + + + +2014-04-26 - 1.3 + + - improved Makefile: notably a better parameterization allowing a non-admin installation - Thanks to G.raud + - wrote much better comments in code for pacman.c and pacmanedit.c + - fixed bug stopping location of Levels from being changed - Thanks to Doncho Gunchev + +2006-12-12 - 1.2 + + - added a simple level editor + - fixed error messages on GCC 2.96 - Thanks to Gerald Schnabel + - added introduction screen + - invincibility is deactivates once level is complete + +2006-12-08 - 1.1 + + - fixed warning messages on GCC 4.1 + - changed background color of blue ghosts to make them more visible + +2006-06-09 - 1.0 + + - initial release + + +Future Releases: +---------------- +1) Different sized mazes +2) Multiplayer +3) World domination diff --git a/Levels/README b/Levels/README new file mode 100755 index 0000000..e531167 --- /dev/null +++ b/Levels/README @@ -0,0 +1,40 @@ +The included level editor (pacmanedit) isn't very difficult to learn to use, +the status bar tells you everything you need to know but here are the keys + +UDLR or WSAD: Move cursor +F: Fills all blank spaces with pellets +C: Clears all pellets from board +Q: Saves and quits +CTRL+C: Quits WITHOUT saving + +Key Inserts +----------------------- +0 or space: Blank +1: Wall +2: Pellet +3: Powerup +4: Ghost/Spawning Wall +5: Blinky +6: Inkey +7: Clyde +8: Pinky +9: Pacman + + +*) The spawning wall is a wall that the ghosts can go through but Pacman + cannot. These can be used to make levels REALLY difficult. Check level 09 + +*) Borders shouldn't need to be used, but give it a more Pacman-like feel. + If a ghost or Pacman are able to reach the very edge of the board, he will + be teleported to the opposite side of the level, both X and Y just like in + the regular game. + +*) See any included level__.dat file for examples. + + +To edit a new or existing level, type: + $ pacmanedit new_or_old_level.dat + + +To load a custom level, run pacman with the level file as the parameter: + $ pacman levelfile.dat diff --git a/Levels/level01.dat b/Levels/level01.dat new file mode 100755 index 0000000..62a32ed --- /dev/null +++ b/Levels/level01.dat @@ -0,0 +1,30 @@ +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 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 +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 +1 3 1 0 0 1 2 1 0 0 0 1 2 1 1 2 1 0 0 0 1 2 1 0 0 1 3 1 +1 2 1 0 0 1 2 1 0 0 0 1 2 1 1 2 1 0 0 0 1 2 1 0 0 1 2 1 +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 +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 +1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 +1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 +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 +1 1 1 1 1 1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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..d60ec49 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +prefix=/usr/local +bindir=$(prefix)/bin +datarootdir=$(prefix)/share + +all: + gcc pacman.c -o pacman -DDATAROOTDIR=\"$(datarootdir)\" $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lncurses + gcc pacmanedit.c -o pacmanedit -DDATAROOTDIR=\"$(datarootdir)\" $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lncurses + +install: all + mkdir -p $(DESTDIR)$(bindir) + mkdir -p $(DESTDIR)$(datarootdir)/pacman + cp -fR Levels/ $(DESTDIR)$(datarootdir)/pacman/ + -chown root:games $(DESTDIR)$(bindir)/pacman + -chown root:games $(DESTDIR)$(datarootdir)/pacman -R + chmod 750 $(DESTDIR)$(bindir)/pacman + chmod 750 $(DESTDIR)$(bindir)/pacmanedit + chmod 750 $(DESTDIR)$(datarootdir)/pacman/ -R + +uninstall: + rm -f $(DESTDIR)$(bindir)/pacman + rm -f $(DESTDIR)$(bindir)/pacmanedit + rm -f $(DESTDIR)$(datarootdir)/pacman/Levels/level0[1-9].dat + rm -f $(DESTDIR)$(datarootdir)/pacman/Levels/README + rm -f $(DESTDIR)$(datarootdir)/pacman/Levels/template.dat + if [ -e $(DESTDIR)$(datarootdir)/pacman/Levels/ ] ; then rmdir $(DESTDIR)$(datarootdir)/pacman/Levels/ ; fi + if [ -e $(DESTDIR)$(datarootdir)/pacman/ ] ; then rmdir $(DESTDIR)$(datarootdir)/pacman/ ; fi + +clean: uninstall + rm -f pacman + rm -f pacmanedit diff --git a/README b/README new file mode 100755 index 0000000..8f338df --- /dev/null +++ b/README @@ -0,0 +1,56 @@ + +Pacman For Console +------------------ +Okay, so basically, I got tired of enabling flash on my browser so that I could play Pacman. +That, and I was extremely bored one night. So I decided to make my own Pacman... for Console. + +Licenseing Information +---------------------- +See COPYING for details on the GNU/GPL + +Compile/Install +--------------- +To make... gee... let's see. type 'make' +To install... type 'make install' +To run...type 'pacman [level_#]' where # is 1-9, for a premade level + OR type 'pacmac [level_file_name]' for a custom level you made +To uninstall... type 'make uninstall' + i.e.: + make && su -c "make install" + pacman 3 # Start @ level 3 + pacman /usr/share/pacman/Levels/level07.dat # Play only level 7 + echo ":-( I don't like it." && make uninstall # Uninstall :-( + +The ASCII art: +-------------- +C - Pacman - That's you. +& - Ghosts - Boo. +. - Pellet - Yummy. Collect all of them to pass to the next level. +* - Power pellet - Makes you invincible for a short while. + - Wall - No one can walk through it. + - Blocker - A.K.A. Ghost wall. Only the Ghosts can walk through this. + + +13 Basics Playing Rules +----------------------- +In case you don't know the rules of Pacman (rules I programmed in), here are most of them +1) Pacman must collect all the pellets of food in the maze. 1 point per pellet. +2) Big pellets make Pacman invincible for a short amount of time. +3) If Pacman touches a ghost without being invincible, he dies and loses 1 life. +4) If Pacman touches a ghost while invincible, the ghost is sent back to its starting point. +5) Points are awarded for each ghost eaten in a row while invincible: 20, 40, 80, 160 (10*2^x). +6) Pacman cannot go through the Ghost Walls (Blockers). +7) Ghosts cannot turn completely around unless there is no other option. +8) While Pacman is invincible, Ghosts will be a bit slower and tend to stay away from him. +9) While Pacman is NOT invincible, Ghosts will tend to come toward him. +10) Pacman starts with 3 extra lives, once all three are gone, the game is over. +11) Extra lives are awarded at 1000 points, 2000, 4000, 8000... (500*2^x). +12) If any character reaches a border of the maze, it will be transported to the opposite side. +13) Each character can only go in one X or Y direction at a time. + +To make your own levels, see Levels/README + +Contact Information +------------------- +Send comments and levels you have made to: michaelbillars@gmail.com +I would love to include more levels. diff --git a/pacman b/pacman new file mode 100755 index 0000000000000000000000000000000000000000..b9682e1603d0d018091a124a227af6121a86e961 GIT binary patch literal 24196 zcmeHveRx#Wx$mANTRvo*V2QQXk3m5ZHJ~L5LNq`IhBlE@jI~-igvrFDB$;$F;ls*3 z8Odn2n}PUod(hUJ_F9it>BUp6NF@ZJPO7a&4^?{QD1P^aIT6> z1?oeMEujcevN@z#_|{l2L1NIS1AY!n0n!EkeH z#(=qa?N>>>(-j`+Ec-dZ1zub8hKAS|jw-y<6$ojJ-4k9MceBK}D_?xwVh3B9)JrQ=d7#CmXpT4HX8QH!aK>u1XpNBU~;dxcR zl6K;;y%*xPuRx%-CR$@t$G5i%wj|Ud#X|b?$4M~U)D&*E5p(U=rSMwZHb*udWjU`v zU~Ow=)*i2)hINW{rZ_4&=Rz)CW}T~8an09!)#UnpTL8IT>lNii`ckdpd58p;@?3 zbd}wxX_aFXQe7`@+G9>zYh+Gi!`eBun;L6D^ZGJwF?Nr|i`Txk=<=--KK|ufH!hw) zd4*({G+ErUZJK$wpi4XJah-KulrtYU%h*P(0IN9ev~0+44z@*FL#@Rn#q)}xO2b;P z<<@h#c4An$vg)nc)EW&n6)#CwLcQ~GQ_n&4n-?+1GU-Ctl^3@In{E*~z zfpH6rTVUJ*;}-b;V}WYF@xFh{z+C@sTVB#P!lbcz*l)BACVc~>{6^9$y%@RsjhC%i zNLcwr2u_)#Y5UGXdC!>$o}uGuykN~j9NRoh%Cn6Qx!?2+`pu0Kts%HQ{!&qJ`+4bt zvWd@^1v5-5P;SitYAOj9>x|Ph4O*~L8g!bYuBT^WEHxJyM&*F%8!+_ya72uiZbt|g zQS&5jC38am7(D(&>4%IA-%+ccx?I9@kl);V^!b7bb4~ZRS#>|bI$r?q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A3K0tzUi$8~({7)D5UZn4 bV1qpK1U87nPQX5Y1vc2no8!)kn)ZJH_0&?V literal 0 HcmV?d00001 diff --git a/pacman.c b/pacman.c new file mode 100755 index 0000000..fda4a6d --- /dev/null +++ b/pacman.c @@ -0,0 +1,750 @@ +/**************************************************** +* Pacman For Console V1.3 * +* By: Mike Billars (michael@gmail.com) * +* Date: 2014-04-26 * +* * +* Please see file COPYING for details on licensing * +* and redistribution of this program * +* * +****************************************************/ + +/*********** +* INCLUDES * +***********/ +#include +#include +#include +#include +#include +#include +#include +#include "pacman.h" + +#define EXIT_MSG "Good bye!" +#define END_MSG "Game Over" +#define QUIT_MSG "Bye" +#define LEVEL_ERR "Cannot find level file: " +#define LEVEL_WIDTH 28 +#define LEVEL_HEIGHT 29 + +/************* +* PROTOTYPES * +*************/ +void IntroScreen(); //Show introduction screen and menu +void CheckCollision(); //See if Pacman and Ghosts collided +void CheckScreenSize(); //Make sure resolution is at least 32x29 +void CreateWindows(int y, int x, int y0, int x0); //Make ncurses windows +void Delay(); //Slow down game for better control +void DrawWindow(); //Refresh display +void ExitProgram(const char *message); //Exit and display something +void GetInput(); //Get user input +void InitCurses(); //Start up ncurses +void LoadLevel(char *levelfile); //Load level into memory +void MainLoop(); //Main program function +void MoveGhosts(); //Update Ghosts' location +void MovePacman(); //Update Pacman's location +void PauseGame(); //Pause + + +/******************* +* GLOBAL VARIABLES * +*******************/ +//I know global variables are bad, but it's just sooo easy! + +//Windows used by ncurses +WINDOW * win; +WINDOW * status; + +//For colors +enum { Wall = 1, Normal, Pellet, PowerUp, GhostWall, Ghost1, Ghost2, Ghost3, Ghost4, BlueGhost, Pacman }; + +int Loc[5][2] = { 0 }; //Location of Ghosts and Pacman +int Dir[5][2] = { 0 }; //Direction of Ghosts and Pacman +int StartingPoints[5][2] = { 0 }; //Default location in case Pacman/Ghosts die +int Invincible = 0; //Check for invincibility +int Food = 0; //Number of pellets left in level +int Level[29][28] = { 0 }; //Main level array +int LevelNumber = 0; //What level number are we on? +int GhostsInARow = 0; //Keep track of how many points to give for eating ghosts +int tleft = 0; //How long left for invincibility + +/**************************************************************** +* Function: main() * +* Parameters: argc, argv (passed from command line) * +* Returns: Success * +* Description: Initiate the program and call the subfunctions * +****************************************************************/ +int main(int argc, char *argv[100]) { + + int j = 0; + srand( (unsigned)time( NULL ) ); + + InitCurses(); //Must be called to start ncurses + CheckScreenSize(); //Make sure screen is big enough + CreateWindows(29, 28, 1, 1); //Create the main and status windows + + //If they specified a level to load + if((argc > 1) && (strlen(argv[1]) > 1)) { + argv[1][99] = '\0'; + LoadLevel(argv[1]); //Load it and... + MainLoop(); //Start the game + } + + //If they did not enter a level, display intro screen then use default levels + else { + IntroScreen(); //Show intro "movie" + j = 1; //Set initial level to 1 + + if(argc > 1) j = argv[1][0] - '0'; //They specified a level on which to start (1-9) + + //Load 9 levels, 1 by 1, if you can beat all 9 levels in a row, you're awesome + for(LevelNumber = j; LevelNumber < 10; LevelNumber++) { + + //Replace level string underscore with the actual level number (see pacman.h) + LevelFile[strlen(LevelFile) - 6] = '0'; + LevelFile[strlen(LevelFile) - 5] = LevelNumber + '0'; + + LoadLevel(LevelFile); //Load level into memory + Invincible = 0; //Reset invincibility with each new level + MainLoop(); //Start the level + + } + + } + + //Game has ended, deactivate and end program + ExitProgram(EXIT_MSG); + + //This doesn't need to be here, but just to be proper + return(0); +} + +/**************************************************************** +* Function: CheckCollision() * +* Parameters: none * +* Returns: none * +* Description: Check and handle if Pacman collided with a ghost * +****************************************************************/ +void CheckCollision() { + + //Temporary variable + int a = 0; + + //Check each ghost, one at a time for collision + for(a = 0; a < 4; a++) { + + //Ghost X and Y location is equal to Pacman X and Y location (collision) + if((Loc[a][0] == Loc[4][0]) && (Loc[a][1] == Loc[4][1])) { + + //Pacman is invincible, ghost dies + if(Invincible == 1) { + + Points = Points + GhostsInARow * 20; //Increase points by an increasing value + + //Display the points earned for eating the ghost + mvwprintw(win, Loc[4][0], Loc[4][1] - 1, "%d", (GhostsInARow * 20)); + GhostsInARow *= 2; + + wrefresh(win); //Update display + usleep(1000000); //and pause for a second + + //Reset the ghost's position to the starting location + Loc[a][0] = StartingPoints[a][0]; Loc[a][1] = StartingPoints[a][1]; + } + + //Pacman is vulnerable, Pacman dies + else { + + //Display an X in position + wattron(win, COLOR_PAIR(Pacman)); + mvwprintw(win, Loc[4][0], Loc[4][1], "X"); + wrefresh(win); + + //Subtract one life and pause for 1 second + Lives--; + usleep(1000000); + + //If no more lives, game over + if(Lives == -1) ExitProgram(END_MSG); + + //If NOT game over... + + //Reset Pacman's and ghosts' positions + for(a = 0; a < 5; a++) { + Loc[a][0] = StartingPoints[a][0]; + Loc[a][1] = StartingPoints[a][1]; + } + + //Reset directions + Dir[0][0] = 1; Dir[0][1] = 0; + Dir[1][0] = -1; Dir[1][1] = 0; + Dir[2][0] = 0; Dir[2][1] = -1; + Dir[3][0] = 0; Dir[3][1] = 1; + Dir[4][0] = 0; Dir[4][1] = -1; + + DrawWindow(); //Redraw window + usleep(1000000); //Pause for 1 second before continuing game + } + } + } +} + +/**************************************************************** +* Function: CheckScreenSize() * +* Parameters: none * +* Returns: none * +* Description: Make sure the virtual console is big enough * +****************************************************************/ +void CheckScreenSize() { + + //Make sure the window is big enough + int h, w; getmaxyx(stdscr, h, w); + + if((h < 32) || (w < 29)) { + endwin(); + fprintf(stderr, "\nSorry.\n"); + fprintf(stderr, "To play Pacman for Console, your console window must be at least 32x29\n"); + fprintf(stderr, "Please resize your window/resolution and re-run the game.\n\n"); + exit(0); + } + +} + +/**************************************************************** +* Function: CreateWindows() * +* Parameters: y, x, y0, x0 (coords and size of window) * +* Returns: none * +* Description: Create the main game windows * +****************************************************************/ +void CreateWindows(int y, int x, int y0, int x0) { + //Create two new windows, for status bar and for main level + win = newwin(y, x, y0, x0); + status = newwin(3, 27, 29, 1); +} + +/**************************************************************** +* Function: Delay() * +* Parameters: none * +* Returns: none * +* Description: Pause the game and still get keyboard input * +****************************************************************/ +void Delay() { + + //Needed to get time + struct timeb t_start, t_current; + ftime(&t_start); + + //Slow down the game a little bit + do { + GetInput(); //Still get the input from keyboard + ftime(&t_current); //Update time and check if enough time has overlapped + } while (abs(t_start.millitm - t_current.millitm) < SpeedOfGame); +} + +/**************************************************************** +* Function: DrawWindow() * +* Parameters: none * +* Returns: none * +* Description: Redraw each window to update the screen * +****************************************************************/ +void DrawWindow() { + + //Temporary variables + int a = 0; int b = 0; + char chr = ' '; //Variable used to display certain characters + int attr; //Variable that displays normal/bold character + + //Display level array + for(a = 0; a < 29; a++) for(b = 0; b < 28; b++) { + //Determine which character is in location and display it + switch(Level[a][b]) { + case 0: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Normal)); break; + case 1: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Wall)); break; + case 2: chr = '.'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Pellet)); break; + case 3: chr = '*'; attr = A_BOLD; wattron(win, COLOR_PAIR(PowerUp)); break; + case 4: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(GhostWall)); break; + } + + //Display character. "attr" is ORed with chr as documented for mvwaddch, + // this will make the character bold/normal + mvwaddch(win, a, b, chr | attr); + } + + //Display number of lives, score, and level + + attr = A_NORMAL; //Reset attribute in case it's set to "BOLD" + + //Switch window to status, and change color + wmove(status, 1, 1); + wattron(status, COLOR_PAIR(Pacman)); + + //Display number of lives + for(a = 0; a < Lives; a++) + wprintw(status, "C "); + wprintw(status, " "); + + //Display level number and score + wattron(status, COLOR_PAIR(Normal)); + mvwprintw(status, 2, 2, "Level: %d Score: %d ", LevelNumber, Points); + + wrefresh(status); //Update status window + + //Display ghosts if Pacman is not invincible + if(Invincible == 0) { + wattron(win, COLOR_PAIR(Ghost1)); mvwaddch(win, Loc[0][0], Loc[0][1], '&'); + wattron(win, COLOR_PAIR(Ghost2)); mvwaddch(win, Loc[1][0], Loc[1][1], '&'); + wattron(win, COLOR_PAIR(Ghost3)); mvwaddch(win, Loc[2][0], Loc[2][1], '&'); + wattron(win, COLOR_PAIR(Ghost4)); mvwaddch(win, Loc[3][0], Loc[3][1], '&'); + } + + //OR display vulnerable ghosts + else { + wattron(win, COLOR_PAIR(BlueGhost)); + mvwaddch(win, Loc[0][0], Loc[0][1], tleft + '0'); + mvwaddch(win, Loc[1][0], Loc[1][1], tleft + '0'); + mvwaddch(win, Loc[2][0], Loc[2][1], tleft + '0'); + mvwaddch(win, Loc[3][0], Loc[3][1], tleft + '0'); + } + + //Display Pacman + wattron(win, COLOR_PAIR(Pacman)); mvwaddch(win, Loc[4][0], Loc[4][1], 'C'); + + wrefresh(win); //Update main window +} + +/**************************************************************** +* Function: ExitProgram() * +* Parameters: message: text to display before exiting * +* Returns: none * +* Description: Gracefully end program * +****************************************************************/ +void ExitProgram(const char *message) { + endwin(); //Uninitialize ncurses and destroy windows + printf("%s\n", message); //Display message + exit(0); //End program, return 0 +} + +/**************************************************************** +* Function: GetInput() * +* Parameters: none * +* Returns: none * +* Description: Get input from user and take appropriate action * +****************************************************************/ +void GetInput() { + + int ch; //Key pushed + static int chtmp; //Buffered key + int tmp; + + ch = getch(); //Figure out which key is pressed + + //If they are not pressing something, use previous input + if(ch == ERR) ch = chtmp; + chtmp = ch; + + //Determine which button is pushed + switch (ch) { + case KEY_UP: case 'w': case 'W': //Move pacman up + if(Loc[4][0] <= 0) tmp = LEVEL_HEIGHT - 1; + else tmp = Loc[4][0] - 1; + if((Level[tmp][Loc[4][1]] != 1) + && (Level[tmp][Loc[4][1]] != 4)) + { Dir[4][0] = -1; Dir[4][1] = 0; } + break; + + case KEY_DOWN: case 's': case 'S': //Move pacman down + if(Loc[4][0] >= 28) tmp = 0; + else tmp = Loc[4][0] + 1; + if((Level[tmp][Loc[4][1]] != 1) + && (Level[tmp][Loc[4][1]] != 4)) + { Dir[4][0] = 1; Dir[4][1] = 0; } + break; + + case KEY_LEFT: case 'a': case 'A': //Move pacman left + if(Loc[4][1] <= 0) tmp = LEVEL_WIDTH - 1; + else tmp = Loc[4][1] - 1; + if((Level[Loc[4][0]][tmp] != 1) + && (Level[Loc[4][0]][tmp] != 4)) + { Dir[4][0] = 0; Dir[4][1] = -1; } + break; + + case KEY_RIGHT: case 'd': case 'D': //Move pacman right + if(Loc[4][1] >= 27) tmp = 0; + else tmp = Loc[4][1] + 1; + if((Level[Loc[4][0]][tmp] != 1) + && (Level[Loc[4][0]][tmp] != 4)) + { Dir[4][0] = 0; Dir[4][1] = 1; } + break; + + case 'p': case 'P': //Pause game + PauseGame(); + chtmp = getch(); //Update buffered input + break; + + case 'q': case 'Q': //End program + ExitProgram(QUIT_MSG); + break; + + } +} + +/**************************************************************** +* Function: InitCurses() * +* Parameters: none * +* Returns: none * +* Description: Initialize ncurses and set defined colors * +****************************************************************/ +void InitCurses() { + + initscr(); //Needed for ncurses windows + start_color(); //Activate colors in console + curs_set(0); // Don't remember + keypad(stdscr, TRUE); //Activate arrow keys + nodelay(stdscr, TRUE); //Allow getch to work without pausing + nonl(); // Don't remember + cbreak(); // Don't remember + noecho(); //Don't display input key + + //Make custom text colors + init_pair(Normal, COLOR_WHITE, COLOR_BLACK); + init_pair(Wall, COLOR_WHITE, COLOR_WHITE); + init_pair(Pellet, COLOR_WHITE, COLOR_BLACK); + init_pair(PowerUp, COLOR_BLUE, COLOR_BLACK); + init_pair(GhostWall, COLOR_WHITE, COLOR_CYAN); + init_pair(Ghost1, COLOR_RED, COLOR_BLACK); + init_pair(Ghost2, COLOR_CYAN, COLOR_BLACK); + init_pair(Ghost3, COLOR_MAGENTA, COLOR_BLACK); + init_pair(Ghost4, COLOR_YELLOW, COLOR_BLACK); + init_pair(BlueGhost, COLOR_BLUE, COLOR_RED); + init_pair(Pacman, COLOR_YELLOW, COLOR_BLACK); +} + +/**************************************************************** +* Function: IntroScreen() * +* Parameters: none * +* Returns: none * +* Description: Display the introduction animation * +****************************************************************/ +void IntroScreen() { + int a = 0; + int b = 23; + + a=getch(); a=getch(); a=getch();//Clear the buffer + + mvwprintw(win, 20, 8, "Press any key..."); + + //Scroll Pacman to middle of screen + for(a = 0; a < 13; a++) { + if(getch()!=ERR) return; + wattron(win, COLOR_PAIR(Pacman)); + mvwprintw(win, 8, a, " C"); + wrefresh(win); + usleep(100000); + } + + //Show "Pacman" + wattron(win, COLOR_PAIR(Pacman)); + mvwprintw(win, 8, 12, "PACMAN"); + wrefresh(win); + usleep(1000000); + + //Ghosts chase Pacman + for(a = 0; a < 23; a++) { + if(getch()!=ERR) return; + wattron(win, COLOR_PAIR(Pellet)); mvwprintw(win, 13, 23, "*"); + wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, a, " C"); + wattron(win, COLOR_PAIR(Ghost1)); mvwprintw(win, 13, a-3, " &"); + wattron(win, COLOR_PAIR(Ghost3)); mvwprintw(win, 13, a-5, " &"); + wattron(win, COLOR_PAIR(Ghost2)); mvwprintw(win, 13, a-7, " &"); + wattron(win, COLOR_PAIR(Ghost4)); mvwprintw(win, 13, a-9, " &"); + wrefresh(win); + usleep(100000); + } + + usleep(150000); + + //Pacman eats powerup and chases Ghosts + for(a = 25; a > 2; a--) { + if(getch()!=ERR) return; + wattron(win, COLOR_PAIR(Pellet)); mvwprintw(win, 13, 23, " "); + + //Make ghosts half as fast so Pacman can catch them + if(a%2) b--; + + wattron(win, COLOR_PAIR(BlueGhost)); mvwprintw(win, 13, b-9, "& & & &"); + + //Erase the old positions of ghosts + wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+1, " "); + wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+3, " "); + wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+5, " "); + wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, b-9+7, " "); + + wattron(win, COLOR_PAIR(Pacman)); mvwprintw(win, 13, a-3, "C "); + + wattron(win, COLOR_PAIR(Pellet)); mvwprintw(win, 13, 23, " "); + wrefresh(win); + usleep(100000); + } + +} + +/**************************************************************** +* Function: LoadLevel() * +* Parameters: levelfile: name of file to load * +* Returns: none * +* Description: Open level file and load it into memory * +****************************************************************/ +void LoadLevel(char levelfile[100]) { + + int a = 0; int b = 0; + size_t l; + char error[sizeof(LEVEL_ERR)+255] = LEVEL_ERR; //Let's assume an error + FILE *fin; //New file variable + Food = 0; //Used to count how many food pellets must be eaten + + //Reset defaults + Dir[0][0] = 1; Dir[0][1] = 0; + Dir[1][0] = -1; Dir[1][1] = 0; + Dir[2][0] = 0; Dir[2][1] = -1; + Dir[3][0] = 0; Dir[3][1] = 1; + Dir[4][0] = 0; Dir[4][1] = -1; + + //Open file + fin = fopen(levelfile, "r"); + + //Make sure it didn't fail + if(!(fin)) { + l = sizeof(error)-strlen(error)-1; + strncat(error, levelfile, l); + if(strlen(levelfile) > l) { + error[sizeof(error)-2] = '.'; + error[sizeof(error)-3] = '.'; + error[sizeof(error)-4] = '.'; + } + ExitProgram(error); + } + + //Open file and load the level into the array + for(a = 0; a < 29; a++) { + for(b = 0; b < 28; b++) { + fscanf(fin, "%d", &Level[a][b]); //Get character from file + if(Level[a][b] == 2) { Food++; } //If it's a pellet, increase the pellet count + + //Store ghosts' and Pacman's locations + if(Level[a][b] == 5) { Loc[0][0] = a; Loc[0][1] = b; Level[a][b] = 0;} + if(Level[a][b] == 6) { Loc[1][0] = a; Loc[1][1] = b; Level[a][b] = 0;} + if(Level[a][b] == 7) { Loc[2][0] = a; Loc[2][1] = b; Level[a][b] = 0;} + if(Level[a][b] == 8) { Loc[3][0] = a; Loc[3][1] = b; Level[a][b] = 0;} + if(Level[a][b] == 9) { Loc[4][0] = a; Loc[4][1] = b; Level[a][b] = 0;} + } + } + + //All done, now get the difficulty level (AKA level number) + fscanf(fin, "%d", &LevelNumber); + + //Save initial character positions in case Pacman or Ghosts die + for(a = 0; a < 5; a++) { + StartingPoints[a][0] = Loc[a][0]; StartingPoints[a][1] = Loc[a][1]; + } + +} + +/**************************************************************** +* Function: MainLoop() * +* Parameters: none * +* Returns: none * +* Description: Control the main execution of the game * +****************************************************************/ +void MainLoop() { + + DrawWindow(); //Draw the screen + wrefresh(win); wrefresh(status); //Refresh it just to make sure + usleep(1000000); //Pause for a second so they know they're about to play + + /* Move Pacman. Move ghosts. Check for extra life awarded + from points. Pause for a brief moment. Repeat until all pellets are eaten */ + do { + MovePacman(); DrawWindow(); CheckCollision(); + MoveGhosts(); DrawWindow(); CheckCollision(); + if(Points > FreeLife) { Lives++; FreeLife *= 2;} + Delay(); + } while (Food > 0); + + DrawWindow(); //Redraw window and... + usleep(1000000); //Pause, level complete + +} + +/**************************************************************** +* Function: MoveGhosts() * +* Parameters: none * +* Returns: none * +* Description: Move all ghosts and check for wall collisions * +****************************************************************/ +void MoveGhosts() { + + //Set up some temporary variables + int a = 0; int b = 0; int c = 0; + int checksides[] = { 0, 0, 0, 0, 0, 0 }; + static int SlowerGhosts = 0; + int tmp; + + /* Move ghosts slower when they are vulnerable. This will allow + the ghosts to move only x times for every y times Pacman moves */ + if(Invincible == 1) { + SlowerGhosts++; + if(SlowerGhosts > HowSlow) + SlowerGhosts = 0; + } + + //If ghosts are not vulnerable OR the ghosts can move now + if((Invincible == 0) || SlowerGhosts < HowSlow) + + //Loop through each ghost, one at a time + for(a = 0; a < 4; a++) { + + //Switch sides? (Transport to other side of screen) + if((Loc[a][0] == 0) && (Dir[a][0] == -1)) Loc[a][0] = 28; + else if((Loc[a][0] == 28) && (Dir[a][0] == 1)) Loc[a][0] = 0; + else if((Loc[a][1] == 0) && (Dir[a][1] == -1)) Loc[a][1] = 27; + else if((Loc[a][1] == 27) && (Dir[a][1] == 1)) Loc[a][1] = 0; + else { + + //Determine which directions we can go + for(b = 0; b < 4; b++) checksides[b] = 0; + if(Loc[a][0] == 28) tmp = 0; + else tmp = Loc[a][0] + 1; + if(Level[tmp][Loc[a][1]] != 1) checksides[0] = 1; + if(Loc[a][0] == 0) tmp = 28; + else tmp = Loc[a][0] - 1; + if(Level[tmp][Loc[a][1]] != 1) checksides[1] = 1; + if(Loc[a][1] == 27) tmp = 0; + else tmp = Loc[a][1] + 1; + if(Level[Loc[a][0]][tmp] != 1) checksides[2] = 1; + if(Loc[a][1] == 0) tmp = 27; + else tmp = Loc[a][1] - 1; + if(Level[Loc[a][0]][tmp] != 1) checksides[3] = 1; + + //Don't do 180 unless we have to + c = 0; for(b = 0; b < 4; b++) if(checksides[b] == 1) c++; + if(c > 1) { + if(Dir[a][0] == 1) checksides[1] = 0; + else if(Dir[a][0] == -1) checksides[0] = 0; + else if(Dir[a][1] == 1) checksides[3] = 0; + else if(Dir[a][1] == -1) checksides[2] = 0; + } + + c = 0; + do { + //Decide direction, based somewhat-randomly + b = (int)(rand() / (1625000000 / 4)); + + /* Tend to mostly chase Pacman if he is vulnerable + or run away when he is invincible */ + if(checksides[b] == 1) { + if(b == 0) { Dir[a][0] = 1; Dir[a][1] = 0; } + else if(b == 1) { Dir[a][0] = -1; Dir[a][1] = 0; } + else if(b == 2) { Dir[a][0] = 0; Dir[a][1] = 1; } + else if(b == 3) { Dir[a][0] = 0; Dir[a][1] = -1; } + } + else { + if(Invincible == 0) { + //Chase Pacman + if((Loc[4][0] > Loc[a][0]) && (checksides[0] == 1)) { Dir[a][0] = 1; Dir[a][1] = 0; c = 1; } + else if((Loc[4][0] < Loc[a][0]) && (checksides[1] == 1)) { Dir[a][0] = -1; Dir[a][1] = 0; c = 1; } + else if((Loc[4][1] > Loc[a][1]) && (checksides[2] == 1)) { Dir[a][0] = 0; Dir[a][1] = 1; c = 1; } + else if((Loc[4][1] < Loc[a][1]) && (checksides[3] == 1)) { Dir[a][0] = 0; Dir[a][1] = -1; c = 1; } + } + + else { + //Run away from Pacman + if((Loc[4][0] > Loc[a][0]) && (checksides[1] == 1)) { Dir[a][0] = -1; Dir[a][1] = 0; c = 1; } + else if((Loc[4][0] < Loc[a][0]) && (checksides[0] == 1)) { Dir[a][0] = 1; Dir[a][1] = 0; c = 1; } + else if((Loc[4][1] > Loc[a][1]) && (checksides[3] == 1)) { Dir[a][0] = 0; Dir[a][1] = -1; c = 1; } + else if((Loc[4][1] < Loc[a][1]) && (checksides[2] == 1)) { Dir[a][0] = 0; Dir[a][1] = 1; c = 1; } + } + } + + } while ((checksides[b] == 0) && (c == 0)); + + //Move Ghost + Loc[a][0] += Dir[a][0]; + Loc[a][1] += Dir[a][1]; + } + } +} + +/**************************************************************** +* Function: MovePacman() * +* Parameters: none * +* Returns: none * +* Description: Move Pacman and check for wall collisions * +****************************************************************/ +void MovePacman() { + + static int itime = 0; + + //Switch sides? (Transport to other side of screen) + if((Loc[4][0] == 0) && (Dir[4][0] == -1)) Loc[4][0] = 28; + else if((Loc[4][0] == 28) && (Dir[4][0] == 1)) Loc[4][0] = 0; + else if((Loc[4][1] == 0) && (Dir[4][1] == -1)) Loc[4][1] = 27; + else if((Loc[4][1] == 27) && (Dir[4][1] == 1)) Loc[4][1] = 0; + + //Or + else { + //Move Pacman + Loc[4][0] += Dir[4][0]; + Loc[4][1] += Dir[4][1]; + + //If he hit a wall, move back + if((Level[Loc[4][0]][Loc[4][1]] == 1) || (Level[Loc[4][0]][Loc[4][1]] == 4)) { + Loc[4][0] -= Dir[4][0]; Loc[4][1] -= Dir[4][1]; + } + } + + //What is Pacman eating? + switch (Level[Loc[4][0]][Loc[4][1]]) { + case 2: //Pellet + Level[Loc[4][0]][Loc[4][1]] = 0; + Points++; + Food--; + break; + case 3: //PowerUp + Level[Loc[4][0]][Loc[4][1]] = 0; + Invincible = 1; + if(GhostsInARow == 0) GhostsInARow = 1; + itime = time(0); + break; + } + + //Is he invincible? + if(Invincible == 1) tleft = (11 - LevelNumber - time(0) + itime); + + //Is invincibility up yet? + if(tleft < 0) { Invincible = 0; GhostsInARow = 0; tleft = 0; } + +} + +/**************************************************************** +* Function: PauseGame() * +* Parameters: none * +* Returns: none * +* Description: Pause game until user presses a button * +****************************************************************/ +void PauseGame() { + + int chtmp; + + //Display pause dialog + wattron(win, COLOR_PAIR(Pacman)); + mvwprintw(win, 12, 10, "********"); + mvwprintw(win, 13, 10, "*PAUSED*"); + mvwprintw(win, 14, 10, "********"); + wrefresh(win); + + //And wait until key is pressed + do { + chtmp = getch(); //Get input + } while (chtmp == ERR); + +} diff --git a/pacman.h b/pacman.h new file mode 100755 index 0000000..b460e42 --- /dev/null +++ b/pacman.h @@ -0,0 +1,12 @@ +// Some variables that you may want to change + +#ifndef DATAROOTDIR +# define DATAROOTDIR "/usr/local/share" +#endif +#define LEVELS_FILE DATAROOTDIR "/pacman/Levels/level__.dat" +char LevelFile[] = LEVELS_FILE; //Locations of default levels +int FreeLife = 1000; //Starting points for free life +int Points = 0; //Initial points +int Lives = 3; //Number of lives you start with +int HowSlow = 3; //How slow vulnerable ghost move +int SpeedOfGame = 175; //How much of a delay is in the game diff --git a/pacmanedit b/pacmanedit new file mode 100755 index 0000000000000000000000000000000000000000..ebe8842ea01fd3e7fa80c3186f4d319b881b47f2 GIT binary patch literal 18792 zcmeHPeRxz=dOs5w#Yh-XPfWKzXWUXZy20u1J?GrX z%uU$G{?k9&IZw_x@B5zjXmtTJJ)%lD$CNb7t#2A}_SbiR3-An<**f$W} zh?-Wr`gZj@>iWBgnjakb=!6*QnFj-!wo$!jV?GO)Uz|^45=Y&b6A@M7LDQmoYg8i0 z?E1D`g2sTp1UUu5Cks%dlUaK%s%epEb6q4$vg`ZaLZNT3b1r| zLy+V7{qaPZ&_{hvf$%>RG)?zu4Pj4{F1YOV8D-dAK`X=SLW&Sd;U=U6shl|lp#Dbe^1 z6kNerC1X>NO+jvrRiLaEcpn7Ps~KC2oa#hlZ(kK~decH z*Mc@3kzG*C;{ppO8p1rZm*i+2%ME0w9FfYn-zQ__BW7*Ge!$xtj_8rn<)zC?QI*Cz z@Y>}Zju+8|jy$;yZIP(nRC;Sx2y)jUQau&;k!;SFcsXzi-$JBv!b3zTgn|bO9w>OA z;DLe%3LYqUpx}Xm2MQi2c%a~cf(Hs7_X1g-JQcqQXQo>8{0?RMsvDj`v_gQ zxOR0Sb;s1SJJveId>VHg?h0P8<9;f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rs==Ak-XXCmd_hJ5~G}WA@LEYBuDkfrjc} zFvNBgZNTMMHC^SgokdZ<-VkMv7tuXnfc{m$lSOcFv^m21il~47x`^(zCb1#hW))%R zM0H^;!j3w8y7z$%-mtC*HsBJEy^a4=(N_xI_A(@CN(Po7>05=QzZ&vE_KAbreYl7f zdFn+S&N{s8ks|Qk1-79-LehITlJ+{1dXQ+8q|fYVIf5piMdl--Y0_KEVbXYJ)&V zrqQdyRl*3~4KNq1rSbDOGJ1`~6^SpE_`qeN{1%C~%kpnaybr%xBKb`cUwoawJ%r;1 z6nBxlobI^E-oW(&kI3@=3W3v=HI;AqmcVyNyjS9Jj!#D_%6~{W^rxl#^MsQ;E;o^} zpIPOoIN`5Jd`R*SNPI+=(@O{NS$)9pV_!H$TZTK1+UTwqgw&9u$_u24}4c{v8YOF;v+C zL<~WOm4)HznBn@DzyHNF;Qz+}KTcuaM8t1~`2RSVkGu>Kp_1kpP2&Ge+X~aH1-8`d zi#COrR%KfPwW_=&Qp;JLwcK?(tB7ei3$-Q|M6DXHVX~l?Y1yS)8(X=x3APC>yNGLi zzo4y>R&q@&@*1t@Ifn-hX7@SkWH5FnuucPF>$CPet$}ZLT7%rjv<9)gWlswdXk$4i z1P;>Kz&aJ=oCmCvK=up(fbaguvF%&?W!}CIgdd2k-P1Y%AeTG8)*`lit%dLPT8p*G Jk2@u?{{|01zi$8l literal 0 HcmV?d00001 diff --git a/pacmanedit.c b/pacmanedit.c new file mode 100755 index 0000000..c99305e --- /dev/null +++ b/pacmanedit.c @@ -0,0 +1,406 @@ +/**************************************************** +* Pacman For Console Level Editor * +* By: Mike Billars (michaelbillars@gmail.com) * +* Date: 2014-04-26 * +* * +* Please see file COPYING for details on licensing * +* and redistribution of this program * +* * +****************************************************/ + +/*********** +* INCLUDES * +***********/ +#include +#include +#include +#include + +/************* +* PROTOTYPES * +*************/ +void CheckScreenSize(); //Make sure resolution is at least 32x29 +void CreateWindows(int y, int x, int y0, int x0); //Make ncurses windows +void DrawWindow(); //Refresh display +void ExitProgram(char message[255]); //Exit gracefully +void GetInput(); //Get user input +void InitCurses(); //Start up ncurses +void LoadLevel(); //Load level into memory +void MainLoop(); //Main loop +void SaveLevel(); //Save level to specified file + +/******************* +* GLOBAL VARIABLES * +*******************/ +//I know global variables are bad, but it's just sooo easy! + +//Windows used by ncurses +WINDOW * win; +WINDOW * status; + +//For colors +enum { Wall = 1, Normal, Pellet, PowerUp, GhostWall, Ghost1, Ghost2, Ghost3, Ghost4, BlueGhost, Pacman, Cursor}; + +int Level[29][28] = { 0 }; //Main level array +int Loc[6][2] = { 0 }; //Ghosts, Pacman, and cursor locations +int tleft = 0; //How long left for invincibility +char filename[255] = ""; //Name of file to load/save + +/**************************************************************** +* Function: main() * +* Parameters: argc, argv (passed from command line) * +* Returns: Success * +* Description: Initiate the program and call the subfunctions * +****************************************************************/ +int main(int argc, char *argv[100]) { + + //Make sure they entered a filename to open/save + if((argc > 1) && (strlen(argv[1]) >= 1)) { + + strcpy(filename, argv[1]); //Copy command line parameter into string + LoadLevel(); //Load the file + + InitCurses(); //Initialize ncurses + CheckScreenSize(); //Make sure the screen is big enough + CreateWindows(29, 28, 1, 1); // + + DrawWindow(); + Loc[5][0]=13; + Loc[5][1]=13; + MainLoop(); + } + else + ExitProgram("You must specify a file to use (load and save)"); + +} + +/**************************************************************** +* Function: CheckScreenSize() * +* Parameters: none * +* Returns: none * +* Description: Make sure the virtual console is big enough * +****************************************************************/ +void CheckScreenSize() { + + //Make sure the window is big enough + int h, w; getmaxyx(stdscr, h, w); + + if((h < 32) || (w < 29)) { + endwin(); + fprintf(stderr, "\nSorry.\n"); + fprintf(stderr, "To edit levels for Pacman for Console, your console window\n"); + fprintf(stderr, "must be at least 32x29 Please resize your window/resolution\n"); + fprintf(stderr, "and re-run the program.\n\n"); + ExitProgram(""); + } +} + +/**************************************************************** +* Function: CreateWindows() * +* Parameters: y, x, y0, x0 (coords and size of window) * +* Returns: none * +* Description: Create the main game windows * +****************************************************************/ +void CreateWindows(int y, int x, int y0, int x0) { + //Create two new windows, for status bar and for main level + win = newwin(y, x, y0, x0); + status = newwin(3, 28, 29, 1); +} + +/**************************************************************** +* Function: DrawWindow() * +* Parameters: none * +* Returns: none * +* Description: Redraw each window to update the screen * +****************************************************************/ +void DrawWindow() { + int a = 0; int b = 0; + char chr = ' '; + int attr; + + //Display level array + for(a = 0; a < 29; a++) for(b = 0; b < 28; b++) { + switch(Level[a][b]) { + case 0: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Normal)); break; + case 1: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(Wall)); break; + case 2: chr = '.'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Pellet)); break; + case 3: chr = '*'; attr = A_BOLD; wattron(win, COLOR_PAIR(PowerUp)); break; + case 4: chr = ' '; attr = A_NORMAL; wattron(win, COLOR_PAIR(GhostWall)); break; + case 5: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost1)); break; + case 6: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost2)); break; + case 7: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost3)); break; + case 8: chr = '&'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Ghost4)); break; + case 9: chr = 'C'; attr = A_NORMAL; wattron(win, COLOR_PAIR(Pacman)); break; + } + mvwaddch(win, a, b, chr | attr); + } + + //Display the cursor + wattron(win,COLOR_PAIR(Cursor)); + mvwaddch(win, Loc[5][0], Loc[5][1], 'X'); + + //Display info in status + wmove(status, 1, 1); + wattron(status, COLOR_PAIR(Normal)); + mvwprintw(status, 1, 0, "0) 1) 2) 3)"); + mvwprintw(status, 2, 0, "4) 5-8) 9) F/C/Q"); + + wattron(status, COLOR_PAIR(Normal)); mvwaddch(status, 1, 3, ' '); + wattron(status, COLOR_PAIR(Wall)); mvwaddch(status, 1, 10, ' '); + wattron(status, COLOR_PAIR(Pellet)); mvwaddch(status, 1, 19, '.'); + wattron(status, COLOR_PAIR(PowerUp)); mvwaddch(status, 1, 26 , '*' | A_BOLD); + wattron(status, COLOR_PAIR(GhostWall)); mvwaddch(status, 2, 3, ' '); + wattron(status, COLOR_PAIR(Ghost1)); mvwaddch(status, 2, 12, '&'); + wattron(status, COLOR_PAIR(Pacman)); mvwaddch(status, 2, 19, 'C'); + + wrefresh(status); + wrefresh(win); +} + +/**************************************************************** +* Function: ExitProgram() * +* Parameters: message: text to display before exiting * +* Returns: none * +* Description: Gracefully end program * +****************************************************************/ +void ExitProgram(char message[255]) { + + endwin(); + + //Must save file + if(message[0]=='s') { + printf("\n\nFile saved as: %s\n", filename); + } + + else + printf("%s\n\n", message); + + exit(0); +} + +/**************************************************************** +* Function: GetInput() * +* Parameters: none * +* Returns: none * +* Description: Get input from user and take appropriate action * +****************************************************************/ +void GetInput() { + int ch; + int a=0; + int b=0; + + static int chtmp; + + ch = getch(); + + //Buffer input + do { + DrawWindow(); + ch = getch(); + } while (ch == ERR); + + switch (ch) { + case KEY_UP: case 'w': case 'W': + Loc[5][0]--; + if(Loc[5][0]<0) { Loc[5][0]=28; } + break; + + case KEY_DOWN: case 's': case 'S': + Loc[5][0]++; + if(Loc[5][0]>28) { Loc[5][0]=0; } + break; + + case KEY_LEFT: case 'a': case 'A': + Loc[5][1]--; + if(Loc[5][1]<0) { Loc[5][1]=27; } + break; + + case KEY_RIGHT: case 'd': case 'D': + Loc[5][1]++; + if(Loc[5][1]>27) { Loc[5][1]=0; } + break; + + case 'q': case 'Q': + //Save and exit + SaveLevel(); + ExitProgram("s"); + break; + + //Draw a blank space + case '0': case ' ': + Level[Loc[5][0]][Loc[5][1]]=0; + break; + + //Draw a wall + case '1': + Level[Loc[5][0]][Loc[5][1]]=1; + break; + + //Draw a pellet + case '2': + Level[Loc[5][0]][Loc[5][1]]=2; + break; + + //Draw a powerup + case '3': + Level[Loc[5][0]][Loc[5][1]]=3; + break; + + //Draw a ghost/spawning wall + case '4': + Level[Loc[5][0]][Loc[5][1]]=4; + break; + + //Draw a ghost/pacman + case '5': case '6': case '7': + case '8': case '9': + //Move ghost/pacman to new location + Level[Loc[5][0]][Loc[5][1]]=ch-'0'; + + //Erase character from previous location and replace with BLANK + if(Level[Loc[ch-'0'-5][0]][Loc[ch-'0'-5][1]]==ch-'0') + Level[Loc[ch-'0'-5][0]][Loc[ch-'0'-5][1]]=0; + + //Set Loc variable to new location + Loc[ch-'0'-5][0]=Loc[5][0]; + Loc[ch-'0'-5][1]=Loc[5][1]; + + break; + + //Fill blank spaces with pellets + case 'f': case 'F': + for(a=0; a<29; a++) + for(b=0; b<28; b++) + if(Level[a][b]==0) Level[a][b]=2; + break; + + //Fill pellet spaces with blanks + case 'c': case 'C': + for(a=0; a<29; a++) + for(b=0; b<28; b++) + if(Level[a][b]==2) Level[a][b]=0; + break; + + } +} + +/**************************************************************** +* Function: InitCurses() * +* Parameters: none * +* Returns: none * +* Description: Initialize ncurses and set defined colors * +****************************************************************/ +void InitCurses() { + + initscr(); //Needed for ncurses windows + start_color(); //Activate colors in console + curs_set(0); // Don't remember + keypad(stdscr, TRUE); //Activate arrow keys + nodelay(stdscr, TRUE); //Allow getch to work without pausing + nonl(); // Don't remember + cbreak(); // Don't remember + noecho(); //Don't display input key + + //Make custom text colors + init_pair(Normal, COLOR_WHITE, COLOR_BLACK); + init_pair(Wall, COLOR_WHITE, COLOR_WHITE); + init_pair(Pellet, COLOR_WHITE, COLOR_BLACK); + init_pair(PowerUp, COLOR_BLUE, COLOR_BLACK); + init_pair(GhostWall, COLOR_WHITE, COLOR_CYAN); + init_pair(Ghost1, COLOR_RED, COLOR_BLACK); + init_pair(Ghost2, COLOR_CYAN, COLOR_BLACK); + init_pair(Ghost3, COLOR_MAGENTA, COLOR_BLACK); + init_pair(Ghost4, COLOR_YELLOW, COLOR_BLACK); + init_pair(BlueGhost, COLOR_BLUE, COLOR_RED); + init_pair(Pacman, COLOR_YELLOW, COLOR_BLACK); + init_pair(Cursor, COLOR_BLUE, COLOR_YELLOW); +} + +/**************************************************************** +* Function: LoadLevel() * +* Parameters: none * +* Returns: none * +* Description: Open level file and load it into memory * +****************************************************************/ +void LoadLevel() { + + int a = 0; int b = 0; + FILE *fin; + + //Open file + fin = fopen(filename, "r"); + + //File doesn't exist, start new + if(!(fin)) { + for(a=0; a<28; a++) { Level[a][0]=1; Level[a][27]=1; } + for(a=0; a<28; a++) { Level[0][a]=1; Level[28][a]=1; } + Loc[0][0]=2; Loc[0][1]=2; + Loc[1][0]=2; Loc[1][1]=4; + Loc[2][0]=2; Loc[2][1]=6; + Loc[3][0]=2; Loc[3][1]=8; + Loc[4][0]=19; Loc[4][1]=19; + Level[Loc[0][0]][Loc[0][1]]=5; + Level[Loc[1][0]][Loc[1][1]]=6; + Level[Loc[2][0]][Loc[2][1]]=7; + Level[Loc[3][0]][Loc[3][1]]=8; + Level[Loc[4][0]][Loc[4][1]]=9; + } + else { + + //Open file and load the level into the array + for(a = 0; a < 29; a++) + for(b = 0; b < 28; b++) { + fscanf(fin, "%d", &Level[a][b]); + if(Level[a][b] == 5) { Loc[0][0]=a; Loc[0][1]=b; } + if(Level[a][b] == 6) { Loc[1][0]=a; Loc[1][1]=b; } + if(Level[a][b] == 7) { Loc[2][0]=a; Loc[2][1]=b; } + if(Level[a][b] == 8) { Loc[3][0]=a; Loc[3][1]=b; } + if(Level[a][b] == 9) { Loc[4][0]=a; Loc[4][1]=b; } + } + } +} + +/**************************************************************** +* Function: MainLoop() * +* Parameters: none * +* Returns: none * +* Description: Control the main execution of the game * +****************************************************************/ +void MainLoop() { + do { + GetInput(); + DrawWindow(); + } while (1); +} + +/**************************************************************** +* Function: SaveLevel() * +* Parameters: none * +* Returns: none * +* Description: Save current level array to a specified file * +****************************************************************/ +void SaveLevel() { + + int a=0; + int b=0; + FILE *fout; + + //Open file + fout = fopen(filename, "w"); + + //Check for write permissions + if(!(fout)) { + ExitProgram("Cannot write file. :-("); + } + + else { + for(a = 0; a < 29; a++) { + for(b = 0; b < 28; b++) { + fprintf(fout, "%d ", Level[a][b]); + } + fprintf(fout, "\n"); + } + fprintf(fout, "1"); + fclose(fout); + } +} diff --git a/screenshot.png b/screenshot.png new file mode 100755 index 0000000000000000000000000000000000000000..6310785d4765bbfa4dc7acdb1d0dfa66103e7a08 GIT binary patch literal 3505 zcmb7G2~-p37LMY>6~WrR3ZaB2DyM2usfb_*xPW3SXj>L#RThyYfCwfg5D^|x45p|E zlt`YZD%C)uqDc@)IHE)ZlDZItY`{p;3IRg|60-1S1eE%$JnuP^JCm8YbMJS*@BaU( z-9FpR=2^{y!C+?IJGT7*`qwbn%+D=mf@g!KJ2!)FZqkmuDKOal&!A(*6G?_1d^o~; z+vcAz9ZJdLJ@Cev9(ypJ7WAbHu58`H&pPsXPB8zT?o!3b3wv{$bum{Na?14~;y)v< zwFWy?T*4lMVt>$%3oxOBg}!A^|2*P&62>}~4w*qLGmyJXViuu~FX=Kp`TslYUNs`< zuyM6mr$4Gbm#0nYhm5s<2X&bC_QnaxTflq_{(Zl5tvv_hYi*OYTu5%5`m$-o@zf z-HvXa>=~#-WdQ{g2Mq>c4rnyDxCuu^73|D^1rrDL3TE3bUkR;utoo{AIYBEdIA3WS zn8J}f(nq#vt0FmjlTGf=arPi3ncQEH?iy~0%?=v5F`PE!neN-J?&&?c%3lmychAhi z?(f`9HM^JMo2TtlIUIaoW>KlyyBxP^M*As2k-%o)@RYZ=QhDh#+<-^kaKAQY6N!F7 zh1ZUT5Wg7z_(TrzujDU8pfSPcAA-#LOGUt zmt)Y449F0@_9_QLT9bEXkpO^K1~|-~brSnq<<5qK1$o-$si}Xg{)u~VqVC9k^ZHsA z?=%R7Gz%=Nxj~UUphSi#zKlTOYMQ1XjeIsh5sO-_=sqgEB{lt4x9Le$khIJE3~vnN z$J&*od%5t8l;Xaoz_2oF=F&INbBp&yiB|5nzGudLLk4tx_M$n?`Z#_+Gu7G70$sH1 zDao5X;{b)HRGrXT<7)iHuNb}QN;Q=(k6zCQhB4ZfXB?&ht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