Просмотр исходного кода

* The big TTYvaders/libcaca split. This is libcaca.

tags/v0.99.beta14
Sam Hocevar sam 21 лет назад
Родитель
Сommit
3c68d1e054
39 измененных файлов: 439 добавлений и 3301 удалений
  1. +421
    -251
      COPYING
  2. +4
    -4
      Makefile.am
  3. +1
    -33
      README
  4. +0
    -34
      TODO
  5. +1
    -1
      bootstrap
  6. +2
    -4
      configure.ac
  7. +0
    -14
      data/Makefile.am
  8. +0
    -27
      data/barboss.txt
  9. +0
    -14
      data/barfight.txt
  10. +0
    -28
      data/bazfight.txt
  11. +0
    -14
      data/bongem.txt
  12. +0
    -14
      data/bonheart.txt
  13. +0
    -29
      data/foofight.txt
  14. +0
    -7
      data/ship.txt
  15. +0
    -86
      data/wpnbomb.txt
  16. +0
    -50
      data/wpnfrag.txt
  17. +0
    -60
      data/xplmed.txt
  18. +0
    -32
      data/xplsmall.txt
  19. +0
    -6
      debian/.cvsignore
  20. +2
    -2
      debian/changelog
  21. +7
    -7
      debian/control
  22. +1
    -1
      debian/rules
  23. +0
    -191
      doc/shapes.txt
  24. +0
    -6
      src/.cvsignore
  25. +0
    -33
      src/Makefile.am
  26. +0
    -136
      src/aliens.c
  27. +0
    -113
      src/bonus.c
  28. +0
    -106
      src/box.c
  29. +0
    -49
      src/ceo.c
  30. +0
    -296
      src/collide.c
  31. +0
    -226
      src/common.h
  32. +0
    -142
      src/explosions.c
  33. +0
    -77
      src/intro.c
  34. +0
    -268
      src/main.c
  35. +0
    -81
      src/overlay.c
  36. +0
    -101
      src/player.c
  37. +0
    -93
      src/starfield.c
  38. +0
    -206
      src/tunnel.c
  39. +0
    -459
      src/weapons.c

+ 421
- 251
COPYING Просмотреть файл

@@ -1,221 +1,400 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991


Copyright (C) 1989, 1991 Free Software Foundation, Inc. GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999

Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.


Preamble [This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]

Preamble


The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free Licenses are intended to guarantee your freedom to share and change
software--to make sure the software is free for all its users. This free software--to make sure the software is free for all its users.
General Public License applies to most of the Free Software This license, the Lesser General Public License, applies to some
Foundation's software and to any other program whose authors commit to specially designated software packages--typically libraries--of the
using it. (Some other Free Software Foundation software is covered by Free Software Foundation and other authors who decide to use it. You
the GNU Library General Public License instead.) You can apply it to can use it too, but we suggest you first think carefully about whether
your programs, too. this license or the ordinary General Public License is the better

strategy to use in any particular case, based on the explanations
When we speak of free software, we are referring to freedom, not below.
price. Our General Public Licenses are designed to make sure that you When we speak of free software, we are referring to freedom of use,
have the freedom to distribute copies of free software (and charge for not price. Our General Public Licenses are designed to make sure that
this service if you wish), that you receive source code or can get it you have the freedom to distribute copies of free software (and charge
if you want it, that you can change the software or use pieces of it for this service if you wish); that you receive source code or can get
in new free programs; and that you know you can do these things. it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.


To protect your rights, we need to make restrictions that forbid 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. distributors to deny you these rights or to ask you to surrender these
These restrictions translate to certain responsibilities for you if you rights. These restrictions translate to certain responsibilities for
distribute copies of the software, or if you modify it. you if you distribute copies of the library or if you modify it.

For example, if you distribute copies of the library, whether gratis
For example, if you distribute copies of such a program, whether or for a fee, you must give the recipients all the rights that we gave
gratis or for a fee, you must give the recipients all the rights that you. You must make sure that they, too, receive or can get the source
you have. You must make sure that they, too, receive or can get the code. If you link other code with the library, you must provide
source code. And you must show them these terms so they know their complete object files to the recipients, so that they can relink them
rights. with the library after making changes to the library and recompiling

it. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and We protect your rights with a two-step method: (1) we copyright the
(2) offer you this license which gives you legal permission to copy, library, and (2) we offer you this license, which gives you legal
distribute and/or modify the software. permission to copy, distribute and/or modify the library.

To protect each distributor, we want to make it very clear that
Also, for each author's protection and ours, we want to make certain there is no warranty for the free library. Also, if the library is
that everyone understands that there is no warranty for this free modified by someone else and passed on, the recipients should know
software. If the software is modified by someone else and passed on, we that what they have is not the original version, so that the original
want its recipients to know that what they have is not the original, so author's reputation will not be affected by problems that might be
that any problems introduced by others will not reflect on the original introduced by others.
authors' reputations. Finally, software patents pose a constant threat to the existence of

any free program. We wish to make sure that a company cannot
Finally, any free program is threatened constantly by software effectively restrict the users of a free program by obtaining a
patents. We wish to avoid the danger that redistributors of a free restrictive license from a patent holder. Therefore, we insist that
program will individually obtain patent licenses, in effect making the any patent license obtained for a version of the library must be
program proprietary. To prevent this, we have made it clear that any consistent with the full freedom of use specified in this license.
patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.

When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.

We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.

For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it
becomes a de-facto standard. To achieve this, non-free programs must
be allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.

In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.

Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.


The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION


0. This License applies to any program or other work which contains 0. This License Agreement applies to any software library or other
a notice placed by the copyright holder saying it may be distributed program which contains a notice placed by the copyright holder or
under the terms of this General Public License. The "Program", below, other authorized party saying it may be distributed under the terms of
refers to any such program or work, and a "work based on the Program" this Lesser General Public License (also called "this License").
means either the Program or any derivative work under copyright law: Each licensee is addressed as "you".
that is to say, a work containing the Program or a portion of it, A "library" means a collection of software functions and/or data
either verbatim or with modifications and/or translated into another prepared so as to be conveniently linked with application programs
language. (Hereinafter, translation is included without limitation in (which use some of those functions and data) to form executables.
the term "modification".) Each licensee is addressed as "you". The "Library", below, refers to any such software library or work

which has been distributed under these terms. A "work based on the
Activities other than copying, distribution and modification are not Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)

"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, 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 library.

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program running a program using the Library is not restricted, and output from
is covered only if its contents constitute a work based on the such a program is covered only if its contents constitute a work based
Program (independent of having been made by running the Program). on the Library (independent of the use of the Library in a tool for
Whether that is true depends on what the Program does. writing it). Whether that is true depends on what the Library does

and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Program's 1. You may copy and distribute verbatim copies of the Library's
source code as you receive it, in any medium, provided that you complete source code as you receive it, in any medium, provided that
conspicuously and appropriately publish on each copy an appropriate you conspicuously and appropriately publish on each copy an
copyright notice and disclaimer of warranty; keep intact all the appropriate copyright notice and disclaimer of warranty; keep intact
notices that refer to this License and to the absence of any warranty; all the notices that refer to this License and to the absence of any
and give any other recipients of the Program a copy of this License warranty; and distribute a copy of this License along with the
along with the Program. Library.

You may charge a fee for the physical act of transferring a copy,
You may charge a fee for the physical act of transferring a copy, and and you may at your option offer warranty protection in exchange for a
you may at your option offer warranty protection in exchange for a fee. fee.

2. You may modify your copy or copies of the Library or any portion
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Library, and copy and
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions: above, provided that you also meet all of these conditions:


a) You must cause the modified files to carry prominent notices a) The modified work must itself be a software library.

b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change. 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 c) You must cause the whole of the work to be licensed at no
whole or in part contains or is derived from the Program or any charge to all third parties under the terms of this License.
part thereof, to be licensed as a whole at no charge to all third d) If a facility in the modified Library refers to a function or a
parties under the terms of this License. table of data to be supplied by an application program that uses

the facility, other than as an argument passed when the facility
c) If the modified program normally reads commands interactively is invoked, then you must make a good faith effort to ensure that,
when run, you must cause it, when started running for such in the event an application does not supply such function or
interactive use in the most ordinary way, to print or display an table, the facility still operates, and performs whatever part of
announcement including an appropriate copyright notice and a its purpose remains meaningful.
notice that there is no warranty (or else, saying that you provide (For example, a function in a library to compute square roots has
a warranty) and that users may redistribute the program under a purpose that is entirely well-defined independent of the
these conditions, and telling the user how to view a copy of this application. Therefore, Subsection 2d requires that any
License. (Exception: if the Program itself is interactive but application-supplied function or table used by this function must
does not normally print such an announcement, your work based on be optional: if the application does not supply it, the square
the Program is not required to print an announcement.) root function must still compute square roots.)

These requirements apply to the modified work as a whole. If These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program, identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you 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 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 on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it. 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 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 your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or exercise the right to control the distribution of derivative or
collective works based on the Program. collective works based on the Library.


In addition, mere aggregation of another work not based on the Program In addition, mere aggregation of another work not based on the Library
with the Program (or with a work based on the Program) on a volume of with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under a storage or distribution medium does not bring the other work under
the scope of this License. the scope of this License.


3. You may copy and distribute the Program (or a work based on it, 3. You may opt to apply the terms of the ordinary GNU General Public
under Section 2) in object code or executable form under the terms of License instead of this License to a given copy of the Library. To do
Sections 1 and 2 above provided that you also do one of the following: this, you must alter all the notices that refer to this License, so

that they refer to the ordinary GNU General Public License, version 2,
a) Accompany it with the complete corresponding machine-readable instead of to this License. (If a newer version than version 2 of the
source code, which must be distributed under the terms of Sections ordinary GNU General Public License has appeared, then you can specify
1 and 2 above on a medium customarily used for software interchange; or, that version instead if you wish.) Do not make any other change in

these notices.
b) Accompany it with a written offer, valid for at least three Once this change is made in a given copy, it is irreversible for
years, to give any third party, for a charge no more than your that copy, so the ordinary GNU General Public License applies to all
cost of physically performing source distribution, a complete subsequent copies and derivative works made from that copy.
machine-readable copy of the corresponding source code, to be This option is useful when you wish to copy part of the code of
distributed under the terms of Sections 1 and 2 above on a medium the Library into a program that is not a library.
customarily used for software interchange; or, 4. You may copy and distribute the Library (or a portion or

derivative of it, under Section 2) in object code or executable form
c) Accompany it with the information you received as to the offer under the terms of Sections 1 and 2 above provided that you accompany
to distribute corresponding source code. (This alternative is it with the complete corresponding machine-readable source code, which
allowed only for noncommercial distribution and only if you must be distributed under the terms of Sections 1 and 2 above on a
received the program in object code or executable form with such medium customarily used for software interchange.
an offer, in accord with Subsection b above.) If distribution of object code is made by offering access to copy

from a designated place, then offering equivalent access to copy the
The source code for a work means the preferred form of the work for source code from the same place satisfies the requirement to
making modifications to it. For an executable work, complete source distribute the source code, even though third parties are not
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. compelled to copy the source along with the object code.

5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.

However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.

When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.

If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)

Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
4. You may not copy, modify, sublicense, or distribute the Program 6. As an exception to the Sections above, you may also combine or
except as expressly provided under this License. Any attempt link a "work that uses the Library" with the Library to produce a
otherwise to copy, modify, sublicense or distribute the Program is work containing portions of the Library, and distribute that work
void, and will automatically terminate your rights under this License. under terms of your choice, provided that the terms permit
However, parties who have received copies, or rights, from you under modification of the work for the customer's own use and reverse
this License will not have their licenses terminated so long as such engineering for debugging such modifications.
parties remain in full compliance. You must give prominent notice with each copy of the work that the

Library is used in it and that the Library and its use are covered by
5. You are not required to accept this License, since you have not this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:

a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)

b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.

c) Accompany the work with a written offer, valid for at least
three years, to give the same user the materials specified in
Subsection 6a, above, for a charge no more than the cost of
performing this distribution.

d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.

e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.

For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be 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.

It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:

a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.

b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.

8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library 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.

9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the modifying or distributing the Library (or any work based on the
Program), you indicate your acceptance of this License to do so, and Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying all its terms and conditions for copying, distributing or modifying
the Program or works based on it. the Library or works based on it.


6. Each time you redistribute the Program (or any work based on the 10. Each time you redistribute the Library (or any work based on the
Program), the recipient automatically receives a license from the Library), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to original licensor to copy, distribute, link with or modify the Library
these terms and conditions. You may not impose any further subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein. restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to You are not responsible for enforcing compliance by third parties with
this License. this License.

11. If, as a consequence of a court judgment or allegation of patent
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then 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 the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program. refrain entirely from distribution of the Library.


If any portion of this section is held invalid or unenforceable under If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other apply, and the section as a whole is intended to apply in other
circumstances. circumstances.


It is not the purpose of this section to induce you to infringe any 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 patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is integrity of the free software distribution system which is
implemented by public license practices. Many people have made implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that through that system in reliance on consistent application of that
@@ -225,116 +404,107 @@ impose that choice.


This section is intended to make thoroughly clear what is believed to This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License. be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding may add an explicit geographical distribution limitation excluding those
those countries, so that distribution is permitted only in or among countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License. the limitation as if written in the body of this License.


9. The Free Software Foundation may publish revised and/or new versions 13. The Free Software Foundation may publish revised and/or new
of the General Public License from time to time. Such new versions will versions of the Lesser General Public License from time to time.
be similar in spirit to the present version, but may differ in detail to Such new versions will be similar in spirit to the present version,
address new problems or concerns. but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Library
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and
specifies a version number of this License which applies to it and "any "any later version", you have the option of following the terms and
later version", you have the option of following the terms and conditions conditions either of that version or of any later version published by
either of that version or of any later version published by the Free the Free Software Foundation. If the Library does not specify a
Software Foundation. If the Program does not specify a version number of license version number, you may choose any version ever published by
this License, you may choose any version ever published by the Free Software the Free Software Foundation.
Foundation. 14. If you wish to incorporate parts of the Library into other free

programs whose distribution conditions are incompatible with these,
10. If you wish to incorporate parts of the Program into other free write to the author to ask for permission. For software which is
programs whose distribution conditions are different, write to the author copyrighted by the Free Software Foundation, write to the Free
to ask for permission. For software which is copyrighted by the Free Software Foundation; we sometimes make exceptions for this. Our
Software Foundation, write to the Free Software Foundation; we sometimes decision will be guided by the two goals of preserving the free status
make exceptions for this. Our decision will be guided by the two goals of all derivatives of our free software and of promoting the sharing
of preserving the free status of all derivatives of our free software and and reuse of software generally.
of promoting the sharing and reuse of software generally. NO WARRANTY

15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
NO WARRANTY WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.

EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
REPAIR OR CORRECTION. AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU

FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY DAMAGES.
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER END OF TERMS AND CONDITIONS
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 How to Apply These Terms to Your New Libraries


If you develop a new program, and you want it to be of the greatest If you develop a new library, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it possible use to the public, we recommend making it free software that
free software which everyone can redistribute and change under these terms. everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms
of the ordinary General Public License).


To do so, attach the following notices to the program. It is safest To apply these terms, attach the following notices to the library.
to attach them to the start of each source file to most effectively It is safest to attach them to the start of each source file to most
convey the exclusion of warranty; and each file should have at least effectively convey the exclusion of warranty; and each file should
the "copyright" line and a pointer to where the full notice is found. have at least the "copyright" line and a pointer to where the full
notice is found.


<one line to give the program's name and a brief idea of what it does.> <one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author> Copyright (C) <year> <name of author>


This program is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Lesser General Public
the Free Software Foundation; either version 2 of the License, or License as published by the Free Software Foundation; either
(at your option) any later version. version 2.1 of the License, or (at your option) any later version.


This program is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Lesser 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Also add information on how to contact you by electronic and paper mail. 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 You should also get your employer (if you work as a programmer) or
when it starts in an interactive mode: your school, if any, to sign a "copyright disclaimer" for the library,

if necessary. Here is a sample; alter the names:
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 Yoyodyne, Inc., hereby disclaims all copyright interest in the
parts of the General Public License. Of course, the commands you use may library `Frob' (a library for tweaking knobs) written by James
be called something other than `show w' and `show c'; they could even be Random Hacker.
mouse-clicks or menu items--whatever suits your program.


You should also get your employer (if you work as a programmer) or your <signature of Ty Coon>, 1 April 1990
school, if any, to sign a "copyright disclaimer" for the program, if Ty Coon, President of Vice
necessary. Here is a sample; alter the names:


Yoyodyne, Inc., hereby disclaims all copyright interest in the program That's all there is to it!
`Gnomovision' (which makes passes at compilers) written by James Hacker.


<signature of Ty Coon>, 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 Library General
Public License instead of this License.

+ 4
- 4
Makefile.am Просмотреть файл

@@ -1,10 +1,10 @@
############################################################################### ###############################################################################
# Automake targets and declarations for ttyvaders # Automake targets and declarations for libcaca
############################################################################### ###############################################################################


SUBDIRS = libcaca test src SUBDIRS = libcaca test
DIST_SUBDIRS = $(SUBDIRS) autotools data debian DIST_SUBDIRS = $(SUBDIRS) autotools debian


EXTRA_DIST = BUGS doc/shapes.txt bootstrap EXTRA_DIST = BUGS bootstrap
AUTOMAKE_OPTIONS = foreign dist-bzip2 AUTOMAKE_OPTIONS = foreign dist-bzip2



+ 1
- 33
README Просмотреть файл

@@ -1,6 +1,6 @@
$Id$ $Id$


Building ttyvaders Building libcaca


o Run configure then make. Useful configure flags are: o Run configure then make. Useful configure flags are:


@@ -12,35 +12,3 @@ Building ttyvaders
./configure --enable-conio --host=i386-pc-msdosdjgpp ./configure --enable-conio --host=i386-pc-msdosdjgpp



History of textmode games

o http://www.textmodegames.com/


Other terminal-based games

o moon-buggy: extremely simple, extremely addictive
http://www.mathematik.uni-kl.de/~wwwstoch/voss/comp/moon-buggy.html

o 0verkill: http://artax.karlin.mff.cuni.cz/~brain/0verkill/

o nInvaders: http://dettus.dyndns.org/ninvaders/
real space invaders clone

o Stardork: http://www.seekrut.com/rk/stardork.html
more strategy than arcade

o Nethack: http://www.nethack.org/

o Tetrinet: http://www.secret.com.au/games/tetrinet/

o MyMan: http://geocities.com/bsittler/
pacman clone

o Tornado: http://home.kcore.de/~kiza/linux/tornado/

o David's Perl games: http://davidsperlgames.sourceforge.net/

o ascii-invaders: http://www.ip9.org/munro/invaders/index.html


+ 0
- 34
TODO Просмотреть файл

@@ -1,7 +1,5 @@
$Id$ $Id$


TODO for libcaca

o Sprite library o Sprite library


o Clip graphics o Clip graphics
@@ -13,35 +11,3 @@ TODO for libcaca


o DONE 12 Nov 2003: Port to conio.h o DONE 12 Nov 2003: Port to conio.h



TODO for ttyvaders

o Let the ship pick up bonuses

o Alien swarms, programmed behaviour

o Spiral weapon (vertical sine)

o Stick aliens to tunnel

o Change tunnel colour

o Draw bosses

o Promote precision for all coordinates except screen

o Animate the ship

o The nuke should break the tunnel
Or at least a bit

o The laser stays alive when the ship explodes

o DONE 12 Nov 2003: Write a generic drawing library with automatic clipping
o DONE 23 Dec 2002: Handle life
o DONE 23 Dec 2002: Mega ball
o DONE 23 Dec 2002: Fragmentation bomb (merge with mega-ball?)
o DONE 23 Dec 2002: Fill holes in the tunnel when |step| > 2
o DONE 19 Dec 2002: Tunnel sometimes doesn't get drawn on the left
o DONE 18 Dec 2002: Draw a 3rd alien type


+ 1
- 1
bootstrap Просмотреть файл

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh


## bootstrap file for ttyvaders -- Sam Hocevar <sam@zoy.org> ## bootstrap file for libcaca -- Sam Hocevar <sam@zoy.org>
## $Id$ ## $Id$


set -x set -x


+ 2
- 4
configure.ac Просмотреть файл

@@ -1,13 +1,13 @@
# $Id$ # $Id$


AC_INIT(ttyvaders,0.0cvs-20031110) AC_INIT(libcaca,0.0cvs-20031110)


AC_PREREQ(2.50) AC_PREREQ(2.50)
AC_CONFIG_SRCDIR(src/main.c) AC_CONFIG_SRCDIR(src/main.c)
AC_CONFIG_AUX_DIR(autotools) AC_CONFIG_AUX_DIR(autotools)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM


AM_INIT_AUTOMAKE(ttyvaders,0.0cvs-20031110) AM_INIT_AUTOMAKE(libcaca,0.0cvs-20031110)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)


AM_PROG_CC_C_O AM_PROG_CC_C_O
@@ -62,9 +62,7 @@ AC_OUTPUT([
Makefile Makefile
libcaca/Makefile libcaca/Makefile
test/Makefile test/Makefile
src/Makefile
autotools/Makefile autotools/Makefile
data/Makefile
debian/Makefile debian/Makefile
]) ])



+ 0
- 14
data/Makefile.am Просмотреть файл

@@ -1,14 +0,0 @@
NULL =
EXTRA_DIST = \
barboss.txt \
barfight.txt \
bazfight.txt \
bongem.txt \
bonheart.txt \
foofight.txt \
ship.txt \
wpnbomb.txt \
wpnfrag.txt \
xplmed.txt \
xplsmall.txt \
$(NULL)

+ 0
- 27
data/barboss.txt Просмотреть файл

@@ -1,27 +0,0 @@
36 13 18 6
_,--._
,' `.
|\ / ,-. ,-. \ /|
)o),/ ( ( o )( o ) ) \.(o(
/o/// /| `-' `-' |\ \\\o\
/ / |\ \( . , )/ /| \ \
| | \o`-/ `\/' \-'o/ | |
\ \ `,' `.' / /
\. \ `-' ,'| /\ |`. `-' / ,/
\`. `.__,' / / \ \ `.__,' ,'/
\o\ ,' ,' `. `. /o/
\o`---' ,' `. `---'o/
`.____,' `.____,'
ffffff
ffffffffff
ff ffhhhffhhhff ff
fhfff ffhhphhhhphhff fffhf
fhfff ffffhhhffhhhffff fffhf
fff ff fffffhffffhfffff ff fff
fff fhfffffffhhhhfffffffhf fff
fff ffffffffffffffffffff fff
ff fffffffffffffffffffff fffff ff
fff ffffff fffff fffff ffffff fff
fhf ffffff ffffff fhf
fhfffffffff fffffffffhf
ffffffff ffffffff

+ 0
- 14
data/barfight.txt Просмотреть файл

@@ -1,14 +0,0 @@
5 3 2 1
,---.
\O o/
^^^^^
fffff
fpppf
fffff
5 3 2 1
,---.
\o O/
^^^^^
fffff
fpppf
fffff

+ 0
- 28
data/bazfight.txt Просмотреть файл

@@ -1,28 +0,0 @@
6 3 2 1
__
/oo\
//'`\\
cc
cppc
cccccc
6 3 2 1
__
/oo\
/(~~)\
cc
cppc
cccccc
6 3 2 1
__
/oo\
((^^))
cc
cppc
cccccc
4 3 1 1
__
/oo\
\\//
cc
cppc
cccc

+ 0
- 14
data/bongem.txt Просмотреть файл

@@ -1,14 +0,0 @@
3 2 1 1
_
/g\
\_/
c
cpc
ccc
3 2 1 1
_
/g\
\_/
p
ppp
ppp

+ 0
- 14
data/bonheart.txt Просмотреть файл

@@ -1,14 +0,0 @@
5 3 2 1
_ _
( '^)
`v'
e e
eeepe
eee
5 3 2 1
_ _
( '^)
`v'
p p
ppppp
ppp

+ 0
- 29
data/foofight.txt Просмотреть файл

@@ -1,29 +0,0 @@
7 3 3 1
. ,
\oXo/
`V'
o o
opopo
ooo
9 3 4 1
. ,
`-oXo-'
`V'
o o
oopopoo
ooo
9 2 4 0
`--oXo--'
`V'
ooopopooo
ooo
9 2 4 0
,-oXo-.
' `V' `
oopopoo
o ooo o
7 2 3 0
,oXo.
/ `V' \
opopo
o ooo o

+ 0
- 7
data/ship.txt Просмотреть файл

@@ -1,7 +0,0 @@
6 3 2 1
/\
(())
I<__>I
cc
cooc
cccccc

+ 0
- 86
data/wpnbomb.txt Просмотреть файл

@@ -1,86 +0,0 @@
5 3 3 1
/`-.
`-._\
`
dddd
dddpp
p
5 3 3 1
_,
,-' /
\,-'
pp
ddddp
dddd
6 2 5 1
____
|____>
dddd
dddddp
4 4 2 1
_,
/ |
/ /
`'
pp
ddp
ddd
dd
4 4 1 1
._
| \
\ \
`'
pp
pdd
ddd
dd
3 3 1 0
,^.
| |
|_|
ppp
ddd
ddd
4 3 2 2
,.
\ \
\_|
dd
ddd
dpp
4 3 1 2
,.
/ /
|_/
dd
ddd
ppd
3 4 1 3
_
| |
| |
`v'
d
ddd
ddd
ppp
5 3 1 1
,-'\
/_,-'
'
dddd
ppddd
p
5 3 1 1
._
\ `-.
`-./
pp
pdddd
dddd
6 2 0 1
____
<____|
dddd
pddddd

+ 0
- 50
data/wpnfrag.txt Просмотреть файл

@@ -1,50 +0,0 @@
6 3 2 1
,--.
( ', )
`--'
dddd
ppddpp
pppp
6 3 2 1
,--.
( ', )
`--'
pppp
ddppdd
dddd
4 4 1 -2
O o
: o
. :
.
d d
i d
i i
i
4 4 1 -2
O
o :
. :
.
d
d i
i i
i
4 4 1 -2
o O
o
: .
.
d d
d
i i
i
4 4 1 -2
o O
: o
:
.
d d
i d
i
i

+ 0
- 60
data/xplmed.txt Просмотреть файл

@@ -1,60 +0,0 @@
1 1 0 0
+
o
1 1 0 0
o
o
3 2 1 1
_
)_(
o
ooo
3 3 1 1
._,
)_(
' `
ooo
ooo
ooo
3 3 1 1
.v,
> <
'^`
ooo
ooo
ooo
5 3 2 1
_\~/_
> <
~/_\~
mmmmm
mmmmm
mmmmm
5 3 2 1
_\~/_
> <
~/_\~
ooooo
ooooo
ooooo
5 3 2 1
_\ /_
~/ \~
mmmmm
mmmmm
mmmmm
5 3 2 1
_\ /_

~/ \~
ooooo
ooooo
ooooo
5 3 2 1
. ' ,

' . `
ppppp
ppppp
ppppp

+ 0
- 32
data/xplsmall.txt Просмотреть файл

@@ -1,32 +0,0 @@
1 1 0 0
+
o
1 1 0 0
o
o
3 2 1 1
_
)_(
o
ooo
3 3 1 1
._,
)_(
' `
ooo
ooo
ooo
3 3 1 1
.v,
> <
'^`
ooo
ooo
ooo
3 3 1 1
. ,

' `
ooo
ooo
ooo

+ 0
- 6
debian/.cvsignore Просмотреть файл

@@ -1,6 +0,0 @@
.dirstamp
Makefile
Makefile.in
files
ttyvaders
ttyvaders.substvars

+ 2
- 2
debian/changelog Просмотреть файл

@@ -1,5 +1,5 @@
ttyvaders (0.0cvs-1) unstable; urgency=low libcaca (0.0cvs-1) unstable; urgency=low


* Not yet released. * Not yet released.


-- Samuel Hocevar <sam@zoy.org> Sat, 14 Dec 2002 15:22:25 +0100 -- Sam Hocevar (Debian packages) <sam+deb@zoy.org> Sat, 14 Dec 2002 15:22:25 +0100

+ 7
- 7
debian/control Просмотреть файл

@@ -1,15 +1,15 @@
Source: ttyvaders Source: libcaca
Section: games Section: games
Priority: optional Priority: optional
Maintainer: Samuel Hocevar <sam@zoy.org> Maintainer: Sam Hocevar (Debian packages) <sam+deb@zoy.org>
Build-Depends: debhelper (>=2.2.0), slang1-dev Build-Depends: debhelper (>= 2.2.0), slang1-dev
Standards-Version: 3.5.6 Standards-Version: 3.6.1.0


Package: ttyvaders Package: libcaca
Section: games Section: games
Architecture: any Architecture: any
Depends: ${shlibs:Depends} Depends: ${shlibs:Depends}
Description: A vertical shoot 'em up with text-mode graphics. Description: text mode graphics library
TTYvaders is a vertical shoot 'em up for the console or the terminal. libcaca is the Color ANSI Console Art library.
. .
It rules. It rules.

+ 1
- 1
debian/rules Просмотреть файл

@@ -38,7 +38,7 @@ install: build
dh_testroot dh_testroot
dh_clean -k dh_clean -k
dh_installdirs dh_installdirs
DESTDIR=`pwd`/debian/ttyvaders/ $(MAKE) install prefix=/usr DESTDIR=`pwd`/debian/libcaca/ $(MAKE) install prefix=/usr


# Build architecture-independent files here. # Build architecture-independent files here.
binary-indep: build install binary-indep: build install


+ 0
- 191
doc/shapes.txt Просмотреть файл

@@ -1,191 +0,0 @@

Starship
--------

/\ /~\
(()) ]O[
I<__>I I\#/I


Aliens
------

,---. ,---.
\O o/ \o O/
^^^^^ ^^^^^
. , . ,
\oXo/ `-oXo-' `--oXo--' ,-oXo-. ,oXo.
`V' `V' `V' ' `V' ` / `V' \

,---. ,---. ,---. ,---. ,---.
(_^_^_) (__^_^) (^__^_) (_^__^) (^_^__)
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
,---. ,---. ,---. ,---. ,---.
(((o))) ((((o)) (((o))) ((o)))) (((o)))
`---' `---' `---' `---' `---'
o
o( )o
(_)

____ ____ ____
/ oO \ / oo \ / oo \
(//~~\\) (((^^))) \\\///

__ __ __ __
/oO\ /oO\ /oo\ /oo\
//'`\\ /(~~)\ ((^^)) \\//

_o|o_
T|T

o_o O_o o_o o_O
( v ) ( v ) ( v ) ( v )
)|( )// )/( \\(
_
,(|). / \
/,-'-.\ ,(_X_).

_>|<_
\ o /
\ /
V

Bonus
-----
_ _ _
/|\ / \ /.\
\|/ \_/ \_/

,--. ,--. ,--.
\VV/ \~~/ \ /
\/ \/ \/
_ _ _ _
( `' ) ( ' )
\ / `v'
\/
___
/ g \
\___/

Shots
-----

.o@ . o @ . o @

.o() . o () . o ()

| / _, ___ ._ \
| / ' ` \


| __/ \__ |
/ \


\ __ __ /
| \ / |

___ _, ._ ,^. _, ._
. o |___> / | | \ | | ,-' / \ `-.
/ / \ \ |_| \,-' `-./
`' `'
___ ,. ,. _
<___| \ \ / / | | /`-. ,-'\
\_| |_/ | | `-._\ /_,-'
`v' ` '

| | | |||| |/\|
|| || || |||||| ||/\||
| | | | | | |

:%%:
:%%: :%##%:
__ __ __ ____ :%%: :%##%: :%####%:
' ` -' `- ,-' `-. ,-' `-. ,-' `-. ,-' `-. ,-' `-.

,--.
( ', )
`--'
o O
o °
. °
.

,--.
( )
||||
||||
||
|

Explosions
----------

| .v, .v, .v, .v, .v, .v, . ,
+ o -o- >o< >o< >o< >o< > < > <
| '^` '^` '^` '^` '^` '^` ' `

.|, .v, .v, .v, .v, .v, . ,
+ o -o- --o-- > o < >( )< > < > o < >( )< - -
'|` '^` '^` '^` '^` '^` ' `

_ ._, .v, _\~/_ _\ /_ . ' ,
+ o )_( )_( > < > < _ _
' ` '^` ~/_\~ / \ ' . `

_ ._, .v, . ,
+ o )_( )_( > <
' ` '^` ' `



#######
### ###
## ##
# #
# #
# #
## ##
### ###
#######

#######
### ###
## ##
# #
# #
# #
## ##
### ###
#######

_______
,-'_______`-.
,',-' _____ `-.`.
/ / ,' ___ `. \ \
| | / ,' _ `. \ | |
| | | | |_| | | | |
| | \ `.___,' / | |
\ \ `._____,' / /
`.`-._______,-','
`-._______,-'


Bosses
------

_,--._
,' `.
|\ / ,-. ,-. \ /|
)o),/ ( ( o )( o ) ) \.(o(
/o/// /| `-' `-' |\ \\\o\
/ / |\ \( . , )/ /| \ \
| | \o`-/ `\/' \-'o/ | |
\ \ `,' `.' / /
\. \ `-' ,'| /\ |`. `-' / ,/
\`. `.__,' / / \ \ `.__,' ,'/
\o\ ,' ,' `. `. /o/
\o`---' ,' `. `---'o/
`.____,' `.____,'


+ 0
- 6
src/.cvsignore Просмотреть файл

@@ -1,6 +0,0 @@
.dirstamp
.deps
Makefile
Makefile.in
*.o
ttyvaders

+ 0
- 33
src/Makefile.am Просмотреть файл

@@ -1,33 +0,0 @@
###############################################################################
# Automake targets and declarations for ttyvaders
###############################################################################

AM_CPPFLAGS = -I$(top_srcdir)/libcaca

if USE_SLANG
LDFLAGS_slang = -lslang
endif
if USE_NCURSES
LDFLAGS_ncurses = -lncurses
endif

bin_PROGRAMS = ttyvaders

ttyvaders_SOURCES = \
aliens.c \
bonus.c \
box.c \
ceo.c \
collide.c \
common.h \
explosions.c \
intro.c \
main.c \
overlay.c \
player.c \
starfield.c \
tunnel.c \
weapons.c \
$(NULL)
ttyvaders_LDADD = ../libcaca/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm


+ 0
- 136
src/aliens.c Просмотреть файл

@@ -1,136 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

struct caca_sprite *foo_sprite;
struct caca_sprite *bar_sprite;
struct caca_sprite *baz_sprite;

void init_aliens(game *g, aliens *al)
{
int i;

for(i = 0; i < ALIENS; i++)
{
al->type[i] = ALIEN_NONE;
}

foo_sprite = caca_load_sprite("data/foofight.txt");
bar_sprite = caca_load_sprite("data/barfight.txt");
baz_sprite = caca_load_sprite("data/bazfight.txt");
}

void draw_aliens(game *g, aliens *al)
{
int i;

for(i = 0; i < ALIENS; i++)
{
switch(al->type[i])
{
case ALIEN_FOO:
caca_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 8);
break;
case ALIEN_BAR:
caca_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2);
break;
case ALIEN_BAZ:
caca_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 6);
break;
case ALIEN_NONE:
break;
}
}
}

void update_aliens(game *g, aliens *al)
{
int i;

for(i = 0; i < ALIENS; i++)
{
/* If alien died, make it explode */
if(al->type[i] != ALIEN_NONE && al->life[i] < 0)
{
add_explosion(g, g->ex, al->x[i], al->y[i], 0, 0, EXPLOSION_MEDIUM);
al->type[i] = ALIEN_NONE;
add_bonus(g, g->bo, al->x[i], al->y[i], caca_rand(0,4) ? BONUS_GREEN : BONUS_LIFE);
}

/* Update coordinates */
switch(al->type[i])
{
case ALIEN_FOO:
case ALIEN_BAR:
case ALIEN_BAZ:
al->x[i] = ((al->x[i] + 5) % (g->w + 3)) - 3;
al->y[i] = al->y[i] + (rand() % 8) / 7 - (rand() % 8) / 7;
al->img[i] = al->img[i] + 1;

/* Check bounds */
if(al->y[i] < 0 ) al->y[i] = 0;
if(al->y[i] > g->w - 1 ) al->y[i] = g->w - 1;
break;
case ALIEN_NONE:
break;
}
}
}

void add_alien(game *g, aliens *al, int x, int y, int type)
{
int i;

for(i = 0; i < ALIENS; i++)
{
if(al->type[i] == ALIEN_NONE)
{
al->type[i] = type;
al->x[i] = x;
al->y[i] = y;
al->img[i] = 0;

switch(al->type[i])
{
case ALIEN_FOO:
al->life[i] = 3;
break;
case ALIEN_BAR:
al->life[i] = 3;
break;
case ALIEN_BAZ:
al->life[i] = 3;
break;
case ALIEN_NONE:
break;
}

break;
}
}
}


+ 0
- 113
src/bonus.c Просмотреть файл

@@ -1,113 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

struct caca_sprite *heart_sprite;
struct caca_sprite *gem_sprite;

void init_bonus(game *g, bonus *bo)
{
int i;

for(i = 0; i < BONUS; i++)
{
bo->type[i] = BONUS_NONE;
}

heart_sprite = caca_load_sprite("data/bonheart.txt");
gem_sprite = caca_load_sprite("data/bongem.txt");
}

void draw_bonus(game *g, bonus *bo)
{
int i;

for(i = 0; i < BONUS; i++)
{
switch(bo->type[i])
{
case BONUS_GREEN:
caca_draw_sprite(bo->x[i], bo->y[i], gem_sprite,
(bo->n[i]/2 % 3) ? 0 : 1);
break;
case BONUS_LIFE:
caca_draw_sprite(bo->x[i], bo->y[i], heart_sprite,
(bo->n[i] % 3) ? 0 : 1);
break;
case BONUS_NONE:
break;
}
}
}

void update_bonus(game *g, bonus *bo)
{
int i;

for(i = 0; i < BONUS; i++)
{
switch(bo->type[i])
{
case BONUS_GREEN:
bo->n[i]++;
bo->y[i]++;
if(bo->y[i] > g->h)
{
bo->type[i] = BONUS_NONE;
}
break;
case BONUS_LIFE:
bo->n[i]++;
bo->y[i]++;
if(bo->y[i] > g->h)
{
bo->type[i] = BONUS_NONE;
}
break;
case BONUS_NONE:
break;
}
}
}

void add_bonus(game *g, bonus *bo, int x, int y, int type)
{
int i;

for(i = 0; i < BONUS; i++)
{
if(bo->type[i] == BONUS_NONE)
{
bo->type[i] = type;
bo->x[i] = x;
bo->y[i] = y;
bo->n[i] = 0;
break;
}
}
}


+ 0
- 106
src/box.c Просмотреть файл

@@ -1,106 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002-2003 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

box * create_box(game *g, int x, int y, int w, int h)
{
box *b = malloc(sizeof(box));
if(b == NULL)
exit(1);

b->x = x;
b->y = y;
b->w = w;
b->h = h;
b->frame = 0;

return b;
}

void draw_box(game *g, box *b)
{
int j, frame;

caca_set_color(EE_YELLOW);

/* Draw the thin horizontal line */
if(b->frame < 8)
{
caca_draw_line(b->x - b->w * b->frame / 16, b->y,
b->x + b->w * b->frame / 16 - 1, b->y, 'X');
return;
}

/* Draw the frame */
frame = b->frame < 12 ? b->frame : 12;

caca_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 'X');
caca_draw_line(b->x - b->w / 2, b->y + b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, 'X');

caca_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, 'X');
caca_draw_line(b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X');

caca_set_color(EE_BLACK);

for(j = b->y - b->h * (frame - 8) / 8 + 1;
j < b->y + b->h * (frame - 8) / 8;
j++)
{
caca_draw_line(b->x - b->w / 2 + 1, j,
b->x + b->w / 2 - 2, j, 'X');
}

if(b->frame < 12)
{
return;
}

/* Draw the text inside the frame */
caca_set_color(EE_YELLOW);

/* FIXME: use a font */
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2,
"XXXX. .XXXX X X .XXXX .XXXX XXXX.");
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3,
"X `X X' X X X X' X' X `X");
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4,
"XXXX' XXXXX X X `XXX XXXX X X");
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5,
"X' X' `X X. ,X `X X' X ,X");
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6,
"X X X `XXXX XXXX' `XXXX XXXX'");
}

void free_box(box *b)
{
free(b);
}


+ 0
- 49
src/ceo.c Просмотреть файл

@@ -1,49 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdio.h>
#include <unistd.h>

#include "common.h"

void ceo_alert(game *g)
{
int end = 0;

while(!end)
{
caca_clear();

if(caca_get_key() == '\t')
{
end = 1;
}

fprintf(stderr, "foo\n");

caca_refresh();

usleep(40000);
}
}

+ 0
- 296
src/collide.c Просмотреть файл

@@ -1,296 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

void collide_weapons_tunnel(game *g, weapons *wp, tunnel *t, explosions *ex)
{
int i, j, x, y;

for(i = 0; i < WEAPONS; i++)
{
x = wp->x[i] >> 4;
y = wp->y[i] >> 4;

switch(wp->type[i])
{
case WEAPON_LIGHTNING:
case WEAPON_NONE:
break;
case WEAPON_SEEKER:
case WEAPON_BOMB:
case WEAPON_FRAGBOMB:
if(y < 0 || y >= g->h)
{
break;
}

if(x <= t->left[y]
|| x >= t->right[y])
{
int damage = wp->type[i] == WEAPON_SEEKER ? 1 : 2;

add_explosion(g, ex, x, y, 0, 1, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM);

if(x <= t->left[y])
{
if(y-2 >= 0) t->left[y-2] -= damage - 1;
if(y-1 >= 0) t->left[y-1] -= damage;
t->left[y] -= damage + 1;
if(y+1 < g->h) t->left[y+1] -= damage;
if(y+2 < g->h) t->left[y+2] -= damage - 1;
}
else
{
if(y-2 >= 0) t->right[y-2] += damage - 1;
if(y-1 >= 0) t->right[y-1] += damage;
t->right[y] += damage + 1;
if(y+1 < g->h) t->right[y+1] += damage;
if(y+2 < g->h) t->right[y+2] += damage - 1;
}

if(wp->type[i] == WEAPON_FRAGBOMB)
{
wp->n[i] = -1;
}
else
{
wp->type[i] = WEAPON_NONE;
}
}
break;
case WEAPON_LASER:
for(j = GET_MIN(0, wp->vy[i] >> 4);
j < GET_MAX(0, wp->vy[i] >> 4);
j++)
{
if(y+j >= g->h || y+j < 0)
{
continue;
}

if(x <= t->left[y+j] || x >= t->right[y+j])
{
add_explosion(g, ex, x, y+j, 0, 1, EXPLOSION_SMALL);
wp->type[i] = WEAPON_NONE;

if(x <= t->left[y+j])
{
if(y+j-1 >= 0) t->left[y+j-1]--;
t->left[y+j] -= 2;
if(y+j+1 < g->h) t->left[y+j+1]--;
}
else
{
if(y+j-1 >= 0) t->right[y+j-1]++;
t->right[y+j] += 2;
if(y+j+1 < g->h) t->right[y+j+1]++;
}
break;
}
}
break;
case WEAPON_BEAM:
if(wp->n[i] > 19)
{
break;
}

j = (29 - wp->n[i]) * (29 - wp->n[i]) / 8;
j = GET_MIN(y, j);

for(; j > 0; j--)
{
if(x - 2 <= t->left[y-j])
{
add_explosion(g, ex, GET_MIN(t->left[y-j], x+3), y-j, 0, 1, EXPLOSION_SMALL);
t->left[y-j] -= caca_rand(0,2);
}
else if(x + 3 >= t->right[y-j])
{
add_explosion(g, ex, GET_MAX(t->right[y-j], x-2), y-j, 0, 1, EXPLOSION_SMALL);
t->right[y-j] += caca_rand(0,2);
}
}
break;

case WEAPON_NUKE:
/* The nuke does not break the tunnel */
break;
}
}
}

void collide_weapons_aliens(game *g, weapons *wp, aliens *al, explosions *ex)
{
int i, j, k, x, y;

for(i = 0; i < WEAPONS; i++)
{
int ok = 0;
int r;

x = wp->x[i] >> 4;
y = wp->y[i] >> 4;

switch(wp->type[i])
{
case WEAPON_LIGHTNING:
case WEAPON_NONE:
break;
case WEAPON_NUKE:
/* Big nuke */
r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8;

for(j = 0; j < ALIENS; j++)
{
if(al->type[j] == ALIEN_NONE || al->life[j] < 0)
{
continue;
}

if(wp->n[i] == 0 /* Nuke destroys _everything_ */ ||
(al->x[j] - x) * (al->x[j] - x)
+ 4 * (al->y[j] - y) * (al->y[j] - y)
<= r * r)
{
/* Kill alien, not nuke */
al->life[j] -= 10;
}
}
break;

case WEAPON_BEAM:
if(wp->n[i] > 19)
{
break;
}

r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8;

for(j = 0; j < ALIENS; j++)
{
if(al->type[j] == ALIEN_NONE || al->life[j] < 0)
{
continue;
}

if(x >= al->x[j] && x <= al->x[j] + 4
&& y >= al->y[j] + 2 && y-5-r <= al->y[j])
{
al->life[j] -= 4;
}
}
break;

case WEAPON_LASER:
for(j = 0; j < ALIENS; j++)
{
if(al->type[j] == ALIEN_NONE || al->life[j] < 0)
{
continue;
}

for(k = GET_MIN(0, wp->vy[i] >> 4);
k < GET_MAX(0, wp->vy[i] >> 4);
k++)
{
if(x >= al->x[j] && x <= al->x[j] + 4
&& y+k >= al->y[j] && y+k <= al->y[j] + 2)
{
al->life[j]--;
ok = 1;
break;
}
}
}

if(ok)
{
add_explosion(g, ex, x, y+1, 0, 0, EXPLOSION_SMALL);
wp->type[i] = WEAPON_NONE;
}
break;

case WEAPON_SEEKER:
case WEAPON_BOMB:
case WEAPON_FRAGBOMB:
for(j = 0; j < ALIENS; j++)
{
if(al->type[j] == ALIEN_NONE || al->life[j] < 0)
{
continue;
}

if(x >= al->x[j] && x <= al->x[j] + 4
&& y >= al->y[j] && y <= al->y[j] + 2)
{
al->life[j] -= wp->type[i] == WEAPON_SEEKER ? 1 : 5;
ok = 1;
}
}

if(ok)
{
add_explosion(g, ex, x, y+1, 0, 0, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM);

if(wp->type[i] == WEAPON_FRAGBOMB)
{
wp->n[i] = -1;
}
else
{
wp->type[i] = WEAPON_NONE;
}
}
break;
}
}
}

void collide_player_tunnel(game *g, player *p, tunnel *t, explosions *ex)
{
if(p->dead)
{
return;
}

if(p->x - 2 <= t->left[p->y])
{
p->x += 3;
p->vx = 2;
add_explosion(g, ex, p->x-1, p->y, 0, 0, EXPLOSION_SMALL);
p->life -= 180;
}
else if(p->x + 3 >= t->right[p->y])
{
p->x -= 3;
p->vx = -2;
add_explosion(g, ex, p->x+2, p->y, 0, 0, EXPLOSION_SMALL);
p->life -= 180;
}
}


+ 0
- 226
src/common.h Просмотреть файл

@@ -1,226 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

void intro(void);

/*
* Compile-time limits
*/
#define STARS 50
#define WEAPONS 200
#define BONUS 30
#define ALIENS 30
#define EXPLOSIONS 200

/*
* Game defines
*/
#define MAX_LIFE 1000
#define MAX_SPECIAL 200

#define COST_NUKE (100*MAX_SPECIAL/100)
#define COST_BEAM (75*MAX_SPECIAL/100)
#define COST_FRAGBOMB (50*MAX_SPECIAL/100)

/*
* Graphics primitives
*/
#include "caca.h"

/*
* Useful macros
*/
#define GET_MAX(a,b) ((a)>(b)?(a):(b))
#define GET_MIN(a,b) ((a)<(b)?(a):(b))

/*
* Game structures
*/
typedef struct
{
int w, h, *left, *right;

} tunnel;

typedef struct
{
int x, y, z, c;
char ch;

} starfield;

typedef struct
{
enum { EXPLOSION_NONE, EXPLOSION_SMALL, EXPLOSION_MEDIUM } type[EXPLOSIONS];
int x[EXPLOSIONS];
int y[EXPLOSIONS];
int vx[EXPLOSIONS];
int vy[EXPLOSIONS];
int n[EXPLOSIONS];

} explosions;

typedef struct
{
enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM, WEAPON_LIGHTNING, WEAPON_BOMB, WEAPON_FRAGBOMB } type[WEAPONS];
int x[WEAPONS];
int y[WEAPONS];
int x2[WEAPONS];
int y2[WEAPONS];
int x3[WEAPONS];
int y3[WEAPONS];
int vx[WEAPONS];
int vy[WEAPONS];
int n[WEAPONS];

} weapons;

typedef struct
{
enum { BONUS_NONE, BONUS_LIFE, BONUS_GREEN } type[BONUS];
int x[BONUS];
int y[BONUS];
int n[BONUS];

} bonus;

typedef struct
{
int x, y;
int vx, vy;
int weapon, special;
int life, dead;

} player;

typedef struct
{
enum { ALIEN_NONE, ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ } type[ALIENS];
int x[ALIENS];
int y[ALIENS];
int life[ALIENS];
int img[ALIENS];

} aliens;

typedef struct
{
int w, h;
int x, y;
int frame;

} box;

typedef struct
{
int w, h;

starfield *sf;
weapons *wp;
explosions *ex;
tunnel *t;
player *p;
aliens *al;
bonus *bo;

} game;

/*
* From aliens.c
*/
void init_aliens(game *, aliens *);
void draw_aliens(game *, aliens *);
void update_aliens(game *, aliens *);
void add_alien(game *, aliens *, int, int, int);

/*
* From bonus.c
*/
void init_bonus(game *, bonus *);
void draw_bonus(game *, bonus *);
void update_bonus(game *, bonus *);
void add_bonus(game *, bonus *, int, int, int);

/*
* From box.c
*/
box * create_box(game *, int, int, int, int);
void draw_box(game *, box *);
void free_box(box *);

/*
* From ceo.c
*/
void ceo_alert(game *);

/*
* From collide.c
*/
void collide_weapons_tunnel(game *, weapons *, tunnel *, explosions *);
void collide_weapons_aliens(game *, weapons *, aliens *, explosions *);
void collide_player_tunnel(game *, player *, tunnel *, explosions *);

/*
* From explosions.c
*/
void init_explosions(game *, explosions *);
void add_explosion(game *, explosions *, int, int, int, int, int);
void draw_explosions(game *, explosions *);
void update_explosions(game *, explosions *);

/*
* From overlay.c
*/
void draw_status(game *);

/*
* From player.c
*/
player * create_player(game *);
void free_player(player *);
void draw_player(game *, player *);
void update_player(game *, player *);

/*
* From starfield.c
*/
starfield * create_starfield(game *);
void draw_starfield(game *, starfield *);
void update_starfield(game *, starfield *);
void free_starfield(game *, starfield *);

/*
* From tunnel.c
*/
tunnel * create_tunnel(game *, int, int);
void free_tunnel(tunnel *);
void draw_tunnel(game *, tunnel *);
void update_tunnel(game *, tunnel *);

/*
* From weapons.c
*/
void init_weapons(game *, weapons *);
void draw_weapons(game *, weapons *);
void update_weapons(game *, weapons *);
void add_weapon(game *, weapons *, int, int, int, int, int);


+ 0
- 142
src/explosions.c Просмотреть файл

@@ -1,142 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

struct caca_sprite *medium_sprite;
struct caca_sprite *small_sprite;

void init_explosions(game *g, explosions *ex)
{
int i;

for(i = 0; i < EXPLOSIONS; i++)
{
ex->type[i] = EXPLOSION_NONE;
}

medium_sprite = caca_load_sprite("data/xplmed.txt");
small_sprite = caca_load_sprite("data/xplsmall.txt");
}

void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type)
{
int i;

for(i = 0; i < EXPLOSIONS; i++)
{
if(ex->type[i] == EXPLOSION_NONE)
{
ex->type[i] = type;
ex->x[i] = x;
ex->y[i] = y;
ex->vx[i] = vx;
ex->vy[i] = vy;
switch(type)
{
case EXPLOSION_MEDIUM:
ex->n[i] = 11;
break;
case EXPLOSION_SMALL:
ex->n[i] = 7;
break;
}
break;
}
}
}

void draw_explosions(game *g, explosions *ex)
{
int i;

for(i = 0; i < EXPLOSIONS; i++)
{
#if 0
caca_set_color(GREEN);
caca_goto(ex->x[i] + 3, ex->y[i]);
switch(caca_rand(0,2))
{
case 0:
caca_putchar('p');
caca_putchar('i');
caca_putchar('f');
break;
case 1:
caca_putchar('p');
caca_putchar('a');
caca_putchar('f');
break;
case 2:
caca_putchar('p');
caca_putchar('o');
caca_putchar('u');
caca_putchar('f');
break;
}
caca_putchar('!');
#endif

switch(ex->type[i])
{
case EXPLOSION_MEDIUM:
caca_draw_sprite(ex->x[i], ex->y[i], medium_sprite,
10 - ex->n[i]);
break;
case EXPLOSION_SMALL:
caca_draw_sprite(ex->x[i], ex->y[i], small_sprite,
6 - ex->n[i]);
break;
case EXPLOSION_NONE:
break;
}
}
}

void update_explosions(game *g, explosions *ex)
{
int i;

for(i = 0; i < EXPLOSIONS; i++)
{
switch(ex->type[i])
{
case EXPLOSION_MEDIUM:
case EXPLOSION_SMALL:
ex->x[i] += ex->vx[i];
ex->y[i] += ex->vy[i];
ex->n[i]--;
if(ex->n[i] < 0)
{
ex->type[i] = EXPLOSION_NONE;
}
break;
case EXPLOSION_NONE:
break;
}
}
}


+ 0
- 77
src/intro.c Просмотреть файл

@@ -1,77 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>
#include <math.h>
#include <unistd.h>

#include "common.h"

void intro(void)
{
struct caca_sprite *foo_sprite = caca_load_sprite("data/foofight.txt");
struct caca_sprite *bar_sprite = caca_load_sprite("data/barfight.txt");
struct caca_sprite *baz_sprite = caca_load_sprite("data/bazfight.txt");

int frame = 0;

while(caca_get_key() == 0)
{
int i, xo, yo, x[5], y[5];

frame++;

caca_clear();

xo = caca_get_width() / 2;
yo = caca_get_height() / 2;

caca_set_color(EE_RED);
caca_fill_ellipse(xo, yo, 16, 8, '#');
caca_set_color(EE_GREEN);
caca_draw_thin_ellipse(xo, yo, 16, 8);

for(i = 0; i < 4; i ++)
{
x[i] = xo + 0.5 + 12 * cos(0.05 * frame + i * M_PI / 2);
y[i] = yo + 0.5 + 6 * sin(0.05 * frame + i * M_PI / 2);
}
x[4] = x[0];
y[4] = y[0];

caca_set_color(EE_BLACK);
caca_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' ');
caca_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' ');
caca_draw_line(x[0], y[0], x[2], y[2], ' ');
caca_set_color(EE_GREEN);
caca_draw_thin_polyline(x, y, 4);

caca_draw_sprite(xo, yo, foo_sprite, frame % 5);

caca_refresh();

usleep(40000);
}
}


+ 0
- 268
src/main.c Просмотреть файл

@@ -1,268 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include <string.h>

#include <time.h>

#include "common.h"

static void start_game (game *);

int main (int argc, char **argv)
{
game *g = malloc(sizeof(game));
if(g == NULL)
exit(1);

srand(time(NULL));

if(caca_init())
{
return 1;
}

caca_set_delay(100000);

/* Initialize our program */
g->w = caca_get_width();
g->h = caca_get_height();

intro();

/* Go ! */
start_game(g);

/* Clean up */
caca_end();

return 0;
}

static void start_game (game *g)
{
int quit = 0;
int poz = 0;
int skip = 0;
int purcompteur = 0;

box *pausebox = NULL;

g->sf = create_starfield(g);
g->wp = malloc(sizeof(weapons));
if(g->wp == NULL)
exit(1);
g->ex = malloc(sizeof(explosions));
if(g->ex == NULL)
exit(1);
g->bo = malloc(sizeof(bonus));
if(g->bo == NULL)
exit(1);
g->t = create_tunnel(g, g->w, g->h);
g->p = create_player(g);
g->al = malloc(sizeof(aliens));
if(g->al == NULL)
exit(1);

init_bonus(g, g->bo);
init_weapons(g, g->wp);
init_explosions(g, g->ex);
init_aliens(g, g->al);

/* Temporary stuff */
g->t->w = 25;

while(!quit)
{
char key;

while((key = caca_get_key()))
{
switch(key)
{
case 'q':
quit = 1;
break;
case 'p':
poz = !poz;
if(poz)
{
pausebox = create_box(g, g->w / 2, g->h / 2,
g->w - 16, 8);
}
else
{
free_box(pausebox);
}
break;
case '\t':
ceo_alert(g);
poz = 1;
break;
case 's':
skip = 1;
break;
default:
if(g->p->dead)
{
break;
}

switch(key)
{
case 'h':
g->p->vx = -2;
break;
case 'j':
if(g->p->y < g->h - 3) g->p->y += 1;
break;
case 'k':
if(g->p->y > 2) g->p->y -= 1;
break;
case 'l':
g->p->vx = 2;
break;
case 'n':
if(g->p->special >= COST_NUKE)
{
g->p->special -= COST_NUKE;
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, 0, WEAPON_NUKE);
}
break;
case 'f':
if(g->p->special >= COST_FRAGBOMB)
{
g->p->special -= COST_FRAGBOMB;
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, -16, WEAPON_FRAGBOMB);
}
break;
case 'b':
if(g->p->special >= COST_BEAM)
{
g->p->special -= COST_BEAM;
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, 0, WEAPON_BEAM);
}
break;
case ' ':
if(g->p->weapon == 0)
{
g->p->weapon = 4;
add_weapon(g, g->wp, (g->p->x - 2) << 4, g->p->y << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 3) << 4, g->p->y << 4, 0, -32, WEAPON_LASER);
/* Extra schtuph */
add_weapon(g, g->wp, (g->p->x - 2) << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x + 3) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER);
/* More schtuph */
add_weapon(g, g->wp, (g->p->x - 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
/* Even more schtuph */
add_weapon(g, g->wp, g->p->x << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
add_weapon(g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER);
/* Extra schtuph */
add_weapon(g, g->wp, (g->p->x - 2) << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER);
add_weapon(g, g->wp, (g->p->x + 3) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER);
/* MORE SCHTUPH! */
add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, -16, WEAPON_BOMB);
}
break;
}
}
}

if(!poz || skip)
{
skip = 0;

/* XXX: to be removed */
if(caca_rand(0, 9) == 0)
{
int list[3] = { ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ };

add_alien(g, g->al, 0, rand() % g->h / 2, list[caca_rand(0,2)]);
}

/* Update game rules */
if(g->t->right[1] - g->t->left[1] == g->t->w)
{
g->t->w = 85 - g->t->w;
}

/* Scroll and update positions */
collide_player_tunnel(g, g->p, g->t, g->ex);
update_player(g, g->p);
collide_player_tunnel(g, g->p, g->t, g->ex);

update_starfield(g, g->sf);
update_bonus(g, g->bo);
update_aliens(g, g->al);

collide_weapons_tunnel(g, g->wp, g->t, g->ex);
collide_weapons_aliens(g, g->wp, g->al, g->ex);
update_weapons(g, g->wp);
collide_weapons_tunnel(g, g->wp, g->t, g->ex);
collide_weapons_aliens(g, g->wp, g->al, g->ex);

update_explosions(g, g->ex);
update_tunnel(g, g->t);
}

/* Clear screen */
caca_clear();

/* Print starfield, tunnel, aliens, player and explosions */
draw_starfield(g, g->sf);
draw_aliens(g, g->al);
draw_tunnel(g, g->t);
draw_bonus(g, g->bo);
draw_explosions(g, g->ex);
draw_weapons(g, g->wp);
draw_player(g, g->p);
draw_status(g);

/* Print pause box if needed */
if(poz)
{
pausebox->frame++;
draw_box(g, pausebox);
}

/* Refresh */
caca_refresh();

purcompteur++;
}

if(pausebox)
{
free_box(pausebox);
}

free_starfield(g, g->sf);
free_tunnel(g->t);
free_player(g->p);
}


+ 0
- 81
src/overlay.c Просмотреть файл

@@ -1,81 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

void draw_status(game *g)
{
static char dots30[] = "------------------------------";
static char dashes30[] = "==============================";

/* Draw life jauge */
caca_set_color(EE_DARKGRAY);
caca_putstr(4, 1, dots30);

if(g->p->life > MAX_LIFE * 7 / 10)
{
caca_set_color(EE_GREEN);
}
else if(g->p->life > MAX_LIFE * 3 / 10)
{
caca_set_color(EE_YELLOW);
}
else
{
caca_set_color(EE_RED);
}

caca_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);

caca_set_color(EE_WHITE);
caca_putstr(1, 1, "L |");
caca_putstr(34, 1, "|");

/* Draw weapon jauge */
caca_set_color(EE_DARKGRAY);
caca_putstr(42, 1, dots30 + 10);

if(g->p->special > MAX_SPECIAL * 9 / 10)
{
caca_set_color(EE_WHITE);
}
else if(g->p->special > MAX_SPECIAL * 3 / 10)
{
caca_set_color(EE_CYAN);
}
else
{
caca_set_color(EE_BLUE);
}

caca_putstr(42, 1, dashes30 + 10
+ (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL);

caca_set_color(EE_WHITE);
caca_putstr(39, 1, "S |");
caca_putstr(62, 1, "|");
}


+ 0
- 101
src/player.c Просмотреть файл

@@ -1,101 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

struct caca_sprite *ship_sprite;

/* Init tunnel */
player * create_player(game *g)
{
player *p = malloc(sizeof(player));
if(p == NULL)
exit(1);

p->x = g->w / 2;
p->y = g->h - 3;
p->vx = 0;
p->vy = 0;
p->weapon = 0;
p->special = MAX_SPECIAL;
p->life = MAX_LIFE;
p->dead = 0;

ship_sprite = caca_load_sprite("data/ship.txt");

return p;
}

void free_player(player *p)
{
free(p);
}

void draw_player(game *g, player *p)
{
if(p->dead)
return;

caca_draw_sprite(p->x, p->y, ship_sprite, 0);
}

void update_player(game *g, player *p)
{
if(p->dead)
return;

if(p->life <= 0)
{
add_explosion(g, g->ex, p->x, p->y, 0, 0, EXPLOSION_SMALL);
p->dead = 1;
return;
}

/* Update weapon stats */
if(p->weapon)
p->weapon--;

if(p->special < MAX_SPECIAL)
p->special++;

/* Update life */
if(p->life < MAX_LIFE)
p->life++;

/* Update coords */
p->x += p->vx;

if(p->vx < 0)
p->vx++;
else if(p->vx > 0)
p->vx--;

if(p->x < 1)
p->x = 1;
else if(p->x > g->w - 7)
p->x = g->w - 7;
}


+ 0
- 93
src/starfield.c Просмотреть файл

@@ -1,93 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

starfield * create_starfield(game *g)
{
int i;
starfield *s;

s = malloc(STARS * sizeof(starfield));
if(s == NULL)
exit(1);

for(i = 0; i < STARS; i++)
{
s[i].x = caca_rand(0, g->w - 1);
s[i].y = caca_rand(0, g->h - 1);
s[i].z = caca_rand(1, 3);
s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY;
s[i].ch = caca_rand(0, 1) ? '.' : '\'';
}

return s;
}

void draw_starfield(game *g, starfield *s)
{
int i;

for(i = 0; i < STARS; i++)
{
if(s[i].x >= 0)
{
caca_set_color(s[i].c);
caca_putchar(s[i].x, s[i].y, s[i].ch);
}
}
}

void update_starfield(game *g, starfield *s)
{
int i;

for(i = 0; i < STARS; i++)
{
if(s[i].x < 0)
{
s[i].x = caca_rand(0, g->w - 1);
s[i].y = 0;
s[i].z = caca_rand(1, 2);
s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY;
s[i].ch = caca_rand(0, 1) ? '.' : '\'';
}
else if(s[i].y < g->h-1)
{
s[i].y += s[i].z;
}
else
{
s[i].x = -1;
}
}
}

void free_starfield(game *g, starfield *s)
{
free(s);
}


+ 0
- 206
src/tunnel.c Просмотреть файл

@@ -1,206 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

/* Init tunnel */
tunnel * create_tunnel(game *g, int w, int h)
{
int i;
tunnel *t = malloc(sizeof(tunnel));
if(t == NULL)
exit(1);

t->left = malloc(h*sizeof(int));
if(t->left == NULL)
exit(1);
t->right = malloc(h*sizeof(int));
if(t->right == NULL)
exit(1);
t->w = w;
t->h = h;

if(t->w >= g->w)
{
for(i = 0; i < g->h; i++)
{
t->left[i] = -10;
t->right[i] = g->w + 10;
}
}
else
{
t->left[0] = (g->w - w) / 2;
t->right[0] = (g->w + w) / 2;
/* Yeah, sub-efficient, but less code to do :-) */
for(i = 0; i < g->h; i++)
{
update_tunnel(g, t);
}
}

return t;
}

void free_tunnel(tunnel *t)
{
free(t->left);
free(t->right);
free(t);
}

void draw_tunnel(game *g, tunnel *t)
{
int i, j;
char c;

caca_set_color(EE_GREEN);

/* Left border */
for(i = 0; i < g->h ; i++)
{
if(t->left[i] <= -10)
continue;

if(i + 1 == g->h || t->left[i] > t->left[i+1])
c = (i == 0 || t->left[i] > t->left[i-1]) ? '>' : '/';
else
c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<';

caca_putchar(t->left[i] + 1, i, c);

if(i + 1 < g->h)
for(j = 1; j < t->left[i+1] - t->left[i]; j++)
caca_putchar(t->left[i] + j + 1, i, '_');
}

/* Right border */
for(i = 0; i < g->h ; i++)
{
if(t->right[i] >= g->w + 10)
continue;

if(i + 1 == g->h || t->right[i] > t->right[i+1])
c = (i == 0 || t->right[i] > t->right[i-1]) ? '>' : '/';
else
c = (i == 0 || t->right[i] > t->right[i-1]) ? '\\' : '<';

if(i + 1 < g->h)
for(j = 1; j < t->right[i] - t->right[i+1]; j++)
caca_putchar(t->right[i+1] + j - 1, i, '_');

caca_putchar(t->right[i] - 1, i, c);
}

caca_set_color(EE_RED);

/* Left concrete */
for(i = 0; i < g->h ; i++)
for(j = 0 ; j <= t->left[i]; j++)
caca_putchar(j, i, '#');

/* Right concrete */
for(i = 0; i < g->h ; i++)
for(j = t->right[i] ; j < g->w ; j++)
caca_putchar(j, i, '#');
}

void update_tunnel(game *g, tunnel *t)
{
static int const delta[] = { -3, -2, -1, 1, 2, 3 };
int i,j,k;

/* Slide tunnel one block vertically */
for(i = t->h - 1; i--;)
{
t->left[i+1] = t->left[i];
t->right[i+1] = t->right[i];
}

/* Generate new values */
i = delta[caca_rand(0,5)];
j = delta[caca_rand(0,5)];

/* Check in which direction we need to alter tunnel */
if(t->right[1] - t->left[1] < t->w)
{
/* Not wide enough, make sure i <= j */
if(i > j)
{
k = j; j = i; i = k;
}
}
else if(t->right[1] - t->left[1] - 2 > t->w)
{
/* Too wide, make sure i >= j */
if(i < j)
{
k = j; j = i; i = k;
}
}
else
{
/* No need to mess with i and j: width is OK */
}

/* If width doesn't exceed game size, update coords */
if(t->w <= g->w || t->right[1] - t->left[1] < t->w)
{
t->left[0] = t->left[1] + i;
t->right[0] = t->right[1] + j;
}
else
{
t->left[0] = -10;
t->right[0] = g->w + 10;
}

if(t->w > g->w)
{
if(t->left[0] < 0 && t->right[0] < g->w - 2)
{
t->left[0] = t->left[1] + 1;
}

if(t->left[0] > 1 && t->right[0] > g->w - 1)
{
t->right[0] = t->right[1] - 1;
}
}
else
{
if(t->left[0] < 0)
{
t->left[0] = t->left[1] + 1;
}

if(t->right[0] > g->w - 1)
{
t->right[0] = t->right[1] - 1;
}
}
}


+ 0
- 459
src/weapons.c Просмотреть файл

@@ -1,459 +0,0 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "config.h"

#include <stdlib.h>

#include "common.h"

static void draw_bomb(int x, int y, int vx, int vy);
static void draw_nuke(int x, int y, int frame);
static void draw_beam(int x, int y, int frame);
static void draw_fragbomb(int x, int y, int frame);

struct caca_sprite *bomb_sprite;
struct caca_sprite *fragbomb_sprite;

void init_weapons(game *g, weapons *wp)
{
int i;

for(i = 0; i < WEAPONS; i++)
{
wp->type[i] = WEAPON_NONE;
}

bomb_sprite = caca_load_sprite("data/wpnbomb.txt");
fragbomb_sprite = caca_load_sprite("data/wpnfrag.txt");
}

void draw_weapons(game *g, weapons *wp)
{
unsigned int i;

for(i = 0; i < WEAPONS; i++)
{
switch(wp->type[i])
{
case WEAPON_LASER:
caca_set_color(EE_WHITE);
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|');
caca_set_color(EE_CYAN);
caca_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
break;
case WEAPON_SEEKER:
caca_set_color(EE_CYAN);
caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
caca_set_color(EE_WHITE);
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@');
break;
case WEAPON_BOMB:
caca_set_color(EE_DARKGRAY);
caca_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
caca_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
caca_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');
caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, '.');
draw_bomb(wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]);
break;
case WEAPON_FRAGBOMB:
draw_fragbomb(wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i]);
break;
case WEAPON_BEAM:
draw_beam(wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i]);
break;
case WEAPON_NUKE:
draw_nuke(wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i]);
break;
case WEAPON_LIGHTNING:
case WEAPON_NONE:
break;
}
}
}

void update_weapons(game *g, weapons *wp)
{
unsigned int i, j;
int dist, xmin, ymin, dx, dy, xnew, ynew;

for(i = 0; i < WEAPONS; i++)
{
switch(wp->type[i])
{
case WEAPON_LASER:
wp->x[i] += wp->vx[i];
wp->y[i] += wp->vy[i];
if(wp->y[i] < 0)
{
wp->type[i] = WEAPON_NONE;
}
break;
case WEAPON_BOMB:
case WEAPON_SEEKER:
/* Update tail */
wp->x3[i] = wp->x2[i];
wp->y3[i] = wp->y2[i];

wp->x2[i] = wp->x[i];
wp->y2[i] = wp->y[i];

wp->x[i] += wp->vx[i];
wp->y[i] += wp->vy[i];

if(wp->y[i] < 0)
{
wp->type[i] = WEAPON_NONE;
break;
}

if(wp->n[i] < 0)
{
/* Stop updating direction */
break;
}

wp->n[i]--;

/* Estimate our position next frames */
xnew = wp->x[i] + wp->vx[i];
ynew = wp->y[i] + wp->vy[i];

xmin = xnew;
ymin = - (g->h << 4);
dist = (xnew - xmin) * (xnew - xmin)
+ 4 * (ynew - ymin) * (ynew - ymin);

/* Find the nearest alien */
for(j = 0; j < ALIENS; j++)
{
if(g->al->type[j] != ALIEN_NONE)
{
int alx = g->al->x[j] << 4;
int aly = g->al->y[j] << 4;
int new = (xnew - alx) * (xnew - alx)
+ 4 * (ynew - aly) * (ynew - aly);
if(new <= dist)
{
dist = new;
xmin = alx;
ymin = aly;
}
}
}

/* Find our new direction */
dx = xmin - wp->x[i];
dy = ymin - wp->y[i];

/* Normalize direction */
if(dx | dy)
{
unsigned int norm = caca_sqrt(dx * dx + 4 * dy * dy);
dx = dx * 32 / norm;
dy = dy * 32 / norm;
}

/* Find our new speed */
dx = (dx + 3 * wp->vx[i]) / 4;
dy = (dy + 3 * wp->vy[i]) / 4;

/* Normalize speed */
if(dx | dy)
{
unsigned int norm = caca_sqrt(dx * dx + 4 * dy * dy);
wp->vx[i] = dx * 32 / norm;
wp->vy[i] = dy * 32 / norm;
}

break;

case WEAPON_FRAGBOMB:
/* If n was set to -1, the fragbomb just exploded */
if(wp->n[i] == -1)
{
int coords[] =
{
32, 0, -32, 0, 0, 16, 0, -16,
28, 8, -28, 8, 28, -8, -28, -8,
24, 12, -24, 12, 24, -12, -24, -12,
16, 14, -16, 14, 16, -14, -16, -14
};

for(j = 0 ; j < sizeof(coords) / sizeof(int) ; j += 2)
{
add_weapon(g, g->wp, wp->x[i] + coords[j], wp->y[i] + coords[j+1] / 2, coords[j], coords[j+1], WEAPON_SEEKER);
add_weapon(g, g->wp, wp->x[i] + coords[j] / 2, wp->y[i] + coords[j+1], coords[j], coords[j+1], WEAPON_SEEKER);
}

wp->type[i] = WEAPON_NONE;
}

wp->x[i] += wp->vx[i];
wp->y[i] += wp->vy[i];
wp->n[i]++;
if(wp->y[i] < 0)
{
wp->type[i] = WEAPON_NONE;
}
break;

case WEAPON_BEAM:
wp->x[i] = g->p->x << 4;
wp->y[i] = g->p->y << 4;
wp->n[i]--;
if(wp->n[i] < 0)
{
wp->type[i] = WEAPON_NONE;
}
break;
case WEAPON_NUKE:
wp->n[i]--;
if(wp->n[i] < 0)
{
wp->type[i] = WEAPON_NONE;
}
break;
case WEAPON_LIGHTNING:
case WEAPON_NONE:
break;
}
}
}

void add_weapon(game *g, weapons *wp, int x, int y, int vx, int vy, int type)
{
int i;

for(i = 0; i < WEAPONS; i++)
{
if(wp->type[i] == WEAPON_NONE)
{
wp->x[i] = x;
wp->y[i] = y;
wp->vx[i] = vx;
wp->vy[i] = vy;
wp->type[i] = type;
wp->n[i] = 0;
switch(type)
{
case WEAPON_LASER:
break;
case WEAPON_FRAGBOMB:
break;
case WEAPON_SEEKER:
case WEAPON_BOMB:
wp->x2[i] = x;
wp->y2[i] = y;
wp->x3[i] = x;
wp->y3[i] = y;
wp->n[i] = 20;
break;
case WEAPON_BEAM:
wp->n[i] = 25;
break;
case WEAPON_NUKE:
wp->n[i] = 25;
break;
case WEAPON_NONE:
break;
}
break;
}
}
}

static void draw_bomb(int x, int y, int vx, int vy)
{
int frame;

/* We have 1x2 pixels */
vy *= 2;

if(vx > vy)
{
if(vx > -vy) /* right quarter */
{
if(vy > vx/4)
frame = 0; /* -pi/6 */
else if(vy < -vx/4)
frame = 1; /* pi/6 */
else
frame = 2; /* 0pi/6 */
}
else /* top quarter */
{
if(vx > -vy/4)
frame = 3; /* 2pi/6 */
else if(vx < vy/4)
frame = 4; /* 4pi/6 */
else
frame = 5; /* 3pi/6 */
}
}
else
{
if(vx > -vy) /* bottom quarter */
{
if(vx > vy/4)
frame = 6; /* -2pi/6 */
else if(vx < -vy/4)
frame = 7; /* -4pi/6 */
else
frame = 8; /* -3pi/6 */
}
else /* left quarter */
{
if(vy > -vx/4)
frame = 9; /* -5pi/6 */
else if(vy < vx/4)
frame = 10; /* 5pi/6 */
else
frame = 11; /* 6pi/6 */
}
}

caca_draw_sprite(x, y, bomb_sprite, frame);
}

static void draw_fragbomb(int x, int y, int frame)
{
/* Draw the head */
caca_draw_sprite(x, y, fragbomb_sprite, frame & 1);

/* Draw the tail */
caca_draw_sprite(x, y, fragbomb_sprite, 2 + (frame % 4));
}

static void draw_beam(int x, int y, int frame)
{
int r = (29 - frame) * (29 - frame) / 8;
int i;

switch(frame)
{
case 24:
caca_set_color(EE_WHITE);
caca_putstr(x, y-3, "__");
caca_putchar(x-1, y-2, '\'');
caca_putchar(x+2, y-2, '`');
break;
case 23:
caca_set_color(EE_CYAN);
caca_putstr(x, y-3, "__");
caca_set_color(EE_WHITE);
caca_putstr(x-2, y-2, "-'");
caca_putstr(x+2, y-2, "`-");
break;
case 22:
caca_set_color(EE_CYAN);
caca_putstr(x, y-3, "__");
caca_putchar(x-1, y-2, '\'');
caca_putchar(x+2, y-2, '`');
caca_set_color(EE_WHITE);
caca_putstr(x-3, y-2, ",-");
caca_putstr(x+3, y-2, "-.");
break;
case 21:
caca_set_color(EE_CYAN);
caca_putstr(x-1, y-3, "____");
caca_putchar(x-2, y-2, '\'');
caca_putchar(x+3, y-2, '`');
caca_set_color(EE_WHITE);
caca_putstr(x-4, y-2, ",-");
caca_putstr(x+4, y-2, "-.");
break;
case 20:
caca_set_color(EE_WHITE);
caca_putstr(x, y-3, "%%");
caca_putchar(x-4, y-2, ',');
caca_putchar(x+5, y-2, '.');
caca_set_color(EE_CYAN);
caca_putchar(x-1, y-3, ':');
caca_putchar(x+2, y-3, ':');
caca_putstr(x-3, y-2, "-'");
caca_putstr(x+3, y-2, "`-");
break;
case 19:
caca_set_color(EE_WHITE);
caca_putstr(x, y-4, "%%");
caca_putstr(x, y-3, "##");
caca_set_color(EE_CYAN);
caca_putchar(x-1, y-4, ':');
caca_putchar(x+2, y-4, ':');
caca_putchar(x-1, y-3, '%');
caca_putchar(x+2, y-3, '%');
caca_putstr(x-4, y-2, ",-'");
caca_putstr(x+3, y-2, "`-.");
caca_set_color(EE_BLUE);
caca_putchar(x-2, y-3, ':');
caca_putchar(x+3, y-3, ':');
break;
case 18:
default:
r = (18 - frame) * (18 - frame);
caca_set_color(EE_WHITE);
caca_putstr(x-1, y-5-r, ":%%:");
caca_putstr(x-1, y-4-r, "%##%");
caca_set_color(EE_CYAN);
caca_putchar(x-2, y-4-r, ':');
caca_putchar(x+3, y-4-r, ':');
caca_putchar(x-2, y-2, '\'');
caca_putchar(x+3, y-2, '`');
caca_set_color(EE_BLUE);
caca_putchar(x-3, y-2, ':');
caca_putchar(x+4, y-2, ':');
for(i = 0; i <= r; i++)
{
caca_set_color(EE_WHITE);
caca_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
caca_set_color(EE_CYAN);
caca_putchar(x-2, y-3-i, '%');
caca_putchar(x+3, y-3-i, '%');
caca_set_color(EE_BLUE);
caca_putchar(x-3, y-3-i, ':');
caca_putchar(x+4, y-3-i, ':');
}
break;
}
}

static void draw_nuke(int x, int y, int frame)
{
int r = (29 - frame) * (29 - frame) / 8;

/* Lots of duplicate pixels, but we don't care */
caca_set_color(EE_BLUE);
caca_draw_ellipse(x, y, r, r / 2, ':');
caca_draw_ellipse(x, y, r + 1, r / 2, ':');
caca_draw_ellipse(x, y, r + 2, r / 2, ':');
caca_set_color(EE_CYAN);
caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '%');
caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '%');
caca_set_color(EE_WHITE);
caca_draw_ellipse(x, y, r + 3, r / 2 + 2, '#');
caca_draw_ellipse(x, y, r + 4, r / 2 + 2, '#');
caca_draw_ellipse(x, y, r + 4, r / 2 + 3, '#');
}


||||||
x
 
000:0
Загрузка…
Отмена
Сохранить