diff --git a/WebGames-master/WebGames-master/assets/n-gon.png b/WebGames-master/WebGames-master/assets/n-gon.png
new file mode 100644
index 00000000..1597569c
Binary files /dev/null and b/WebGames-master/WebGames-master/assets/n-gon.png differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/.gitignore b/WebGames-master/WebGames-master/n-gon-master/.gitignore
new file mode 100644
index 00000000..ef23d46d
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/.gitignore
@@ -0,0 +1,6 @@
+
+.jsbeautifyrc
+.DS_Store
+.DS_Store
+.DS_Store
+js/workspace.code-workspace
diff --git a/WebGames-master/WebGames-master/n-gon-master/LICENSE b/WebGames-master/WebGames-master/n-gon-master/LICENSE
new file mode 100644
index 00000000..f288702d
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/WebGames-master/WebGames-master/n-gon-master/README.md b/WebGames-master/WebGames-master/n-gon-master/README.md
new file mode 100644
index 00000000..e2b8697c
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/README.md
@@ -0,0 +1,3 @@
+2-d physics rogue-lite platformer shooter
+
+https://landgreen.github.io/n-gon/
diff --git a/WebGames-master/WebGames-master/n-gon-master/favicon.ico b/WebGames-master/WebGames-master/n-gon-master/favicon.ico
new file mode 100644
index 00000000..ce083ff5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/favicon.ico differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/1s half-life.webp b/WebGames-master/WebGames-master/n-gon-master/img/1s half-life.webp
new file mode 100644
index 00000000..e6e39192
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/1s half-life.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/1st ionization energy.webp b/WebGames-master/WebGames-master/n-gon-master/img/1st ionization energy.webp
new file mode 100644
index 00000000..78906ed2
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/1st ionization energy.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/6s half-life.webp b/WebGames-master/WebGames-master/n-gon-master/img/6s half-life.webp
new file mode 100644
index 00000000..5ecd2c37
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/6s half-life.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Abelian group.webp b/WebGames-master/WebGames-master/n-gon-master/img/Abelian group.webp
new file mode 100644
index 00000000..916f9551
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Abelian group.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Bayesian statistics.webp b/WebGames-master/WebGames-master/n-gon-master/img/Bayesian statistics.webp
new file mode 100644
index 00000000..8dd3651f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Bayesian statistics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Bessemer process.webp b/WebGames-master/WebGames-master/n-gon-master/img/Bessemer process.webp
new file mode 100644
index 00000000..bca9b045
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Bessemer process.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Bitter electromagnet.webp b/WebGames-master/WebGames-master/n-gon-master/img/Bitter electromagnet.webp
new file mode 100644
index 00000000..9d325d36
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Bitter electromagnet.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Born rule.webp b/WebGames-master/WebGames-master/n-gon-master/img/Born rule.webp
new file mode 100644
index 00000000..dac853bf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Born rule.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/CIWS.webp b/WebGames-master/WebGames-master/n-gon-master/img/CIWS.webp
new file mode 100644
index 00000000..2033c20d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/CIWS.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/CPT symmetry.webp b/WebGames-master/WebGames-master/n-gon-master/img/CPT symmetry.webp
new file mode 100644
index 00000000..f28d0b17
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/CPT symmetry.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Gibbs free energy.webp b/WebGames-master/WebGames-master/n-gon-master/img/Gibbs free energy.webp
new file mode 100644
index 00000000..b4b03d3d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Gibbs free energy.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Halbach array.webp b/WebGames-master/WebGames-master/n-gon-master/img/Halbach array.webp
new file mode 100644
index 00000000..5d166c38
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Halbach array.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Higgs mechanism.webp b/WebGames-master/WebGames-master/n-gon-master/img/Higgs mechanism.webp
new file mode 100644
index 00000000..26ede450
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Higgs mechanism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Hilbert space.webp b/WebGames-master/WebGames-master/n-gon-master/img/Hilbert space.webp
new file mode 100644
index 00000000..b772ad80
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Hilbert space.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ICBM.webp b/WebGames-master/WebGames-master/n-gon-master/img/ICBM.webp
new file mode 100644
index 00000000..ac2f753e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ICBM.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/K-selection.webp b/WebGames-master/WebGames-master/n-gon-master/img/K-selection.webp
new file mode 100644
index 00000000..595519aa
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/K-selection.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Lorentz transformation.webp b/WebGames-master/WebGames-master/n-gon-master/img/Lorentz transformation.webp
new file mode 100644
index 00000000..c7c52e8a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Lorentz transformation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/MACHO.webp b/WebGames-master/WebGames-master/n-gon-master/img/MACHO.webp
new file mode 100644
index 00000000..0875e673
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/MACHO.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/MIRV.webp b/WebGames-master/WebGames-master/n-gon-master/img/MIRV.webp
new file mode 100644
index 00000000..32db2961
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/MIRV.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/MOND.webp b/WebGames-master/WebGames-master/n-gon-master/img/MOND.webp
new file mode 100644
index 00000000..53a447a0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/MOND.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Maxwells demon.webp b/WebGames-master/WebGames-master/n-gon-master/img/Maxwells demon.webp
new file mode 100644
index 00000000..9152cad7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Maxwells demon.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Meissner effect.webp b/WebGames-master/WebGames-master/n-gon-master/img/Meissner effect.webp
new file mode 100644
index 00000000..329bc13e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Meissner effect.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Monte Carlo method.webp b/WebGames-master/WebGames-master/n-gon-master/img/Monte Carlo method.webp
new file mode 100644
index 00000000..017fb090
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Monte Carlo method.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/NAND gate.webp b/WebGames-master/WebGames-master/n-gon-master/img/NAND gate.webp
new file mode 100644
index 00000000..0525c8ba
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/NAND gate.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/NOR gate.webp b/WebGames-master/WebGames-master/n-gon-master/img/NOR gate.webp
new file mode 100644
index 00000000..bd71ef30
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/NOR gate.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Newtons 1st law.webp b/WebGames-master/WebGames-master/n-gon-master/img/Newtons 1st law.webp
new file mode 100644
index 00000000..02ac9b67
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Newtons 1st law.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Newtons 2nd law.webp b/WebGames-master/WebGames-master/n-gon-master/img/Newtons 2nd law.webp
new file mode 100644
index 00000000..9e173548
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Newtons 2nd law.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Newtons 3rd law.webp b/WebGames-master/WebGames-master/n-gon-master/img/Newtons 3rd law.webp
new file mode 100644
index 00000000..ad9c801c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Newtons 3rd law.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Noether violation.webp b/WebGames-master/WebGames-master/n-gon-master/img/Noether violation.webp
new file mode 100644
index 00000000..b3c6797f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Noether violation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Occams razor.webp b/WebGames-master/WebGames-master/n-gon-master/img/Occams razor.webp
new file mode 100644
index 00000000..cf6a4d39
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Occams razor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Pareto efficiency.webp b/WebGames-master/WebGames-master/n-gon-master/img/Pareto efficiency.webp
new file mode 100644
index 00000000..e8d661dd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Pareto efficiency.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Pauli exclusion.webp b/WebGames-master/WebGames-master/n-gon-master/img/Pauli exclusion.webp
new file mode 100644
index 00000000..589abb58
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Pauli exclusion.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/UHMWPE.webp b/WebGames-master/WebGames-master/n-gon-master/img/UHMWPE.webp
new file mode 100644
index 00000000..b893961f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/UHMWPE.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Verlet integration.webp b/WebGames-master/WebGames-master/n-gon-master/img/Verlet integration.webp
new file mode 100644
index 00000000..733638bf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Verlet integration.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/WIMPs.webp b/WebGames-master/WebGames-master/n-gon-master/img/WIMPs.webp
new file mode 100644
index 00000000..66ba2fbf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/WIMPs.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Zectron.webp b/WebGames-master/WebGames-master/n-gon-master/img/Zectron.webp
new file mode 100644
index 00000000..89ebe0f0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Zectron.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Zenos paradox.webp b/WebGames-master/WebGames-master/n-gon-master/img/Zenos paradox.webp
new file mode 100644
index 00000000..c3284964
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Zenos paradox.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/abiogenesis.webp b/WebGames-master/WebGames-master/n-gon-master/img/abiogenesis.webp
new file mode 100644
index 00000000..082de302
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/abiogenesis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ablative drones.webp b/WebGames-master/WebGames-master/n-gon-master/img/ablative drones.webp
new file mode 100644
index 00000000..78f4c4a9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ablative drones.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/accretion disk.webp b/WebGames-master/WebGames-master/n-gon-master/img/accretion disk.webp
new file mode 100644
index 00000000..d8a6013c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/accretion disk.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/accretion.webp b/WebGames-master/WebGames-master/n-gon-master/img/accretion.webp
new file mode 100644
index 00000000..6a7fc452
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/accretion.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/acetone peroxide.webp b/WebGames-master/WebGames-master/n-gon-master/img/acetone peroxide.webp
new file mode 100644
index 00000000..71847e6f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/acetone peroxide.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/active cooling.webp b/WebGames-master/WebGames-master/n-gon-master/img/active cooling.webp
new file mode 100644
index 00000000..a264fa1c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/active cooling.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ad hoc.webp b/WebGames-master/WebGames-master/n-gon-master/img/ad hoc.webp
new file mode 100644
index 00000000..44a62e35
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ad hoc.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/additive manufacturing.webp b/WebGames-master/WebGames-master/n-gon-master/img/additive manufacturing.webp
new file mode 100644
index 00000000..3a7b15a8
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/additive manufacturing.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/adiabatic healing.webp b/WebGames-master/WebGames-master/n-gon-master/img/adiabatic healing.webp
new file mode 100644
index 00000000..0e253591
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/adiabatic healing.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/aerogel.webp b/WebGames-master/WebGames-master/n-gon-master/img/aerogel.webp
new file mode 100644
index 00000000..597078b8
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/aerogel.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/aerostat.webp b/WebGames-master/WebGames-master/n-gon-master/img/aerostat.webp
new file mode 100644
index 00000000..2e2077f9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/aerostat.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/affine connection.webp b/WebGames-master/WebGames-master/n-gon-master/img/affine connection.webp
new file mode 100644
index 00000000..fb05fd09
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/affine connection.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/alternator.webp b/WebGames-master/WebGames-master/n-gon-master/img/alternator.webp
new file mode 100644
index 00000000..ef2098d0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/alternator.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ammo.webp b/WebGames-master/WebGames-master/n-gon-master/img/ammo.webp
new file mode 100644
index 00000000..782d63d5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ammo.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ammonium nitrate.webp b/WebGames-master/WebGames-master/n-gon-master/img/ammonium nitrate.webp
new file mode 100644
index 00000000..77f2c096
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ammonium nitrate.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/amplitude.webp b/WebGames-master/WebGames-master/n-gon-master/img/amplitude.webp
new file mode 100644
index 00000000..202f93d4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/amplitude.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/annihilation.webp b/WebGames-master/WebGames-master/n-gon-master/img/annihilation.webp
new file mode 100644
index 00000000..4a37c35b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/annihilation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ansatz.webp b/WebGames-master/WebGames-master/n-gon-master/img/ansatz.webp
new file mode 100644
index 00000000..3b9a4d78
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ansatz.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/anthropic principle.webp b/WebGames-master/WebGames-master/n-gon-master/img/anthropic principle.webp
new file mode 100644
index 00000000..28035f9a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/anthropic principle.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/anti-shear topology.webp b/WebGames-master/WebGames-master/n-gon-master/img/anti-shear topology.webp
new file mode 100644
index 00000000..61dcda6e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/anti-shear topology.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/anticorrelation.webp b/WebGames-master/WebGames-master/n-gon-master/img/anticorrelation.webp
new file mode 100644
index 00000000..2d6a05ed
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/anticorrelation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/antiscience.webp b/WebGames-master/WebGames-master/n-gon-master/img/antiscience.webp
new file mode 100644
index 00000000..057e650a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/antiscience.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/anyon.webp b/WebGames-master/WebGames-master/n-gon-master/img/anyon.webp
new file mode 100644
index 00000000..3f88a63f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/anyon.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/aperture.webp b/WebGames-master/WebGames-master/n-gon-master/img/aperture.webp
new file mode 100644
index 00000000..01c9e7da
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/aperture.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/apomixis.webp b/WebGames-master/WebGames-master/n-gon-master/img/apomixis.webp
new file mode 100644
index 00000000..1aa7128a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/apomixis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/applied science.webp b/WebGames-master/WebGames-master/n-gon-master/img/applied science.webp
new file mode 100644
index 00000000..aecde798
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/applied science.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/arsenal.webp b/WebGames-master/WebGames-master/n-gon-master/img/arsenal.webp
new file mode 100644
index 00000000..3a22e858
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/arsenal.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/autocannon.webp b/WebGames-master/WebGames-master/n-gon-master/img/autocannon.webp
new file mode 100644
index 00000000..c8823d13
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/autocannon.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/autonomous defense.webp b/WebGames-master/WebGames-master/n-gon-master/img/autonomous defense.webp
new file mode 100644
index 00000000..3065ae8a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/autonomous defense.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/axial flux motor.webp b/WebGames-master/WebGames-master/n-gon-master/img/axial flux motor.webp
new file mode 100644
index 00000000..a178c525
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/axial flux motor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/axion.webp b/WebGames-master/WebGames-master/n-gon-master/img/axion.webp
new file mode 100644
index 00000000..3e79c125
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/axion.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/band gap.webp b/WebGames-master/WebGames-master/n-gon-master/img/band gap.webp
new file mode 100644
index 00000000..0427cd4a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/band gap.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/beta radiation.webp b/WebGames-master/WebGames-master/n-gon-master/img/beta radiation.webp
new file mode 100644
index 00000000..24970c63
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/beta radiation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/blast ball.webp b/WebGames-master/WebGames-master/n-gon-master/img/blast ball.webp
new file mode 100644
index 00000000..b7164665
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/blast ball.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/booby trap.webp b/WebGames-master/WebGames-master/n-gon-master/img/booby trap.webp
new file mode 100644
index 00000000..ea063523
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/booby trap.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/boom-bot upgrade.webp b/WebGames-master/WebGames-master/n-gon-master/img/boom-bot upgrade.webp
new file mode 100644
index 00000000..127b91d5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/boom-bot upgrade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/boom-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/boom-bot.webp
new file mode 100644
index 00000000..76ee2fd3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/boom-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/boson composite.webp b/WebGames-master/WebGames-master/n-gon-master/img/boson composite.webp
new file mode 100644
index 00000000..18fb1ecf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/boson composite.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/bot fabrication.webp b/WebGames-master/WebGames-master/n-gon-master/img/bot fabrication.webp
new file mode 100644
index 00000000..8e4efae0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/bot fabrication.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/bot manufacturing.webp b/WebGames-master/WebGames-master/n-gon-master/img/bot manufacturing.webp
new file mode 100644
index 00000000..930875f7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/bot manufacturing.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/bot prototypes.webp b/WebGames-master/WebGames-master/n-gon-master/img/bot prototypes.webp
new file mode 100644
index 00000000..431a668e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/bot prototypes.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/bound state.webp b/WebGames-master/WebGames-master/n-gon-master/img/bound state.webp
new file mode 100644
index 00000000..f134f44d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/bound state.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/brainstorming.webp b/WebGames-master/WebGames-master/n-gon-master/img/brainstorming.webp
new file mode 100644
index 00000000..d7d327f9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/brainstorming.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/bremsstrahlung.webp b/WebGames-master/WebGames-master/n-gon-master/img/bremsstrahlung.webp
new file mode 100644
index 00000000..d7fe0fcd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/bremsstrahlung.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/brittle.webp b/WebGames-master/WebGames-master/n-gon-master/img/brittle.webp
new file mode 100644
index 00000000..85dd2fe0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/brittle.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/brushless motor.webp b/WebGames-master/WebGames-master/n-gon-master/img/brushless motor.webp
new file mode 100644
index 00000000..7ad17531
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/brushless motor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/bubble fusion.webp b/WebGames-master/WebGames-master/n-gon-master/img/bubble fusion.webp
new file mode 100644
index 00000000..c45a1798
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/bubble fusion.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/buckling.webp b/WebGames-master/WebGames-master/n-gon-master/img/buckling.webp
new file mode 100644
index 00000000..17f10fe1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/buckling.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cache.webp b/WebGames-master/WebGames-master/n-gon-master/img/cache.webp
new file mode 100644
index 00000000..d0dcbdcf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cache.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/capacitor bank.webp b/WebGames-master/WebGames-master/n-gon-master/img/capacitor bank.webp
new file mode 100644
index 00000000..2f631d63
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/capacitor bank.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cascading failure.webp b/WebGames-master/WebGames-master/n-gon-master/img/cascading failure.webp
new file mode 100644
index 00000000..443206ed
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cascading failure.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/catabolism.webp b/WebGames-master/WebGames-master/n-gon-master/img/catabolism.webp
new file mode 100644
index 00000000..3fbfea31
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/catabolism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/causality bombs.webp b/WebGames-master/WebGames-master/n-gon-master/img/causality bombs.webp
new file mode 100644
index 00000000..2b789961
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/causality bombs.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/causality bots.webp b/WebGames-master/WebGames-master/n-gon-master/img/causality bots.webp
new file mode 100644
index 00000000..333ece1f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/causality bots.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cavitation.webp b/WebGames-master/WebGames-master/n-gon-master/img/cavitation.webp
new file mode 100644
index 00000000..332ec5a4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cavitation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ceramics.webp b/WebGames-master/WebGames-master/n-gon-master/img/ceramics.webp
new file mode 100644
index 00000000..ca6c1770
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ceramics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/chain reaction.webp b/WebGames-master/WebGames-master/n-gon-master/img/chain reaction.webp
new file mode 100644
index 00000000..d2a54486
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/chain reaction.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cherenkov radiation.webp b/WebGames-master/WebGames-master/n-gon-master/img/cherenkov radiation.webp
new file mode 100644
index 00000000..23c62968
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cherenkov radiation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/clock gating.webp b/WebGames-master/WebGames-master/n-gon-master/img/clock gating.webp
new file mode 100644
index 00000000..03bdc913
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/clock gating.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/coherence.webp b/WebGames-master/WebGames-master/n-gon-master/img/coherence.webp
new file mode 100644
index 00000000..c433b176
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/coherence.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/collider.webp b/WebGames-master/WebGames-master/n-gon-master/img/collider.webp
new file mode 100644
index 00000000..ef6c55f0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/collider.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/colony.webp b/WebGames-master/WebGames-master/n-gon-master/img/colony.webp
new file mode 100644
index 00000000..c572b6e7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/colony.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/combinatorial optimization.webp b/WebGames-master/WebGames-master/n-gon-master/img/combinatorial optimization.webp
new file mode 100644
index 00000000..dc22e75b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/combinatorial optimization.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/commodities exchange.webp b/WebGames-master/WebGames-master/n-gon-master/img/commodities exchange.webp
new file mode 100644
index 00000000..edad9af5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/commodities exchange.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/compound lens.webp b/WebGames-master/WebGames-master/n-gon-master/img/compound lens.webp
new file mode 100644
index 00000000..1357aefc
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/compound lens.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/control theory.webp b/WebGames-master/WebGames-master/n-gon-master/img/control theory.webp
new file mode 100644
index 00000000..2843288c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/control theory.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cordyceps.webp b/WebGames-master/WebGames-master/n-gon-master/img/cordyceps.webp
new file mode 100644
index 00000000..14497808
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cordyceps.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/corona discharge.webp b/WebGames-master/WebGames-master/n-gon-master/img/corona discharge.webp
new file mode 100644
index 00000000..4c3bb589
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/corona discharge.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/correlated damage.webp b/WebGames-master/WebGames-master/n-gon-master/img/correlated damage.webp
new file mode 100644
index 00000000..cd93b2cd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/correlated damage.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cosmic string.webp b/WebGames-master/WebGames-master/n-gon-master/img/cosmic string.webp
new file mode 100644
index 00000000..51338ebf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cosmic string.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cross-disciplinary.webp b/WebGames-master/WebGames-master/n-gon-master/img/cross-disciplinary.webp
new file mode 100644
index 00000000..31c94f40
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cross-disciplinary.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cruise missile.webp b/WebGames-master/WebGames-master/n-gon-master/img/cruise missile.webp
new file mode 100644
index 00000000..d1e9e449
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cruise missile.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/cryodesiccation.webp b/WebGames-master/WebGames-master/n-gon-master/img/cryodesiccation.webp
new file mode 100644
index 00000000..f36e2726
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/cryodesiccation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/crystallizer.webp b/WebGames-master/WebGames-master/n-gon-master/img/crystallizer.webp
new file mode 100644
index 00000000..8539db92
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/crystallizer.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dark energy.webp b/WebGames-master/WebGames-master/n-gon-master/img/dark energy.webp
new file mode 100644
index 00000000..faca967e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dark energy.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dark matter.webp b/WebGames-master/WebGames-master/n-gon-master/img/dark matter.webp
new file mode 100644
index 00000000..8570ee05
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dark matter.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dark patterns.webp b/WebGames-master/WebGames-master/n-gon-master/img/dark patterns.webp
new file mode 100644
index 00000000..f147c9ed
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dark patterns.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dark star.webp b/WebGames-master/WebGames-master/n-gon-master/img/dark star.webp
new file mode 100644
index 00000000..ca23c349
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dark star.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dazzler.webp b/WebGames-master/WebGames-master/n-gon-master/img/dazzler.webp
new file mode 100644
index 00000000..2cdb34fd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dazzler.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dead reckoning.webp b/WebGames-master/WebGames-master/n-gon-master/img/dead reckoning.webp
new file mode 100644
index 00000000..05e9abff
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dead reckoning.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/decoherence.webp b/WebGames-master/WebGames-master/n-gon-master/img/decoherence.webp
new file mode 100644
index 00000000..82b46502
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/decoherence.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/decorrelation.webp b/WebGames-master/WebGames-master/n-gon-master/img/decorrelation.webp
new file mode 100644
index 00000000..8abd9424
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/decorrelation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/decoupling.webp b/WebGames-master/WebGames-master/n-gon-master/img/decoupling.webp
new file mode 100644
index 00000000..6776cc33
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/decoupling.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/degenerate matter.webp b/WebGames-master/WebGames-master/n-gon-master/img/degenerate matter.webp
new file mode 100644
index 00000000..de582167
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/degenerate matter.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/delayed-choice.webp b/WebGames-master/WebGames-master/n-gon-master/img/delayed-choice.webp
new file mode 100644
index 00000000..8f98107e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/delayed-choice.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/delivery drone.webp b/WebGames-master/WebGames-master/n-gon-master/img/delivery drone.webp
new file mode 100644
index 00000000..91c74779
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/delivery drone.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/depolarization.webp b/WebGames-master/WebGames-master/n-gon-master/img/depolarization.webp
new file mode 100644
index 00000000..1ff8484a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/depolarization.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/deprecated.webp b/WebGames-master/WebGames-master/n-gon-master/img/deprecated.webp
new file mode 100644
index 00000000..8ef13875
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/deprecated.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/desublimated ammunition.webp b/WebGames-master/WebGames-master/n-gon-master/img/desublimated ammunition.webp
new file mode 100644
index 00000000..541e2a1d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/desublimated ammunition.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/determinism.webp b/WebGames-master/WebGames-master/n-gon-master/img/determinism.webp
new file mode 100644
index 00000000..02b07fb4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/determinism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/diaphragm.webp b/WebGames-master/WebGames-master/n-gon-master/img/diaphragm.webp
new file mode 100644
index 00000000..10a8bc21
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/diaphragm.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/diffraction grating.webp b/WebGames-master/WebGames-master/n-gon-master/img/diffraction grating.webp
new file mode 100644
index 00000000..53fed27a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/diffraction grating.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/diffuse beam.webp b/WebGames-master/WebGames-master/n-gon-master/img/diffuse beam.webp
new file mode 100644
index 00000000..54027930
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/diffuse beam.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/drone repair.webp b/WebGames-master/WebGames-master/n-gon-master/img/drone repair.webp
new file mode 100644
index 00000000..bc4ee461
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/drone repair.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dye laser.webp b/WebGames-master/WebGames-master/n-gon-master/img/dye laser.webp
new file mode 100644
index 00000000..3a9cf69d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dye laser.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dynamic equilibrium.webp b/WebGames-master/WebGames-master/n-gon-master/img/dynamic equilibrium.webp
new file mode 100644
index 00000000..c26522bd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dynamic equilibrium.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dynamical systems.webp b/WebGames-master/WebGames-master/n-gon-master/img/dynamical systems.webp
new file mode 100644
index 00000000..141e818b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dynamical systems.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dynamo-bot upgrade.webp b/WebGames-master/WebGames-master/n-gon-master/img/dynamo-bot upgrade.webp
new file mode 100644
index 00000000..15b3d618
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dynamo-bot upgrade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/dynamo-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/dynamo-bot.webp
new file mode 100644
index 00000000..71f5d05f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/dynamo-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/eddy current brake.webp b/WebGames-master/WebGames-master/n-gon-master/img/eddy current brake.webp
new file mode 100644
index 00000000..9d95e5ad
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/eddy current brake.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/electric armor.webp b/WebGames-master/WebGames-master/n-gon-master/img/electric armor.webp
new file mode 100644
index 00000000..2ee7dc0b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/electric armor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/electric generator.webp b/WebGames-master/WebGames-master/n-gon-master/img/electric generator.webp
new file mode 100644
index 00000000..9c23ad3f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/electric generator.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/electronegativity.webp b/WebGames-master/WebGames-master/n-gon-master/img/electronegativity.webp
new file mode 100644
index 00000000..4df69cd6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/electronegativity.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/electrostatic induction.webp b/WebGames-master/WebGames-master/n-gon-master/img/electrostatic induction.webp
new file mode 100644
index 00000000..3cc3bf38
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/electrostatic induction.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/elephants toothpaste.webp b/WebGames-master/WebGames-master/n-gon-master/img/elephants toothpaste.webp
new file mode 100644
index 00000000..3e945973
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/elephants toothpaste.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/emergence.webp b/WebGames-master/WebGames-master/n-gon-master/img/emergence.webp
new file mode 100644
index 00000000..f7d87e08
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/emergence.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/energy conservation.webp b/WebGames-master/WebGames-master/n-gon-master/img/energy conservation.webp
new file mode 100644
index 00000000..e825adb7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/energy conservation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/enthalpy.webp b/WebGames-master/WebGames-master/n-gon-master/img/enthalpy.webp
new file mode 100644
index 00000000..761e8f8f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/enthalpy.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/entropic gravity.webp b/WebGames-master/WebGames-master/n-gon-master/img/entropic gravity.webp
new file mode 100644
index 00000000..339af23d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/entropic gravity.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ergodicity.webp b/WebGames-master/WebGames-master/n-gon-master/img/ergodicity.webp
new file mode 100644
index 00000000..969e577d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ergodicity.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ersatz bots.webp b/WebGames-master/WebGames-master/n-gon-master/img/ersatz bots.webp
new file mode 100644
index 00000000..3074c078
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ersatz bots.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/eternalism.webp b/WebGames-master/WebGames-master/n-gon-master/img/eternalism.webp
new file mode 100644
index 00000000..08df1eaa
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/eternalism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/exchange symmetry.webp b/WebGames-master/WebGames-master/n-gon-master/img/exchange symmetry.webp
new file mode 100644
index 00000000..15a2c097
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/exchange symmetry.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/exciton.webp b/WebGames-master/WebGames-master/n-gon-master/img/exciton.webp
new file mode 100644
index 00000000..d6a99ba2
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/exciton.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/exothermic process.webp b/WebGames-master/WebGames-master/n-gon-master/img/exothermic process.webp
new file mode 100644
index 00000000..3d790088
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/exothermic process.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/expansion.webp b/WebGames-master/WebGames-master/n-gon-master/img/expansion.webp
new file mode 100644
index 00000000..0a0bf977
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/expansion.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/extended magazine.webp b/WebGames-master/WebGames-master/n-gon-master/img/extended magazine.webp
new file mode 100644
index 00000000..f3507c3f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/extended magazine.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/externality.webp b/WebGames-master/WebGames-master/n-gon-master/img/externality.webp
new file mode 100644
index 00000000..69fda3a5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/externality.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/extruder.webp b/WebGames-master/WebGames-master/n-gon-master/img/extruder.webp
new file mode 100644
index 00000000..52021429
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/extruder.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/fault tolerance.webp b/WebGames-master/WebGames-master/n-gon-master/img/fault tolerance.webp
new file mode 100644
index 00000000..359b3920
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/fault tolerance.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/fermion.webp b/WebGames-master/WebGames-master/n-gon-master/img/fermion.webp
new file mode 100644
index 00000000..0de0dab6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/fermion.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field coupling.webp b/WebGames-master/WebGames-master/n-gon-master/img/field coupling.webp
new file mode 100644
index 00000000..06376a91
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field coupling.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter0.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter0.webp
new file mode 100644
index 00000000..d6a9f989
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter0.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter1.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter1.webp
new file mode 100644
index 00000000..8451986c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter1.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter10.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter10.webp
new file mode 100644
index 00000000..46bdc8d3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter10.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter11.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter11.webp
new file mode 100644
index 00000000..d5f4beda
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter11.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter12.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter12.webp
new file mode 100644
index 00000000..4452eb32
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter12.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter13.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter13.webp
new file mode 100644
index 00000000..cea1f4f8
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter13.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter14.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter14.webp
new file mode 100644
index 00000000..20dde97d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter14.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter15.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter15.webp
new file mode 100644
index 00000000..10e73064
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter15.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter16.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter16.webp
new file mode 100644
index 00000000..21912d14
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter16.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter17.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter17.webp
new file mode 100644
index 00000000..96d8dc41
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter17.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter18.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter18.webp
new file mode 100644
index 00000000..532b8edf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter18.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter19.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter19.webp
new file mode 100644
index 00000000..98206f53
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter19.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter2.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter2.webp
new file mode 100644
index 00000000..e6ac3509
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter2.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter20.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter20.webp
new file mode 100644
index 00000000..58e0cd77
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter20.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter21.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter21.webp
new file mode 100644
index 00000000..2c1ba1da
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter21.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter22.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter22.webp
new file mode 100644
index 00000000..9c0e8a1f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter22.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter23.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter23.webp
new file mode 100644
index 00000000..72adb696
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter23.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter24.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter24.webp
new file mode 100644
index 00000000..9634dcba
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter24.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter25.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter25.webp
new file mode 100644
index 00000000..aa48cdd5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter25.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter3.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter3.webp
new file mode 100644
index 00000000..6d38a825
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter3.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter4.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter4.webp
new file mode 100644
index 00000000..8bff0164
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter4.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter5.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter5.webp
new file mode 100644
index 00000000..5f40e76a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter5.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter6.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter6.webp
new file mode 100644
index 00000000..c251cff6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter6.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter7.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter7.webp
new file mode 100644
index 00000000..baad4a32
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter7.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter8.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter8.webp
new file mode 100644
index 00000000..4ed2781e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter8.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter9.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter9.webp
new file mode 100644
index 00000000..7b9a8471
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/field emitter9.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/grappling hook.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/grappling hook.webp
new file mode 100644
index 00000000..1b138264
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/grappling hook.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/metamaterial cloaking.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/metamaterial cloaking.webp
new file mode 100644
index 00000000..08d39e04
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/metamaterial cloaking.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/molecular assembler.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/molecular assembler.webp
new file mode 100644
index 00000000..89a2ab22
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/molecular assembler.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/negative mass.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/negative mass.webp
new file mode 100644
index 00000000..f6f94dd2
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/negative mass.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/perfect diamagnetism.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/perfect diamagnetism.webp
new file mode 100644
index 00000000..82a5f1fc
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/perfect diamagnetism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/pilot wave.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/pilot wave.webp
new file mode 100644
index 00000000..d6b52813
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/pilot wave.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/plasma torch.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/plasma torch.webp
new file mode 100644
index 00000000..95cbaef3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/plasma torch.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/standing wave.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/standing wave.webp
new file mode 100644
index 00000000..7b130a78
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/standing wave.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/time dilation.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/time dilation.webp
new file mode 100644
index 00000000..e7c0cc14
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/time dilation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/field/wormhole.webp b/WebGames-master/WebGames-master/n-gon-master/img/field/wormhole.webp
new file mode 100644
index 00000000..ec2fab4a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/field/wormhole.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/fine-structure constant.webp b/WebGames-master/WebGames-master/n-gon-master/img/fine-structure constant.webp
new file mode 100644
index 00000000..d070faa1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/fine-structure constant.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/fireworks.webp b/WebGames-master/WebGames-master/n-gon-master/img/fireworks.webp
new file mode 100644
index 00000000..27fad969
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/fireworks.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/first derivative.webp b/WebGames-master/WebGames-master/n-gon-master/img/first derivative.webp
new file mode 100644
index 00000000..f32d1bdc
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/first derivative.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/flagella.webp b/WebGames-master/WebGames-master/n-gon-master/img/flagella.webp
new file mode 100644
index 00000000..130ca508
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/flagella.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/flame test.webp b/WebGames-master/WebGames-master/n-gon-master/img/flame test.webp
new file mode 100644
index 00000000..50c30904
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/flame test.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/flash freeze.webp b/WebGames-master/WebGames-master/n-gon-master/img/flash freeze.webp
new file mode 100644
index 00000000..bb5d0a07
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/flash freeze.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/flip-flop.webp b/WebGames-master/WebGames-master/n-gon-master/img/flip-flop.webp
new file mode 100644
index 00000000..5c6b8be8
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/flip-flop.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/fluoroantimonic acid.webp b/WebGames-master/WebGames-master/n-gon-master/img/fluoroantimonic acid.webp
new file mode 100644
index 00000000..99a37443
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/fluoroantimonic acid.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/flux pinning.webp b/WebGames-master/WebGames-master/n-gon-master/img/flux pinning.webp
new file mode 100644
index 00000000..aa2baa04
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/flux pinning.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/flywheel.webp b/WebGames-master/WebGames-master/n-gon-master/img/flywheel.webp
new file mode 100644
index 00000000..953e9f24
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/flywheel.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/foam fractionation.webp b/WebGames-master/WebGames-master/n-gon-master/img/foam fractionation.webp
new file mode 100644
index 00000000..811a613d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/foam fractionation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/foam-bot upgrade.webp b/WebGames-master/WebGames-master/n-gon-master/img/foam-bot upgrade.webp
new file mode 100644
index 00000000..f64ec65e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/foam-bot upgrade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/foam-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/foam-bot.webp
new file mode 100644
index 00000000..7c9fe501
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/foam-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/foam-shot.webp b/WebGames-master/WebGames-master/n-gon-master/img/foam-shot.webp
new file mode 100644
index 00000000..73a53a7c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/foam-shot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/fracture analysis.webp b/WebGames-master/WebGames-master/n-gon-master/img/fracture analysis.webp
new file mode 100644
index 00000000..16007711
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/fracture analysis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/fragmentation.webp b/WebGames-master/WebGames-master/n-gon-master/img/fragmentation.webp
new file mode 100644
index 00000000..ea6c04b9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/fragmentation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/frame-dragging.webp b/WebGames-master/WebGames-master/n-gon-master/img/frame-dragging.webp
new file mode 100644
index 00000000..09b90ba5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/frame-dragging.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/free-electron laser.webp b/WebGames-master/WebGames-master/n-gon-master/img/free-electron laser.webp
new file mode 100644
index 00000000..236492f4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/free-electron laser.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/freezer burn.webp b/WebGames-master/WebGames-master/n-gon-master/img/freezer burn.webp
new file mode 100644
index 00000000..57750a4b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/freezer burn.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/frequency.webp b/WebGames-master/WebGames-master/n-gon-master/img/frequency.webp
new file mode 100644
index 00000000..b8b26a25
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/frequency.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/futures exchange.webp b/WebGames-master/WebGames-master/n-gon-master/img/futures exchange.webp
new file mode 100644
index 00000000..561c99f3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/futures exchange.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gauge.webp b/WebGames-master/WebGames-master/n-gon-master/img/gauge.webp
new file mode 100644
index 00000000..a4f5231a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gauge.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/generalist.webp b/WebGames-master/WebGames-master/n-gon-master/img/generalist.webp
new file mode 100644
index 00000000..802cbb21
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/generalist.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/geodesics.webp b/WebGames-master/WebGames-master/n-gon-master/img/geodesics.webp
new file mode 100644
index 00000000..4cb475b5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/geodesics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ground state.webp b/WebGames-master/WebGames-master/n-gon-master/img/ground state.webp
new file mode 100644
index 00000000..5e6ba803
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ground state.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun turret.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun turret.webp
new file mode 100644
index 00000000..ca8bc6c9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun turret.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/drones.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/drones.webp
new file mode 100644
index 00000000..a91022d7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/drones.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/foam.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/foam.webp
new file mode 100644
index 00000000..f70c3182
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/foam.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/grenades.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/grenades.webp
new file mode 100644
index 00000000..6a6c048a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/grenades.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/harpoon.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/harpoon.webp
new file mode 100644
index 00000000..fb158cf1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/harpoon.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/laser.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/laser.webp
new file mode 100644
index 00000000..de8624e5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/laser.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/mine.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/mine.webp
new file mode 100644
index 00000000..4a2304ed
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/mine.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/missiles.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/missiles.webp
new file mode 100644
index 00000000..2e822b59
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/missiles.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/nail gun.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/nail gun.webp
new file mode 100644
index 00000000..66ac2017
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/nail gun.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/shotgun.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/shotgun.webp
new file mode 100644
index 00000000..436490af
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/shotgun.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/spores.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/spores.webp
new file mode 100644
index 00000000..d8fca1fe
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/spores.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/super balls.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/super balls.webp
new file mode 100644
index 00000000..3e0c03c0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/super balls.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/gun/wave.webp b/WebGames-master/WebGames-master/n-gon-master/img/gun/wave.webp
new file mode 100644
index 00000000..b769112d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/gun/wave.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/heals.webp b/WebGames-master/WebGames-master/n-gon-master/img/heals.webp
new file mode 100644
index 00000000..d92dcd9c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/heals.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/heat engine.webp b/WebGames-master/WebGames-master/n-gon-master/img/heat engine.webp
new file mode 100644
index 00000000..df299f82
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/heat engine.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/heuristics.webp b/WebGames-master/WebGames-master/n-gon-master/img/heuristics.webp
new file mode 100644
index 00000000..8b8c0abb
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/heuristics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/hidden-variable theory.webp b/WebGames-master/WebGames-master/n-gon-master/img/hidden-variable theory.webp
new file mode 100644
index 00000000..1db74f5d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/hidden-variable theory.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/holographic principle.webp b/WebGames-master/WebGames-master/n-gon-master/img/holographic principle.webp
new file mode 100644
index 00000000..79b6d26f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/holographic principle.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/homeostasis.webp b/WebGames-master/WebGames-master/n-gon-master/img/homeostasis.webp
new file mode 100644
index 00000000..862ae53f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/homeostasis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ice crystal nucleation.webp b/WebGames-master/WebGames-master/n-gon-master/img/ice crystal nucleation.webp
new file mode 100644
index 00000000..160876b1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ice crystal nucleation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ice-shot.webp b/WebGames-master/WebGames-master/n-gon-master/img/ice-shot.webp
new file mode 100644
index 00000000..4f3169ed
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ice-shot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ideal gas law.webp b/WebGames-master/WebGames-master/n-gon-master/img/ideal gas law.webp
new file mode 100644
index 00000000..c2097ef0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ideal gas law.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/incendiary ammunition.webp b/WebGames-master/WebGames-master/n-gon-master/img/incendiary ammunition.webp
new file mode 100644
index 00000000..643248d7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/incendiary ammunition.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/induction brake.webp b/WebGames-master/WebGames-master/n-gon-master/img/induction brake.webp
new file mode 100644
index 00000000..fbb44244
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/induction brake.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/induction furnace.webp b/WebGames-master/WebGames-master/n-gon-master/img/induction furnace.webp
new file mode 100644
index 00000000..af1aac85
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/induction furnace.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/inductive charging.webp b/WebGames-master/WebGames-master/n-gon-master/img/inductive charging.webp
new file mode 100644
index 00000000..55643bdf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/inductive charging.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/inertial confinement.webp b/WebGames-master/WebGames-master/n-gon-master/img/inertial confinement.webp
new file mode 100644
index 00000000..068f0c08
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/inertial confinement.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/inertial mass.webp b/WebGames-master/WebGames-master/n-gon-master/img/inertial mass.webp
new file mode 100644
index 00000000..06309001
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/inertial mass.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/inflation.webp b/WebGames-master/WebGames-master/n-gon-master/img/inflation.webp
new file mode 100644
index 00000000..1f4374ee
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/inflation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/infrared diode.webp b/WebGames-master/WebGames-master/n-gon-master/img/infrared diode.webp
new file mode 100644
index 00000000..e6a0d5a0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/infrared diode.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/instability.webp b/WebGames-master/WebGames-master/n-gon-master/img/instability.webp
new file mode 100644
index 00000000..fdcbf8f4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/instability.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/integrated armament.webp b/WebGames-master/WebGames-master/n-gon-master/img/integrated armament.webp
new file mode 100644
index 00000000..53dbad21
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/integrated armament.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/integrated circuit.webp b/WebGames-master/WebGames-master/n-gon-master/img/integrated circuit.webp
new file mode 100644
index 00000000..3feb4a4c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/integrated circuit.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/interest.webp b/WebGames-master/WebGames-master/n-gon-master/img/interest.webp
new file mode 100644
index 00000000..51efb085
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/interest.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/invariant.webp b/WebGames-master/WebGames-master/n-gon-master/img/invariant.webp
new file mode 100644
index 00000000..9092bed6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/invariant.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/iridescence.webp b/WebGames-master/WebGames-master/n-gon-master/img/iridescence.webp
new file mode 100644
index 00000000..4bdb1e1d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/iridescence.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/iridium-192.webp b/WebGames-master/WebGames-master/n-gon-master/img/iridium-192.webp
new file mode 100644
index 00000000..bd589490
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/iridium-192.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/irradiated drones.webp b/WebGames-master/WebGames-master/n-gon-master/img/irradiated drones.webp
new file mode 100644
index 00000000..d3f2db5d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/irradiated drones.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/irradiated nails.webp b/WebGames-master/WebGames-master/n-gon-master/img/irradiated nails.webp
new file mode 100644
index 00000000..7ce6e2c6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/irradiated nails.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/isotropic.webp b/WebGames-master/WebGames-master/n-gon-master/img/isotropic.webp
new file mode 100644
index 00000000..ef8984b2
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/isotropic.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/junk DNA.webp b/WebGames-master/WebGames-master/n-gon-master/img/junk DNA.webp
new file mode 100644
index 00000000..c8029c66
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/junk DNA.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/junk.webp b/WebGames-master/WebGames-master/n-gon-master/img/junk.webp
new file mode 100644
index 00000000..af38107c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/junk.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/kinetic bombardment.webp b/WebGames-master/WebGames-master/n-gon-master/img/kinetic bombardment.webp
new file mode 100644
index 00000000..f7cd8b50
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/kinetic bombardment.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/laser-bot upgrade.webp b/WebGames-master/WebGames-master/n-gon-master/img/laser-bot upgrade.webp
new file mode 100644
index 00000000..6df8d4eb
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/laser-bot upgrade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/laser-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/laser-bot.webp
new file mode 100644
index 00000000..1e82e9ad
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/laser-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/laser-mines.webp b/WebGames-master/WebGames-master/n-gon-master/img/laser-mines.webp
new file mode 100644
index 00000000..639f6cac
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/laser-mines.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/launch system.webp b/WebGames-master/WebGames-master/n-gon-master/img/launch system.webp
new file mode 100644
index 00000000..8c10eaba
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/launch system.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/lens.webp b/WebGames-master/WebGames-master/n-gon-master/img/lens.webp
new file mode 100644
index 00000000..1ad4e50a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/lens.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/lithium-ion.webp b/WebGames-master/WebGames-master/n-gon-master/img/lithium-ion.webp
new file mode 100644
index 00000000..73ae0e78
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/lithium-ion.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/logistics.webp b/WebGames-master/WebGames-master/n-gon-master/img/logistics.webp
new file mode 100644
index 00000000..1b31696f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/logistics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/maintenance.webp b/WebGames-master/WebGames-master/n-gon-master/img/maintenance.webp
new file mode 100644
index 00000000..ea53c8a7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/maintenance.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/many-worlds.webp b/WebGames-master/WebGames-master/n-gon-master/img/many-worlds.webp
new file mode 100644
index 00000000..186e8746
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/many-worlds.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/marginal utility.webp b/WebGames-master/WebGames-master/n-gon-master/img/marginal utility.webp
new file mode 100644
index 00000000..92e54bd4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/marginal utility.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/martingale.webp b/WebGames-master/WebGames-master/n-gon-master/img/martingale.webp
new file mode 100644
index 00000000..8f1e712c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/martingale.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/mass driver.webp b/WebGames-master/WebGames-master/n-gon-master/img/mass driver.webp
new file mode 100644
index 00000000..fe943e31
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/mass driver.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/mass production.webp b/WebGames-master/WebGames-master/n-gon-master/img/mass production.webp
new file mode 100644
index 00000000..b8cf5f89
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/mass production.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/mass-energy equivalence.webp b/WebGames-master/WebGames-master/n-gon-master/img/mass-energy equivalence.webp
new file mode 100644
index 00000000..95a6a2b1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/mass-energy equivalence.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/mechanical resonance.webp b/WebGames-master/WebGames-master/n-gon-master/img/mechanical resonance.webp
new file mode 100644
index 00000000..c6092319
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/mechanical resonance.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/mechatronics.webp b/WebGames-master/WebGames-master/n-gon-master/img/mechatronics.webp
new file mode 100644
index 00000000..37d69f45
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/mechatronics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/meta-analysis.webp b/WebGames-master/WebGames-master/n-gon-master/img/meta-analysis.webp
new file mode 100644
index 00000000..3fe80d82
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/meta-analysis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/metamaterial absorber.webp b/WebGames-master/WebGames-master/n-gon-master/img/metamaterial absorber.webp
new file mode 100644
index 00000000..42bb32b3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/metamaterial absorber.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/metastability.webp b/WebGames-master/WebGames-master/n-gon-master/img/metastability.webp
new file mode 100644
index 00000000..6c80be4b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/metastability.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/microstates.webp b/WebGames-master/WebGames-master/n-gon-master/img/microstates.webp
new file mode 100644
index 00000000..df7f9787
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/microstates.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/missile-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/missile-bot.webp
new file mode 100644
index 00000000..d465f098
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/missile-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/mutualism.webp b/WebGames-master/WebGames-master/n-gon-master/img/mutualism.webp
new file mode 100644
index 00000000..5b0252eb
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/mutualism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/mycelial fragmentation.webp b/WebGames-master/WebGames-master/n-gon-master/img/mycelial fragmentation.webp
new file mode 100644
index 00000000..5035c1b6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/mycelial fragmentation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nail-bot upgrade.webp b/WebGames-master/WebGames-master/n-gon-master/img/nail-bot upgrade.webp
new file mode 100644
index 00000000..832ff436
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nail-bot upgrade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nail-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/nail-bot.webp
new file mode 100644
index 00000000..9b9c3a73
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nail-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nail-shot.webp b/WebGames-master/WebGames-master/n-gon-master/img/nail-shot.webp
new file mode 100644
index 00000000..eb412f03
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nail-shot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nanowires.webp b/WebGames-master/WebGames-master/n-gon-master/img/nanowires.webp
new file mode 100644
index 00000000..e7c6b614
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nanowires.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/necrophage.webp b/WebGames-master/WebGames-master/n-gon-master/img/necrophage.webp
new file mode 100644
index 00000000..47f7fae0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/necrophage.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/needle gun.webp b/WebGames-master/WebGames-master/n-gon-master/img/needle gun.webp
new file mode 100644
index 00000000..129df9ad
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/needle gun.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/needle ice.webp b/WebGames-master/WebGames-master/n-gon-master/img/needle ice.webp
new file mode 100644
index 00000000..42356953
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/needle ice.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/negative feedback.webp b/WebGames-master/WebGames-master/n-gon-master/img/negative feedback.webp
new file mode 100644
index 00000000..68611ba4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/negative feedback.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nematodes.webp b/WebGames-master/WebGames-master/n-gon-master/img/nematodes.webp
new file mode 100644
index 00000000..637b19ea
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nematodes.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/network effect.webp b/WebGames-master/WebGames-master/n-gon-master/img/network effect.webp
new file mode 100644
index 00000000..1084a7e7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/network effect.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/neutron bomb.webp b/WebGames-master/WebGames-master/n-gon-master/img/neutron bomb.webp
new file mode 100644
index 00000000..e5ea20fa
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/neutron bomb.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/neutronium.webp b/WebGames-master/WebGames-master/n-gon-master/img/neutronium.webp
new file mode 100644
index 00000000..fce6535d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/neutronium.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nitinol.webp b/WebGames-master/WebGames-master/n-gon-master/img/nitinol.webp
new file mode 100644
index 00000000..5c7290e9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nitinol.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nitroglycerin.webp b/WebGames-master/WebGames-master/n-gon-master/img/nitroglycerin.webp
new file mode 100644
index 00000000..55f5f2e5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nitroglycerin.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/no-cloning theorem.webp b/WebGames-master/WebGames-master/n-gon-master/img/no-cloning theorem.webp
new file mode 100644
index 00000000..cd6cdee5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/no-cloning theorem.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/non-Newtonian armor.webp b/WebGames-master/WebGames-master/n-gon-master/img/non-Newtonian armor.webp
new file mode 100644
index 00000000..f7e3823b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/non-Newtonian armor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/non-renewables.webp b/WebGames-master/WebGames-master/n-gon-master/img/non-renewables.webp
new file mode 100644
index 00000000..6fa89593
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/non-renewables.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/nuclear transmutation.webp b/WebGames-master/WebGames-master/n-gon-master/img/nuclear transmutation.webp
new file mode 100644
index 00000000..ba6b3f92
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/nuclear transmutation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/null hypothesis.webp b/WebGames-master/WebGames-master/n-gon-master/img/null hypothesis.webp
new file mode 100644
index 00000000..f7ca944b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/null hypothesis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/open-source.webp b/WebGames-master/WebGames-master/n-gon-master/img/open-source.webp
new file mode 100644
index 00000000..44b6a233
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/open-source.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/optical amplifier.webp b/WebGames-master/WebGames-master/n-gon-master/img/optical amplifier.webp
new file mode 100644
index 00000000..7fa80514
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/optical amplifier.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/options exchange.webp b/WebGames-master/WebGames-master/n-gon-master/img/options exchange.webp
new file mode 100644
index 00000000..a805ffce
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/options exchange.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/orbital-bot upgrade.webp b/WebGames-master/WebGames-master/n-gon-master/img/orbital-bot upgrade.webp
new file mode 100644
index 00000000..46ff5385
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/orbital-bot upgrade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/orbital-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/orbital-bot.webp
new file mode 100644
index 00000000..1ab8298f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/orbital-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ordnance.webp b/WebGames-master/WebGames-master/n-gon-master/img/ordnance.webp
new file mode 100644
index 00000000..f28c241b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ordnance.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/orthocyclic winding.webp b/WebGames-master/WebGames-master/n-gon-master/img/orthocyclic winding.webp
new file mode 100644
index 00000000..770461b5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/orthocyclic winding.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/output coupler.webp b/WebGames-master/WebGames-master/n-gon-master/img/output coupler.webp
new file mode 100644
index 00000000..61670f8a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/output coupler.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/overcharge.webp b/WebGames-master/WebGames-master/n-gon-master/img/overcharge.webp
new file mode 100644
index 00000000..7c20edb4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/overcharge.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/pair production.webp b/WebGames-master/WebGames-master/n-gon-master/img/pair production.webp
new file mode 100644
index 00000000..6e6d6343
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/pair production.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/paradigm shift.webp b/WebGames-master/WebGames-master/n-gon-master/img/paradigm shift.webp
new file mode 100644
index 00000000..49553951
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/paradigm shift.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/parasitism.webp b/WebGames-master/WebGames-master/n-gon-master/img/parasitism.webp
new file mode 100644
index 00000000..3db9826d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/parasitism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/parthenogenesis.webp b/WebGames-master/WebGames-master/n-gon-master/img/parthenogenesis.webp
new file mode 100644
index 00000000..e74f1c5c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/parthenogenesis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/patch.webp b/WebGames-master/WebGames-master/n-gon-master/img/patch.webp
new file mode 100644
index 00000000..2e65da5c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/patch.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/path integral.webp b/WebGames-master/WebGames-master/n-gon-master/img/path integral.webp
new file mode 100644
index 00000000..a81389bd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/path integral.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/path integration.webp b/WebGames-master/WebGames-master/n-gon-master/img/path integration.webp
new file mode 100644
index 00000000..9427793c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/path integration.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/peer review.webp b/WebGames-master/WebGames-master/n-gon-master/img/peer review.webp
new file mode 100644
index 00000000..0a91809a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/peer review.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/perimeter defense.webp b/WebGames-master/WebGames-master/n-gon-master/img/perimeter defense.webp
new file mode 100644
index 00000000..071ecc59
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/perimeter defense.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/perturbation theory.webp b/WebGames-master/WebGames-master/n-gon-master/img/perturbation theory.webp
new file mode 100644
index 00000000..ffff9b8e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/perturbation theory.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/phase velocity.webp b/WebGames-master/WebGames-master/n-gon-master/img/phase velocity.webp
new file mode 100644
index 00000000..35875c2d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/phase velocity.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/phonon.webp b/WebGames-master/WebGames-master/n-gon-master/img/phonon.webp
new file mode 100644
index 00000000..53f7afe1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/phonon.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/piezoelectricity.webp b/WebGames-master/WebGames-master/n-gon-master/img/piezoelectricity.webp
new file mode 100644
index 00000000..455fd7c3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/piezoelectricity.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/pigeonhole principle.webp b/WebGames-master/WebGames-master/n-gon-master/img/pigeonhole principle.webp
new file mode 100644
index 00000000..9475d19c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/pigeonhole principle.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/planned obsolescence.webp b/WebGames-master/WebGames-master/n-gon-master/img/planned obsolescence.webp
new file mode 100644
index 00000000..b47d9284
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/planned obsolescence.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/plasma ball.webp b/WebGames-master/WebGames-master/n-gon-master/img/plasma ball.webp
new file mode 100644
index 00000000..a2a692f0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/plasma ball.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/plasma jet.webp b/WebGames-master/WebGames-master/n-gon-master/img/plasma jet.webp
new file mode 100644
index 00000000..e6142696
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/plasma jet.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/plasma-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/plasma-bot.webp
new file mode 100644
index 00000000..9d71d506
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/plasma-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/pneumatic actuator.webp b/WebGames-master/WebGames-master/n-gon-master/img/pneumatic actuator.webp
new file mode 100644
index 00000000..9bb5a7f0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/pneumatic actuator.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/polariton.webp b/WebGames-master/WebGames-master/n-gon-master/img/polariton.webp
new file mode 100644
index 00000000..b512f02d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/polariton.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/polyurethane foam.webp b/WebGames-master/WebGames-master/n-gon-master/img/polyurethane foam.webp
new file mode 100644
index 00000000..d5745625
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/polyurethane foam.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/pressure vessel.webp b/WebGames-master/WebGames-master/n-gon-master/img/pressure vessel.webp
new file mode 100644
index 00000000..a4e27dee
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/pressure vessel.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/propagation.webp b/WebGames-master/WebGames-master/n-gon-master/img/propagation.webp
new file mode 100644
index 00000000..c47af7fb
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/propagation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/pseudoscience.webp b/WebGames-master/WebGames-master/n-gon-master/img/pseudoscience.webp
new file mode 100644
index 00000000..fdee13b9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/pseudoscience.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/pulse.webp b/WebGames-master/WebGames-master/n-gon-master/img/pulse.webp
new file mode 100644
index 00000000..6225cde0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/pulse.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/pyrotechnics.webp b/WebGames-master/WebGames-master/n-gon-master/img/pyrotechnics.webp
new file mode 100644
index 00000000..8ab09211
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/pyrotechnics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/quantum immortality.webp b/WebGames-master/WebGames-master/n-gon-master/img/quantum immortality.webp
new file mode 100644
index 00000000..028c9f7a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/quantum immortality.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/quasiparticles.webp b/WebGames-master/WebGames-master/n-gon-master/img/quasiparticles.webp
new file mode 100644
index 00000000..18d3bad1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/quasiparticles.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/quenching.webp b/WebGames-master/WebGames-master/n-gon-master/img/quenching.webp
new file mode 100644
index 00000000..ecf7887e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/quenching.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/quintessence.webp b/WebGames-master/WebGames-master/n-gon-master/img/quintessence.webp
new file mode 100644
index 00000000..617bb16c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/quintessence.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/radiative equilibrium.webp b/WebGames-master/WebGames-master/n-gon-master/img/radiative equilibrium.webp
new file mode 100644
index 00000000..6fd3b3d2
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/radiative equilibrium.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/radioactive contamination.webp b/WebGames-master/WebGames-master/n-gon-master/img/radioactive contamination.webp
new file mode 100644
index 00000000..347dab41
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/radioactive contamination.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/railgun.webp b/WebGames-master/WebGames-master/n-gon-master/img/railgun.webp
new file mode 100644
index 00000000..d80883f6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/railgun.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/reaction inhibitor.webp b/WebGames-master/WebGames-master/n-gon-master/img/reaction inhibitor.webp
new file mode 100644
index 00000000..de5a4404
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/reaction inhibitor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/rebound.webp b/WebGames-master/WebGames-master/n-gon-master/img/rebound.webp
new file mode 100644
index 00000000..01e098c3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/rebound.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/recycling.webp b/WebGames-master/WebGames-master/n-gon-master/img/recycling.webp
new file mode 100644
index 00000000..775edc5d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/recycling.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/reduced tolerances.webp b/WebGames-master/WebGames-master/n-gon-master/img/reduced tolerances.webp
new file mode 100644
index 00000000..35b4ee8d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/reduced tolerances.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/reel.webp b/WebGames-master/WebGames-master/n-gon-master/img/reel.webp
new file mode 100644
index 00000000..af2baa09
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/reel.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/refraction.webp b/WebGames-master/WebGames-master/n-gon-master/img/refraction.webp
new file mode 100644
index 00000000..4901c68c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/refraction.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/refractory metal.webp b/WebGames-master/WebGames-master/n-gon-master/img/refractory metal.webp
new file mode 100644
index 00000000..c44f3e24
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/refractory metal.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/refrigerant.webp b/WebGames-master/WebGames-master/n-gon-master/img/refrigerant.webp
new file mode 100644
index 00000000..d8f27c32
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/refrigerant.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/regression.webp b/WebGames-master/WebGames-master/n-gon-master/img/regression.webp
new file mode 100644
index 00000000..da119ef6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/regression.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/reinforcement learning.webp b/WebGames-master/WebGames-master/n-gon-master/img/reinforcement learning.webp
new file mode 100644
index 00000000..77118538
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/reinforcement learning.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/relativistic momentum.webp b/WebGames-master/WebGames-master/n-gon-master/img/relativistic momentum.webp
new file mode 100644
index 00000000..55422658
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/relativistic momentum.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/relay switch.webp b/WebGames-master/WebGames-master/n-gon-master/img/relay switch.webp
new file mode 100644
index 00000000..d6707f91
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/relay switch.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/renormalization.webp b/WebGames-master/WebGames-master/n-gon-master/img/renormalization.webp
new file mode 100644
index 00000000..6b0391bf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/renormalization.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/repeater.webp b/WebGames-master/WebGames-master/n-gon-master/img/repeater.webp
new file mode 100644
index 00000000..1be7058f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/repeater.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/replication.webp b/WebGames-master/WebGames-master/n-gon-master/img/replication.webp
new file mode 100644
index 00000000..8dfb21cf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/replication.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/repolarization.webp b/WebGames-master/WebGames-master/n-gon-master/img/repolarization.webp
new file mode 100644
index 00000000..29326078
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/repolarization.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/research.webp b/WebGames-master/WebGames-master/n-gon-master/img/research.webp
new file mode 100644
index 00000000..99ac3962
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/research.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/residual dipolar coupling.webp b/WebGames-master/WebGames-master/n-gon-master/img/residual dipolar coupling.webp
new file mode 100644
index 00000000..5fcb9722
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/residual dipolar coupling.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/restitution.webp b/WebGames-master/WebGames-master/n-gon-master/img/restitution.webp
new file mode 100644
index 00000000..3ec9f61d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/restitution.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/retrocausality.webp b/WebGames-master/WebGames-master/n-gon-master/img/retrocausality.webp
new file mode 100644
index 00000000..17997c76
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/retrocausality.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ricochet.webp b/WebGames-master/WebGames-master/n-gon-master/img/ricochet.webp
new file mode 100644
index 00000000..5863d225
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ricochet.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/rivet gun.webp b/WebGames-master/WebGames-master/n-gon-master/img/rivet gun.webp
new file mode 100644
index 00000000..a94f4f68
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/rivet gun.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/robotics.webp b/WebGames-master/WebGames-master/n-gon-master/img/robotics.webp
new file mode 100644
index 00000000..feba476d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/robotics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/rocket-propelled grenade.webp b/WebGames-master/WebGames-master/n-gon-master/img/rocket-propelled grenade.webp
new file mode 100644
index 00000000..efe978b0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/rocket-propelled grenade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/rotary cannon.webp b/WebGames-master/WebGames-master/n-gon-master/img/rotary cannon.webp
new file mode 100644
index 00000000..69df5fca
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/rotary cannon.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/scrap bots.webp b/WebGames-master/WebGames-master/n-gon-master/img/scrap bots.webp
new file mode 100644
index 00000000..9482b30f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/scrap bots.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/scrap refit.webp b/WebGames-master/WebGames-master/n-gon-master/img/scrap refit.webp
new file mode 100644
index 00000000..243fcc7a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/scrap refit.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/self-assembly.webp b/WebGames-master/WebGames-master/n-gon-master/img/self-assembly.webp
new file mode 100644
index 00000000..3cb0fe2d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/self-assembly.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/sentry.webp b/WebGames-master/WebGames-master/n-gon-master/img/sentry.webp
new file mode 100644
index 00000000..a9cfb29c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/sentry.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/shape-memory alloy.webp b/WebGames-master/WebGames-master/n-gon-master/img/shape-memory alloy.webp
new file mode 100644
index 00000000..fc76420e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/shape-memory alloy.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/shaped charge.webp b/WebGames-master/WebGames-master/n-gon-master/img/shaped charge.webp
new file mode 100644
index 00000000..70b7a7c8
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/shaped charge.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/shear stress.webp b/WebGames-master/WebGames-master/n-gon-master/img/shear stress.webp
new file mode 100644
index 00000000..211b5a94
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/shear stress.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/shock wave.webp b/WebGames-master/WebGames-master/n-gon-master/img/shock wave.webp
new file mode 100644
index 00000000..ff4d9459
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/shock wave.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/simulated annealing.webp b/WebGames-master/WebGames-master/n-gon-master/img/simulated annealing.webp
new file mode 100644
index 00000000..bfc1ef43
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/simulated annealing.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/siphonaptera.webp b/WebGames-master/WebGames-master/n-gon-master/img/siphonaptera.webp
new file mode 100644
index 00000000..1b55f51c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/siphonaptera.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/smelting.webp b/WebGames-master/WebGames-master/n-gon-master/img/smelting.webp
new file mode 100644
index 00000000..783d4df7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/smelting.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/sound-bot upgrade.webp b/WebGames-master/WebGames-master/n-gon-master/img/sound-bot upgrade.webp
new file mode 100644
index 00000000..119cbfa1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/sound-bot upgrade.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/sound-bot.webp b/WebGames-master/WebGames-master/n-gon-master/img/sound-bot.webp
new file mode 100644
index 00000000..85b39b8a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/sound-bot.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/specular reflection.webp b/WebGames-master/WebGames-master/n-gon-master/img/specular reflection.webp
new file mode 100644
index 00000000..3218665e
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/specular reflection.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/spherical harmonics.webp b/WebGames-master/WebGames-master/n-gon-master/img/spherical harmonics.webp
new file mode 100644
index 00000000..1aedfd1d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/spherical harmonics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/spin-statistics theorem.webp b/WebGames-master/WebGames-master/n-gon-master/img/spin-statistics theorem.webp
new file mode 100644
index 00000000..297a2db1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/spin-statistics theorem.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/spin-statistics.webp b/WebGames-master/WebGames-master/n-gon-master/img/spin-statistics.webp
new file mode 100644
index 00000000..2f2b4700
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/spin-statistics.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/stability.webp b/WebGames-master/WebGames-master/n-gon-master/img/stability.webp
new file mode 100644
index 00000000..f9a7dab2
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/stability.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/stellarator.webp b/WebGames-master/WebGames-master/n-gon-master/img/stellarator.webp
new file mode 100644
index 00000000..49fe2efa
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/stellarator.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/stimulated emission.webp b/WebGames-master/WebGames-master/n-gon-master/img/stimulated emission.webp
new file mode 100644
index 00000000..ce9a1ccf
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/stimulated emission.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/strange attractor.webp b/WebGames-master/WebGames-master/n-gon-master/img/strange attractor.webp
new file mode 100644
index 00000000..983778f7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/strange attractor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/strange loop.webp b/WebGames-master/WebGames-master/n-gon-master/img/strange loop.webp
new file mode 100644
index 00000000..ed374c33
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/strange loop.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/stress concentration.webp b/WebGames-master/WebGames-master/n-gon-master/img/stress concentration.webp
new file mode 100644
index 00000000..92b1806c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/stress concentration.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/strong anthropic principle.webp b/WebGames-master/WebGames-master/n-gon-master/img/strong anthropic principle.webp
new file mode 100644
index 00000000..ffbfd315
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/strong anthropic principle.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/super ball.webp b/WebGames-master/WebGames-master/n-gon-master/img/super ball.webp
new file mode 100644
index 00000000..9c7f945a
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/super ball.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/super duper.webp b/WebGames-master/WebGames-master/n-gon-master/img/super duper.webp
new file mode 100644
index 00000000..d5e1f2a6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/super duper.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/supercritical fission.webp b/WebGames-master/WebGames-master/n-gon-master/img/supercritical fission.webp
new file mode 100644
index 00000000..4e9c3c07
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/supercritical fission.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/superdeterminism.webp b/WebGames-master/WebGames-master/n-gon-master/img/superdeterminism.webp
new file mode 100644
index 00000000..d07b9b01
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/superdeterminism.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/superfluidity.webp b/WebGames-master/WebGames-master/n-gon-master/img/superfluidity.webp
new file mode 100644
index 00000000..7f0bc3dd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/superfluidity.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/supply chain.webp b/WebGames-master/WebGames-master/n-gon-master/img/supply chain.webp
new file mode 100644
index 00000000..29814efc
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/supply chain.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/surface plasmons.webp b/WebGames-master/WebGames-master/n-gon-master/img/surface plasmons.webp
new file mode 100644
index 00000000..a78ba3a8
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/surface plasmons.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/surface tension.webp b/WebGames-master/WebGames-master/n-gon-master/img/surface tension.webp
new file mode 100644
index 00000000..469fe59f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/surface tension.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/surfactant.webp b/WebGames-master/WebGames-master/n-gon-master/img/surfactant.webp
new file mode 100644
index 00000000..291fd6c1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/surfactant.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/swarf.webp b/WebGames-master/WebGames-master/n-gon-master/img/swarf.webp
new file mode 100644
index 00000000..8c77f01b
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/swarf.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/symbiosis.webp b/WebGames-master/WebGames-master/n-gon-master/img/symbiosis.webp
new file mode 100644
index 00000000..61c253e7
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/symbiosis.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/sympathetic resonance.webp b/WebGames-master/WebGames-master/n-gon-master/img/sympathetic resonance.webp
new file mode 100644
index 00000000..5f0a77dd
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/sympathetic resonance.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/technical debt.webp b/WebGames-master/WebGames-master/n-gon-master/img/technical debt.webp
new file mode 100644
index 00000000..7f5facb0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/technical debt.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/ternary.webp b/WebGames-master/WebGames-master/n-gon-master/img/ternary.webp
new file mode 100644
index 00000000..e39b90c5
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/ternary.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/tessellation.webp b/WebGames-master/WebGames-master/n-gon-master/img/tessellation.webp
new file mode 100644
index 00000000..4992624f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/tessellation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/thermal runaway.webp b/WebGames-master/WebGames-master/n-gon-master/img/thermal runaway.webp
new file mode 100644
index 00000000..a7c59932
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/thermal runaway.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/thermocouple.webp b/WebGames-master/WebGames-master/n-gon-master/img/thermocouple.webp
new file mode 100644
index 00000000..d669ea57
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/thermocouple.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/thermoelectric effect.webp b/WebGames-master/WebGames-master/n-gon-master/img/thermoelectric effect.webp
new file mode 100644
index 00000000..bc91ec21
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/thermoelectric effect.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/time crystals.webp b/WebGames-master/WebGames-master/n-gon-master/img/time crystals.webp
new file mode 100644
index 00000000..5b06557f
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/time crystals.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/tokamak.webp b/WebGames-master/WebGames-master/n-gon-master/img/tokamak.webp
new file mode 100644
index 00000000..4a37b667
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/tokamak.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/topological defect.webp b/WebGames-master/WebGames-master/n-gon-master/img/topological defect.webp
new file mode 100644
index 00000000..a4be7c93
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/topological defect.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/torpor.webp b/WebGames-master/WebGames-master/n-gon-master/img/torpor.webp
new file mode 100644
index 00000000..cc1165fc
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/torpor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/transdimensional worms.webp b/WebGames-master/WebGames-master/n-gon-master/img/transdimensional worms.webp
new file mode 100644
index 00000000..e01c7807
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/transdimensional worms.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/transistor.webp b/WebGames-master/WebGames-master/n-gon-master/img/transistor.webp
new file mode 100644
index 00000000..f62e0c34
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/transistor.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/triple point.webp b/WebGames-master/WebGames-master/n-gon-master/img/triple point.webp
new file mode 100644
index 00000000..260cba62
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/triple point.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/tungsten carbide.webp b/WebGames-master/WebGames-master/n-gon-master/img/tungsten carbide.webp
new file mode 100644
index 00000000..3fc90ed4
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/tungsten carbide.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/uncertainty principle.webp b/WebGames-master/WebGames-master/n-gon-master/img/uncertainty principle.webp
new file mode 100644
index 00000000..892fcde0
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/uncertainty principle.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/unified field theory.webp b/WebGames-master/WebGames-master/n-gon-master/img/unified field theory.webp
new file mode 100644
index 00000000..43230ce3
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/unified field theory.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/vacuum bomb.webp b/WebGames-master/WebGames-master/n-gon-master/img/vacuum bomb.webp
new file mode 100644
index 00000000..88011ca1
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/vacuum bomb.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/vacuum fluctuation.webp b/WebGames-master/WebGames-master/n-gon-master/img/vacuum fluctuation.webp
new file mode 100644
index 00000000..c7126526
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/vacuum fluctuation.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/vacuum permittivity.webp b/WebGames-master/WebGames-master/n-gon-master/img/vacuum permittivity.webp
new file mode 100644
index 00000000..f81f9009
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/vacuum permittivity.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/virtual particles.webp b/WebGames-master/WebGames-master/n-gon-master/img/virtual particles.webp
new file mode 100644
index 00000000..a02e99c6
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/virtual particles.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/von Neumann probe.webp b/WebGames-master/WebGames-master/n-gon-master/img/von Neumann probe.webp
new file mode 100644
index 00000000..7addbb36
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/von Neumann probe.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/waste heat recovery.webp b/WebGames-master/WebGames-master/n-gon-master/img/waste heat recovery.webp
new file mode 100644
index 00000000..e291aba9
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/waste heat recovery.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/water shielding.webp b/WebGames-master/WebGames-master/n-gon-master/img/water shielding.webp
new file mode 100644
index 00000000..3dc396eb
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/water shielding.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/weak anthropic principle.webp b/WebGames-master/WebGames-master/n-gon-master/img/weak anthropic principle.webp
new file mode 100644
index 00000000..c0ed499c
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/weak anthropic principle.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/working mass.webp b/WebGames-master/WebGames-master/n-gon-master/img/working mass.webp
new file mode 100644
index 00000000..d98237bc
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/working mass.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/zero point energy.webp b/WebGames-master/WebGames-master/n-gon-master/img/zero point energy.webp
new file mode 100644
index 00000000..21c7d162
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/zero point energy.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/zoospore vector.webp b/WebGames-master/WebGames-master/n-gon-master/img/zoospore vector.webp
new file mode 100644
index 00000000..305d241d
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/zoospore vector.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/img/Ψ(t) collapse.webp b/WebGames-master/WebGames-master/n-gon-master/img/Ψ(t) collapse.webp
new file mode 100644
index 00000000..b703bebc
Binary files /dev/null and b/WebGames-master/WebGames-master/n-gon-master/img/Ψ(t) collapse.webp differ
diff --git a/WebGames-master/WebGames-master/n-gon-master/index.html b/WebGames-master/WebGames-master/n-gon-master/index.html
new file mode 100644
index 00000000..099c0762
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/index.html
@@ -0,0 +1,316 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ n-gon
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ settings
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ controls
+
+ To change controls click a box
+ and press an unused key.
+
+ I wrote n-gon in JavaScript, CSS, and HTML using the matter.js 2-D physics library.
+ The code is free and open source on Github.
+ This is just my hobby project, but I try to fix bugs when reported.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/n-gon-master/js/bullet.js b/WebGames-master/WebGames-master/n-gon-master/js/bullet.js
new file mode 100644
index 00000000..dcca903b
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/js/bullet.js
@@ -0,0 +1,7535 @@
+let bullet = [];
+
+const b = {
+ // dmgScale: null, //scales all damage, but not raw .dmg
+ gravity: 0.0006, //most other bodies have gravity = 0.001
+ activeGun: null, //current gun in use by player
+ inventoryGun: 0,
+ inventory: [], //list of what guns player has // 0 starts with basic gun
+ setFireMethod() {
+ if (tech.isFireMoveLock) {
+ b.fire = b.fireFloat
+ // } else if (tech.isFireNotMove) {
+ // if (tech.isAlwaysFire) {
+ // b.fire = b.fireAlwaysFire
+ // } else {
+ // b.fire = b.fireNotMove
+ // }
+ } else if (tech.isAlwaysFire) {
+ b.fire = b.fireAlwaysFire
+ } else {
+ b.fire = b.fireNormal
+ }
+ },
+ fire() { },
+ fireNormal() {
+ if (b.inventory.length && (b.activeGun !== null && b.activeGun !== undefined)) {
+ if (input.fire && m.fireCDcycle < m.cycle && (!input.field || m.fieldFire)) {
+ if (b.guns[b.activeGun].ammo > 0) {
+ b.fireWithAmmo()
+ } else {
+ b.outOfAmmo()
+ }
+ if (m.holdingTarget) m.drop();
+ }
+ b.guns[b.activeGun].do();
+ }
+ },
+ fireNotMove() { //added && player.speed < 0.5 && m.onGround
+ if (b.inventory.length && (b.activeGun !== null && b.activeGun !== undefined)) {
+ if (input.fire && m.fireCDcycle < m.cycle && (!input.field || m.fieldFire) && player.speed < 2.5 && m.onGround && Math.abs(m.yOff - m.yOffGoal) < 1) {
+ if (b.guns[b.activeGun].ammo > 0) {
+ b.fireWithAmmo()
+ } else {
+ b.outOfAmmo()
+ }
+ if (m.holdingTarget) m.drop();
+ }
+ b.guns[b.activeGun].do();
+ }
+ },
+ fireAlwaysFire() { //added && player.speed < 0.5 && m.onGround //removed input.fire && (!input.field || m.fieldFire)
+ if (b.inventory.length && (b.activeGun !== null && b.activeGun !== undefined)) {
+ if (m.fireCDcycle < m.cycle && player.speed < 0.5 && m.onGround && Math.abs(m.yOff - m.yOffGoal) < 1) {
+ if (b.guns[b.activeGun].ammo > 0) {
+ b.fireWithAmmo()
+ }
+ if (m.holdingTarget) m.drop();
+ }
+ b.guns[b.activeGun].do();
+ }
+ },
+ fireFloat() { //added && player.speed < 0.5 && m.onGround
+ if (b.inventory.length && (b.activeGun !== null && b.activeGun !== undefined)) {
+ if (input.fire && (!input.field || m.fieldFire)) {
+ if (m.fireCDcycle < m.cycle) {
+ if (b.guns[b.activeGun].ammo > 0) {
+ b.fireWithAmmo()
+ } else {
+ b.outOfAmmo()
+ }
+ if (m.holdingTarget) m.drop();
+ }
+ Matter.Body.setVelocity(player, {
+ x: 0,
+ y: -55 * player.mass * simulation.g //undo gravity before it is added
+ });
+ player.force.x = 0
+ player.force.y = 0
+ }
+ b.guns[b.activeGun].do();
+ }
+ },
+ fireWithAmmo() { //triggers after firing when you have ammo
+ b.guns[b.activeGun].fire();
+ if (tech.crouchAmmoCount && m.crouch) {
+ if (tech.crouchAmmoCount % 2) {
+ b.guns[b.activeGun].ammo--;
+ if (level.is2xAmmo && b.guns[b.activeGun].ammo > 0) b.guns[b.activeGun].ammo--;
+ simulation.updateGunHUD();
+ }
+ tech.crouchAmmoCount++ //makes the no ammo toggle off and on
+ } else {
+ b.guns[b.activeGun].ammo--;
+ if (level.is2xAmmo && b.guns[b.activeGun].ammo > 0) b.guns[b.activeGun].ammo--;
+ simulation.updateGunHUD();
+ }
+ },
+ outOfAmmo() { //triggers after firing when you have NO ammo
+ simulation.inGameConsole(`${b.guns[b.activeGun].name}.ammo: 0`);
+ m.fireCDcycle = m.cycle + 30; //fire cooldown
+ if (tech.isAmmoFromHealth) {
+ const amount = 0.02
+ if (tech.isEnergyHealth) {
+ if (m.maxEnergy > amount * 2) {
+ tech.healMaxEnergyBonus -= amount * 2
+ m.setMaxEnergy();
+ for (let i = 0; i < 4; i++) powerUps.spawn(m.pos.x + 50 * (Math.random() - 0.5), m.pos.y + 50 * (Math.random() - 0.5), "ammo");
+ }
+ } else {
+ if (m.health > amount) {
+ tech.extraMaxHealth -= amount //decrease max health
+ m.setMaxHealth();
+ for (let i = 0; i < 4; i++) powerUps.spawn(m.pos.x + 50 * (Math.random() - 0.5), m.pos.y + 50 * (Math.random() - 0.5), "ammo");
+ }
+ }
+ }
+ },
+ refundAmmo() { //triggers after firing when you removed ammo for a gun, but didn't need to
+ if (tech.crouchAmmoCount && m.crouch && (b.activeGun !== null && b.activeGun !== undefined)) {
+ tech.crouchAmmoCount--
+ if ((tech.crouchAmmoCount) % 2) {
+ b.guns[b.activeGun].ammo++;
+ simulation.updateGunHUD();
+ }
+ } else {
+ b.guns[b.activeGun].ammo++;
+ simulation.updateGunHUD();
+ }
+ },
+ // returnGunAmmo(name) {
+ // for (i = 0, len = b.guns.length; i < len; i++) { //find which gun
+ // if (b.guns[i].name === name) return b.guns[i].ammo
+ // }
+ // },
+ giveGuns(gun = "random", ammoPacks = 22) {
+ if (tech.ammoCap) ammoPacks = tech.ammoCap
+ if (tech.isOneGun) b.resetAllGuns();
+ if (gun === "random") {
+ //find what guns player doesn't have
+ options = []
+ for (let i = 0, len = b.guns.length; i < len; i++) {
+ if (!b.guns[i].have) options.push(i)
+ }
+ if (options.length === 0) return
+ //randomly pick from list of possible guns
+ gun = options[Math.floor(Math.random() * options.length)]
+ }
+ if (gun === "all") {
+ for (let i = 0; i < b.guns.length; i++) {
+ b.inventory[i] = i;
+ b.guns[i].have = true;
+ if (b.guns[i].ammo !== Infinity) b.guns[i].ammo = Math.ceil(b.guns[i].ammoPack * ammoPacks);
+ }
+ b.inventoryGun = 0;
+ b.activeGun = b.inventory[0];
+ } else {
+ if (isNaN(gun)) { //find gun by name
+ let found = false;
+ for (let i = 0; i < b.guns.length; i++) {
+ if (gun === b.guns[i].name) {
+ gun = i
+ found = true;
+ break
+ }
+ }
+ if (!found) return //if no gun found don't give a gun
+ }
+ if (!b.guns[gun].have) b.inventory.push(gun);
+ b.guns[gun].have = true;
+ if (b.guns[gun].ammo !== Infinity) b.guns[gun].ammo = Math.ceil(b.guns[gun].ammoPack * ammoPacks);
+ if (b.activeGun === null) {
+ b.inventoryGun = 0;
+ b.activeGun = b.inventory[0] //if no active gun switch to new gun
+ if (b.guns[b.activeGun].charge) b.guns[b.activeGun].charge = 0; //set foam charge to zero if foam is a new gun
+ }
+ }
+ simulation.makeGunHUD();
+ simulation.switchGun();
+ b.setFireCD();
+ if (tech.isOneGun && b.inventory > 0) {
+ //count how many gun tech you have and remove them
+ let gunTechCount = 0 //2 bonus gun tech
+ for (let i = 0, len = tech.tech.length; i < len; i++) {
+ if (tech.tech[i].isGunTech && tech.tech[i].count > 0 && !tech.tech[i].isInstant && !tech.tech[i].isRemoveGun) {
+ const remove = tech.removeTech(i)
+ gunTechCount += remove
+ }
+ }
+
+ //get a random gun tech for your gun
+ for (let i = 0; i < gunTechCount; i++) {
+ const gunTechPool = []
+ for (let j = 0, len = tech.tech.length; j < len; j++) {
+ if (tech.tech[j].isGunTech && tech.tech[j].allowed() && !tech.tech[i].isRemoveGun && !tech.tech[j].isJunk && !tech.tech[j].isBadRandomOption && tech.tech[j].count < tech.tech[j].maxCount) {
+ const regex = tech.tech[j].requires.search(b.guns[b.activeGun].name) //get string index of gun name
+ const not = tech.tech[j].requires.search(' not ') //get string index of ' not '
+ //look for the gun name in the requirements, but the gun name needs to show up before the word ' not '
+ if (regex !== -1 && (not === -1 || not > regex)) gunTechPool.push(j)
+ }
+ }
+ if (gunTechPool.length) {
+ const index = Math.floor(Math.random() * gunTechPool.length)
+ simulation.inGameConsole(`tech.giveTech("${tech.tech[gunTechPool[index]].name}")`)
+ tech.giveTech(gunTechPool[index]) // choose from the gun pool
+ } else {
+ tech.giveTech() //get normal tech if you can't find any gun tech
+ }
+ }
+
+ }
+ },
+ removeGun(gunName) {
+ for (let i = 0; i < b.guns.length; i++) {
+ if (b.guns[i].name === gunName && b.guns[i].have) {
+ b.guns[i].have = false
+ for (let j = 0; j < b.inventory.length; j++) {
+ if (b.inventory[j] === i) {
+ b.inventory.splice(j, 1)
+ break
+ }
+ }
+ if (b.inventory.length > 0) {
+ b.activeGun = b.inventory[0];
+ } else {
+ b.activeGun = null;
+ }
+ b.inventoryGun = 0;
+ simulation.makeGunHUD();
+ break
+ }
+ }
+ b.setFireCD();
+ },
+ resetAllGuns() {
+ b.inventory = []; //removes guns and ammo
+ for (let i = 0, len = b.guns.length; i < len; ++i) {
+ b.guns[i].count = 0;
+ b.guns[i].have = false;
+ b.guns[i].ammoPack = b.guns[i].defaultAmmoPack;
+ if (b.guns[i].ammo != Infinity) b.guns[i].ammo = 0;
+ }
+ tech.buffedGun = 0
+ b.activeGun = null;
+ b.inventoryGun = 0;
+ simulation.drawCursor = simulation.drawCursorBasic //set cross hairs
+ },
+ bulletRemove() { //run in main loop
+ //remove bullet if at end cycle for that bullet
+ let i = bullet.length;
+ while (i--) {
+ if (bullet[i].endCycle < simulation.cycle) {
+ bullet[i].onEnd(i); //some bullets do stuff on end
+ if (bullet[i]) {
+ Matter.Composite.remove(engine.world, bullet[i]);
+ bullet.splice(i, 1);
+ } else {
+ break; //if bullet[i] doesn't exist don't complete the for loop, because the game probably reset
+ }
+ }
+ }
+ },
+ bulletDraw() {
+ ctx.beginPath();
+ for (let i = 0, len = bullet.length; i < len; i++) {
+ let vertices = bullet[i].vertices;
+ ctx.moveTo(vertices[0].x, vertices[0].y);
+ for (let j = 1; j < vertices.length; j += 1) {
+ ctx.lineTo(vertices[j].x, vertices[j].y);
+ }
+ ctx.lineTo(vertices[0].x, vertices[0].y);
+ }
+ ctx.fillStyle = color.bullet;
+ ctx.fill();
+ },
+ bulletDo() {
+ for (let i = 0, len = bullet.length; i < len; i++) {
+ bullet[i].do();
+ }
+ },
+ fireProps(cd, speed, dir, me) {
+ m.fireCDcycle = m.cycle + Math.floor(cd * b.fireCDscale); // cool down
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.5 * player.velocity.x + speed * Math.cos(dir),
+ y: 0.5 * player.velocity.y + speed * Math.sin(dir)
+ });
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ fireCDscale: 1,
+ setFireCD() {
+ b.fireCDscale = tech.fireRate * tech.slowFire * tech.researchHaste * tech.aimDamage
+ if (m.fieldMode === 6) b.fireCDscale *= 0.8
+ if (tech.isFastTime) b.fireCDscale *= 0.666
+ if (tech.isFireRateForGuns) b.fireCDscale *= Math.pow(0.76923, Math.max(0, b.inventory.length - 1))
+ if (tech.isFireMoveLock) b.fireCDscale *= 0.25
+ },
+ fireAttributes(dir, rotate = true) {
+ if (rotate) {
+ return {
+ // density: 0.0015, //frictionAir: 0.01, //restitution: 0,
+ angle: dir,
+ friction: 0.5,
+ frictionAir: 0,
+ dmg: 0, //damage done in addition to the damage from momentum
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ minDmgSpeed: 10,
+ beforeDmg() { }, //this.endCycle = 0 //triggers despawn
+ onEnd() { }
+ };
+ } else {
+ return {
+ // density: 0.0015, //frictionAir: 0.01, //restitution: 0,
+ inertia: Infinity, //prevents rotation
+ angle: dir,
+ friction: 0.5,
+ frictionAir: 0,
+ dmg: 0, //damage done in addition to the damage from momentum
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ minDmgSpeed: 10,
+ beforeDmg() { }, //this.endCycle = 0 //triggers despawn
+ onEnd() { }
+ };
+ }
+ },
+ muzzleFlash(radius = 30) {
+ // ctx.fillStyle = "#fb0";
+ // ctx.beginPath();
+ // ctx.arc(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), radius, 0, 2 * Math.PI);
+ // ctx.fill();
+
+ simulation.drawList.push({ //add dmg to draw queue
+ x: m.pos.x + 20 * Math.cos(m.angle),
+ y: m.pos.y + 20 * Math.sin(m.angle),
+ radius: radius,
+ color: "#fb0",
+ time: 1
+ });
+ },
+ removeConsBB(me) {
+ for (let i = 0, len = consBB.length; i < len; ++i) {
+ if (consBB[i].bodyA === me) {
+ consBB[i].bodyA = consBB[i].bodyB;
+ consBB.splice(i, 1);
+ break;
+ } else if (consBB[i].bodyB === me) {
+ consBB[i].bodyB = consBB[i].bodyA;
+ consBB.splice(i, 1);
+ break;
+ }
+ }
+ },
+ onCollision(event) {
+ const pairs = event.pairs;
+ for (let i = 0, j = pairs.length; i != j; i++) {
+ //map + bullet collisions
+ if (pairs[i].bodyA.collisionFilter.category === cat.map && pairs[i].bodyB.collisionFilter.category === cat.bullet) {
+ collideBulletStatic(pairs[i].bodyB)
+ } else if (pairs[i].bodyB.collisionFilter.category === cat.map && pairs[i].bodyA.collisionFilter.category === cat.bullet) {
+ collideBulletStatic(pairs[i].bodyA)
+ }
+
+ function collideBulletStatic(obj) {
+ if (obj.onWallHit) obj.onWallHit();
+ }
+ }
+ },
+ explosionRange() {
+ return tech.explosiveRadius * (tech.isExplosionHarm ? 1.7 : 1) * (tech.isSmallExplosion ? 0.7 : 1) * (tech.isExplodeRadio ? 1.25 : 1)
+ },
+ explosion(where, radius, color = "rgba(255,25,0,0.6)", reducedKnock = 1) { // typically explode is used for some bullets with .onEnd
+ radius *= tech.explosiveRadius
+
+ let knock;
+ let dmg = radius * 0.019
+ if (tech.isExplosionHarm) radius *= 1.7 // 1/sqrt(2) radius -> area
+ if (tech.isSmallExplosion) {
+ // color = "rgba(255,0,30,0.7)"
+ radius *= 0.7
+ dmg *= 1.7
+ }
+ let sub = Vector.sub(where, player.position);
+ let dist = Vector.magnitude(sub);
+ if (tech.isSmartRadius && radius > dist - 50) radius = Math.max(dist - 50, 1)
+
+ if (tech.isExplodeRadio) { //radiation explosion
+ radius *= 1.25; //alert range
+ // if (tech.isSmartRadius) radius = Math.max(Math.min(radius, Vector.magnitude(Vector.sub(where, player.position)) - 25), 1)
+ color = "rgba(25,139,170,0.25)"
+ simulation.drawList.push({ //add dmg to draw queue
+ x: where.x,
+ y: where.y,
+ radius: radius,
+ color: color,
+ time: simulation.drawTime * 2
+ });
+
+ //player damage
+ if (Vector.magnitude(Vector.sub(where, player.position)) < radius) {
+ const DRAIN = (tech.isExplosionHarm ? 0.6 : 0.45) * (tech.isRadioactiveResistance ? 0.2 : 1)
+ if (m.immuneCycle < m.cycle) m.energy -= DRAIN
+ if (m.energy < 0) {
+ m.energy = 0
+ if (simulation.dmgScale) m.damage(tech.radioactiveDamage * 0.03 * (tech.isRadioactiveResistance ? 0.2 : 1));
+ }
+ }
+
+ //mob damage and knock back with alert
+ let damageScale = 1.5; // reduce dmg for each new target to limit total AOE damage
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (mob[i].alive && !mob[i].isShielded) {
+ sub = Vector.sub(where, mob[i].position);
+ dist = Vector.magnitude(sub) - mob[i].radius;
+ if (dist < radius) {
+ if (mob[i].shield) dmg *= 2.5 //balancing explosion dmg to shields
+ if (Matter.Query.ray(map, mob[i].position, where).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way
+ mobs.statusDoT(mob[i], dmg * damageScale * 0.25, 240) //apply radiation damage status effect on direct hits
+ if (tech.isStun) mobs.statusStun(mob[i], 30)
+ mob[i].locatePlayer();
+ damageScale *= 0.87 //reduced damage for each additional explosion target
+ }
+ }
+ }
+ } else { //normal explosions
+ // if (tech.isSmartRadius) radius = Math.max(Math.min(radius, Vector.magnitude(Vector.sub(where, player.position)) - 25), 1)
+ simulation.drawList.push({ //add dmg to draw queue
+ x: where.x,
+ y: where.y,
+ radius: radius,
+ color: color,
+ time: simulation.drawTime
+ });
+ const alertRange = 100 + radius * 2; //alert range
+ simulation.drawList.push({ //add alert to draw queue
+ x: where.x,
+ y: where.y,
+ radius: alertRange,
+ color: "rgba(100,20,0,0.03)",
+ time: simulation.drawTime
+ });
+
+ //player damage and knock back
+ if (m.immuneCycle < m.cycle) {
+ if (dist < radius) {
+ if (simulation.dmgScale) {
+ const harm = tech.isExplosionHarm ? 0.067 : 0.05
+ if (tech.isImmuneExplosion && m.energy > 0.25) {
+ // const mitigate = Math.min(1, Math.max(1 - m.energy * 0.5, 0))
+ m.energy -= 0.25
+ // m.damage(0.01 * harm); //remove 99% of the damage 1-0.99
+ knock = Vector.mult(Vector.normalise(sub), -0.6 * player.mass * Math.max(0, Math.min(0.15 - 0.002 * player.speed, 0.15)));
+ player.force.x = knock.x; // not += so crazy forces can't build up with MIRV
+ player.force.y = knock.y - 0.3; //some extra vertical kick
+ } else {
+ if (simulation.dmgScale) m.damage(harm);
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass * 0.013);
+ player.force.x += knock.x;
+ player.force.y += knock.y;
+ }
+ }
+ } else if (dist < alertRange) {
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass * 0.005);
+ player.force.x += knock.x;
+ player.force.y += knock.y;
+ }
+ }
+
+ //body knock backs
+ for (let i = body.length - 1; i > -1; i--) {
+ if (!body[i].isNotHoldable) {
+ sub = Vector.sub(where, body[i].position);
+ dist = Vector.magnitude(sub);
+ if (dist < radius) {
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * body[i].mass * 0.022);
+ body[i].force.x += knock.x;
+ body[i].force.y += knock.y;
+ if (tech.isBlockExplode) {
+ if (body[i] === m.holdingTarget) m.drop()
+ const size = 20 + 300 * Math.pow(body[i].mass, 0.25)
+ const where = body[i].position
+ const onLevel = level.onLevel //prevent explosions in the next level
+ Matter.Composite.remove(engine.world, body[i]);
+ body.splice(i, 1);
+ setTimeout(() => {
+ if (onLevel === level.onLevel) b.explosion(where, size); //makes bullet do explosive damage at end
+ }, 250 + 300 * Math.random());
+ }
+ } else if (dist < alertRange) {
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * body[i].mass * 0.011);
+ body[i].force.x += knock.x;
+ body[i].force.y += knock.y;
+ }
+ }
+ }
+
+ //power up knock backs
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ sub = Vector.sub(where, powerUp[i].position);
+ dist = Vector.magnitude(sub);
+ if (dist < radius) {
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * powerUp[i].mass * 0.013);
+ powerUp[i].force.x += knock.x;
+ powerUp[i].force.y += knock.y;
+ } else if (dist < alertRange) {
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * powerUp[i].mass * 0.007);
+ powerUp[i].force.x += knock.x;
+ powerUp[i].force.y += knock.y;
+ }
+ }
+
+ //mob damage and knock back with alert
+ let damageScale = 1.5; // reduce dmg for each new target to limit total AOE damage
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (mob[i].alive && !mob[i].isShielded) {
+ sub = Vector.sub(where, mob[i].position);
+ dist = Vector.magnitude(sub) - mob[i].radius;
+ if (dist < radius) {
+ if (mob[i].shield) dmg *= 2.5 //balancing explosion dmg to shields
+ if (Matter.Query.ray(map, mob[i].position, where).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way
+ mob[i].damage(dmg * damageScale * m.dmgScale);
+ mob[i].locatePlayer();
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg * damageScale) * mob[i].mass * (mob[i].isBoss ? 0.003 : 0.01) * reducedKnock);
+ if (tech.isStun) {
+ mobs.statusStun(mob[i], 30)
+ } else if (!mob[i].isInvulnerable) {
+ mob[i].force.x += knock.x;
+ mob[i].force.y += knock.y;
+ }
+ radius *= 0.95 //reduced range for each additional explosion target
+ damageScale *= 0.87 //reduced damage for each additional explosion target
+ } else if (!mob[i].seePlayer.recall && dist < alertRange) {
+ mob[i].locatePlayer();
+ knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg * damageScale) * mob[i].mass * (mob[i].isBoss ? 0 : 0.006 * reducedKnock));
+ if (tech.isStun) {
+ mobs.statusStun(mob[i], 30)
+ } else if (!mob[i].isInvulnerable) {
+ mob[i].force.x += knock.x;
+ mob[i].force.y += knock.y;
+ }
+ }
+ }
+ }
+ }
+ },
+ pulse(charge, angle = m.angle, where = m.pos) {
+ let best;
+ let explosionRadius = 5.5 * charge
+ let range = 5000
+ const path = [{
+ x: where.x + 20 * Math.cos(angle),
+ y: where.y + 20 * Math.sin(angle)
+ },
+ {
+ x: where.x + range * Math.cos(angle),
+ y: where.y + range * Math.sin(angle)
+ }
+ ];
+ //check for collisions
+ best = {
+ x: null,
+ y: null,
+ dist2: Infinity,
+ who: null,
+ v1: null,
+ v2: null
+ };
+ if (!best.who) {
+ best = vertexCollision(path[0], path[1], [mob, map, body]);
+ if (best.dist2 != Infinity) { //if hitting something
+ path[path.length - 1] = {
+ x: best.x,
+ y: best.y
+ };
+ }
+ }
+ if (best.who) {
+ b.explosion(path[1], explosionRadius)
+ const off = explosionRadius * 1.2
+ b.explosion({
+ x: path[1].x + off * (Math.random() - 0.5),
+ y: path[1].y + off * (Math.random() - 0.5)
+ }, explosionRadius)
+ b.explosion({
+ x: path[1].x + off * (Math.random() - 0.5),
+ y: path[1].y + off * (Math.random() - 0.5)
+ }, explosionRadius)
+ }
+ //draw laser beam
+ ctx.beginPath();
+ ctx.moveTo(path[0].x, path[0].y);
+ ctx.lineTo(path[1].x, path[1].y);
+ if (charge > 50) {
+ ctx.strokeStyle = "rgba(255,0,0,0.10)"
+ ctx.lineWidth = 70
+ ctx.stroke();
+ }
+ ctx.strokeStyle = "rgba(255,0,0,0.25)"
+ ctx.lineWidth = 20
+ ctx.stroke();
+ ctx.strokeStyle = "#f00";
+ ctx.lineWidth = 4
+ ctx.stroke();
+
+ //draw little dots along the laser path
+ const sub = Vector.sub(path[1], path[0])
+ const mag = Vector.magnitude(sub)
+ for (let i = 0, len = Math.floor(mag * 0.0005 * charge); i < len; i++) {
+ const dist = Math.random()
+ simulation.drawList.push({
+ x: path[0].x + sub.x * dist + 10 * (Math.random() - 0.5),
+ y: path[0].y + sub.y * dist + 10 * (Math.random() - 0.5),
+ radius: 1.5 + 5 * Math.random(),
+ color: "rgba(255,0,0,0.5)",
+ time: Math.floor(9 + 25 * Math.random() * Math.random())
+ });
+ }
+ },
+ clusterExplode(where, size) { //can occur after grenades detonate
+ const cycle = () => {
+ if (m.alive) {
+ if (simulation.paused || m.isTimeDilated) {
+ requestAnimationFrame(cycle)
+ } else {
+ count++
+ if (count < 84) requestAnimationFrame(cycle);
+ if (!(count % 7)) {
+ const unit = Vector.rotate({ x: 1, y: 0 }, 6.28 * Math.random())
+ b.explosion(Vector.add(where, Vector.mult(unit, size * (count * 0.01 + 0.03 * Math.random()))), size * (0.4 + Math.random() * 0.35), `hsla(${360 * Math.random()},100%,66%,0.6)`, 0.2); //makes bullet do explosive damage at end
+ }
+ }
+ }
+ }
+ let count = 7
+ requestAnimationFrame(cycle);
+ },
+ starburst(where, size) { //can occur after grenades detonate
+ const color = `hsla(${360 * Math.random()},100%,66%,0.6)`
+ const cycle = () => {
+ if (m.alive) {
+ if (simulation.paused || m.isTimeDilated) {
+ requestAnimationFrame(cycle)
+ } else {
+ count++
+ if (count < 21) requestAnimationFrame(cycle);
+ if (count % 2) {
+ const unit = Vector.rotate({
+ x: 1,
+ y: 0
+ }, curl * 6.28 * count / 18 + off)
+ b.explosion(Vector.add(where, Vector.mult(unit, size * 0.75)), size * 0.7, color, 0.5); //makes bullet do explosive damage at end
+ }
+ }
+ }
+ }
+ const off = 6 * Math.random()
+ const curl = Math.random() < 0.5 ? -1 : 1;
+ let count = 0
+ requestAnimationFrame(cycle);
+ },
+ fireFlower(where, size) { //can occur after grenades detonate
+ // size *= b.explosionRange()
+ const range = size * Math.sqrt(b.explosionRange())
+ const cycle = () => {
+ if (m.alive) {
+ if (simulation.paused || m.isTimeDilated) {
+ requestAnimationFrame(cycle)
+ } else {
+ if (count < 30 && m.alive) requestAnimationFrame(cycle);
+ if (count === 0) {
+ const color = `hsla(${360 * Math.random()},100%,66%,0.6)`
+ b.explosion(where, size * 0.8, color, 0.5);
+ }
+ if (count === 8) {
+ const color = `hsla(${360 * Math.random()},100%,66%,0.6)`
+ for (let i = 0, len = 6; i < len; i++) {
+ const unit = Vector.rotate({
+ x: 1,
+ y: 0
+ }, 6.28 * i / len)
+ b.explosion(Vector.add(where, Vector.mult(unit, 1.1 * range)), size * 0.6, color, 0.5); //makes bullet do explosive damage at end
+ }
+ }
+ if (count === 16) {
+ const color = `hsla(${360 * Math.random()},100%,66%,0.6)`
+ for (let i = 0, len = 10; i < len; i++) {
+ const unit = Vector.rotate({
+ x: 1,
+ y: 0
+ }, 6.28 * i / len)
+ b.explosion(Vector.add(where, Vector.mult(unit, 1.4 * range)), size * 0.45, color, 0.5); //makes bullet do explosive damage at end
+ }
+ }
+ count++
+ }
+ }
+ }
+ let count = 0
+ requestAnimationFrame(cycle);
+ },
+ grenadeEnd() {
+ if (tech.isCircleExplode) {
+ b.starburst(this.position, this.explodeRad)
+ } else if (tech.isPetalsExplode) {
+ b.fireFlower(this.position, this.explodeRad)
+ } else if (tech.isClusterExplode) {
+ b.clusterExplode(this.position, this.explodeRad)
+ } else {
+ b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
+ }
+ if (tech.fragments) b.targetedNail(this.position, tech.fragments * Math.floor(2 + 1.5 * Math.random()))
+ },
+ grenade() {
+
+ },
+ setGrenadeMode() {
+ grenadeDefault = function (where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, angle = m.angle, size = 1) {
+ const me = bullet.length;
+ bullet[me] = Bodies.circle(where.x, where.y, 15, b.fireAttributes(angle, false));
+ Matter.Body.setDensity(bullet[me], 0.0003);
+ bullet[me].explodeRad = 300 * size + 100 * tech.isBlockExplode;
+ bullet[me].onEnd = b.grenadeEnd
+ bullet[me].minDmgSpeed = 1;
+ bullet[me].beforeDmg = function () {
+ this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
+ };
+ speed = m.crouch ? 43 : 32
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.5 * player.velocity.x + speed * Math.cos(angle),
+ y: 0.5 * player.velocity.y + speed * Math.sin(angle)
+ });
+ bullet[me].endCycle = simulation.cycle + Math.floor(m.crouch ? 120 : 80) * tech.bulletsLastLonger;
+ bullet[me].restitution = 0.4;
+ bullet[me].do = function () {
+ this.force.y += this.mass * 0.0025; //extra gravity for harder arcs
+ };
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ }
+ grenadeRPG = function (where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, angle = m.angle, size = 1) {
+ const me = bullet.length;
+ bullet[me] = Bodies.circle(where.x, where.y, 15, b.fireAttributes(angle, false));
+ Matter.Body.setDensity(bullet[me], 0.0003);
+ bullet[me].explodeRad = 300 * size + 100 * tech.isBlockExplode;
+ bullet[me].onEnd = b.grenadeEnd
+ bullet[me].minDmgSpeed = 1;
+ bullet[me].beforeDmg = function () {
+ this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
+ };
+ speed = m.crouch ? 46 : 32
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.8 * player.velocity.x + speed * Math.cos(angle),
+ y: 0.5 * player.velocity.y + speed * Math.sin(angle)
+ });
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+
+ bullet[me].endCycle = simulation.cycle + 70 * tech.bulletsLastLonger;
+ bullet[me].frictionAir = 0.07;
+ const MAG = 0.015
+ bullet[me].thrust = {
+ x: bullet[me].mass * MAG * Math.cos(angle),
+ y: bullet[me].mass * MAG * Math.sin(angle)
+ }
+ bullet[me].do = function () {
+ this.force.x += this.thrust.x;
+ this.force.y += this.thrust.y;
+ if (Matter.Query.collides(this, map).length || Matter.Query.collides(this, body).length) {
+ this.endCycle = 0; //explode if touching map or blocks
+ }
+ };
+ }
+ grenadeRPGVacuum = function (where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, angle = m.angle, size = 1) {
+ const me = bullet.length;
+ bullet[me] = Bodies.circle(where.x, where.y, 15, b.fireAttributes(angle, false));
+ Matter.Body.setDensity(bullet[me], 0.0003);
+ bullet[me].explodeRad = 350 * size + Math.floor(Math.random() * 50) + tech.isBlockExplode * 100
+ bullet[me].onEnd = b.grenadeEnd
+ bullet[me].minDmgSpeed = 1;
+ bullet[me].beforeDmg = function () {
+ this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
+ };
+ speed = m.crouch ? 46 : 32
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.8 * player.velocity.x + speed * Math.cos(angle),
+ y: 0.5 * player.velocity.y + speed * Math.sin(angle)
+ });
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ bullet[me].endCycle = simulation.cycle + 70 * tech.bulletsLastLonger;
+ bullet[me].frictionAir = 0.07;
+ bullet[me].suckCycles = 40
+ const MAG = 0.015
+ bullet[me].thrust = {
+ x: bullet[me].mass * MAG * Math.cos(angle),
+ y: bullet[me].mass * MAG * Math.sin(angle)
+ }
+ bullet[me].suck = function () {
+ const suck = (who, radius = this.explodeRad * 3.2) => {
+ for (i = 0, len = who.length; i < len; i++) {
+ const sub = Vector.sub(this.position, who[i].position);
+ const dist = Vector.magnitude(sub);
+ if (dist < radius && dist > 150 && !who.isInvulnerable && who[i] !== this) {
+ knock = Vector.mult(Vector.normalise(sub), mag * who[i].mass / Math.sqrt(dist));
+ who[i].force.x += knock.x;
+ who[i].force.y += knock.y;
+ }
+ }
+ }
+ let mag = 0.1
+ if (simulation.cycle > this.endCycle - 5) {
+ mag = -0.22
+ suck(mob, this.explodeRad * 3)
+ suck(body, this.explodeRad * 2)
+ suck(powerUp, this.explodeRad * 1.5)
+ suck(bullet, this.explodeRad * 1.5)
+ suck([player], this.explodeRad * 1.3)
+ } else {
+ mag = 0.11
+ suck(mob, this.explodeRad * 3)
+ suck(body, this.explodeRad * 2)
+ suck(powerUp, this.explodeRad * 1.5)
+ suck(bullet, this.explodeRad * 1.5)
+ suck([player], this.explodeRad * 1.3)
+ }
+
+ Matter.Body.setVelocity(this, { x: 0, y: 0 }); //keep bomb in place
+ //draw suck
+ const radius = 2.75 * this.explodeRad * (this.endCycle - simulation.cycle) / this.suckCycles
+ ctx.fillStyle = "rgba(0,0,0,0.1)";
+ ctx.beginPath();
+ ctx.arc(this.position.x, this.position.y, radius, 0, 2 * Math.PI);
+ ctx.fill();
+ }
+ bullet[me].do = function () {
+ if (simulation.cycle > this.endCycle - this.suckCycles) { //suck
+ this.do = this.suck
+ } else if (Matter.Query.collides(this, map).length || Matter.Query.collides(this, body).length) {
+ Matter.Body.setPosition(this, Vector.sub(this.position, this.velocity)) //undo last movement
+ this.do = this.suck
+ } else {
+ this.force.x += this.thrust.x;
+ this.force.y += this.thrust.y;
+ }
+ };
+ }
+ grenadeVacuum = function (where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, angle = m.angle, size = 1) {
+ const me = bullet.length;
+ bullet[me] = Bodies.circle(where.x, where.y, 20, b.fireAttributes(angle, false));
+ Matter.Body.setDensity(bullet[me], 0.0002);
+ bullet[me].explodeRad = 350 * size + Math.floor(Math.random() * 50) + tech.isBlockExplode * 100
+ bullet[me].onEnd = b.grenadeEnd
+ bullet[me].beforeDmg = function () {
+ this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
+ };
+ bullet[me].restitution = 0.4;
+ bullet[me].do = function () {
+ this.force.y += this.mass * 0.0025; //extra gravity for harder arcs
+
+ const suckCycles = 40
+ if (simulation.cycle > this.endCycle - suckCycles) { //suck
+ const that = this
+
+ function suck(who, radius = that.explodeRad * 3.2) {
+ for (i = 0, len = who.length; i < len; i++) {
+ const sub = Vector.sub(that.position, who[i].position);
+ const dist = Vector.magnitude(sub);
+ if (dist < radius && dist > 150 && !who.isInvulnerable) {
+ knock = Vector.mult(Vector.normalise(sub), mag * who[i].mass / Math.sqrt(dist));
+ who[i].force.x += knock.x;
+ who[i].force.y += knock.y;
+ }
+ }
+ }
+ let mag = 0.1
+ if (simulation.cycle > this.endCycle - 5) {
+ mag = -0.22
+ suck(mob, this.explodeRad * 3)
+ suck(body, this.explodeRad * 2)
+ suck(powerUp, this.explodeRad * 1.5)
+ suck(bullet, this.explodeRad * 1.5)
+ suck([player], this.explodeRad * 1.3)
+ } else {
+ mag = 0.11
+ suck(mob, this.explodeRad * 3)
+ suck(body, this.explodeRad * 2)
+ suck(powerUp, this.explodeRad * 1.5)
+ suck(bullet, this.explodeRad * 1.5)
+ suck([player], this.explodeRad * 1.3)
+ }
+ //keep bomb in place
+ Matter.Body.setVelocity(this, {
+ x: 0,
+ y: 0
+ });
+ //draw suck
+ const radius = 2.75 * this.explodeRad * (this.endCycle - simulation.cycle) / suckCycles
+ ctx.fillStyle = "rgba(0,0,0,0.1)";
+ ctx.beginPath();
+ ctx.arc(this.position.x, this.position.y, radius, 0, 2 * Math.PI);
+ ctx.fill();
+ }
+ };
+ speed = 35
+ // speed = m.crouch ? 43 : 32
+
+ bullet[me].endCycle = simulation.cycle + 70 * tech.bulletsLastLonger;
+ if (m.crouch) {
+ speed += 9
+ bullet[me].endCycle += 20;
+ }
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.5 * player.velocity.x + speed * Math.cos(angle),
+ y: 0.5 * player.velocity.y + speed * Math.sin(angle)
+ });
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ }
+
+ grenadeNeutron = function (where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle, size = 1) {
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(where.x, where.y, 10, 4, b.fireAttributes(angle, false));
+ b.fireProps((m.crouch ? 45 : 25) / Math.pow(0.92, tech.missileCount), m.crouch ? 35 : 20, angle, me); //cd , speed
+ Matter.Body.setDensity(bullet[me], 0.000001);
+ bullet[me].endCycle = 500 + simulation.cycle;
+ bullet[me].frictionAir = 0;
+ bullet[me].friction = 1;
+ bullet[me].frictionStatic = 1;
+ bullet[me].restitution = 0;
+ bullet[me].minDmgSpeed = 0;
+ bullet[me].damageRadius = 100;
+ bullet[me].maxDamageRadius = 450 * size + 130 * tech.isNeutronSlow //+ 150 * Math.random()
+ bullet[me].radiusDecay = (0.81 + 0.15 * tech.isNeutronSlow) / tech.bulletsLastLonger
+ bullet[me].stuckTo = null;
+ bullet[me].stuckToRelativePosition = null;
+ if (tech.isRPG) {
+ const SCALE = 2
+ Matter.Body.scale(bullet[me], SCALE, SCALE);
+ speed = m.crouch ? 25 : 15
+ // speed = m.crouch ? 43 : 32
+ Matter.Body.setVelocity(bullet[me], { x: 0.5 * player.velocity.x + speed * Math.cos(angle), y: 0.5 * player.velocity.y + speed * Math.sin(angle) });
+ const MAG = 0.005
+ bullet[me].thrust = { x: bullet[me].mass * MAG * Math.cos(angle), y: bullet[me].mass * MAG * Math.sin(angle) }
+ }
+
+ bullet[me].beforeDmg = function () { };
+ bullet[me].stuck = function () { };
+ bullet[me].do = function () {
+ const onCollide = () => {
+ this.collisionFilter.mask = 0; //non collide with everything
+ Matter.Body.setVelocity(this, { x: 0, y: 0 });
+ if (tech.isRPG) this.thrust = { x: 0, y: 0 }
+ this.do = this.radiationMode;
+ }
+ const mobCollisions = Matter.Query.collides(this, mob)
+ if (mobCollisions.length) {
+ onCollide()
+ this.stuckTo = mobCollisions[0].bodyA
+ mobs.statusDoT(this.stuckTo, 0.6, 360) //apply radiation damage status effect on direct hits
+ if (this.stuckTo.isVerticesChange) {
+ this.stuckToRelativePosition = { x: 0, y: 0 }
+ } else {
+ //find the relative position for when the mob is at angle zero by undoing the mobs rotation
+ this.stuckToRelativePosition = Vector.rotate(Vector.sub(this.position, this.stuckTo.position), -this.stuckTo.angle)
+ }
+ this.stuck = function () {
+ if (this.stuckTo && this.stuckTo.alive) {
+ const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
+ Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
+ Matter.Body.setVelocity(this, this.stuckTo.velocity); //so that it will move properly if it gets unstuck
+ } else {
+ this.collisionFilter.mask = cat.map | cat.body | cat.player | cat.mob; //non collide with everything but map
+ this.stuck = function () {
+ this.force.y += this.mass * 0.001;
+ }
+ }
+ }
+ } else {
+ const bodyCollisions = Matter.Query.collides(this, body)
+ if (bodyCollisions.length) {
+ if (!bodyCollisions[0].bodyA.isNotHoldable) {
+ onCollide()
+ this.stuckTo = bodyCollisions[0].bodyA
+ //find the relative position for when the mob is at angle zero by undoing the mobs rotation
+ this.stuckToRelativePosition = Vector.rotate(Vector.sub(this.position, this.stuckTo.position), -this.stuckTo.angle)
+ } else {
+ this.do = this.radiationMode;
+ }
+ this.stuck = function () {
+ if (this.stuckTo) {
+ const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
+ Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
+ // Matter.Body.setVelocity(this, this.stuckTo.velocity); //so that it will move properly if it gets unstuck
+ } else {
+ this.force.y += this.mass * 0.001;
+ }
+ }
+ } else {
+ if (Matter.Query.collides(this, map).length) {
+ onCollide()
+ } else if (tech.isRPG) { //if colliding with nothing
+ this.force.x += this.thrust.x;
+ this.force.y += this.thrust.y;
+ } else {
+ this.force.y += this.mass * 0.001;
+ }
+ }
+ }
+ }
+ bullet[me].radiationMode = function () { //the do code after the bullet is stuck on something, projects a damaging radiation field
+ this.stuck(); //runs different code based on what the bullet is stuck to
+ this.damageRadius = this.damageRadius * 0.85 + 0.15 * this.maxDamageRadius //smooth radius towards max
+ this.maxDamageRadius -= this.radiusDecay
+ if (this.damageRadius < 15) {
+ this.endCycle = 0;
+ } else {
+ //aoe damage to player
+ if (Vector.magnitude(Vector.sub(player.position, this.position)) < this.damageRadius) {
+ const DRAIN = (tech.isRadioactiveResistance ? 0.0025 * 0.2 : 0.0025)
+ if (m.energy > DRAIN) {
+ if (m.immuneCycle < m.cycle) m.energy -= DRAIN
+ } else {
+ m.energy = 0;
+ if (simulation.dmgScale) m.damage((tech.isRadioactiveResistance ? 0.00016 * 0.2 : 0.00016) * tech.radioactiveDamage) //0.00015
+ }
+ }
+ //aoe damage to mobs
+ let dmg = m.dmgScale * 0.15 * tech.radioactiveDamage
+ for (let i = 0, len = mob.length; i < len; i++) {
+ if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < this.damageRadius + mob[i].radius) {
+ if (Matter.Query.ray(map, mob[i].position, this.position).length > 0) dmg *= 0.2 //reduce damage if a wall is in the way
+ mob[i].damage(mob[i].shield ? dmg * 3 : dmg);
+ mob[i].locatePlayer();
+ if (tech.isNeutronSlow && mob[i].speed > 4) {
+ Matter.Body.setVelocity(mob[i], { x: mob[i].velocity.x * 0.97, y: mob[i].velocity.y * 0.97 });
+ }
+ }
+ }
+ ctx.beginPath();
+ ctx.arc(this.position.x, this.position.y, this.damageRadius, 0, 2 * Math.PI);
+ ctx.globalCompositeOperation = "lighter"
+ ctx.fillStyle = `rgba(25,139,170,${0.2 + 0.06 * Math.random()})`;
+ ctx.fill();
+ ctx.globalCompositeOperation = "source-over"
+ if (tech.isNeutronSlow) {
+ let slow = (who, radius = this.explodeRad * 3.2) => {
+ for (i = 0, len = who.length; i < len; i++) {
+ const sub = Vector.sub(this.position, who[i].position);
+ const dist = Vector.magnitude(sub);
+ if (dist < radius) {
+ Matter.Body.setVelocity(who[i], { x: who[i].velocity.x * 0.975, y: who[i].velocity.y * 0.975 });
+ }
+ }
+ }
+ slow(body, this.damageRadius)
+ slow([player], this.damageRadius)
+ }
+ }
+ }
+ }
+
+ if (tech.isNeutronBomb) {
+ b.grenade = grenadeNeutron
+ if (tech.isRPG) {
+ b.guns[5].do = function () { }
+ } else {
+ b.guns[5].do = function () {
+ if (!input.field && m.crouch) {
+ const cycles = 80
+ const speed = m.crouch ? 35 : 20 //m.crouch ? 43 : 32
+ const g = m.crouch ? 0.137 : 0.135
+ const v = {
+ x: speed * Math.cos(m.angle),
+ y: speed * Math.sin(m.angle)
+ }
+ ctx.strokeStyle = "rgba(68, 68, 68, 0.2)" //color.map
+ ctx.lineWidth = 2
+ ctx.beginPath()
+ for (let i = 1, len = 19; i < len + 1; i++) {
+ const time = cycles * i / len
+ ctx.lineTo(m.pos.x + time * v.x, m.pos.y + time * v.y + g * time * time)
+ }
+ ctx.stroke()
+ }
+ }
+ }
+ } else if (tech.isRPG) {
+ b.guns[5].do = function () { }
+ if (tech.isVacuumBomb) {
+ b.grenade = grenadeRPGVacuum
+ } else {
+ b.grenade = grenadeRPG
+ }
+ } else if (tech.isVacuumBomb) {
+ b.grenade = grenadeVacuum
+ b.guns[5].do = function () {
+ if (!input.field && m.crouch) {
+ const cycles = Math.floor(m.crouch ? 50 : 30) //30
+ const speed = m.crouch ? 44 : 35
+ const v = { x: speed * Math.cos(m.angle), y: speed * Math.sin(m.angle) }
+ ctx.strokeStyle = "rgba(68, 68, 68, 0.2)" //color.map
+ ctx.lineWidth = 2
+ ctx.beginPath()
+ for (let i = 1.6, len = 19; i < len + 1; i++) {
+ const time = cycles * i / len
+ ctx.lineTo(m.pos.x + time * v.x, m.pos.y + time * v.y + 0.34 * time * time)
+ }
+ ctx.stroke()
+ }
+ }
+ } else {
+ b.grenade = grenadeDefault
+ b.guns[5].do = function () {
+ if (!input.field && m.crouch) {
+ const cycles = Math.floor(m.crouch ? 120 : 80) //30
+ const speed = m.crouch ? 43 : 32
+ const v = { x: speed * Math.cos(m.angle), y: speed * Math.sin(m.angle) } //m.Vy / 2 + removed to make the path less jerky
+ ctx.strokeStyle = "rgba(68, 68, 68, 0.2)" //color.map
+ ctx.lineWidth = 2
+ ctx.beginPath()
+ for (let i = 0.5, len = 19; i < len + 1; i++) {
+ const time = cycles * i / len
+ ctx.lineTo(m.pos.x + time * v.x, m.pos.y + time * v.y + 0.34 * time * time)
+ }
+ ctx.stroke()
+ }
+ }
+ }
+ },
+ grapple(where, angle = m.angle) {
+ const me = bullet.length;
+ const returnRadius = 100
+ bullet[me] = Bodies.fromVertices(where.x, where.y, [{
+ x: -40,
+ y: 2,
+ index: 0,
+ isInternal: false
+ }, {
+ x: -40,
+ y: -2,
+ index: 1,
+ isInternal: false
+ }, {
+ x: 37,
+ y: -2,
+ index: 2,
+ isInternal: false
+ }, {
+ x: 40,
+ y: -1,
+ index: 3,
+ isInternal: false
+ }, {
+ x: 37,
+ y: 3,
+ index: 4,
+ isInternal: false
+ }],
+ {
+ angle: angle,
+ friction: 1,
+ frictionAir: 0.4,
+ thrustMag: 0.13,
+ dmg: 8, //damage done in addition to the damage from momentum
+ classType: "bullet",
+ endCycle: simulation.cycle + 70,
+ isSlowPull: false,
+ drawStringControlMagnitude: 1000 + 1000 * Math.random(),
+ drawStringFlip: (Math.round(Math.random()) ? 1 : -1),
+ attached: false,
+ glowColor: tech.hookNails ? "rgba(200,0,0,0.07)" : tech.isHarmReduce ? "rgba(50,100,255,0.1)" : "rgba(0,200,255,0.07)",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: tech.isShieldPierce ? cat.body | cat.mob | cat.mobBullet : cat.body | cat.mob | cat.mobBullet | cat.mobShield,
+ },
+ minDmgSpeed: 4,
+ // lookFrequency: Math.floor(7 + Math.random() * 3),
+ density: 0.004, //0.001 is normal for blocks, 0.004 is normal for harpoon
+ drain: 0.001,
+ powerUpDamage: tech.isHarpoonPowerUp && simulation.cycle - 480 < tech.harpoonPowerUpCycle,
+ draw() {
+ // draw rope
+ const where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }
+ const sub = Vector.sub(where, this.vertices[0])
+ ctx.strokeStyle = "#000" // "#0ce"
+ ctx.lineWidth = 0.5
+ ctx.beginPath();
+ ctx.moveTo(where.x, where.y);
+ if (this.attached) {
+ const controlPoint = Vector.add(where, Vector.mult(sub, -0.5))
+ ctx.quadraticCurveTo(controlPoint.x, controlPoint.y, this.vertices[0].x, this.vertices[0].y)
+ } else {
+ const long = Math.max(Vector.magnitude(sub), 60)
+ const perpendicular = Vector.mult(Vector.normalise(Vector.perp(sub)), this.drawStringFlip * Math.min(0.7 * long, 10 + this.drawStringControlMagnitude / (10 + Vector.magnitude(sub))))
+ const controlPoint = Vector.add(Vector.add(where, Vector.mult(sub, -0.5)), perpendicular)
+ ctx.quadraticCurveTo(controlPoint.x, controlPoint.y, this.vertices[0].x, this.vertices[0].y)
+ }
+ // ctx.lineTo(this.vertices[0].x, this.vertices[0].y);
+ // ctx.stroke();
+ ctx.strokeStyle = this.glowColor // "#0ce"
+ ctx.lineWidth = 10
+ ctx.stroke();
+ ctx.strokeStyle = "#000" // "#0ce"
+ ctx.lineWidth = 0.5
+ ctx.stroke();
+
+ if (this.powerUpDamage) {
+ ctx.beginPath();
+ ctx.moveTo(this.vertices[0].x, this.vertices[0].y);
+ ctx.lineTo(this.vertices[1].x, this.vertices[1].y);
+ ctx.lineTo(this.vertices[2].x, this.vertices[2].y);
+ ctx.lineTo(this.vertices[3].x, this.vertices[3].y);
+ ctx.lineTo(this.vertices[4].x, this.vertices[4].y);
+ ctx.lineJoin = "miter"
+ ctx.miterLimit = 30;
+ ctx.lineWidth = 25;
+ ctx.strokeStyle = "rgba(0,255,255,0.4)";
+ ctx.stroke();
+ ctx.lineWidth = 8;
+ ctx.strokeStyle = "rgb(0,255,255)";
+ ctx.stroke();
+ ctx.lineJoin = "round"
+ ctx.miterLimit = 5
+ ctx.fillStyle = "#000"
+ ctx.fill();
+ }
+ //draw hook
+ ctx.beginPath();
+ ctx.lineTo(this.vertices[0].x, this.vertices[0].y);
+ const spike = Vector.add(this.vertices[3], Vector.mult(Vector.sub(this.vertices[3], this.vertices[2]), 2))
+ ctx.moveTo(this.vertices[2].x, this.vertices[2].y);
+ ctx.lineTo(spike.x, spike.y);
+ ctx.lineTo(this.vertices[1].x, this.vertices[1].y);
+ ctx.fillStyle = '#000'
+ ctx.fill();
+ },
+ beforeDmg(who) {
+ if (tech.isShieldPierce && who.isShielded) { //disable shields
+ who.isShielded = false
+ requestAnimationFrame(() => { who.isShielded = true });
+ }
+ if (m.fieldCDcycle < m.cycle + 40) m.fieldCDcycle = m.cycle + 40 //extra long cooldown on hitting mobs
+ if (tech.hookNails) {
+ // if (m.immuneCycle < m.cycle + m.collisionImmuneCycles) m.immuneCycle = m.cycle + 5; //player is immune to damage for 5 cycles
+ // b.explosion(this.position, 300 + 150 * Math.random()); //makes bullet do explosive damage at end
+ b.targetedNail(this.position, tech.hookNails)
+ const ANGLE = 2 * Math.PI * Math.random() //make a few random ones
+ for (let i = 0; i < 4; i++) b.nail(this.position, { x: 10.5 * Math.cos(ANGLE), y: 10.5 * Math.sin(ANGLE) }, 1.2)
+ }
+ // if (this.powerUpDamage) this.density = 2 * 0.004 //double damage after pick up power up for 8 seconds
+
+
+ if (tech.isHarpoonPowerUp && simulation.cycle - 480 < tech.harpoonPowerUpCycle) {
+ Matter.Body.setDensity(this, 1.8 * 0.004); //+90% damage after pick up power up for 8 seconds
+ } else if (tech.isHarpoonFullHealth && who.health === 1) {
+ Matter.Body.setDensity(this, 2.11 * 0.004); //+90% damage if mob has full health do
+ simulation.ephemera.push({
+ name: "grapple outline",
+ count: 3, //cycles before it self removes
+ vertices: this.vertices,
+ do() {
+ this.count--
+ if (this.count < 0) simulation.removeEphemera(this.name)
+
+ ctx.beginPath();
+ ctx.moveTo(this.vertices[0].x, this.vertices[0].y);
+ for (let j = 1, len = this.vertices.length; j < len; j += 1) ctx.lineTo(this.vertices[j].x, this.vertices[j].y);
+ ctx.lineTo(this.vertices[0].x, this.vertices[0].y);
+ ctx.lineJoin = "miter"
+ ctx.miterLimit = 20;
+ ctx.lineWidth = 40;
+ ctx.strokeStyle = "rgba(255,0,100,0.35)";
+ ctx.stroke();
+ ctx.lineWidth = 10;
+ ctx.strokeStyle = `#f07`;
+ ctx.stroke();
+ ctx.lineJoin = "round"
+ ctx.miterLimit = 5
+ ctx.fillStyle = "#000"
+ ctx.fill();
+ },
+ })
+ }
+
+
+ this.retract()
+ },
+ caughtPowerUp: null,
+ dropCaughtPowerUp() {
+ if (this.caughtPowerUp) {
+ this.caughtPowerUp.collisionFilter.category = cat.powerUp
+ this.caughtPowerUp.collisionFilter.mask = cat.map | cat.powerUp
+ this.caughtPowerUp = null
+ }
+ },
+ onEnd() {
+ if (this.caughtPowerUp && !simulation.isChoosing && (this.caughtPowerUp.name !== "heal" || m.health !== m.maxHealth || tech.isOverHeal)) {
+ let index = null //find index
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ if (powerUp[i] === this.caughtPowerUp) index = i
+ }
+ if (index !== null) {
+ powerUps.onPickUp(this.caughtPowerUp);
+ this.caughtPowerUp.effect();
+ Matter.Composite.remove(engine.world, this.caughtPowerUp);
+ powerUp.splice(index, 1);
+ if (tech.isHarpoonPowerUp) tech.harpoonPowerUpCycle = simulation.cycle
+ } else {
+ this.dropCaughtPowerUp()
+ }
+ } else {
+ this.dropCaughtPowerUp()
+ }
+ },
+ retract() {
+ this.attached = false
+ this.do = this.returnToPlayer
+ this.endCycle = simulation.cycle + 60
+ Matter.Body.setDensity(this, 0.0005); //reduce density on return
+ if (this.angularSpeed < 0.5) this.torque += this.inertia * 0.001 * (Math.random() - 0.5) //(Math.round(Math.random()) ? 1 : -1)
+ this.collisionFilter.mask = 0//cat.map | cat.mob | cat.mobBullet | cat.mobShield // | cat.body
+ //recoil on pulling grapple back
+ // if (this.pickUpTarget.mass) console.log(this.pickUpTarget.mass)
+ const mag = this.pickUpTarget ? Math.min(5, Math.max(this.pickUpTarget.mass, 0.5)) : 0.5
+ const unit = Vector.normalise(Vector.sub(this.position, m.pos))
+ const momentum = Vector.mult(unit, mag * (m.crouch ? 0.1 : 0.2))
+ player.force.x += momentum.x
+ player.force.y += momentum.y
+ },
+ returnToPlayer() {
+ if (m.fieldCDcycle < m.cycle + 5) m.fieldCDcycle = m.cycle + 5
+ if (Vector.magnitude(Vector.sub(this.position, m.pos)) < returnRadius) { //near player
+ this.endCycle = 0;
+ //recoil on catching grapple
+ // const momentum = Vector.mult(Vector.sub(this.velocity, player.velocity), (m.crouch ? 0.0001 : 0.0002))
+ const unit = Vector.normalise(Vector.sub(this.velocity, player.velocity))
+ const momentum = Vector.mult(unit, (m.crouch ? 0.0001 : 0.0002))
+ player.force.x += momentum.x
+ player.force.y += momentum.y
+ if (this.pickUpTarget) {
+ if (tech.isReel && this.blockDist > 150) {
+ // console.log(0.0003 * Math.min(this.blockDist, 1000))
+ m.energy += 0.00113 * Math.min(this.blockDist, 800) * level.isReducedRegen //max 0.352 energy
+ simulation.drawList.push({ //add dmg to draw queue
+ x: m.pos.x,
+ y: m.pos.y,
+ radius: 10,
+ color: m.fieldMeterColor,
+ time: simulation.drawTime
+ });
+ }
+ m.holdingTarget = this.pickUpTarget
+ // give block to player after it returns
+ m.isHolding = true;
+ //conserve momentum when player mass changes
+ const blockMass = Math.min(5, this.pickUpTarget.mass)
+ const grappleMomentum = Vector.mult(Vector.normalise(this.velocity), 15 * blockMass)
+ const playerMomentum = Vector.mult(player.velocity, player.mass)
+ totalMomentum = Vector.add(playerMomentum, grappleMomentum)
+ Matter.Body.setVelocity(player, Vector.mult(totalMomentum, 1 / (m.defaultMass + blockMass)));
+
+ m.definePlayerMass(m.defaultMass + this.pickUpTarget.mass * m.holdingMassScale)
+ //make block collide with nothing
+ m.holdingTarget.collisionFilter.category = 0;
+ m.holdingTarget.collisionFilter.mask = 0;
+ this.pickUpTarget = null
+ }
+ } else {
+ if (m.energy > this.drain) m.energy -= this.drain
+ const sub = Vector.sub(this.position, m.pos)
+ const rangeScale = 1 + 0.000003 * Vector.magnitude(sub) //return faster when far from player
+ const returnForce = Vector.mult(Vector.normalise(sub), rangeScale * this.thrustMag * this.mass)
+ this.force.x -= returnForce.x
+ this.force.y -= returnForce.y
+ this.grabPowerUp()
+ this.grabBlocks()
+ }
+ this.draw();
+ },
+ destroyBlocks() {//not used?
+ const blocks = Matter.Query.collides(this, body)
+ if (blocks.length && !blocks[0].bodyA.isNotHoldable) {
+ if (blocks[0].bodyA.mass > 2.5) this.retract()
+ const block = blocks[0].bodyA.vertices
+ Composite.remove(engine.world, blocks[0].bodyA)
+ body.splice(body.indexOf(blocks[0].bodyA), 1)
+ //animate the block fading away
+ simulation.ephemera.push({
+ name: "blockFadeOut",
+ count: 25, //cycles before it self removes
+ do() {
+ this.count--
+ if (this.count < 0) simulation.removeEphemera(this.name)
+ ctx.beginPath();
+ ctx.moveTo(block[0].x, block[0].y);
+ for (let j = 1; j < block.length; j++) ctx.lineTo(block[j].x, block[j].y);
+ ctx.lineTo(block[0].x, block[0].y);
+ ctx.lineWidth = 2;
+ ctx.strokeStyle = `rgba(0,0,0,${this.count / 25})`
+ ctx.stroke();
+ },
+ })
+ }
+ },
+ pickUpTarget: null,
+ grabBlocks() {
+ if (this.pickUpTarget) { //if always attached to a block
+ //position block on hook
+ Matter.Body.setPosition(this.pickUpTarget, Vector.add(this.vertices[2], this.velocity))
+ Matter.Body.setVelocity(this.pickUpTarget, { x: 0, y: 0 })
+ } else {
+ const blocks = Matter.Query.collides(this, body)
+ if (blocks.length) {
+ for (let i = 0; i < blocks.length; i++) {
+ if (blocks[i].bodyA.classType === "body" && !blocks[i].bodyA.isNotHoldable && blocks[0].bodyA.mass < 40) {
+ this.retract()
+ if (tech.hookNails) {
+ b.targetedNail(this.position, 3 * tech.hookNails)
+ const ANGLE = 2 * Math.PI * Math.random() //make a few random ones
+ for (let i = 0; i < 13; i++) b.nail(this.position, { x: 10.5 * Math.cos(ANGLE), y: 10.5 * Math.sin(ANGLE) }, 1.2)
+
+ const blockVertices = blocks[i].bodyA.vertices
+ Composite.remove(engine.world, blocks[i].bodyA)
+ body.splice(body.indexOf(blocks[i].bodyA), 1)
+ //animate the block fading away
+ simulation.ephemera.push({
+ name: "blockFadeOut",
+ count: 25, //cycles before it self removes
+ do() {
+ this.count--
+ if (this.count < 0) simulation.removeEphemera(this.name)
+ ctx.beginPath();
+ ctx.moveTo(blockVertices[0].x, blockVertices[0].y);
+ for (let j = 1; j < blockVertices.length; j++) ctx.lineTo(blockVertices[j].x, blockVertices[j].y);
+ ctx.lineTo(blockVertices[0].x, blockVertices[0].y);
+ ctx.lineWidth = 2;
+ ctx.strokeStyle = `rgba(0,0,0,${this.count / 25})`
+ ctx.stroke();
+ },
+ })
+ } else {
+ this.pickUpTarget = blocks[i].bodyA
+ this.blockDist = Vector.magnitude(Vector.sub(this.pickUpTarget.position, m.pos))
+ }
+ }
+ }
+ }
+ }
+ },
+ grabPowerUp() { //grab power ups near the tip of the harpoon
+ if (this.caughtPowerUp) {
+ Matter.Body.setPosition(this.caughtPowerUp, Vector.add(this.vertices[2], this.velocity))
+ Matter.Body.setVelocity(this.caughtPowerUp, { x: 0, y: 0 })
+ } else {
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ if (tech.isEnergyNoAmmo && powerUp[i].name === "ammo") continue
+ const radius = powerUp[i].circleRadius + 50
+ if (Vector.magnitudeSquared(Vector.sub(this.vertices[2], powerUp[i].position)) < radius * radius) {
+ if (powerUp[i].name !== "heal" || m.health !== m.maxHealth || tech.isOverHeal) {
+ this.caughtPowerUp = powerUp[i]
+ Matter.Body.setVelocity(powerUp[i], { x: 0, y: 0 })
+ Matter.Body.setPosition(powerUp[i], this.vertices[2])
+ powerUp[i].collisionFilter.category = 0
+ powerUp[i].collisionFilter.mask = 0
+ this.thrustMag *= 0.6
+ this.endCycle += 0.5 //it pulls back slower, so this prevents it from ending early
+ // this.retract()
+ break //just pull 1 power up if possible
+ }
+ }
+ }
+ }
+ m.grabPowerUp();
+ },
+ do() {
+ if (m.fieldCDcycle < m.cycle + 5) m.fieldCDcycle = m.cycle + 5
+ if (input.field) {
+ this.grabBlocks()
+ this.grabPowerUp()
+ } else {
+ this.retract()
+ }
+ //grappling hook
+ if (input.field && Matter.Query.collides(this, map).length) {
+ Matter.Body.setPosition(this, Vector.add(this.position, { x: -20 * Math.cos(this.angle), y: -20 * Math.sin(this.angle) }))
+ if (Matter.Query.collides(this, map).length) {
+ if (tech.hookNails) {
+ b.targetedNail(this.position, tech.hookNails)
+ const ANGLE = 2 * Math.PI * Math.random() //make a few random ones
+ for (let i = 0; i < 4; i++) b.nail(this.position, { x: 10.5 * Math.cos(ANGLE), y: 10.5 * Math.sin(ANGLE) }, 1.2)
+
+ }
+ this.attached = true
+ Matter.Body.setVelocity(this, { x: 0, y: 0 });
+ Matter.Sleeping.set(this, true)
+ this.endCycle = simulation.cycle + 5
+ this.do = () => {
+ if (m.fieldCDcycle < m.cycle + 5) m.fieldCDcycle = m.cycle + 5
+ this.grabPowerUp()
+
+ //between player nose and the grapple
+ const sub = Vector.sub(this.vertices[0], { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) })
+ let dist = Vector.magnitude(sub)
+ if (input.field) {
+ this.endCycle = simulation.cycle + 10
+ if (input.down) { //down
+ this.isSlowPull = true
+ dist = 0
+ player.force.y += 3 * player.mass * simulation.g; //adjust this to control fall rate while hooked and pressing down
+ } else if (input.up) {
+ this.isSlowPull = false
+ player.force.y -= player.mass * simulation.g; //adjust this to control fall rate while hooked and pressing down
+ }
+ if (m.energy < this.drain) this.isSlowPull = true
+
+ // pulling friction that allowed a slight swinging, but has high linear pull at short dist
+ const drag = 1 - 30 / Math.min(Math.max(100, dist), 700) - 0.1 * (player.speed > 66)
+ Matter.Body.setVelocity(player, { x: player.velocity.x * drag, y: player.velocity.y * drag });
+ const pull = Vector.mult(Vector.normalise(sub), 0.0004 * Math.min(Math.max(15, dist), this.isSlowPull ? 70 : 200))
+ //original pulling force with high friction and very linear pull
+ // Matter.Body.setVelocity(player, { x: player.velocity.x * 0.85, y: player.velocity.y * 0.85 });
+ // const pull = Vector.mult(Vector.normalise(sub), 0.0008 * Math.min(Math.max(15, dist), this.isSlowPull ? 100 : 200))
+
+ player.force.x += pull.x
+ player.force.y += pull.y
+ if (dist > 500) m.energy -= this.drain
+ } else {
+ Matter.Sleeping.set(this, false)
+ this.retract()
+ }
+ this.draw();
+ }
+ }
+ }
+ this.force.x += this.thrustMag * this.mass * Math.cos(this.angle);
+ this.force.y += this.thrustMag * this.mass * Math.sin(this.angle);
+ this.draw()
+ },
+ });
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ harpoon(where, target, angle = m.angle, harpoonSize = 1, isReturn = false, totalCycles = 35, isReturnAmmo = true, thrust = 0.1) {
+ const me = bullet.length;
+ const returnRadius = 100 * Math.sqrt(harpoonSize)
+ bullet[me] = Bodies.fromVertices(where.x, where.y, [{
+ x: -40 * harpoonSize,
+ y: 2 * harpoonSize,
+ index: 0,
+ isInternal: false
+ }, {
+ x: -40 * harpoonSize,
+ y: -2 * harpoonSize,
+ index: 1,
+ isInternal: false
+ }, {
+ x: 50 * harpoonSize,
+ y: -3 * harpoonSize,
+ index: 3,
+ isInternal: false
+ }, {
+ x: 30 * harpoonSize,
+ y: 2 * harpoonSize,
+ index: 4,
+ isInternal: false
+ }], {
+ cycle: 0,
+ angle: angle,
+ friction: 1,
+ frictionAir: 0.4,
+ // thrustMag: 0.1,
+ drain: tech.isRailEnergy ? 0.0002 : 0.006,
+ turnRate: isReturn ? 0.1 : 0.03, //0.015
+ drawStringControlMagnitude: 3000 + 5000 * Math.random(),
+ drawStringFlip: (Math.round(Math.random()) ? 1 : -1),
+ dmg: 6, //damage done in addition to the damage from momentum
+ classType: "bullet",
+ endCycle: simulation.cycle + totalCycles * 2.5 + 40,
+ collisionFilter: {
+ category: cat.bullet,
+ mask: tech.isShieldPierce ? cat.map | cat.body | cat.mob | cat.mobBullet : cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield,
+ },
+ minDmgSpeed: 4,
+ lookFrequency: Math.floor(7 + Math.random() * 3),
+ density: tech.harpoonDensity, //0.001 is normal for blocks, 0.004 is normal for harpoon, 0.004*6 when buffed
+ foamSpawned: 0,
+ beforeDmg(who) {
+ if (tech.isShieldPierce && who.isShielded) { //disable shields
+ who.isShielded = false
+ requestAnimationFrame(() => {
+ who.isShielded = true
+ });
+ }
+ if (tech.fragments) {
+ b.targetedNail(this.vertices[2], tech.fragments * Math.floor(2 + Math.random()))
+ if (!isReturn) this.endCycle = 0;
+ }
+ if (!who.isBadTarget) {
+ if (isReturn) {
+ this.do = this.returnToPlayer
+ } else {
+ this.frictionAir = 0.01
+ this.do = () => {
+ this.force.y += this.mass * 0.003; //gravity
+ this.draw();
+ }
+ }
+ }
+ if (tech.isFoamBall && this.foamSpawned < 55) {
+ for (let i = 0, len = Math.min(30, 2 + 3 * Math.sqrt(this.mass)); i < len; i++) {
+ const radius = 5 + 9 * Math.random()
+ const velocity = { x: Math.max(0.5, 2 - radius * 0.1), y: 0 }
+ b.foam(this.position, Vector.rotate(velocity, 6.28 * Math.random()), radius)
+ this.foamSpawned++
+ }
+ }
+ if (tech.isHarpoonPowerUp && simulation.cycle - 480 < tech.harpoonPowerUpCycle) {
+ Matter.Body.setDensity(this, 1.8 * tech.harpoonDensity); //+90% damage after pick up power up for 8 seconds
+ } else if (tech.isHarpoonFullHealth && who.health === 1) {
+ Matter.Body.setDensity(this, 2.2 * tech.harpoonDensity); //+90% damage if mob has full health do
+ simulation.ephemera.push({
+ name: "harpoon outline",
+ count: 2, //cycles before it self removes
+ vertices: this.vertices,
+ do() {
+ this.count--
+ if (this.count < 0) simulation.removeEphemera(this.name)
+
+ ctx.beginPath();
+ ctx.moveTo(this.vertices[0].x, this.vertices[0].y);
+ for (let j = 1, len = this.vertices.length; j < len; j += 1) ctx.lineTo(this.vertices[j].x, this.vertices[j].y);
+ ctx.lineTo(this.vertices[0].x, this.vertices[0].y);
+ ctx.lineJoin = "miter"
+ ctx.miterLimit = 20;
+ ctx.lineWidth = 40;
+ ctx.strokeStyle = "rgba(255,0,100,0.35)";
+ ctx.stroke();
+ ctx.lineWidth = 10;
+ ctx.strokeStyle = `#f07`;
+ ctx.stroke();
+ ctx.lineJoin = "round"
+ ctx.miterLimit = 5
+ ctx.fillStyle = "#000"
+ ctx.fill();
+ },
+ })
+ }
+ },
+ caughtPowerUp: null,
+ dropCaughtPowerUp() {
+ if (this.caughtPowerUp) {
+ this.caughtPowerUp.collisionFilter.category = cat.powerUp
+ this.caughtPowerUp.collisionFilter.mask = cat.map | cat.powerUp
+ this.caughtPowerUp = null
+ }
+ },
+ onEnd() {
+ if (this.caughtPowerUp && !simulation.isChoosing && (this.caughtPowerUp.name !== "heal" || m.health !== m.maxHealth || tech.isOverHeal)) {
+ let index = null //find index
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ if (powerUp[i] === this.caughtPowerUp) index = i
+ }
+ if (index !== null) {
+ powerUps.onPickUp(this.caughtPowerUp);
+ this.caughtPowerUp.effect();
+ Matter.Composite.remove(engine.world, this.caughtPowerUp);
+ powerUp.splice(index, 1);
+ if (tech.isHarpoonPowerUp) tech.harpoonPowerUpCycle = simulation.cycle
+ } else {
+ this.dropCaughtPowerUp()
+ }
+ } else {
+ this.dropCaughtPowerUp()
+ }
+ },
+ drawDamageAura() {
+ ctx.beginPath();
+ ctx.moveTo(this.vertices[0].x, this.vertices[0].y);
+ for (let j = 1, len = this.vertices.length; j < len; j += 1) ctx.lineTo(this.vertices[j].x, this.vertices[j].y);
+ ctx.lineTo(this.vertices[0].x, this.vertices[0].y);
+ ctx.lineJoin = "miter"
+ ctx.miterLimit = 20;
+ ctx.lineWidth = 15;
+ ctx.strokeStyle = "rgba(255,0,100,0.25)";
+ ctx.stroke();
+ ctx.lineWidth = 4;
+ ctx.strokeStyle = `#f07`;
+ ctx.stroke();
+ ctx.lineJoin = "round"
+ ctx.miterLimit = 5
+ ctx.fillStyle = "#000"
+ ctx.fill();
+ },
+ drawString() {
+ const where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }
+ const sub = Vector.sub(where, this.vertices[0])
+ const perpendicular = Vector.mult(Vector.normalise(Vector.perp(sub)), this.drawStringFlip * Math.min(80, 10 + this.drawStringControlMagnitude / (10 + Vector.magnitude(sub))))
+ const controlPoint = Vector.add(Vector.add(where, Vector.mult(sub, -0.5)), perpendicular)
+ ctx.strokeStyle = "#000" // "#0ce"
+ ctx.lineWidth = 0.5
+ ctx.beginPath();
+ ctx.moveTo(where.x, where.y);
+ ctx.quadraticCurveTo(controlPoint.x, controlPoint.y, this.vertices[0].x, this.vertices[0].y)
+ // ctx.lineTo(this.vertices[0].x, this.vertices[0].y);
+ ctx.stroke();
+ },
+ draw() { },
+ returnToPlayer() {
+ if (Vector.magnitude(Vector.sub(this.position, m.pos)) < returnRadius) { //near player
+ this.endCycle = 0;
+ // if (m.energy < 0.05) {
+ // m.fireCDcycle = m.cycle + 80 * b.fireCDscale; //fire cooldown is much longer when out of energy
+ // } else if (m.cycle + 20 * b.fireCDscale < m.fireCDcycle) {
+ // if (m.energy > 0.05) m.fireCDcycle = m.cycle + 20 * b.fireCDscale //lower cd to 25 if it is above 25
+ // }
+ //recoil on catching
+ const momentum = Vector.mult(Vector.sub(this.velocity, player.velocity), (m.crouch ? 0.0001 : 0.0002))
+ player.force.x += momentum.x
+ player.force.y += momentum.y
+ // refund ammo
+ if (isReturnAmmo) {
+ b.guns[9].ammo++;
+ if (level.is2xAmmo) b.guns[9].ammo++;
+ simulation.updateGunHUD();
+ // for (i = 0, len = b.guns.length; i < len; i++) { //find which gun
+ // if (b.guns[i].name === "harpoon") {
+ // break;
+ // }
+ // }
+ }
+ } else {
+ const sub = Vector.sub(this.position, m.pos)
+ const rangeScale = 1 + 0.000001 * Vector.magnitude(sub) * Vector.magnitude(sub) //return faster when far from player
+ const returnForce = Vector.mult(Vector.normalise(sub), rangeScale * thrust * this.mass)
+ if (m.energy > this.drain) m.energy -= this.drain
+ if (m.energy < 0.05) {
+ this.force.x -= returnForce.x * 0.15
+ this.force.y -= returnForce.y * 0.15
+ } else { //if (m.cycle + 20 * b.fireCDscale < m.fireCDcycle)
+ this.force.x -= returnForce.x
+ this.force.y -= returnForce.y
+ }
+ this.grabPowerUp()
+ }
+ this.draw();
+ },
+ grabPowerUp() { //grab power ups near the tip of the harpoon
+ if (this.caughtPowerUp) {
+ Matter.Body.setPosition(this.caughtPowerUp, Vector.add(this.vertices[2], this.velocity))
+ Matter.Body.setVelocity(this.caughtPowerUp, { x: 0, y: 0 })
+ } else { //&& simulation.cycle % 2
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ if (tech.isEnergyNoAmmo && powerUp[i].name === "ammo") continue
+ const radius = powerUp[i].circleRadius + 50
+ if (Vector.magnitudeSquared(Vector.sub(this.vertices[2], powerUp[i].position)) < radius * radius && !powerUp[i].isGrabbed) {
+ if (powerUp[i].name !== "heal" || m.health !== m.maxHealth || tech.isOverHeal) {
+ powerUp[i].isGrabbed = true
+ this.caughtPowerUp = powerUp[i]
+ Matter.Body.setVelocity(powerUp[i], { x: 0, y: 0 })
+ Matter.Body.setPosition(powerUp[i], this.vertices[2])
+ powerUp[i].collisionFilter.category = 0
+ powerUp[i].collisionFilter.mask = 0
+ thrust *= 0.6
+ this.endCycle += 0.5 //it pulls back slower, so this prevents it from ending early
+ break //just pull 1 power up if possible
+ }
+ }
+ }
+ }
+ },
+ do() {
+ this.cycle++
+ if (isReturn || target) {
+ if (isReturn) {
+ if (this.cycle > totalCycles) { //return to player //|| !input.fire
+ this.do = this.returnToPlayer
+ if (this.angularSpeed < 0.5) this.torque += this.inertia * 0.001 * (Math.random() - 0.5) //(Math.round(Math.random()) ? 1 : -1)
+ Matter.Sleeping.set(this, false)
+ this.endCycle = simulation.cycle + 240
+ const momentum = Vector.mult(Vector.sub(this.velocity, player.velocity), (m.crouch ? 0.00015 : 0.0003)) //recoil on jerking line
+ player.force.x += momentum.x
+ player.force.y += momentum.y
+ requestAnimationFrame(() => { //delay this for 1 cycle to get the proper hit graphics
+ this.collisionFilter.category = 0
+ this.collisionFilter.mask = 0
+ });
+ } else {
+ this.grabPowerUp()
+ }
+ }
+ if (target) { //rotate towards the target
+ const face = {
+ x: Math.cos(this.angle),
+ y: Math.sin(this.angle)
+ };
+ const vectorGoal = Vector.normalise(Vector.sub(this.position, target.position));
+ if (Vector.cross(vectorGoal, face) > 0) {
+ Matter.Body.rotate(this, this.turnRate);
+ } else {
+ Matter.Body.rotate(this, -this.turnRate);
+ }
+ }
+ this.force.x += thrust * this.mass * Math.cos(this.angle);
+ this.force.y += thrust * this.mass * Math.sin(this.angle);
+ }
+ this.draw()
+ },
+ });
+ if (!isReturn && !target) {
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.7 * player.velocity.x + 600 * thrust * Math.cos(bullet[me].angle),
+ y: 0.5 * player.velocity.x + 600 * thrust * Math.sin(bullet[me].angle)
+ });
+ bullet[me].frictionAir = 0.002
+ bullet[me].do = function () {
+ if (this.speed < 20) this.force.y += 0.0005 * this.mass;
+ this.draw();
+ }
+ }
+ if (tech.isHarpoonPowerUp && simulation.cycle - 480 < tech.harpoonPowerUpCycle) { //8 seconds
+ if (isReturn) {
+ bullet[me].draw = function () {
+ this.drawDamageAura()
+ this.drawString()
+ }
+ } else {
+ bullet[me].draw = function () {
+ this.drawDamageAura()
+ }
+ }
+ } else if (isReturn) {
+ bullet[me].draw = function () {
+ this.drawString()
+ }
+ }
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ missile(where, angle, speed, size = 1) {
+ if (tech.isMissileBig) {
+ size *= 1.55
+ if (tech.isMissileBiggest) {
+ size *= 1.55
+
+ }
+ }
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(where.x, where.y, 30 * size, 4 * size, {
+ angle: angle,
+ friction: 0.5,
+ frictionAir: 0.045,
+ dmg: 0, //damage done in addition to the damage from momentum
+ classType: "bullet",
+ endCycle: simulation.cycle + Math.floor((230 + 40 * Math.random()) * tech.bulletsLastLonger + 120 * tech.isMissileBiggest + 60 * tech.isMissileBig),
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ minDmgSpeed: 10,
+ lookFrequency: Math.floor(10 + Math.random() * 3),
+ explodeRad: (tech.isMissileBig ? 230 : 180) + 60 * Math.random(),
+ density: 0.02, //0.001 is normal
+ beforeDmg() {
+ Matter.Body.setDensity(this, 0.0001); //reduce density to normal
+ this.tryToLockOn();
+ this.endCycle = 0; //bullet ends cycle after doing damage // also triggers explosion
+ },
+ onEnd() {
+ b.explosion(this.position, this.explodeRad * size); //makes bullet do explosive damage at end
+ if (tech.fragments) b.targetedNail(this.position, tech.fragments * Math.floor(2 + 1.5 * Math.random()))
+ },
+ lockedOn: null,
+ tryToLockOn() {
+ let closeDist = Infinity;
+ const futurePos = Vector.add(this.position, Vector.mult(this.velocity, 30)) //look for closest target to where the missile will be in 30 cycles
+ this.lockedOn = null;
+ // const futurePos = this.lockedOn ? :Vector.add(this.position, Vector.mult(this.velocity, 50))
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (
+ mob[i].alive && !mob[i].isBadTarget &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ const futureDist = Vector.magnitude(Vector.sub(futurePos, mob[i].position));
+ if (futureDist < closeDist) {
+ closeDist = futureDist;
+ this.lockedOn = mob[i];
+ // this.frictionAir = 0.04; //extra friction once a target it locked
+ }
+ if (Vector.magnitude(Vector.sub(this.position, mob[i].position) < this.explodeRad)) {
+ this.endCycle = 0; //bullet ends cycle after doing damage //also triggers explosion
+ mob[i].lockedOn.damage(m.dmgScale * 2 * size); //does extra damage to target
+ }
+ }
+ }
+ //explode when bullet is close enough to target
+ if (this.lockedOn && Vector.magnitude(Vector.sub(this.position, this.lockedOn.position)) < this.explodeRad) {
+ this.endCycle = 0; //bullet ends cycle after doing damage //also triggers explosion
+ this.lockedOn.damage(m.dmgScale * 4 * size); //does extra damage to target
+ }
+ },
+ do() {
+ if (!(m.cycle % this.lookFrequency)) this.tryToLockOn();
+ if (this.lockedOn) { //rotate missile towards the target
+ const face = {
+ x: Math.cos(this.angle),
+ y: Math.sin(this.angle)
+ };
+ const target = Vector.normalise(Vector.sub(this.position, this.lockedOn.position));
+ const dot = Vector.dot(target, face)
+ const aim = Math.min(0.08, (1 + dot) * 1)
+ if (Vector.cross(target, face) > 0) {
+ Matter.Body.rotate(this, aim);
+ } else {
+ Matter.Body.rotate(this, -aim);
+ }
+ this.frictionAir = Math.min(0.1, Math.max(0.04, 1 + dot)) //0.08; //extra friction if turning
+ }
+ //accelerate in direction bullet is facing
+ const dir = this.angle;
+ this.force.x += thrust * Math.cos(dir);
+ this.force.y += thrust * Math.sin(dir);
+
+ ctx.beginPath(); //draw rocket
+ ctx.arc(this.position.x - Math.cos(this.angle) * (25 * size - 3) + (Math.random() - 0.5) * 4,
+ this.position.y - Math.sin(this.angle) * (25 * size - 3) + (Math.random() - 0.5) * 4,
+ 11 * size, 0, 2 * Math.PI);
+ ctx.fillStyle = "rgba(255,155,0,0.5)";
+ ctx.fill();
+ },
+ });
+ const thrust = 0.0066 * bullet[me].mass * (tech.isMissileBig ? (tech.isMissileBiggest ? 0.3 : 0.7) : 1);
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.5 * player.velocity.x + speed * Math.cos(angle),
+ y: 0.5 * player.velocity.y + speed * Math.sin(angle)
+ });
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ lastAngle: 0,
+ wasExtruderOn: false,
+ isExtruderOn: false,
+ didExtruderDrain: false,
+ canExtruderFire: true,
+ extruder() {
+ const DRAIN = 0.0012
+ if (m.energy > DRAIN && b.canExtruderFire) {
+ m.energy -= DRAIN
+ if (m.energy < 0) {
+ m.fieldCDcycle = m.cycle + 120;
+ m.energy = 0;
+ }
+ b.isExtruderOn = true
+ const SPEED = 8 + 12 * tech.isPlasmaRange
+ const me = bullet.length;
+ const where = Vector.add(m.pos, player.velocity)
+ bullet[me] = Bodies.polygon(where.x + 20 * Math.cos(m.angle), where.y + 20 * Math.sin(m.angle), 4, 0.01, {
+ cycle: -0.5,
+ isWave: true,
+ endCycle: simulation.cycle + 40, // + 30 * tech.isPlasmaRange,
+ inertia: Infinity,
+ frictionAir: 0,
+ isInHole: true, //this keeps the bullet from entering wormholes
+ minDmgSpeed: 0,
+ dmg: m.dmgScale * 2.7, //damage also changes when you divide by mob.mass on in .do()
+ classType: "bullet",
+ isBranch: false,
+ restitution: 0,
+ collisionFilter: {
+ // category: 0,
+ // mask: 0, //cat.mob | cat.mobBullet | cat.mobShield
+ category: 0, //cat.bullet,
+ mask: 0, //cat.map, //cat.mob | cat.mobBullet | cat.mobShield
+ },
+ beforeDmg() { },
+ onEnd() { },
+ do() {
+ if (this.endCycle < simulation.cycle + 1) this.isWave = false
+ if (Matter.Query.point(map, this.position).length) { //check if inside map //|| Matter.Query.point(body, this.position).length
+ this.isBranch = true;
+ this.do = () => {
+ if (this.endCycle < simulation.cycle + 1) this.isWave = false
+ }
+ } else { //check if inside a mob
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position))
+ const radius = mob[i].radius + tech.extruderRange / 2
+ if (dist < radius * radius) {
+ if (mob[i].speed > 2) {
+ if (mob[i].isBoss || mob[i].isShielded) {
+ Matter.Body.setVelocity(mob[i], { x: mob[i].velocity.x * 0.95, y: mob[i].velocity.y * 0.95 });
+ } else {
+ Matter.Body.setVelocity(mob[i], { x: mob[i].velocity.x * 0.25, y: mob[i].velocity.y * 0.25 });
+ }
+ }
+ // Matter.Body.setPosition(this, Vector.add(this.position, mob[i].velocity)) //move with the medium
+ let dmg = this.dmg / Math.min(10, mob[i].mass)
+ mob[i].damage(dmg);
+ if (mob[i].alive) mob[i].foundPlayer();
+ }
+ }
+ }
+ this.cycle++
+ const wiggleMag = (m.crouch ? 6 : 12) * Math.cos(simulation.cycle * 0.09)
+ const wiggle = Vector.mult(transverse, wiggleMag * Math.cos(this.cycle * 0.36)) //+ wiggleMag * Math.cos(simulation.cycle * 0.3))
+ const velocity = Vector.mult(player.velocity, 0.4) //move with player
+ Matter.Body.setPosition(this, Vector.add(velocity, Vector.add(this.position, wiggle)))
+ }
+ });
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ Matter.Body.setVelocity(bullet[me], {
+ x: SPEED * Math.cos(m.angle),
+ y: SPEED * Math.sin(m.angle)
+ });
+ const transverse = Vector.normalise(Vector.perp(bullet[me].velocity))
+ if (180 - Math.abs(Math.abs(b.lastAngle - m.angle) - 180) > 0.13 || !b.wasExtruderOn) {
+ bullet[me].isBranch = true; //don't draw stroke for this bullet
+ bullet[me].do = function () {
+ if (this.endCycle < simulation.cycle + 1) this.isWave = false
+ }
+ }
+ b.lastAngle = m.angle //track last angle for the above angle difference calculation
+ } else {
+ b.canExtruderFire = false;
+ }
+ },
+ plasma() {
+ const DRAIN = 0.00075
+ if (m.energy > DRAIN) {
+ m.energy -= DRAIN;
+ if (m.energy < 0) {
+ m.fieldCDcycle = m.cycle + 120;
+ m.energy = 0;
+ }
+
+ //calculate laser collision
+ let range = tech.isPlasmaRange * (120 + (m.crouch ? 400 : 300) * Math.sqrt(Math.random())) //+ 100 * Math.sin(m.cycle * 0.3);
+ // const dir = m.angle // + 0.04 * (Math.random() - 0.5)
+ const path = [
+ { x: m.pos.x + 20 * Math.cos(m.angle), y: m.pos.y + 20 * Math.sin(m.angle) },
+ { x: m.pos.x + range * Math.cos(m.angle), y: m.pos.y + range * Math.sin(m.angle) }
+ ];
+ //check for collisions
+ let best = {
+ x: null,
+ y: null,
+ dist2: Infinity,
+ who: null,
+ v1: null,
+ v2: null
+ };
+ best = vertexCollision(path[0], path[1], [mob, map, body]);
+ if (best.dist2 != Infinity) { //if hitting something
+ path[path.length - 1] = { x: best.x, y: best.y };
+ if (best.who.alive) {
+ const dmg = 0.9 * m.dmgScale; //********** SCALE DAMAGE HERE *********************
+ best.who.damage(dmg);
+ best.who.locatePlayer();
+
+ //push mobs away
+ if (best.who.speed > 3) {
+ const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.005 * Math.min(5, best.who.mass))
+ Matter.Body.applyForce(best.who, path[1], force)
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.4, y: best.who.velocity.y * 0.4 });
+ } else {
+ const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.01 * Math.min(5, best.who.mass))
+ Matter.Body.applyForce(best.who, path[1], force)
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.7, y: best.who.velocity.y * 0.7 });
+ }
+ //draw mob damage circle
+ simulation.drawList.push({
+ x: path[1].x,
+ y: path[1].y,
+ radius: Math.sqrt(2000 * dmg * best.who.damageReduction),
+ color: "rgba(255,0,255,0.2)",
+ time: simulation.drawTime * 4
+ });
+ } else if (!best.who.isStatic) {
+ //push blocks away
+ const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.007 * Math.sqrt(Math.sqrt(best.who.mass)))
+ Matter.Body.applyForce(best.who, path[1], force)
+ }
+ }
+
+ //draw blowtorch laser beam
+ ctx.strokeStyle = "rgba(255,0,255,0.1)"
+ ctx.lineWidth = 14
+ ctx.beginPath();
+ ctx.moveTo(path[0].x, path[0].y);
+ ctx.lineTo(path[1].x, path[1].y);
+ ctx.stroke();
+ ctx.strokeStyle = "#f0f";
+ ctx.lineWidth = 2
+ ctx.stroke();
+
+ //draw electricity
+ const Dx = Math.cos(m.angle);
+ const Dy = Math.sin(m.angle);
+ let x = m.pos.x + 20 * Dx;
+ let y = m.pos.y + 20 * Dy;
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ const step = Vector.magnitude(Vector.sub(path[0], path[1])) / 10
+ for (let i = 0; i < 8; i++) {
+ x += step * (Dx + 1.5 * (Math.random() - 0.5))
+ y += step * (Dy + 1.5 * (Math.random() - 0.5))
+ ctx.lineTo(x, y);
+ }
+ ctx.lineWidth = 2 * Math.random();
+ ctx.stroke();
+ }
+ },
+ laser(where = {
+ x: m.pos.x + 20 * Math.cos(m.angle),
+ y: m.pos.y + 20 * Math.sin(m.angle)
+ }, whereEnd = {
+ x: where.x + 3000 * Math.cos(m.angle),
+ y: where.y + 3000 * Math.sin(m.angle)
+ }, dmg = tech.laserDamage, reflections = tech.laserReflections, isThickBeam = false, push = 1) {
+ const reflectivity = 1 - 1 / (reflections * 3)
+ let damage = m.dmgScale * dmg
+ let best = { x: 1, y: 1, dist2: Infinity, who: null, v1: 1, v2: 1 };
+ const path = [{ x: where.x, y: where.y }, { x: whereEnd.x, y: whereEnd.y }];
+
+ const checkForCollisions = function () {
+ best = vertexCollision(path[path.length - 2], path[path.length - 1], [mob, map, body]);
+ };
+ const laserHitMob = function () {
+ if (best.who.alive) {
+ best.who.locatePlayer();
+ if (best.who.damageReduction) {
+ if ( //iridescence
+ tech.laserCrit && !best.who.shield &&
+ Vector.dot(Vector.normalise(Vector.sub(best.who.position, path[path.length - 1])), Vector.normalise(Vector.sub(path[path.length - 1], path[path.length - 2]))) > 0.999 - 0.5 / best.who.radius
+ ) {
+ damage *= 1 + tech.laserCrit
+ simulation.drawList.push({ //add dmg to draw queue
+ x: path[path.length - 1].x,
+ y: path[path.length - 1].y,
+ radius: Math.sqrt(2500 * damage * best.who.damageReduction) + 5,
+ color: `hsla(${60 + 283 * Math.random()},100%,70%,0.5)`, // random hue, but not red
+ time: 16
+ });
+ } else {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: path[path.length - 1].x,
+ y: path[path.length - 1].y,
+ radius: Math.sqrt(2000 * damage * best.who.damageReduction) + 2,
+ color: tech.laserColorAlpha,
+ time: simulation.drawTime
+ });
+ }
+ best.who.damage(damage);
+ }
+ if (tech.isLaserPush) { //push mobs away
+ const index = path.length - 1
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.97, y: best.who.velocity.y * 0.97 });
+ const force = Vector.mult(Vector.normalise(Vector.sub(path[index], path[Math.max(0, index - 1)])), 0.003 * push * Math.min(6, best.who.mass))
+ Matter.Body.applyForce(best.who, path[index], force)
+ }
+ } else if (tech.isLaserPush && best.who.classType === "body") {
+ const index = path.length - 1
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.97, y: best.who.velocity.y * 0.97 });
+ const force = Vector.mult(Vector.normalise(Vector.sub(path[index], path[Math.max(0, index - 1)])), 0.003 * push * Math.min(6, best.who.mass))
+ Matter.Body.applyForce(best.who, path[index], force)
+ }
+ };
+ const reflection = function () { // https://math.stackexchange.com/questions/13261/how-to-get-a-reflection-vector
+ const n = Vector.perp(Vector.normalise(Vector.sub(best.v1, best.v2)));
+ const d = Vector.sub(path[path.length - 1], path[path.length - 2]);
+ const nn = Vector.mult(n, 2 * Vector.dot(d, n));
+ const r = Vector.normalise(Vector.sub(d, nn));
+ path[path.length] = Vector.add(Vector.mult(r, 3000), path[path.length - 1]);
+ };
+
+ checkForCollisions();
+ let lastBestOdd
+ let lastBestEven = best.who //used in hack below
+ if (best.dist2 !== Infinity) { //if hitting something
+ path[path.length - 1] = { x: best.x, y: best.y };
+ laserHitMob();
+ for (let i = 0; i < reflections; i++) {
+ reflection();
+ checkForCollisions();
+ if (best.dist2 !== Infinity) { //if hitting something
+ lastReflection = best
+ path[path.length - 1] = { x: best.x, y: best.y };
+ damage *= reflectivity
+ laserHitMob();
+ //I'm not clear on how this works, but it gets rid of a bug where the laser reflects inside a block, often vertically.
+ //I think it checks to see if the laser is reflecting off a different part of the same block, if it is "inside" a block
+ if (i % 2) {
+ if (lastBestOdd === best.who) break
+ } else {
+ lastBestOdd = best.who
+ if (lastBestEven === best.who) break
+ }
+ } else {
+ break
+ }
+ }
+ }
+ if (isThickBeam) {
+ for (let i = 1, len = path.length; i < len; ++i) {
+ ctx.moveTo(path[i - 1].x, path[i - 1].y);
+ ctx.lineTo(path[i].x, path[i].y);
+ }
+ } else if (tech.isLaserLens && b.guns[11].lensDamage !== 1) {
+ ctx.strokeStyle = tech.laserColor;
+ ctx.lineWidth = 2
+ ctx.lineDashOffset = 900 * Math.random()
+ ctx.setLineDash([50 + 120 * Math.random(), 50 * Math.random()]);
+ for (let i = 1, len = path.length; i < len; ++i) {
+ ctx.beginPath();
+ ctx.moveTo(path[i - 1].x, path[i - 1].y);
+ ctx.lineTo(path[i].x, path[i].y);
+ ctx.stroke();
+ ctx.globalAlpha *= reflectivity; //reflections are less intense
+ }
+ ctx.setLineDash([]);
+ // ctx.globalAlpha = 1;
+
+ //glow
+ ctx.lineWidth = 9 + 2 * b.guns[11].lensDamageOn
+ ctx.globalAlpha = 0.13
+ ctx.beginPath();
+ for (let i = 1, len = path.length; i < len; ++i) {
+ ctx.moveTo(path[i - 1].x, path[i - 1].y);
+ ctx.lineTo(path[i].x, path[i].y);
+ }
+ ctx.stroke();
+ ctx.globalAlpha = 1;
+ } else {
+ ctx.strokeStyle = tech.laserColor;
+ ctx.lineWidth = 2
+ ctx.lineDashOffset = 900 * Math.random()
+ ctx.setLineDash([50 + 120 * Math.random(), 50 * Math.random()]);
+ for (let i = 1, len = path.length; i < len; ++i) {
+ ctx.beginPath();
+ ctx.moveTo(path[i - 1].x, path[i - 1].y);
+ ctx.lineTo(path[i].x, path[i].y);
+ ctx.stroke();
+ ctx.globalAlpha *= reflectivity; //reflections are less intense
+ }
+ ctx.setLineDash([]);
+ ctx.globalAlpha = 1;
+ }
+ },
+ AoEStunEffect(where, range, cycles = 120 + 60 * Math.random()) {
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (mob[i].alive && !mob[i].isShielded && !mob[i].shield && !mob[i].isBadTarget) {
+ if (Vector.magnitude(Vector.sub(where, mob[i].position)) - mob[i].radius < range) mobs.statusStun(mob[i], cycles)
+ }
+ }
+ simulation.drawList.push({
+ x: where.x,
+ y: where.y,
+ radius: range,
+ color: "rgba(0,0,0,0.1)",
+ time: 15
+ });
+ },
+ laserMine(position, velocity = {
+ x: 0,
+ y: -8
+ }) {
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(position.x, position.y, 3, 25, {
+ bulletType: "laser mine",
+ angle: m.angle,
+ friction: 0,
+ frictionAir: 0.025,
+ restitution: 0.5,
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ lookFrequency: 67 + Math.floor(7 * Math.random()),
+ drain: 0.7 * tech.laserDrain,
+ isDetonated: false,
+ torqueMagnitude: 0.000003 * (Math.round(Math.random()) ? 1 : -1),
+ range: 1500,
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ beforeDmg() { },
+ onEnd() { },
+ do() {
+ if (!(simulation.cycle % this.lookFrequency) && m.energy > this.drain) { //find mob targets
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (
+ Vector.magnitude(Vector.sub(this.position, mob[i].position)) < 1300 &&
+ !mob[i].isBadTarget &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0
+ ) {
+ if (tech.isStun) b.AoEStunEffect(this.position, 1300); //AoEStunEffect(where, range, cycles = 90 + 60 * Math.random()) {
+ this.do = this.laserSpin
+ if (this.angularSpeed < 0.5) this.torque += this.inertia * this.torqueMagnitude * 200 //spin
+ this.endCycle = simulation.cycle + 360 + 120
+ // if (this.angularSpeed < 0.01) this.torque += this.inertia * this.torqueMagnitude * 5 //spin
+ this.isDetonated = true
+ break
+ }
+ }
+ }
+ },
+ reflections: Math.max(0, tech.laserReflections - 2),
+ laserSpin() {
+ //drain energy
+ if (m.energy > this.drain) {
+ m.energy -= this.drain
+ if (this.angularSpeed < 0.05) this.torque += this.inertia * this.torqueMagnitude //spin
+
+ //fire lasers
+ ctx.strokeStyle = tech.laserColor;
+ ctx.lineWidth = 1.5
+ // ctx.globalAlpha = 1;
+ ctx.beginPath();
+ for (let i = 0; i < 3; i++) {
+ const where = this.vertices[i]
+ const endPoint = Vector.add(where, Vector.mult(Vector.normalise(Vector.sub(where, this.position)), 2500))
+ b.laser(where, endPoint, tech.laserDamage * 13, this.reflections, true)
+ }
+ ctx.stroke();
+ // ctx.globalAlpha = 1;
+ }
+ if (this.endCycle - 60 < simulation.cycle) {
+ this.do = () => { } //no nothing, no laser, no spin
+ }
+ },
+ })
+ Matter.Body.setVelocity(bullet[me], velocity);
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ mine(where, velocity, angle = 0) {
+ const bIndex = bullet.length;
+ bullet[bIndex] = Bodies.rectangle(where.x, where.y, 45, 16, {
+ angle: angle,
+ friction: 1,
+ frictionStatic: 1,
+ frictionAir: 0,
+ restitution: 0,
+ dmg: 0, //damage done in addition to the damage from momentum
+ classType: "bullet",
+ bulletType: "mine",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield // | cat.bullet //doesn't collide with other bullets until it lands (was crashing into bots)
+ },
+ minDmgSpeed: 5,
+ stillCount: 0,
+ isArmed: false,
+ endCycle: Infinity,
+ lookFrequency: 0,
+ range: 700 - 300 * tech.isFoamMine,
+ beforeDmg() { },
+ onEnd() {
+ if (this.isArmed && !tech.isMineSentry) {
+ if (tech.isFoamMine) {
+ //send 14 in random directions slowly
+ for (let i = 0; i < 12; i++) {
+ const radius = 13 + 8 * Math.random()
+ const velocity = { x: 0.5 + 5.5 * Math.random(), y: 0 }
+ b.foam(this.position, Vector.rotate(velocity, this.angle + 1.57 + 3 * (Math.random() - 0.5)), radius) //6.28 * Math.random()
+ }
+ //send 40 targeted
+ let count = 0
+ let cycle = () => {
+ if (count < 50) {
+ if (!simulation.paused && !simulation.isChoosing) { //!(simulation.cycle % 1) &&
+ count++
+ b.targetedFoam(this.position)
+ }
+ requestAnimationFrame(cycle);
+ }
+ }
+ requestAnimationFrame(cycle)
+ } else if (tech.isSuperMine) {
+ b.targetedBall(this.position, 22 + 2 * tech.extraSuperBalls)
+ } else {
+ b.targetedNail(this.position, 22, 40 + 10 * Math.random(), 1200, 2.2)
+ }
+ }
+ },
+ do() {
+ this.force.y += this.mass * 0.002; //extra gravity
+ let collide = Matter.Query.collides(this, map) //check if collides with map
+ if (collide.length > 0) {
+ for (let i = 0; i < collide.length; i++) {
+ if (collide[i].bodyA.collisionFilter.category === cat.map) { // || collide[i].bodyB.collisionFilter.category === cat.map) {
+ const angle = Vector.angle(collide[i].normal, { x: 1, y: 0 })
+ Matter.Body.setAngle(this, Math.atan2(collide[i].tangent.y, collide[i].tangent.x))
+ for (let j = 0; j < 10; j++) { //move until touching map again after rotation
+ if (Matter.Query.collides(this, map).length > 0) { //touching map
+ if (angle > -0.2 || angle < -1.5) { //don't stick to level ground
+ Matter.Body.setVelocity(this, { x: 0, y: 0 });
+ Matter.Body.setStatic(this, true) //don't set to static if not touching map
+ this.collisionFilter.category = 0
+ this.collisionFilter.mask = 0 //cat.map | cat.bullet
+ } else {
+ Matter.Body.setVelocity(this, { x: 0, y: 0 });
+ Matter.Body.setAngularVelocity(this, 0)
+ }
+ this.arm();
+ //sometimes the mine can't attach to map and it just needs to be reset
+ setTimeout(() => {
+ if (Matter.Query.collides(this, map).length === 0 || Matter.Query.point(map, this.position).length > 0) {
+ this.endCycle = 0 // if not touching map explode
+ this.isArmed = false
+ b.mine(this.position, this.velocity, this.angle)
+ }
+ }, 100);
+ break
+ }
+ Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(collide[i].normal, 2))) //move until you are touching the wall
+ }
+ break
+ }
+ }
+ } else {
+ if (this.speed < 1 && this.angularSpeed < 0.01) this.stillCount++
+ }
+ if (this.stillCount > 25) this.arm();
+ },
+ arm() {
+ this.collisionFilter.mask = cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield | cat.bullet //can now collide with other bullets
+ this.lookFrequency = simulation.cycle + 60
+ this.do = function () { //overwrite the do method for this bullet
+ this.force.y += this.mass * 0.002; //extra gravity
+ if (simulation.cycle > this.lookFrequency) {
+ this.isArmed = true
+ this.lookFrequency = 55 + Math.floor(22 * Math.random())
+ simulation.drawList.push({ x: this.position.x, y: this.position.y, radius: 10, color: "#f00", time: 4 });
+ this.do = function () { //overwrite the do method for this bullet
+ this.force.y += this.mass * 0.002; //extra gravity
+ if (!(simulation.cycle % this.lookFrequency)) { //find mob targets
+ const random = 300 * Math.random()
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (
+ !mob[i].isBadTarget &&
+ !mob[i].isInvulnerable &&
+ Vector.magnitude(Vector.sub(this.position, mob[i].position)) < this.range + mob[i].radius + random &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0
+ ) {
+ if (tech.isStun) b.AoEStunEffect(this.position, this.range + mob[i].radius + random); //AoEStunEffect(where, range, cycles = 90 + 60 * Math.random()) {
+ if (tech.isMineSentry) {
+ this.lookFrequency = Math.floor(7 + 7 * b.fireCDscale + 10 * (tech.oneSuperBall && tech.isSuperMine) + Math.floor(3 * Math.random()))
+ // this.endCycle = Infinity
+ this.shots = tech.sentryAmmo
+ this.do = function () { //overwrite the do method for this bullet
+ this.force.y += this.mass * 0.002; //extra gravity
+ if (!(simulation.cycle % this.lookFrequency)) { //find mob targets
+ if (tech.isFoamMine) {
+ this.shots -= 0.6 * b.targetedFoam(this.position, 1, 21 + 7 * Math.random(), 1200, false)
+ b.targetedFoam(this.position, 1, 21 + 7 * Math.random(), 1200, false)
+ } else if (tech.isSuperMine) {
+ const cost = tech.oneSuperBall ? 2 : 0.7
+ this.shots -= cost * b.targetedBall(this.position, 1, 42 + 12 * Math.random(), 1200, false)
+ for (let i = 0, len = tech.extraSuperBalls / 4; i < len; i++) {
+ if (Math.random() < 0.33) b.targetedBall(this.position, 1, 42 + 12 * Math.random(), 1200, false)
+ }
+ } else {
+ this.shots -= b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, 2.3)
+ }
+ if (this.shots < 0) this.endCycle = 0
+ if (!(simulation.cycle % (this.lookFrequency * 6))) {
+ simulation.drawList.push({ x: this.position.x, y: this.position.y, radius: 8, color: "#fe0", time: 4 });
+ }
+ }
+ }
+ break
+ } else {
+ this.endCycle = 0 //end life if mob is near and visible
+ break
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ });
+ bullet[bIndex].torque += bullet[bIndex].inertia * 0.0002 * (0.5 - Math.random())
+ Matter.Body.setVelocity(bullet[bIndex], velocity);
+ Composite.add(engine.world, bullet[bIndex]); //add bullet to world
+ },
+ worm(where, isFreeze = tech.isSporeFreeze) { //used with the tech upgrade in mob.death()
+ const bIndex = bullet.length;
+ const wormSize = 6 + tech.wormSize * 4.2 * Math.random()
+ if (bIndex < 500) { //can't make over 500 spores
+ bullet[bIndex] = Bodies.polygon(where.x, where.y, 3, 3, {
+ inertia: Infinity,
+ isFreeze: isFreeze,
+ restitution: 0.5,
+ // angle: Math.random() * 2 * Math.PI,
+ friction: 0,
+ frictionAir: 0.025,
+ thrust: (tech.isSporeFollow ? 0.0012 : 0.00055) * (1 + 0.5 * (Math.random() - 0.5)),
+ wormSize: wormSize,
+ wormTail: 1 + Math.max(4, Math.min(wormSize - 2 * tech.wormSize, 30)),
+ dmg: (tech.isMutualism ? 9.5 : 3.2) * wormSize,
+ lookFrequency: 100 + Math.floor(37 * Math.random()),
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.mob | cat.mobBullet | cat.mobShield //no collide with body
+ },
+ endCycle: simulation.cycle + Math.floor((600 + Math.floor(Math.random() * 420)) * tech.bulletsLastLonger),
+ minDmgSpeed: 0,
+ playerOffPosition: { //used when moving towards player to keep spores separate
+ x: 100 * (Math.random() - 0.5),
+ y: 100 * (Math.random() - 0.5)
+ },
+ beforeDmg(who) {
+ if (who.isInvulnerable) {
+ Matter.Body.setVelocity(this, Vector.mult(this.velocity, 0.1));
+ } else {
+ if (tech.isSpawnBulletsOnDeath && who.alive && who.isDropPowerUp) {
+ setTimeout(() => {
+ if (!who.alive) {
+ for (let i = 0; i < 3; i++) { //spawn 3 more
+ b.worm(this.position)
+ bullet[bullet.length - 1].endCycle = Math.min(simulation.cycle + Math.floor(420 * tech.bulletsLastLonger), this.endCycle + 180 + Math.floor(60 * Math.random())) //simulation.cycle + Math.floor(420 * tech.bulletsLastLonger)
+ }
+ }
+ this.endCycle = 0; //bullet ends cycle after doing damage
+ }, 1);
+ } else {
+ this.endCycle = 0; //bullet ends cycle after doing damage
+ }
+ if (this.isFreeze) mobs.statusSlow(who, 90)
+ }
+ },
+ onEnd() {
+ if (tech.isMutualism && this.isMutualismActive && !tech.isEnergyHealth) {
+ m.health += 0.02
+ if (m.health > m.maxHealth) m.health = m.maxHealth;
+ m.displayHealth();
+ }
+ },
+ tailCycle: 6.28 * Math.random(),
+ do() {
+ this.tailCycle += this.speed * 0.025
+ ctx.beginPath(); //draw nematode
+ ctx.moveTo(this.position.x, this.position.y);
+ // const dir = Vector.mult(Vector.normalise(this.velocity), -Math.min(100, this.wormTail * this.speed))
+ const speed = Math.min(7, this.speed)
+ const dir = Vector.mult(Vector.normalise(this.velocity), -0.6 * this.wormTail * speed)
+ const tail = Vector.add(this.position, dir)
+ const wiggle = Vector.add(Vector.add(tail, dir), Vector.rotate(dir, Math.sin(this.tailCycle)))
+ // const wiggle = Vector.add(tail, Vector.rotate(dir, Math.sin((m.cycle - this.endCycle) * 0.03 * this.speed)))
+ ctx.quadraticCurveTo(tail.x, tail.y, wiggle.x, wiggle.y) // ctx.quadraticCurveTo(controlPoint.x, controlPoint.y, this.vertices[0].x, this.vertices[0].y)
+ // ctx.lineTo(tail.x, tail.y);
+ ctx.lineWidth = this.wormSize;
+ ctx.strokeStyle = "#000";
+ ctx.stroke();
+
+
+ if (this.lockedOn && this.lockedOn.alive) {
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), this.mass * this.thrust)
+ } else {
+ if (!(simulation.cycle % this.lookFrequency)) { //find mob targets
+ this.closestTarget = null;
+ this.lockedOn = null;
+ let closeDist = Infinity;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (!mob[i].isBadTarget && Matter.Query.ray(map, this.position, mob[i].position).length === 0 && !mob[i].isInvulnerable) {
+ const targetVector = Vector.sub(this.position, mob[i].position)
+ const dist = Vector.magnitude(targetVector) * (Math.random() + 0.5);
+ if (dist < closeDist) {
+ this.closestTarget = mob[i].position;
+ closeDist = dist;
+ this.lockedOn = mob[i]
+ if (0.3 > Math.random()) break //doesn't always target the closest mob
+ }
+ }
+ }
+ }
+ if (tech.isSporeFollow && this.lockedOn === null) { //move towards player //checking for null means that the spores don't go after the player until it has looked and not found a target
+ const dx = this.position.x - m.pos.x;
+ const dy = this.position.y - m.pos.y;
+ if (dx * dx + dy * dy > 10000) {
+ this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, Vector.add(this.playerOffPosition, this.position))), this.mass * this.thrust)
+ }
+ } else {
+ const unit = Vector.normalise(this.velocity)
+ const force = Vector.mult(Vector.rotate(unit, 0.005 * this.playerOffPosition.x), 0.000003)
+ this.force.x += force.x
+ this.force.y += force.y
+ }
+ }
+ },
+ });
+ const SPEED = 2 + 1 * Math.random();
+ const ANGLE = 2 * Math.PI * Math.random()
+ Matter.Body.setVelocity(bullet[bIndex], {
+ x: SPEED * Math.cos(ANGLE),
+ y: SPEED * Math.sin(ANGLE)
+ });
+ Composite.add(engine.world, bullet[bIndex]); //add bullet to world
+ if (tech.isMutualism && m.health > 0.04) {
+ m.health -= 0.02
+ m.displayHealth();
+ bullet[bIndex].isMutualismActive = true
+ }
+ }
+ },
+ spore(where, isFreeze = tech.isSporeFreeze) { //used with the tech upgrade in mob.death()
+ const bIndex = bullet.length;
+ const size = 4
+ if (bIndex < 500) { //can't make over 500 spores
+ bullet[bIndex] = Bodies.polygon(where.x, where.y, size, size, {
+ // density: 0.0015, //frictionAir: 0.01,
+ inertia: Infinity,
+ isFreeze: isFreeze,
+ restitution: 0.5,
+ angle: Math.random() * 2 * Math.PI,
+ friction: 0,
+ frictionAir: 0.025,
+ thrust: (tech.isSporeFollow ? 0.0011 : 0.0005) * (1 + 0.3 * (Math.random() - 0.5)),
+ dmg: (tech.isMutualism ? 20 : 7), //bonus damage from tech.isMutualism
+ lookFrequency: 100 + Math.floor(117 * Math.random()),
+ classType: "bullet",
+ isSpore: true,
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.mob | cat.mobBullet | cat.mobShield //no collide with body
+ },
+ endCycle: simulation.cycle + Math.floor((540 + Math.floor(Math.random() * 420)) * tech.bulletsLastLonger),
+ minDmgSpeed: 0,
+ playerOffPosition: { //used when moving towards player to keep spores separate
+ x: 100 * (Math.random() - 0.5),
+ y: 100 * (Math.random() - 0.5)
+ },
+ beforeDmg(who) {
+ if (!who.isInvulnerable) {
+ this.endCycle = 0; //bullet ends cycle after doing damage
+ if (this.isFreeze) mobs.statusSlow(who, 90)
+ }
+ },
+ onEnd() {
+ if (tech.isMutualism && this.isMutualismActive && !tech.isEnergyHealth) {
+ m.health += 0.01
+ if (m.health > m.maxHealth) m.health = m.maxHealth;
+ m.displayHealth();
+ }
+ // console.log(this.dmg)
+ },
+ do() {
+ if (this.lockedOn && this.lockedOn.alive) {
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), this.mass * this.thrust)
+ } else {
+ if (!(simulation.cycle % this.lookFrequency)) { //find mob targets
+ this.closestTarget = null;
+ this.lockedOn = null;
+ let closeDist = Infinity;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (!mob[i].isBadTarget && Matter.Query.ray(map, this.position, mob[i].position).length === 0 && !mob[i].isInvulnerable) {
+ const targetVector = Vector.sub(this.position, mob[i].position)
+ const dist = Vector.magnitude(targetVector) * (Math.random() + 0.5);
+ if (dist < closeDist) {
+ this.closestTarget = mob[i].position;
+ closeDist = dist;
+ this.lockedOn = mob[i]
+ if (0.3 > Math.random()) break //doesn't always target the closest mob
+ }
+ }
+ }
+ }
+ if (tech.isSporeFollow && this.lockedOn === null) { //move towards player
+ //checking for null means that the spores don't go after the player until it has looked and not found a target
+ const dx = this.position.x - m.pos.x;
+ const dy = this.position.y - m.pos.y;
+ if (dx * dx + dy * dy > 10000) {
+ this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, Vector.add(this.playerOffPosition, this.position))), this.mass * this.thrust)
+ }
+ } else {
+ this.force.y += this.mass * 0.0001; //gravity
+ }
+
+ }
+
+ // if (!this.lockedOn && !(simulation.cycle % this.lookFrequency)) { //find mob targets
+ // this.closestTarget = null;
+ // this.lockedOn = null;
+ // let closeDist = Infinity;
+ // for (let i = 0, len = mob.length; i < len; ++i) {
+ // if (mob[i].isDropPowerUp && Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
+ // // Matter.Query.ray(body, this.position, mob[i].position).length === 0
+ // const targetVector = Vector.sub(this.position, mob[i].position)
+ // const dist = Vector.magnitude(targetVector);
+ // if (dist < closeDist) {
+ // this.closestTarget = mob[i].position;
+ // closeDist = dist;
+ // this.lockedOn = mob[i] //Vector.normalise(targetVector);
+ // if (0.3 > Math.random()) break //doesn't always target the closest mob
+ // }
+ // }
+ // }
+ // }
+ // if (this.lockedOn && this.lockedOn.alive) { //accelerate towards mobs
+ // this.force = Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), this.mass * this.thrust)
+ // } else if (tech.isSporeFollow && this.lockedOn !== undefined) { //move towards player
+ // //checking for undefined means that the spores don't go after the player until it has looked and not found a target
+ // const dx = this.position.x - m.pos.x;
+ // const dy = this.position.y - m.pos.y;
+ // if (dx * dx + dy * dy > 10000) {
+ // this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, Vector.add(this.playerOffPosition, this.position))), this.mass * this.thrust)
+ // }
+ // // this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, this.position)), this.mass * this.thrust)
+ // } else {
+ // this.force.y += this.mass * 0.0001; //gravity
+ // }
+
+ // if (this.nextPortCycle < simulation.cycle) { //teleport around if you have tech.isBulletTeleport
+ // this.nextPortCycle = simulation.cycle + this.portFrequency
+ // const range = 50 * Math.random()
+ // Matter.Body.setPosition(this, Vector.add(this.position, Vector.rotate({ x: range, y: 0 }, 2 * Math.PI * Math.random())))
+ // }
+ },
+ });
+ // if (tech.isBulletTeleport) {
+ // bullet[bIndex].portFrequency = 10 + Math.floor(5 * Math.random())
+ // bullet[bIndex].nextPortCycle = simulation.cycle + bullet[bIndex].portFrequency
+ // }
+
+ const SPEED = 4 + 8 * Math.random();
+ const ANGLE = 2 * Math.PI * Math.random()
+ Matter.Body.setVelocity(bullet[bIndex], {
+ x: SPEED * Math.cos(ANGLE),
+ y: SPEED * Math.sin(ANGLE)
+ });
+ Composite.add(engine.world, bullet[bIndex]); //add bullet to world
+
+ if (tech.isMutualism && m.health > 0.01) {
+ m.health -= 0.01
+ m.displayHealth();
+ bullet[bIndex].isMutualismActive = true
+ }
+ }
+ },
+ iceIX(speed = 0, dir = m.angle + Math.PI * 2 * Math.random(), where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }) {
+ const me = bullet.length;
+ const THRUST = 0.0018
+ const RADIUS = 18
+ const SCALE = 1 - 0.11 / tech.bulletsLastLonger
+ bullet[me] = Bodies.polygon(where.x, where.y, 3, RADIUS, {
+ angle: dir - Math.PI,
+ // inertia: Infinity,
+ spin: 0.00004 * (0.1 + Math.random()) * (Math.round(Math.random()) ? 1 : -1),
+ friction: 0,
+ frictionAir: 0.02,
+ restitution: 0.9,
+ dmg: 1.3, //damage done in addition to the damage from momentum
+ lookFrequency: 14 + Math.floor(8 * Math.random()),
+ endCycle: simulation.cycle + 65 * tech.bulletsLastLonger + Math.floor(25 * Math.random()),
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield //self collide
+ },
+ minDmgSpeed: 0,
+ lockedOn: null,
+ beforeDmg(who) {
+ if (!who.isInvulnerable) {
+ if (tech.iceEnergy && !who.shield && !who.isShielded && who.isDropPowerUp && who.alive && m.immuneCycle < m.cycle) {
+ setTimeout(() => {
+ if (!who.alive) m.energy += tech.iceEnergy * 0.8 * level.isReducedRegen
+ }, 10);
+ }
+ mobs.statusSlow(who, tech.iceIXFreezeTime)
+ this.endCycle = simulation.cycle
+ }
+ // if (tech.isHeavyWater) mobs.statusDoT(who, 0.15, 300)
+ },
+ onEnd() { },
+ do() {
+ // this.force.y += this.mass * 0.0002;
+ //find mob targets
+ if (!(simulation.cycle % this.lookFrequency)) {
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.lockedOn = null;
+ let closeDist = Infinity;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (
+ !mob[i].isBadTarget &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ const TARGET_VECTOR = Vector.sub(this.position, mob[i].position)
+ const DIST = Vector.magnitude(TARGET_VECTOR);
+ if (DIST < closeDist) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ }
+ if (this.lockedOn) { //accelerate towards mobs
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), this.mass * THRUST)
+ } else {
+ this.force = Vector.mult(Vector.normalise(this.velocity), this.mass * THRUST)
+ }
+ this.torque += this.inertia * this.spin
+ }
+ })
+
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ // Matter.Body.setAngularVelocity(bullet[me], 2 * (0.5 - Math.random())) //doesn't work due to high friction
+ Matter.Body.setVelocity(bullet[me], {
+ x: speed * Math.cos(dir),
+ y: speed * Math.sin(dir)
+ });
+ Matter.Body.setAngularVelocity(bullet[me], 3000 * bullet[me].spin);
+ },
+ flea(where, velocity, radius = 6 + 3 * Math.random() + 10 * tech.wormSize * Math.random()) {
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(where.x, where.y, 5, radius, {
+ isFlea: true,
+ angle: 0.5 * Math.random(),
+ friction: 1,
+ frictionStatic: 1,
+ frictionAir: 0, //0.01,
+ restitution: 0,
+ density: 0.0005, // 0.001 is normal density
+ lookFrequency: 19 + Math.floor(7 * Math.random()),
+ endCycle: simulation.cycle + Math.floor((900 * tech.bulletsLastLonger + 420 * Math.random()) + Math.max(0, 150 - bullet.length)), // 13 - 19s
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ minDmgSpeed: 0,
+ lockedOn: null,
+ delay: 50,
+ cd: simulation.cycle + 10,
+ dmg: 0,
+ setDamage() { //dmg is set to zero after doing damage once, and set back to normal after jumping
+ this.dmg = radius * (tech.isMutualism ? 3.3 : 1.1) //damage done in addition to the damage from momentum //spores do 7 dmg, worms do 18
+ },
+ beforeDmg(who) {
+ Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(Vector.sub(this.position, who.position)), 10 + 10 * Math.random())); //push away from target
+ this.cd = simulation.cycle + this.delay;
+ if (!who.isInvulnerable && this.dmg !== 0) {
+ this.endCycle -= 110
+ if (tech.isSporeFreeze) mobs.statusSlow(who, 90)
+ if (tech.isSpawnBulletsOnDeath && who.alive && who.isDropPowerUp) {
+ setTimeout(() => {
+ if (!who.alive) {
+ for (let i = 0; i < 2; i++) { //spawn 2 more
+ const speed = 10 + 5 * Math.random()
+ const angle = 2 * Math.PI * Math.random()
+ b.flea(this.position, {
+ x: speed * Math.cos(angle),
+ y: speed * Math.sin(angle)
+ })
+ }
+ }
+ this.endCycle = 0;
+ }, 1);
+ }
+ setTimeout(() => {
+ this.dmg = 0
+ })
+ }
+ },
+ onEnd() {
+ if (tech.isMutualism && this.isMutualismActive && !tech.isEnergyHealth) {
+ m.health += 0.02
+ if (m.health > m.maxHealth) m.health = m.maxHealth;
+ m.displayHealth();
+ }
+ },
+ gravity: 0.002 + 0.002 * tech.isSporeFollow,
+ do() {
+ this.force.y += this.gravity * this.mass
+ if (this.cd < simulation.cycle && (Matter.Query.collides(this, map).length || Matter.Query.collides(this, body).length)) { //if on the ground and not on jump cooldown //
+ this.cd = simulation.cycle + this.delay;
+ this.lockedOn = null; //find a target
+ let closeDist = Infinity;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (
+ !mob[i].isBadTarget &&
+ !mob[i].isInvulnerable &&
+ mob[i].alive &&
+ this.position.y - mob[i].position.y < 1500 && //this is about how high fleas can jump with capMaxY = 0.12 + 0.04 * Math.random()
+ this.position.y - mob[i].position.y > -300 && //not too far below the flea (note that fleas should be on the ground most of the time when doing this check)
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0
+ ) {
+ const TARGET_VECTOR = Vector.sub(this.position, mob[i].position)
+ const DIST = Vector.magnitude(TARGET_VECTOR);
+ if (DIST < closeDist) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ if (tech.isSporeFollow && !this.lockedOn && Matter.Query.ray(map, this.position, m.pos).length === 0) {
+ this.lockedOn = { //make target player if there are no mobs to target
+ position: m.pos,
+ velocity: { x: 0, y: 0 }
+ }
+ }
+ if (this.lockedOn) { //hop towards mob target
+ const where = Vector.add(this.lockedOn.position, Vector.mult(this.lockedOn.velocity, 5)) //estimate where the mob will be in 5 cycles
+ const Dy = Math.max(0, this.position.y - where.y) //can't be negative because you can't hop down
+ const Dx = this.position.x - where.x
+ const Vx = -0.06 * Dx / Math.sqrt(2 * Dy / this.gravity) //calibrated to hit target, don't mess with this
+ const Vy = 0.085 * Math.sqrt(this.gravity * Dy) //calibrated to hit target, don't mess with this
+ const capX = 0.07 + 0.02 * tech.isSporeFollow
+ const capMaxY = 0.12 + 0.04 * Math.random() + 0.05 * tech.isSporeFollow
+ const capMinY = closeDist > 500 ? 0.05 + 0.02 * Math.random() : 0.02 + 0.01 * Math.random() //don't jump super low, unless you are very close to mob target
+ this.force.x = Math.max(-capX, Math.min(capX, Vx)) * this.mass;
+ this.force.y = -Math.max(capMinY, Math.min(capMaxY, Vy)) * this.mass
+ } else { //random hops
+ if (Math.random() < 0.5) { //chance to continue in the same horizontal direction
+ this.force.x = (0.01 + 0.03 * Math.random()) * this.mass * (this.velocity.x > 0 ? 1 : -1); //random move
+ } else {
+ this.force.x = (0.01 + 0.03 * Math.random()) * this.mass * (Math.random() < 0.5 ? 1 : -1); //random move
+ }
+ this.force.y = -(0.03 + 0.08 * Math.random()) * this.mass
+ }
+ Matter.Body.setVelocity(this, { x: 0, y: 0 });
+ this.setDamage() //after jumping damage is no longer zero
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ Matter.Body.setVelocity(bullet[me], velocity);
+ if (tech.isMutualism && m.health > 0.01) {
+ m.health -= 0.01
+ m.displayHealth();
+ bullet[bullet.length - 1].isMutualismActive = true
+ }
+ },
+ delayDrones(where, droneCount = 1, deliveryCount = 0) {
+ let respawnDrones = () => {
+ if (droneCount > 0) {
+ requestAnimationFrame(respawnDrones);
+ if (!simulation.paused && !simulation.isChoosing && m.alive) {
+ droneCount--
+ if (tech.isDroneRadioactive) {
+ b.droneRadioactive({ x: where.x + 50 * (Math.random() - 0.5), y: where.y + 50 * (Math.random() - 0.5) }, 0)
+ } else {
+ b.drone({ x: where.x + 50 * (Math.random() - 0.5), y: where.y + 50 * (Math.random() - 0.5) }, 0)
+ if (tech.isDroneGrab && deliveryCount > 0) { //
+ const who = bullet[bullet.length - 1]
+ who.isImproved = true;
+ const SCALE = 2.25
+ Matter.Body.scale(who, SCALE, SCALE);
+ who.lookFrequency = 30 + Math.floor(11 * Math.random());
+ who.endCycle += 3000 * tech.droneCycleReduction * tech.bulletsLastLonger
+ deliveryCount--
+ }
+ }
+ }
+ }
+ }
+ requestAnimationFrame(respawnDrones);
+ },
+ drone(where = { x: m.pos.x + 30 * Math.cos(m.angle) + 20 * (Math.random() - 0.5), y: m.pos.y + 30 * Math.sin(m.angle) + 20 * (Math.random() - 0.5) }, speed = 1) {
+ const me = bullet.length;
+ const THRUST = 0.0015
+ const dir = m.angle + 0.2 * (Math.random() - 0.5);
+ const RADIUS = (4.5 + 3 * Math.random())
+ bullet[me] = Bodies.polygon(where.x, where.y, 8, RADIUS, {
+ angle: dir,
+ inertia: Infinity,
+ friction: 0.05,
+ frictionAir: 0,
+ restitution: 1,
+ density: 0.0005, // 0.001 is normal density
+ dmg: 0.34 + 0.12 * tech.isDroneTeleport + 0.15 * tech.isDroneFastLook, //damage done in addition to the damage from momentum
+ lookFrequency: (tech.isDroneFastLook ? 20 : 70) + Math.floor(17 * Math.random()),
+ endCycle: simulation.cycle + Math.floor((950 + 400 * Math.random()) * tech.bulletsLastLonger * tech.droneCycleReduction) + 5 * RADIUS + Math.max(0, 150 - bullet.length),
+ classType: "bullet",
+ isDrone: true,
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield //self collide
+ },
+ minDmgSpeed: 0,
+ lockedOn: null,
+ deathCycles: 110 + RADIUS * 5,
+ isImproved: false,
+ beforeDmg(who) {
+ if (who.isInvulnerable) {
+ //move away from target after hitting
+ const unit = Vector.mult(Vector.normalise(Vector.sub(this.position, who.position)), -20)
+ Matter.Body.setVelocity(this, { x: unit.x, y: unit.y });
+ this.lockedOn = null
+ } else {
+ // if (tech.isIncendiary && simulation.cycle + this.deathCycles < this.endCycle && !tech.isForeverDrones) {
+ // const max = Math.max(Math.min(this.endCycle - simulation.cycle - this.deathCycles, 1500), 0)
+ // b.explosion(this.position, max * 0.14 + this.isImproved * 110 + 60 * Math.random()); //makes bullet do explosive damage at end
+ // if (tech.isForeverDrones) {
+ // this.endCycle = 0
+ // b.drone({ x: m.pos.x + 30 * (Math.random() - 0.5), y: m.pos.y + 30 * (Math.random() - 0.5) }, 5)
+ // bullet[bullet.length - 1].endCycle = Infinity
+ // } else {
+ // this.endCycle -= max
+ // }
+ // } else {
+ //move away from target after hitting
+ const unit = Vector.mult(Vector.normalise(Vector.sub(this.position, who.position)), -20)
+ Matter.Body.setVelocity(this, { x: unit.x, y: unit.y });
+ this.lockedOn = null
+ if (this.endCycle > simulation.cycle + this.deathCycles) {
+ this.endCycle -= 60
+ if (simulation.cycle + this.deathCycles > this.endCycle) this.endCycle = simulation.cycle + this.deathCycles
+ }
+ // }
+ }
+ },
+ onEnd() {
+ if (tech.isDroneRespawn) {
+ //are there any nearby bodies nearby that aren't blocked by map?
+ const canSee = body.filter(a => Matter.Query.ray(map, this.position, a.position).length === 0 && !a.isNotHoldable && Vector.magnitude(Vector.sub(this.position, a.position)) < 70 + 30 * a.mass)
+ if (canSee.length) {
+ //find the closest body to the drone from the canSee array
+ const found = canSee.reduce((a, b) => {
+ const distA = Vector.magnitude(Vector.sub(this.position, a.position))
+ const distB = Vector.magnitude(Vector.sub(this.position, b.position))
+ return distA < distB ? a : b
+ })
+ if (found && m.energy > 0.041) {
+ m.energy -= 0.04
+ //remove the body and spawn a new drone
+ Composite.remove(engine.world, found)
+ body.splice(body.indexOf(found), 1)
+ b.delayDrones(found.position, Math.sqrt(found.mass))
+ //draw a line from the drone to the body on the canvas
+ ctx.beginPath();
+ ctx.moveTo(this.position.x, this.position.y);
+ ctx.lineTo(found.position.x, found.position.y);
+ ctx.strokeStyle = "#000";
+ ctx.lineWidth = 2;
+ ctx.stroke();
+
+ //animate the block fading away
+ simulation.ephemera.push({
+ name: "droneRespawn",
+ count: 60, //cycles before it self removes
+ do() {
+ this.count--
+ if (this.count < 0) simulation.removeEphemera(this.name)
+ ctx.beginPath();
+ let vertices = found.vertices;
+ ctx.moveTo(vertices[0].x, vertices[0].y);
+ for (let j = 1; j < vertices.length; j++) ctx.lineTo(vertices[j].x, vertices[j].y);
+ ctx.lineTo(vertices[0].x, vertices[0].y);
+ ctx.lineWidth = 2;
+ ctx.strokeStyle = `rgba(0,0,0,${this.count / 60})`
+ ctx.stroke();
+ },
+ })
+ }
+ }
+ }
+ },
+ doRespawning() { //fall shrink and die
+ const scale = 0.995;
+ Matter.Body.scale(this, scale, scale);
+ if (this.bodyTarget) {
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.position, this.bodyTarget.position)), -this.mass * THRUST)
+ } else {
+ this.force.y += this.mass * 0.0012;
+ }
+ },
+ doDieing() { //fall shrink and die
+ this.force.y += this.mass * 0.0012;
+ const scale = 0.995;
+ Matter.Body.scale(this, scale, scale);
+ },
+ hasExploded: false,
+ do() {
+ if (simulation.cycle + this.deathCycles > this.endCycle) {
+ if (tech.isIncendiary && !this.hasExploded) {
+ this.hasExploded = true
+ // const max = Math.max(Math.min(this.endCycle - simulation.cycle - this.deathCycles, 1500), 0)
+ // this.endCycle -= max
+ b.explosion(this.position, 200 + this.isImproved * 110 + 60 * Math.random()); //makes bullet do explosive damage at end
+ }
+ this.restitution = 0.2;
+ if (tech.isDroneRespawn) {
+ this.do = this.doRespawning
+ //make a list of all elements of array body that a ray can be drawn to from the drone
+ const canSee = body.filter(a => Matter.Query.ray(map, this.position, a.position).length === 0 && !a.isNotHoldable)
+ if (canSee.length) {
+ //find the closest body to the drone from the canSee array
+ const found = canSee.reduce((a, b) => {
+ const distA = Vector.magnitude(Vector.sub(this.position, a.position))
+ const distB = Vector.magnitude(Vector.sub(this.position, b.position))
+ return distA < distB ? a : b
+ })
+ if (found) this.bodyTarget = found
+ }
+ } else {
+ this.do = this.doDieing
+ }
+ }
+
+ this.force.y += this.mass * 0.0002;
+ if (!(simulation.cycle % this.lookFrequency)) {
+ //find mob targets
+ this.lockedOn = null;
+ let closeDist = Infinity;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (
+ !mob[i].isBadTarget &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ const TARGET_VECTOR = Vector.sub(this.position, mob[i].position)
+ const DIST = Vector.magnitude(TARGET_VECTOR)
+ if (DIST < closeDist) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ //blink towards mobs
+ if (tech.isDroneTeleport && this.lockedOn) {
+ const sub = Vector.sub(this.lockedOn.position, this.position);
+ const distMag = Vector.magnitude(sub);
+ const unit = Vector.normalise(sub)
+ Matter.Body.setVelocity(this, Vector.mult(unit, Math.max(20, this.speed * 1.5)));
+ ctx.beginPath();
+ ctx.moveTo(this.position.x, this.position.y);
+ Matter.Body.translate(this, Vector.mult(unit, Math.min(350, distMag - this.lockedOn.radius + 10)));
+ ctx.lineTo(this.position.x, this.position.y);
+ ctx.lineWidth = RADIUS * 2;
+ ctx.strokeStyle = "rgba(0,0,0,0.5)";
+ ctx.stroke();
+ }
+ //power ups
+ if (!this.isImproved && !simulation.isChoosing) {
+ if (this.lockedOn) {
+ for (let i = 0, len = powerUp.length; i < len; ++i) { //grab, but don't lock onto nearby power up
+ if (
+ Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 20000 &&
+ !(
+ (m.health > 0.93 * m.maxHealth && !tech.isDroneGrab && powerUp[i].name === "heal") ||
+ (tech.isSuperDeterminism && powerUp[i].name === "field") ||
+ ((tech.isEnergyNoAmmo || b.inventory.length === 0) && powerUp[i].name === "ammo")
+ )
+ ) {
+ //draw pickup for a single cycle
+ ctx.beginPath();
+ ctx.moveTo(this.position.x, this.position.y);
+ ctx.lineTo(powerUp[i].position.x, powerUp[i].position.y);
+ ctx.strokeStyle = "#000"
+ ctx.lineWidth = 4
+ ctx.stroke();
+ //pick up nearby power ups
+ powerUps.onPickUp(powerUp[i]);
+ powerUp[i].effect();
+ Matter.Composite.remove(engine.world, powerUp[i]);
+ powerUp.splice(i, 1);
+ if (tech.isDroneGrab) {
+ this.isImproved = true;
+ const SCALE = 2.25
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.lookFrequency = 30 + Math.floor(11 * Math.random());
+ this.endCycle += 3000 * tech.droneCycleReduction * tech.bulletsLastLonger
+ }
+ break;
+ }
+ }
+ } else {
+ //look for power ups to lock onto
+ let closeDist = Infinity;
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ if (!(
+ (m.health > 0.93 * m.maxHealth && !tech.isDroneGrab && powerUp[i].name === "heal") ||
+ (tech.isSuperDeterminism && powerUp[i].name === "field") ||
+ ((tech.isEnergyNoAmmo || b.inventory.length === 0) && powerUp[i].name === "ammo")
+ )) {
+ if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 20000 && !simulation.isChoosing) {
+ //draw pickup for a single cycle
+ ctx.beginPath();
+ ctx.moveTo(this.position.x, this.position.y);
+ ctx.lineTo(powerUp[i].position.x, powerUp[i].position.y);
+ ctx.strokeStyle = "#000"
+ ctx.lineWidth = 4
+ ctx.stroke();
+ //pick up nearby power ups
+ powerUps.onPickUp(powerUp[i]);
+ powerUp[i].effect();
+ Matter.Composite.remove(engine.world, powerUp[i]);
+ powerUp.splice(i, 1);
+ if (tech.isDroneGrab) {
+ this.isImproved = true;
+ const SCALE = 2.25
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.lookFrequency = 30 + Math.floor(11 * Math.random());
+ this.endCycle += 3000 * tech.droneCycleReduction * tech.bulletsLastLonger
+ // this.frictionAir = 0
+ }
+ break;
+ }
+ //look for power ups to lock onto
+ if (
+ Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 //&& Matter.Query.ray(body, this.position, powerUp[i].position).length === 0
+ ) {
+ const TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position)
+ const DIST = Vector.magnitude(TARGET_VECTOR);
+ if (DIST < closeDist) {
+ closeDist = DIST;
+ this.lockedOn = powerUp[i]
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (this.lockedOn) { //accelerate towards mobs
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
+ } else { //accelerate towards mouse
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.position, simulation.mouseInGame)), -this.mass * THRUST)
+ }
+ // speed cap instead of friction to give more agility
+ if (this.speed > 6) {
+ Matter.Body.setVelocity(this, { x: this.velocity.x * 0.97, y: this.velocity.y * 0.97 });
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ Matter.Body.setVelocity(bullet[me], { x: speed * Math.cos(dir), y: speed * Math.sin(dir) });
+ },
+ droneRadioactive(where = {
+ x: m.pos.x + 30 * Math.cos(m.angle) + 20 * (Math.random() - 0.5),
+ y: m.pos.y + 30 * Math.sin(m.angle) + 20 * (Math.random() - 0.5)
+ }, speed = 1) {
+ const me = bullet.length;
+ const THRUST = (tech.isFastDrones ? 0.003 : 0.0012) + 0.0005 * (Math.random() - 0.5)
+ const dir = m.angle + 0.4 * (Math.random() - 0.5);
+ const RADIUS = 3
+ bullet[me] = Bodies.polygon(where.x, where.y, 8, RADIUS, {
+ angle: dir,
+ inertia: Infinity,
+ friction: 0,
+ frictionAir: 0,
+ restitution: 0.4 + 0.199 * Math.random(),
+ dmg: 0, //0.24 damage done in addition to the damage from momentum and radiation
+ lookFrequency: 120 + Math.floor(23 * Math.random()),
+ endCycle: simulation.cycle + Math.floor((900 + 110 * Math.random()) * tech.bulletsLastLonger / tech.droneRadioDamage) + 5 * RADIUS + Math.max(0, 150 - 2 * bullet.length),
+ classType: "bullet",
+ isDrone: true,
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield //self collide
+ },
+ minDmgSpeed: 0,
+ speedCap: 5 + 2 * Math.random(), //6 is normal
+ lockedOn: null,
+ deathCycles: 110 + RADIUS * 5,
+ isImproved: false,
+ radioRadius: 0,
+ maxRadioRadius: 270 + Math.floor(90 * Math.random()),
+ beforeDmg() { },
+ onEnd() {
+ if (tech.isDroneRespawn) {
+ //are there any nearby bodies nearby that aren't blocked by map?
+ const canSee = body.filter(a => Matter.Query.ray(map, this.position, a.position).length === 0 && !a.isNotHoldable && Vector.magnitude(Vector.sub(this.position, a.position)) < 70 + 30 * a.mass)
+ if (canSee.length) {
+ //find the closest body to the drone from the canSee array
+ const found = canSee.reduce((a, b) => {
+ const distA = Vector.magnitude(Vector.sub(this.position, a.position))
+ const distB = Vector.magnitude(Vector.sub(this.position, b.position))
+ return distA < distB ? a : b
+ })
+ if (found && m.energy > 0.091) {
+ m.energy -= 0.09
+ //remove the body and spawn a new drone
+ Composite.remove(engine.world, found)
+ body.splice(body.indexOf(found), 1)
+ b.delayDrones(found.position, 0.5 * Math.sqrt(found.mass))
+ //draw a line from the drone to the body on the canvas
+ ctx.beginPath();
+ ctx.moveTo(this.position.x, this.position.y);
+ ctx.lineTo(found.position.x, found.position.y);
+ ctx.strokeStyle = "#000";
+ ctx.lineWidth = 2;
+ ctx.stroke();
+
+ //animate the block fading away
+ simulation.ephemera.push({
+ name: "droneRespawn",
+ count: 60, //cycles before it self removes
+ do() {
+ this.count--
+ if (this.count < 0) simulation.removeEphemera(this.name)
+ ctx.beginPath();
+ let vertices = found.vertices;
+ ctx.moveTo(vertices[0].x, vertices[0].y);
+ for (let j = 1; j < vertices.length; j++) {
+ ctx.lineTo(vertices[j].x, vertices[j].y);
+ }
+ ctx.lineTo(vertices[0].x, vertices[0].y);
+ ctx.lineWidth = 2;
+ ctx.strokeStyle = `rgba(0,0,0,${this.count / 60})`
+ ctx.stroke();
+ },
+ })
+ }
+ }
+ }
+ },
+ do() {
+ //radioactive zone
+ this.radioRadius = this.radioRadius * 0.993 + 0.007 * this.maxRadioRadius //smooth radius towards max
+ //aoe damage to player
+ if (Vector.magnitude(Vector.sub(player.position, this.position)) < this.radioRadius) {
+ const DRAIN = tech.isRadioactiveResistance ? 0.001 : 0.004
+ if (m.energy > DRAIN) {
+ if (m.immuneCycle < m.cycle) m.energy -= DRAIN
+ } else {
+ m.energy = 0;
+ if (simulation.dmgScale) m.damage((tech.isRadioactiveResistance ? 0.00004 : 0.0002) * tech.radioactiveDamage) //0.00015
+ }
+ }
+ //aoe damage to mobs
+ let dmg = (0.12 + 0.04 * tech.isFastDrones) * m.dmgScale * tech.droneRadioDamage * tech.radioactiveDamage
+ for (let i = 0, len = mob.length; i < len; i++) {
+ if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < this.radioRadius + mob[i].radius) {
+ if (Matter.Query.ray(map, mob[i].position, this.position).length > 0) dmg *= 0.25 //reduce damage if a wall is in the way
+ mob[i].damage(mob[i].shield ? dmg * 3 : dmg);
+ mob[i].locatePlayer();
+ }
+ }
+ //draw
+ ctx.beginPath();
+ ctx.arc(this.position.x, this.position.y, this.radioRadius, 0, 2 * Math.PI);
+ ctx.globalCompositeOperation = "lighter"
+ // ctx.fillStyle = `rgba(25,139,170,${0.15+0.05*Math.random()})`;
+ // ctx.fillStyle = `rgba(36, 207, 255,${0.1+0.05*Math.random()})`;
+ ctx.fillStyle = `rgba(28, 175, 217,${0.13 + 0.07 * Math.random()})`;
+ ctx.fill();
+ ctx.globalCompositeOperation = "source-over"
+
+ //normal drone actions
+ if (simulation.cycle + this.deathCycles > this.endCycle) { //fall shrink and die
+ this.force.y += this.mass * 0.0012;
+ this.restitution = 0.2;
+ const scale = 0.995;
+ Matter.Body.scale(this, scale, scale);
+ this.maxRadioRadius = 0
+ this.radioRadius = this.radioRadius * 0.98 //let radioactivity decrease
+ } else {
+ this.force.y += this.mass * 0.0002; //gravity
+
+ if (!(simulation.cycle % this.lookFrequency)) {
+ //find mob targets
+ this.lockedOn = null;
+ let closeDist = Infinity;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (
+ !mob[i].isBadTarget &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ const TARGET_VECTOR = Vector.sub(this.position, mob[i].position)
+ const DIST = Vector.magnitude(TARGET_VECTOR);
+ if (DIST < closeDist) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ //power ups
+ if (!this.isImproved && !simulation.isChoosing) {
+ if (this.lockedOn) {
+ //grab, but don't lock onto nearby power up
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ if (
+ Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 20000 &&
+ !(
+ (m.health > 0.93 * m.maxHealth && !tech.isDroneGrab && powerUp[i].name === "heal") ||
+ (tech.isSuperDeterminism && powerUp[i].name === "field") ||
+ ((tech.isEnergyNoAmmo || b.inventory.length === 0) && powerUp[i].name === "ammo")
+ )
+ ) {
+ //draw pickup for a single cycle
+ ctx.beginPath();
+ ctx.moveTo(this.position.x, this.position.y);
+ ctx.lineTo(powerUp[i].position.x, powerUp[i].position.y);
+ ctx.strokeStyle = "#000"
+ ctx.lineWidth = 4
+ ctx.stroke();
+ //pick up nearby power ups
+ powerUps.onPickUp(powerUp[i]);
+ powerUp[i].effect();
+ Matter.Composite.remove(engine.world, powerUp[i]);
+ powerUp.splice(i, 1);
+ if (tech.isDroneGrab) {
+ this.isImproved = true;
+ const SCALE = 2.25
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.lookFrequency = 30 + Math.floor(11 * Math.random());
+ this.endCycle += 1000 * tech.bulletsLastLonger
+ this.maxRadioRadius *= 1.25
+ }
+ break;
+ }
+ }
+ } else {
+ //look for power ups to lock onto
+ let closeDist = Infinity;
+ for (let i = 0, len = powerUp.length; i < len; ++i) {
+ if (!(
+ (m.health > 0.93 * m.maxHealth && !tech.isDroneGrab && powerUp[i].name === "heal") ||
+ (tech.isSuperDeterminism && powerUp[i].name === "field") ||
+ ((tech.isEnergyNoAmmo || b.inventory.length === 0) && powerUp[i].name === "ammo")
+ )) {
+ if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 20000 && !simulation.isChoosing) {
+ //draw pickup for a single cycle
+ ctx.beginPath();
+ ctx.moveTo(this.position.x, this.position.y);
+ ctx.lineTo(powerUp[i].position.x, powerUp[i].position.y);
+ ctx.strokeStyle = "#000"
+ ctx.lineWidth = 4
+ ctx.stroke();
+ //pick up nearby power ups
+ powerUps.onPickUp(powerUp[i]);
+ powerUp[i].effect();
+ Matter.Composite.remove(engine.world, powerUp[i]);
+ powerUp.splice(i, 1);
+ if (tech.isDroneGrab) {
+ this.isImproved = true;
+ const SCALE = 2.25
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.lookFrequency = 30 + Math.floor(11 * Math.random());
+ this.endCycle += 1000 * tech.bulletsLastLonger
+ this.maxRadioRadius *= 1.25
+ }
+ break;
+ }
+ //look for power ups to lock onto
+ if (
+ Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, powerUp[i].position).length === 0
+ ) {
+ const TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position)
+ const DIST = Vector.magnitude(TARGET_VECTOR);
+ if (DIST < closeDist) {
+ closeDist = DIST;
+ this.lockedOn = powerUp[i]
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (this.lockedOn) { //accelerate towards mobs
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
+ } else { //accelerate towards mouse
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.position, simulation.mouseInGame)), -this.mass * THRUST)
+ }
+ // speed cap instead of friction to give more agility
+ if (this.speed > this.speedCap) {
+ Matter.Body.setVelocity(this, {
+ x: this.velocity.x * 0.97,
+ y: this.velocity.y * 0.97
+ });
+ }
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ Matter.Body.setVelocity(bullet[me], {
+ x: speed * Math.cos(dir),
+ y: speed * Math.sin(dir)
+ });
+ },
+ superBall(where, velocity, radius) {
+ let gravity = 0.001
+ if (tech.superBallDelay) {
+ velocity = Vector.mult(velocity, 1.4)
+ gravity *= 6
+ }
+ let dir = m.angle
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(where.x, where.y, 12, radius, b.fireAttributes(dir, false));
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ Matter.Body.setVelocity(bullet[me], velocity);
+ Matter.Body.setDensity(bullet[me], 0.0007 + 0.0007 * tech.isSuperHarm + 0.0007 * tech.isBulletTeleport);
+ bullet[me].endCycle = simulation.cycle + Math.floor(270 + 90 * Math.random());
+ bullet[me].minDmgSpeed = 0;
+ bullet[me].restitution = 1;
+ bullet[me].frictionAir = 0;
+ bullet[me].friction = 0;
+ bullet[me].frictionStatic = 0;
+ if (tech.isSuperHarm) {
+ bullet[me].collidePlayerDo = function () {
+ this.force.y += this.mass * gravity;;
+ if (Matter.Query.collides(this, [player]).length) {
+ this.endCycle = 0
+ // m.energy -= 0.04
+ // if (m.energy < 0) m.energy = 0
+ // simulation.drawList.push({ //add dmg to draw queue
+ // x: this.position.x,
+ // y: this.position.y,
+ // radius: radius,
+ // color: "#0ad",
+ // time: 15
+ // });
+ }
+ }
+ bullet[me].cycle = 0
+ bullet[me].do = function () {
+ this.cycle++
+ if (this.cycle > 2) this.do = this.collidePlayerDo
+ this.force.y += this.mass * 0.001;
+ };
+ } else if (tech.isBulletTeleport) {
+ bullet[me].portFrequency = 25 + Math.floor(10 * Math.random())
+ bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency
+ bullet[me].do = function () {
+ this.force.y += this.mass * gravity;
+ if (this.nextPortCycle < simulation.cycle) { //teleport around if you have tech.isBulletTeleport
+ this.nextPortCycle = simulation.cycle + this.portFrequency
+ const range = 33 * Math.sqrt(radius) * Math.random()
+ Matter.Body.setPosition(this, Vector.add(this.position, Vector.rotate({ x: range, y: 0 }, 2 * Math.PI * Math.random())))
+ Matter.Body.setVelocity(this, Vector.rotate(this.velocity, 2 * (Math.random() * Math.random() - 0.25)))
+ }
+ };
+ } else {
+ bullet[me].do = function () {
+ this.force.y += this.mass * gravity;
+ };
+ }
+ bullet[me].beforeDmg = function (who) {
+ if (!who.isInvulnerable) {
+ if (tech.oneSuperBall) mobs.statusStun(who, 120) // (2.3) * 2 / 14 ticks (2x damage over 7 seconds)
+ if (tech.isFoamBall) {
+ for (let i = 0, len = 6 * this.mass; i < len; i++) {
+ const radius = 6 + 9 * Math.random()
+ const velocity = { x: Math.max(0.5, 2 - radius * 0.1), y: 0 }
+ b.foam(this.position, Vector.rotate(velocity, 6.28 * Math.random()), radius)
+ }
+ this.endCycle = 0
+ }
+ if (tech.isIncendiary) {
+ b.explosion(this.position, this.mass * 280); //makes bullet do explosive damage at end
+ this.endCycle = 0
+ } else if (tech.isSuperBounce) {
+ const cycle = () => {
+ Matter.Body.setDensity(this, (0.0007 + 0.0007 * tech.isSuperHarm + 0.0007 * tech.isBulletTeleport) * 1.33);//33% more density and damage
+ this.endCycle = simulation.cycle + Math.floor(300 + 90 * Math.random()); //reset to full duration of time
+ Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), 60)); //reset to high velocity
+ let count = 5
+ const wait = () => {
+ count--
+ if (count > 0) requestAnimationFrame(wait);
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ radius: radius,
+ color: 'rgba(255, 0, 0, 0.33)',
+ time: 8
+ });
+ }
+ requestAnimationFrame(wait);
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ radius: radius,
+ color: 'rgba(255, 0, 0, 0.33)',
+ time: 8
+ });
+ }
+ requestAnimationFrame(cycle);
+ }
+ }
+ };
+ },
+ targetedBall(position, num = 1, speed = 42 + 12 * Math.random(), range = 1200, isRandomAim = true) {
+ let shotsFired = 0
+ const targets = [] //target nearby mobs
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist = Vector.magnitude(Vector.sub(position, mob[i].position));
+ if (
+ dist < range + mob[i].radius &&
+ !mob[i].isBadTarget &&
+ Matter.Query.ray(map, position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ targets.push(Vector.add(mob[i].position, Vector.mult(mob[i].velocity, dist / 60))) //predict where the mob will be in a few cycles
+ }
+ }
+ const radius = (11 + 9 * tech.oneSuperBall) * tech.bulletSize
+ for (let i = 0; i < num; i++) {
+ if (targets.length > 0) { // aim near a random target in array
+ const index = Math.floor(Math.random() * targets.length)
+ const SPREAD = 160 / targets.length
+ const WHERE = {
+ x: targets[index].x + SPREAD * (Math.random() - 0.5),
+ y: targets[index].y + SPREAD * (Math.random() - 0.5)
+ }
+ b.superBall(position, Vector.mult(Vector.normalise(Vector.sub(WHERE, position)), speed), radius)
+ shotsFired++
+ } else if (isRandomAim) { // aim in random direction
+ const ANGLE = 2 * Math.PI * Math.random()
+ b.superBall(position, { x: speed * Math.cos(ANGLE), y: speed * Math.sin(ANGLE) }, radius)
+ }
+ }
+ return shotsFired
+ },
+ targetedFoam(position, num = 1, speed = 21 + 7 * Math.random(), range = 1200, isRandomAim = true) {
+ let shotsFired = 0
+ const targets = [] //target nearby mobs
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist = Vector.magnitude(Vector.sub(position, mob[i].position));
+ if (
+ dist < range + mob[i].radius &&
+ !mob[i].isBadTarget && //|| mob[i].isMobBullet
+ Matter.Query.ray(map, position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ targets.push(Vector.add(mob[i].position, Vector.mult(mob[i].velocity, dist / 60))) //predict where the mob will be in a few cycles
+ }
+ }
+ for (let i = 0; i < num; i++) {
+ if (targets.length > 0) { // aim near a random target in array
+ const SPREAD = 160 / targets.length
+ const index = Math.floor(Math.random() * targets.length)
+ const radius = 11 + 12 * Math.random()
+ const where = {
+ x: targets[index].x + SPREAD * (Math.random() - 0.5),
+ y: targets[index].y + SPREAD * (Math.random() - 0.5)
+ }
+ b.foam(position, Vector.mult(Vector.normalise(Vector.sub(where, position)), speed - radius * 0.25), radius)
+ shotsFired++
+ } else if (isRandomAim) { // aim in random direction
+ const ANGLE = 2 * Math.PI * Math.random()
+ b.foam(position, { x: speed * Math.cos(ANGLE), y: speed * Math.sin(ANGLE) }, 8 + 11 * Math.random())
+ }
+ }
+ return shotsFired
+ },
+ foam(position, velocity, radius) {
+ if (tech.isFoamCavitation && Math.random() < 0.25) {
+ velocity = Vector.mult(velocity, 1.35)
+ radius = 1.2 * radius + 13
+ }
+ // radius *= Math.sqrt(tech.bulletSize)
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(position.x, position.y, 20, radius, {
+ density: 0.000001, // 0.001 is normal density
+ inertia: Infinity,
+ frictionAir: 0.003,
+ dmg: 0, //damage on impact
+ damage: tech.foamDamage * (tech.isFastFoam ? 2.8 : 1) * (tech.isBulletTeleport ? 1.53 : 1), //damage done over time
+ scale: 1 - 0.006 / tech.bulletsLastLonger * (tech.isFastFoam ? 1.65 : 1),
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.mob | cat.mobBullet // cat.map | cat.body | cat.mob | cat.mobShield
+ },
+ minDmgSpeed: 0,
+ endCycle: Infinity,
+ count: 0,
+ radius: radius,
+ target: null,
+ targetVertex: null,
+ targetRelativePosition: null,
+ portFrequency: 7 + Math.floor(5 * Math.random()),
+ nextPortCycle: Infinity, //disabled unless you have the teleport tech
+ beforeDmg(who) {
+ if (!this.target && who.alive) {
+ this.target = who;
+ if (who.radius < 20) {
+ this.targetRelativePosition = {
+ x: 0,
+ y: 0
+ } //find relative position vector for zero mob rotation
+ } else if (Matter.Query.collides(this, [who]).length > 0) {
+ const normal = Matter.Query.collides(this, [who])[0].normal
+ this.targetRelativePosition = Vector.rotate(Vector.sub(Vector.sub(this.position, who.position), Vector.mult(normal, -this.radius)), -who.angle) //find relative position vector for zero mob rotation
+ } else {
+ this.targetRelativePosition = Vector.rotate(Vector.sub(this.position, who.position), -who.angle) //find relative position vector for zero mob rotation
+ }
+ this.collisionFilter.category = cat.body;
+ this.collisionFilter.mask = null;
+
+ let bestVertexDistance = Infinity
+ let bestVertex = null
+ for (let i = 0; i < this.target.vertices.length; i++) {
+ const dist = Vector.magnitude(Vector.sub(this.position, this.target.vertices[i]));
+ if (dist < bestVertexDistance) {
+ bestVertex = i
+ bestVertexDistance = dist
+ }
+ }
+ this.targetVertex = bestVertex
+ Matter.Body.setVelocity(this, { x: 0, y: 0 });
+ }
+ },
+ onEnd() { },
+ do() {
+ if (this.count < 20) {
+ this.count++
+ //grow
+ const SCALE = 1.06
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.radius *= SCALE;
+ } else {
+ //shrink
+ Matter.Body.scale(this, this.scale, this.scale);
+ this.radius *= this.scale;
+ if (this.radius < 8) this.endCycle = 0;
+ }
+ if (this.target && this.target.alive) { //if stuck to a target
+ const rotate = Vector.rotate(this.targetRelativePosition, this.target.angle) //add in the mob's new angle to the relative position vector
+ if (this.target.isVerticesChange) {
+ Matter.Body.setPosition(this, this.target.vertices[this.targetVertex])
+ } else {
+ Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.target.velocity), this.target.position))
+ }
+ if (this.target.isBoss) {
+ if (this.target.speed > 6.5) Matter.Body.setVelocity(this.target, Vector.mult(this.target.velocity, 0.975))
+ } else {
+ if (this.target.speed > 2.5) Matter.Body.setVelocity(this.target, Vector.mult(this.target.velocity, 0.94))
+ }
+
+ Matter.Body.setAngularVelocity(this.target, this.target.angularVelocity * 0.9);
+ // Matter.Body.setAngularVelocity(this.target, this.target.angularVelocity * 0.9)
+ if (this.target.isShielded) {
+ this.target.damage(m.dmgScale * this.damage, true); //shield damage bypass
+ const SCALE = 1 - 0.004 / tech.bulletsLastLonger //shrink if mob is shielded
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.radius *= SCALE;
+ } else {
+ this.target.damage(m.dmgScale * this.damage);
+ }
+ } else if (this.target !== null) { //look for a new target
+ this.collisionFilter.category = cat.bullet;
+ this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
+ Matter.Body.setVelocity(this, { x: this.target.velocity.x, y: this.target.velocity.y });
+ if (tech.isSpawnBulletsOnDeath && bullet.length < 180 && !this.target.isMobBullet) {
+ let targets = []
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
+ if (dist < 1000000) targets.push(mob[i])
+ }
+ const radius = Math.min(this.radius * 0.5, 9)
+ const len = bullet.length < 80 ? 2 : 1
+ for (let i = 0; i < len; i++) {
+ if (targets.length - i > 0) {
+ const index = Math.floor(Math.random() * targets.length)
+ const speed = 6 + 6 * Math.random()
+ const velocity = Vector.mult(Vector.normalise(Vector.sub(targets[index].position, this.position)), speed)
+ b.foam(this.position, Vector.rotate(velocity, 0.5 * (Math.random() - 0.5)), radius)
+ } else {
+ b.foam(this.position, Vector.rotate({
+ x: 15 + 10 * Math.random(),
+ y: 0
+ }, 2 * Math.PI * Math.random()), radius)
+ }
+ }
+ }
+ this.target = null
+ } else if (Matter.Query.point(map, this.position).length > 0) { //slow when touching map
+ const slow = 0.87
+ Matter.Body.setVelocity(this, { x: this.velocity.x * slow, y: this.velocity.y * slow });
+ const SCALE = 0.97
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.radius *= SCALE;
+ // } else if (Matter.Query.collides(this, body).length > 0) {
+ } else if (Matter.Query.point(body, this.position).length > 0) { //slow when touching blocks
+ const slow = 0.94
+ Matter.Body.setVelocity(this, { x: this.velocity.x * slow, y: this.velocity.y * slow });
+ const SCALE = 0.99
+ Matter.Body.scale(this, SCALE, SCALE);
+ this.radius *= SCALE;
+ } else {
+ this.force.y += this.mass * tech.foamGravity; //gravity
+ if (tech.isFoamAttract) {
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const range = Vector.magnitude(Vector.sub(mob[i].position, this.position))
+ if (
+ !mob[i].isBadTarget &&
+ mob[i].alive &&
+ !mob[i].isInvulnerable &&
+ range < 500 &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0
+ ) {
+ const mag = 0.001 * Math.min(1, 200 / range)
+ this.force = Vector.mult(Vector.normalise(Vector.sub(mob[i].position, this.position)), this.mass * mag)
+ const slow = 0.98
+ Matter.Body.setVelocity(this, { x: this.velocity.x * slow, y: this.velocity.y * slow });
+ break
+ }
+ }
+ }
+ }
+ if (this.nextPortCycle < simulation.cycle) { //teleport around if you have tech.isBulletTeleport
+ this.nextPortCycle = simulation.cycle + this.portFrequency
+ const range = 13 * Math.sqrt(this.radius) * Math.random()
+ Matter.Body.setPosition(this, Vector.add(this.position, Vector.rotate({
+ x: range,
+ y: 0
+ }, 2 * Math.PI * Math.random())))
+ }
+ }
+ });
+ if (tech.isBulletTeleport) bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ Matter.Body.setVelocity(bullet[me], velocity);
+ },
+ targetedBlock(who, speed = 50 - Math.min(20, who.mass * 2), range = 1600) {
+ let closestMob, dist
+ for (let i = 0, len = mob.length; i < len; i++) {
+ if (who !== mob[i] && !mob[i].isBadTarget && !mob[i].isInvulnerable) {
+ dist = Vector.magnitude(Vector.sub(who.position, mob[i].position));
+ if (dist < range && Matter.Query.ray(map, who.position, mob[i].position).length === 0) { //&& Matter.Query.ray(body, position, mob[i].position).length === 0
+ closestMob = mob[i]
+ range = dist
+ }
+ }
+ }
+ if (closestMob) {
+ const where = Vector.add(closestMob.position, Vector.mult(closestMob.velocity, dist / 60))
+ const velocity = Vector.mult(Vector.normalise(Vector.sub(where, who.position)), speed)
+ velocity.y -= Math.abs(who.position.x - closestMob.position.x) / 150; //gives an arc, but not a good one
+ Matter.Body.setVelocity(who, velocity);
+ }
+ },
+ targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, damage = 1.4) {
+ let shotsFired = 0
+ const targets = [] //target nearby mobs
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist = Vector.magnitude(Vector.sub(position, mob[i].position));
+ if (
+ dist < range + mob[i].radius &&
+ !mob[i].isBadTarget && //|| mob[i].isMobBullet
+ Matter.Query.ray(map, position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ targets.push(Vector.add(mob[i].position, Vector.mult(mob[i].velocity, dist / 60))) //predict where the mob will be in a few cycles
+ }
+ }
+ for (let i = 0; i < num; i++) {
+ if (targets.length > 0) { // aim near a random target in array
+ const index = Math.floor(Math.random() * targets.length)
+ const SPREAD = 150 / targets.length
+ const WHERE = {
+ x: targets[index].x + SPREAD * (Math.random() - 0.5),
+ y: targets[index].y + SPREAD * (Math.random() - 0.5)
+ }
+ b.nail(position, Vector.mult(Vector.normalise(Vector.sub(WHERE, position)), speed), damage)
+ shotsFired++
+ } else { // aim in random direction
+ const ANGLE = 2 * Math.PI * Math.random()
+ b.nail(position, {
+ x: speed * Math.cos(ANGLE),
+ y: speed * Math.sin(ANGLE)
+ }, damage)
+ shotsFired++
+ }
+ }
+ return shotsFired
+ },
+ crit(mob, bullet) {
+ if (!mob.shield && Vector.dot(Vector.normalise(Vector.sub(mob.position, bullet.position)), Vector.normalise(bullet.velocity)) > 0.999 - 1 / mob.radius) {
+ if (mob.isFinalBoss && !(Vector.dot(Vector.normalise(Vector.sub(mob.position, bullet.position)), Vector.normalise(bullet.velocity)) > 0.999999)) return
+ let cycle = () => { //makes this run after damage
+ if (mob.health < 0.5 && mob.damageReduction > 0 && mob.alive) {
+ // mob.death();
+ // mob.damage(this.health * Math.sqrt(this.mass) / this.damageReduction);
+ mob.damage(Infinity);
+
+ const color = 'rgb(255,255,255)'
+ simulation.drawList.push({
+ x: mob.position.x,
+ y: mob.position.y,
+ radius: mob.radius * 1.2,
+ color: color, //"rgba(0,0,0,0.6)",
+ time: 8
+ });
+ simulation.drawList.push({
+ x: mob.position.x,
+ y: mob.position.y,
+ radius: mob.radius * 0.75,
+ color: color, //"rgba(0,0,0,0.85)",
+ time: 15
+ });
+ simulation.drawList.push({
+ x: mob.position.x,
+ y: mob.position.y,
+ radius: mob.radius * 0.4,
+ color: color, //"rgb(0,0,0)",
+ time: 20
+ });
+ }
+ }
+ requestAnimationFrame(cycle);
+ }
+ },
+ nail(pos, velocity, dmg = 1) {
+ dmg *= tech.bulletSize
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(pos.x, pos.y, 25 * tech.bulletSize, 2 * tech.bulletSize, b.fireAttributes(Math.atan2(velocity.y, velocity.x)));
+ Matter.Body.setVelocity(bullet[me], velocity);
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ bullet[me].endCycle = simulation.cycle + 60 + 18 * Math.random();
+ bullet[me].dmg = tech.isNailRadiation ? 0 : dmg
+ bullet[me].beforeDmg = function (who) { //beforeDmg is rewritten with ice crystal tech
+ if (tech.isNailRadiation) mobs.statusDoT(who, dmg * (tech.isFastRadiation ? 1.3 : 0.44), tech.isSlowRadiation ? 360 : (tech.isFastRadiation ? 60 : 180)) // one tick every 30 cycles
+ if (tech.isNailCrit) { //makes bullet do explosive damage if it hits center
+ if (!who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.97 - 1 / who.radius) {
+ b.explosion(this.position, 80 + 90 * (b.activeGun === 0) + 30 * Math.random()); //larger explosions for human aimed nail gun, smaller for auto aimed sources, like bots, and mine
+ }
+ }
+ this.ricochet(who)
+ };
+ bullet[me].ricochet = function (who) { //use for normal nails, and ice crystal nails
+ if (tech.isRicochet) {
+ const targets = [] //target nearby mobs
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist = Vector.magnitude(Vector.sub(this.position, mob[i].position));
+ if (
+ mob[i] !== who &&
+ dist < 2500 + mob[i].radius &&
+ !mob[i].isBadTarget && //|| mob[i].isMobBullet
+ !mob[i].isInvulnerable &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0
+ ) {
+ targets.push(Vector.add(mob[i].position, Vector.mult(mob[i].velocity, dist / 60))) //predict where the mob will be in a few cycles
+ }
+ }
+ if (targets.length > 0) { // aim near a random target in array
+ const index = Math.floor(Math.random() * targets.length)
+ Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(Vector.sub(targets[index], this.position)), 45));
+ Matter.Body.setAngle(this, Math.atan2(this.velocity.y, this.velocity.x))
+ Matter.Body.setAngularVelocity(this, 0);
+ }
+ this.dmg += 2
+ }
+ }
+ bullet[me].do = function () { };
+ },
+ needle(angle = m.angle) {
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(m.pos.x + 40 * Math.cos(m.angle), m.pos.y + 40 * Math.sin(m.angle), 75 * tech.bulletSize, 0.75 * tech.bulletSize, b.fireAttributes(angle));
+ Matter.Body.setDensity(bullet[me], 0.00001); //0.001 is normal
+ bullet[me].immuneList = []
+ bullet[me].dmg = 6
+ if (tech.needleTunnel) {
+ bullet[me].dmg *= 1.2
+ bullet[me].endCycle = simulation.cycle + 300;
+ bullet[me].collisionFilter.mask = tech.isShieldPierce ? 0 : cat.mobShield
+ // bullet[me].turnRate = 0.005 * (Math.random() - 0.5)
+ bullet[me].isInMap = false
+ bullet[me].do = function () {
+ const whom = Matter.Query.collides(this, mob)
+ if (whom.length && this.speed > 20) { //if touching a mob
+ for (let i = 0, len = whom.length; i < len; i++) {
+ who = whom[i].bodyA
+ if (who && who.mob) {
+ let immune = false
+ for (let i = 0; i < this.immuneList.length; i++) { //check if this needle has hit this mob already
+ if (this.immuneList[i] === who.id) {
+ immune = true
+ break
+ }
+ }
+ if (!immune) {
+ if (tech.isNailCrit) {
+ if (!who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.97 - 1 / who.radius) {
+ b.explosion(this.position, 220 + 50 * Math.random()); //makes bullet do explosive damage at end
+ }
+ } else if (tech.isCritKill) b.crit(who, this)
+
+ this.immuneList.push(who.id) //remember that this needle has hit this mob once already
+ let dmg = this.dmg * tech.bulletSize * m.dmgScale
+ if (tech.isNailRadiation) {
+ mobs.statusDoT(who, (tech.isFastRadiation ? 6 : 2) * tech.bulletSize, tech.isSlowRadiation ? 360 : (tech.isFastRadiation ? 60 : 180)) // one tick every 30 cycles
+ dmg *= 0.25
+ }
+ if (tech.isCrit && who.isStunned) dmg *= 4
+ who.damage(dmg, tech.isShieldPierce);
+ if (who.alive) who.foundPlayer();
+ if (who.damageReduction) {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ radius: Math.log(dmg + 1.1) * 40 * who.damageReduction + 3,
+ color: simulation.playerDmgColor,
+ time: simulation.drawTime
+ });
+ }
+ }
+ }
+ }
+ } else if (Matter.Query.collides(this, map).length) { //penetrate walls
+ if (!this.isInMap) { //turn after entering the map, but only turn once
+ this.isInMap = true
+ Matter.Body.setVelocity(this, Vector.rotate(this.velocity, 0.25 * (Math.random() - 0.5)));
+ Matter.Body.setAngle(this, Math.atan2(this.velocity.y, this.velocity.x))
+ }
+ Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(this.velocity, -0.98))) //move back 1/2 your velocity = moving at 1/2 speed
+ } else if (Matter.Query.collides(this, body).length) { //penetrate blocks
+ Matter.Body.setAngularVelocity(this, 0)
+ Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(this.velocity, -0.94))) //move back 1/2 your velocity = moving at 1/2 speed
+ } else if (this.speed < 30) {
+ this.force.y += this.mass * 0.001; //no gravity until it slows down to improve aiming
+ }
+ };
+ } else {
+ bullet[me].endCycle = simulation.cycle + 100;
+ bullet[me].collisionFilter.mask = tech.isShieldPierce ? cat.body : cat.body | cat.mobShield
+ bullet[me].do = function () {
+ const whom = Matter.Query.collides(this, mob)
+ if (whom.length && this.speed > 20) { //if touching a mob
+ for (let i = 0, len = whom.length; i < len; i++) {
+ who = whom[i].bodyA
+ if (who && who.mob) {
+ let immune = false
+ for (let i = 0; i < this.immuneList.length; i++) { //check if this needle has hit this mob already
+ if (this.immuneList[i] === who.id) {
+ immune = true
+ break
+ }
+ }
+ if (!immune) {
+ if (tech.isNailCrit) {
+ if (!who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.97 - 1 / who.radius) {
+ b.explosion(this.position, 220 + 50 * Math.random()); //makes bullet do explosive damage at end
+ }
+ } else if (tech.isCritKill) b.crit(who, this)
+
+ this.immuneList.push(who.id) //remember that this needle has hit this mob once already
+ let dmg = this.dmg * tech.bulletSize * m.dmgScale
+ if (tech.isNailRadiation) {
+ mobs.statusDoT(who, (tech.isFastRadiation ? 6 : 2) * tech.bulletSize, tech.isSlowRadiation ? 360 : (tech.isFastRadiation ? 60 : 180)) // one tick every 30 cycles
+ dmg *= 0.25
+ }
+ if (tech.isCrit && who.isStunned) dmg *= 4
+ who.damage(dmg, tech.isShieldPierce);
+ if (who.alive) who.foundPlayer();
+ if (who.damageReduction) {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ radius: Math.log(dmg + 1.1) * 40 * who.damageReduction + 3,
+ color: simulation.playerDmgColor,
+ time: simulation.drawTime
+ });
+ }
+ }
+ }
+ }
+ } else if (Matter.Query.collides(this, map).length) { //stick in walls
+ this.collisionFilter.mask = 0;
+ Matter.Body.setAngularVelocity(this, 0)
+ Matter.Body.setVelocity(this, {
+ x: 0,
+ y: 0
+ });
+ this.do = function () {
+ if (!Matter.Query.collides(this, map).length) this.force.y += this.mass * 0.001;
+ }
+ if (tech.isNeedleIce) {
+ b.iceIX(5 + 5 * Math.random(), 2 * Math.PI * Math.random(), this.position) // iceIX(speed = 0, dir = m.angle + Math.PI * 2 * Math.random(), where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }) {
+ if (0.5 < Math.random()) b.iceIX(5 + 5 * Math.random(), 2 * Math.PI * Math.random(), this.position)
+ }
+ } else if (this.speed < 30) {
+ this.force.y += this.mass * 0.001; //no gravity until it slows down to improve aiming
+ }
+ };
+ }
+ const SPEED = 90
+ Matter.Body.setVelocity(bullet[me], {
+ x: 0.5 * player.velocity.x + SPEED * Math.cos(angle),
+ y: 0.5 * player.velocity.y + SPEED * Math.sin(angle)
+ });
+ // Matter.Body.setDensity(bullet[me], 0.00001);
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ // **************************************************************************************************
+ // **************************************************************************************************
+ // ******************************** Bots *********************************************
+ // **************************************************************************************************
+ // **************************************************************************************************
+ totalBots() {
+ return tech.dynamoBotCount + tech.foamBotCount + tech.soundBotCount + tech.nailBotCount + tech.laserBotCount + tech.boomBotCount + tech.orbitBotCount + tech.plasmaBotCount + tech.missileBotCount
+ },
+ hasBotUpgrade() {
+ return tech.isNailBotUpgrade + tech.isFoamBotUpgrade + tech.isBoomBotUpgrade + tech.isLaserBotUpgrade + tech.isOrbitBotUpgrade + tech.isDynamoBotUpgrade + tech.isSoundBotUpgrade
+ },
+ convertBotsTo(type) { //type can be a string like "dynamoBotCount"
+ const totalPermanentBots = b.totalBots()
+ //remove all bots techs and convert them to the new type so that tech refunds work correctly
+ let totalTechToConvert = 0 //count how many tech need to be converted
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (tech.tech[i].count && tech.tech[i].isBot) {
+ totalTechToConvert += tech.tech[i].count
+ tech.removeTech(i)
+ }
+ }
+ //remove all bots
+ b.zeroBotCount()
+ b.clearPermanentBots()
+ for (let i = 0; i < totalTechToConvert; i++) tech.giveTech(type) //spawn tech for the correct bot type
+
+ //find index of new bot type tech effect
+ let index = null
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (tech.tech[i].name === type) {
+ index = i
+ break
+ }
+ }
+ for (let i = 0, len = totalPermanentBots - totalTechToConvert; i < len; i++) tech.tech[index].effect(); //also convert any permanent bots that didn't come from a tech
+ //in experiment mode set the unselect color for bot tech that was converted
+ // if (build.isExperimentSelection) { }
+ },
+ clearPermanentBots() {
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType && bullet[i].endCycle === Infinity) bullet[i].endCycle = 0 //remove active bots, but don't remove temp bots
+ }
+ },
+ removeBot() {
+ if (tech.nailBotCount > 1) {
+ tech.nailBotCount--
+ return
+ }
+ if (tech.laserBotCount > 1) {
+ tech.laserBotCount--
+ return
+ }
+ if (tech.foamBotCount > 1) {
+ tech.foamBotCount--
+ return
+ }
+ if (tech.soundBotCount > 1) {
+ tech.soundBotCount--
+ return
+ }
+ if (tech.boomBotCount > 1) {
+ tech.boomBotCount--
+ return
+ }
+ if (tech.orbitBotCount > 1) {
+ tech.orbitBotCount--
+ return
+ }
+ if (tech.dynamoBotCount > 1) {
+ tech.dynamoBotCount--
+ return
+ }
+ if (tech.missileBotCount > 1) {
+ tech.missileBotCount--
+ return
+ }
+ if (tech.plasmaBotCount > 1) {
+ tech.plasmaBotCount--
+ return
+ }
+ },
+ zeroBotCount() { //remove all bots
+ tech.dynamoBotCount = 0;
+ tech.nailBotCount = 0;
+ tech.laserBotCount = 0;
+ tech.orbitBotCount = 0;
+ tech.foamBotCount = 0;
+ tech.soundBotCount = 0;
+ tech.boomBotCount = 0;
+ tech.plasmaBotCount = 0;
+ tech.missileBotCount = 0;
+ },
+ respawnBots() {
+ for (let i = 0; i < tech.dynamoBotCount; i++) b.dynamoBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ }, !level.isSlowBots)
+ for (let i = 0; i < tech.laserBotCount; i++) b.laserBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ }, !level.isSlowBots)
+ for (let i = 0; i < tech.nailBotCount; i++) b.nailBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ }, !level.isSlowBots)
+ for (let i = 0; i < tech.foamBotCount; i++) b.foamBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ }, !level.isSlowBots)
+ for (let i = 0; i < tech.soundBotCount; i++) b.soundBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ }, !level.isSlowBots)
+ for (let i = 0; i < tech.boomBotCount; i++) b.boomBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ }, !level.isSlowBots)
+ for (let i = 0; i < tech.orbitBotCount; i++) b.orbitBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ }, !level.isSlowBots)
+ for (let i = 0; i < tech.plasmaBotCount; i++) b.plasmaBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ })
+ for (let i = 0; i < tech.missileBotCount; i++) b.missileBot({
+ x: player.position.x + 50 * (Math.random() - 0.5),
+ y: player.position.y + 50 * (Math.random() - 0.5)
+ })
+ if (tech.isIntangible && m.isCloak) {
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType) bullet[i].collisionFilter.mask = cat.map | cat.bullet | cat.mobBullet | cat.mobShield
+ }
+ }
+ },
+ randomBot(where = player.position, isKeep = true, isLaser = true) {
+ if (Math.random() < 0.5) { //chance to match bot to your upgrade
+ if (tech.isNailBotUpgrade) { //check for upgrades first
+ b.nailBot(where, isKeep)
+ if (isKeep) tech.nailBotCount++;
+ } else if (tech.isFoamBotUpgrade) {
+ b.foamBot(where, isKeep)
+ if (isKeep) tech.foamBotCount++;
+ } else if (tech.isSoundBotUpgrade) {
+ b.soundBot(where, isKeep)
+ if (isKeep) tech.soundBotCount++;
+ } else if (tech.isBoomBotUpgrade) {
+ b.boomBot(where, isKeep)
+ if (isKeep) tech.boomBotCount++;
+ } else if (tech.isLaserBotUpgrade) {
+ b.laserBot(where, isKeep)
+ if (isKeep) tech.laserBotCount++;
+ } else if (tech.isOrbitBotUpgrade) {
+ b.orbitBot(where, isKeep);
+ if (isKeep) tech.orbitBotCount++;
+ } else if (tech.isDynamoBotUpgrade) {
+ b.dynamoBot(where, isKeep)
+ if (isKeep) tech.dynamoBotCount++;
+ } else if (Math.random() < 0.143) { //random
+ b.soundBot(where, isKeep)
+ if (isKeep) tech.soundBotCount++;
+ } else if (Math.random() < 0.166 && isLaser) {
+ b.laserBot(where, isKeep)
+ if (isKeep) tech.laserBotCount++;
+ } else if (Math.random() < 0.2) {
+ b.dynamoBot(where, isKeep)
+ if (isKeep) tech.dynamoBotCount++;
+ } else if (Math.random() < 0.25) {
+ b.orbitBot(where, isKeep);
+ if (isKeep) tech.orbitBotCount++;
+ } else if (Math.random() < 0.33) {
+ b.nailBot(where, isKeep)
+ if (isKeep) tech.nailBotCount++;
+ } else if (Math.random() < 0.5) {
+ b.foamBot(where, isKeep)
+ if (isKeep) tech.foamBotCount++;
+ } else {
+ b.boomBot(where, isKeep)
+ if (isKeep) tech.boomBotCount++;
+ }
+ } else { //else don't match bot to upgrade
+ if (Math.random() < 0.143) { //random
+ b.soundBot(where, isKeep)
+ if (isKeep) tech.soundBotCount++;
+ } else if (Math.random() < 0.166 && isLaser) { //random
+ b.laserBot(where, isKeep)
+ if (isKeep) tech.laserBotCount++;
+ } else if (Math.random() < 0.2) {
+ b.dynamoBot(where, isKeep)
+ if (isKeep) tech.dynamoBotCount++;
+ } else if (Math.random() < 0.25) {
+ b.orbitBot(where, isKeep);
+ if (isKeep) tech.orbitBotCount++;
+ } else if (Math.random() < 0.33) {
+ b.nailBot(where, isKeep)
+ if (isKeep) tech.nailBotCount++;
+ } else if (Math.random() < 0.5) {
+ b.foamBot(where, isKeep)
+ if (isKeep) tech.foamBotCount++;
+ } else {
+ b.boomBot(where, isKeep)
+ if (isKeep) tech.boomBotCount++;
+ }
+ }
+
+ },
+ setDynamoBotDelay() {
+ let total = 0
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType === 'dynamo') total++
+ }
+ let count = 0
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType === 'dynamo') {
+ count++
+ const step = Math.max(60 - 3 * total, 10)
+ if (bullet[i].isKeep) {
+ bullet[i].followDelay = (step * count) % 600
+ } else {
+ bullet[i].followDelay = Math.floor(step * bullet.length * Math.random()) % 600
+ }
+ }
+ }
+ },
+ dynamoBot(position = player.position, isKeep = true) {
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(position.x, position.y, 5, 10, {
+ isUpgraded: tech.isDynamoBotUpgrade,
+ botType: "dynamo",
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.02,
+ spin: 0.07 * (Math.random() < 0.5 ? -1 : 1),
+ // isStatic: true,
+ isKeep: isKeep,
+ isSensor: true,
+ restitution: 0,
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 0,
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: 0 //cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ beforeDmg() { },
+ onEnd() {
+ b.setDynamoBotDelay()
+ },
+ followDelay: 0,
+ phase: Math.floor(60 * Math.random()),
+ do() {
+ // if (Vector.magnitude(Vector.sub(this.position, player.position)) < 150) {
+ // ctx.fillStyle = "rgba(0,0,0,0.06)";
+ // ctx.beginPath();
+ // ctx.arc(this.position.x, this.position.y, 150, 0, 2 * Math.PI);
+ // ctx.fill();
+ // }
+
+ //check for damage
+ if (m.immuneCycle < m.cycle && !((m.cycle + this.phase) % 30)) { //twice a second
+ if (Vector.magnitude(Vector.sub(this.position, player.position)) < 250 && m.immuneCycle < m.cycle) { //give energy
+ Matter.Body.setAngularVelocity(this, this.spin)
+ if (this.isUpgraded) {
+ m.energy += 0.12 * level.isReducedRegen
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ radius: 10,
+ color: m.fieldMeterColor,
+ time: simulation.drawTime
+ });
+ } else {
+ m.energy += 0.04 * level.isReducedRegen
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ radius: 5,
+ color: m.fieldMeterColor,
+ time: simulation.drawTime
+ });
+ }
+ }
+ }
+
+ if (!m.isCloak) { //if cloaking field isn't active
+ const size = 33 - 6 * isKeep
+ q = Matter.Query.region(mob, {
+ min: {
+ x: this.position.x - size,
+ y: this.position.y - size
+ },
+ max: {
+ x: this.position.x + size,
+ y: this.position.y + size
+ }
+ })
+ for (let i = 0; i < q.length; i++) {
+ if (!q[i].isShielded) {
+ Matter.Body.setAngularVelocity(this, this.spin)
+ // mobs.statusStun(q[i], 180)
+ // const dmg = 0.5 * m.dmgScale * (this.isUpgraded ? 2.5 : 1)
+ const dmg = 0.5 * m.dmgScale
+ q[i].damage(dmg);
+ if (q[i].alive) q[i].foundPlayer();
+ if (q[i].damageReduction) {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ // radius: 600 * dmg * q[i].damageReduction,
+ radius: Math.sqrt(2000 * dmg * q[i].damageReduction) + 2,
+ color: 'rgba(0,0,0,0.4)',
+ time: simulation.drawTime
+ });
+ }
+ }
+ }
+ }
+ let history = m.history[(m.cycle - this.followDelay) % 600]
+ Matter.Body.setPosition(this, { x: history.position.x, y: history.position.y - history.yOff + 24.2859 }) //bullets move with player
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ b.setDynamoBotDelay()
+ },
+ nailBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isKeep = true) {
+ const me = bullet.length;
+ const dir = m.angle;
+ const RADIUS = (12 + 4 * Math.random())
+ bullet[me] = Bodies.polygon(position.x, position.y, 4, RADIUS, {
+ isUpgraded: tech.isNailBotUpgrade,
+ botType: "nail",
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.05,
+ restitution: 0.6 * (1 + 0.5 * Math.random()),
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ // lookFrequency: 56 + Math.floor(17 * Math.random()) - isUpgraded * 20,
+ lastLookCycle: simulation.cycle + 60 * Math.random(),
+ delay: Math.floor((tech.isNailBotUpgrade ? 22 : 85) + 10 * isKeep),
+ acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
+ range: 60 * (1 + 0.3 * Math.random()) + 3 * b.totalBots() + !isKeep * 100,
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: b.totalBots() < 50 ? cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield : cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield //if over 50 bots, they no longer collide with each other
+ },
+ beforeDmg() { },
+ onEnd() { },
+ do() {
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, m.pos))
+ if (distanceToPlayer > this.range) { //if far away move towards player
+ this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, this.position)), this.mass * this.acceleration)
+ } else { //close to player
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+ if (this.lastLookCycle < simulation.cycle && !m.isCloak) {
+ this.lastLookCycle = simulation.cycle + this.delay
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
+ if (
+ !mob[i].isBadTarget &&
+ dist < 3000000 &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0 &&
+ !mob[i].isShielded &&
+ !mob[i].isInvulnerable
+ ) {
+ const unit = Vector.normalise(Vector.sub(Vector.add(mob[i].position, Vector.mult(mob[i].velocity, Math.sqrt(dist) / 60)), this.position))
+ if (this.isUpgraded) {
+ const SPEED = 60
+ b.nail(this.position, Vector.mult(unit, SPEED))
+ this.force = Vector.mult(unit, -0.02 * this.mass)
+ } else {
+ const SPEED = 45
+ b.nail(this.position, Vector.mult(unit, SPEED))
+ this.force = Vector.mult(unit, -0.012 * this.mass)
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ missileBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isKeep = true) {
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(position.x, position.y, 28, 11, {
+ botType: "missile",
+ angle: m.angle,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.04,
+ restitution: 0.7,
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ lookFrequency: 26 + Math.ceil(6 * Math.random()),
+ cd: 0,
+ delay: Math.floor(60),
+ range: 70 + 3 * b.totalBots(),
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: b.totalBots() < 50 ? (cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield) : (cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield) //if over 50 bots, they no longer collide with each other
+ },
+ beforeDmg() { },
+ onEnd() { },
+ do() {
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, m.pos))
+ if (distanceToPlayer > this.range) { //if far away move towards player
+ this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, this.position)), this.mass * 0.006)
+ } else { //close to player
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+ if (this.cd < simulation.cycle && !(simulation.cycle % this.lookFrequency) && !m.isCloak) {
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist2 = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
+ if (
+ mob[i].alive &&
+ !mob[i].isBadTarget &&
+ dist2 > 40000 &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ this.cd = simulation.cycle + this.delay;
+ const angle = Vector.angle(this.position, mob[i].position)
+ Matter.Body.setAngle(this, angle)
+ // Matter.Body.setAngularVelocity(this, 0.025)
+ this.torque += this.inertia * 0.00004 * (Math.round(Math.random()) ? 1 : -1)
+ this.force = Vector.mult(Vector.normalise(Vector.sub(this.position, mob[i].position)), this.mass * 0.02)
+
+ if (tech.missileCount > 1) {
+ const countReduction = Math.pow(0.85, tech.missileCount)
+ const size = Math.sqrt(countReduction)
+ const direction = { x: Math.cos(angle), y: Math.sin(angle) }
+ const push = Vector.mult(Vector.perp(direction), 0.015 * countReduction / Math.sqrt(tech.missileCount))
+ for (let i = 0; i < tech.missileCount; i++) {
+ setTimeout(() => {
+ b.missile(this.position, angle, -8, size)
+ bullet[bullet.length - 1].force.x += push.x * (i - (tech.missileCount - 1) / 2);
+ bullet[bullet.length - 1].force.y += push.y * (i - (tech.missileCount - 1) / 2);
+ }, 40 * tech.missileCount * Math.random());
+ }
+ } else {
+ b.missile(this.position, angle, -8) // missile(where, angle, speed, size = 1) {
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ foamBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isKeep = true) {
+ const me = bullet.length;
+ const dir = m.angle;
+ const RADIUS = (10 + 5 * Math.random())
+ bullet[me] = Bodies.polygon(position.x, position.y, 6, RADIUS, {
+ isUpgraded: tech.isFoamBotUpgrade,
+ botType: "foam",
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.05,
+ restitution: 0.6 * (1 + 0.5 * Math.random()),
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ lookFrequency: 60 + Math.floor(17 * Math.random()) - 50 * tech.isFoamBotUpgrade,
+ cd: 0,
+ fireCount: 0,
+ fireLimit: 5 + 2 * tech.isFoamBotUpgrade - isKeep,
+ delay: Math.floor((200 + (tech.isFoamBotUpgrade ? 0 : 200))),// + 30 - 20 * tech.isFoamBotUpgrade,//20 + Math.floor(85 * b.fireCDscale) - 20 * tech.isFoamBotUpgrade,
+ acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
+ range: 60 * (1 + 0.3 * Math.random()) + 3 * b.totalBots() + !isKeep * 100, //how far from the player the bot will move
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: b.totalBots() < 50 ? cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield : cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield //if over 50 bots, they no longer collide with each other
+ },
+ beforeDmg() { },
+ onEnd() { },
+ fireTarget: { x: 0, y: 0 },
+ fire() {
+ this.fireCount++
+ if (this.fireCount > this.fireLimit) {
+ this.fireCount = 0
+ this.cd = simulation.cycle + this.delay;
+ } // else {this.cd = simulation.cycle + 1;}
+
+ const radius = 5 + 3 * Math.random()
+ const SPEED = Math.max(5, 25 - radius * 0.4); //(m.crouch ? 32 : 20) - radius * 0.7;
+ const velocity = Vector.mult(Vector.normalise(Vector.sub(this.fireTarget, this.position)), SPEED)
+ b.foam(this.position, Vector.rotate(velocity, 0.07 * (Math.random() - 0.5)), radius + 5 * this.isUpgraded)
+
+ //recoil
+ // const force = Vector.mult(Vector.normalise(velocity), 0.005 * this.mass * (tech.isFoamCavitation ? 2 : 1))
+ const force = Vector.mult(velocity, 0.0001 * this.mass * (tech.isFoamCavitation ? 2 : 1))
+ this.force.x -= force.x
+ this.force.y -= force.y
+ },
+ do() {
+ if (this.fireCount === 0) { //passive mode: look for targets and following player
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, m.pos))
+ if (distanceToPlayer > this.range) { //if far away move towards player
+ this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, this.position)), this.mass * this.acceleration)
+ } else { //close to player
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+ }
+
+ if (this.cd < simulation.cycle && !m.isCloak && !(simulation.cycle % this.lookFrequency)) {
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist2 = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
+ if (dist2 < 1600000 && !mob[i].isBadTarget && Matter.Query.ray(map, this.position, mob[i].position).length === 0 && !mob[i].isInvulnerable) {
+ this.fireTarget = Vector.add(mob[i].position, Vector.mult(mob[i].velocity, Math.sqrt(dist2) / 60)) //set target to where the mob will be in 1 second
+ this.fire()
+ break;
+ }
+ }
+ }
+ } else { //fire mode: quickly fire at targets and doesn't follow player
+ this.fire()
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ soundBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isKeep = true) {
+ const me = bullet.length;
+ const dir = m.angle;
+ bullet[me] = Bodies.rectangle(position.x, position.y, 12, 30, {
+ isUpgraded: tech.isSoundBotUpgrade,
+ botType: "sound",
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.05,
+ restitution: 0.6 * (1 + 0.5 * Math.random()),
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ lookFrequency: 17 + Math.floor(7 * Math.random()) - 3 * tech.isSoundBotUpgrade,
+ cd: 0,
+ fireCount: 0,
+ fireLimit: 5 - isKeep,
+ delay: Math.floor(140),// + 30 - 20 * tech.isFoamBotUpgrade,//20 + Math.floor(85 * b.fireCDscale) - 20 * tech.isFoamBotUpgrade,
+ acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
+ range: 60 * (1 + 0.3 * Math.random()) + 3 * b.totalBots() + !isKeep * 100, //how far from the player the bot will move
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: b.totalBots() < 50 ? cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield : cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield //if over 50 bots, they no longer collide with each other
+ },
+ beforeDmg() { },
+ onEnd() { },
+ fireTarget: { x: 0, y: 0 },
+ waves: [],
+ phononWaveCD: 0,
+ addWave(where, angle) {
+ const halfArc = 0.2 * (tech.isBulletTeleport ? 0.66 + (Math.random() - 0.5) : 1) + 0.04 * tech.isSoundBotUpgrade //6.28 is a full circle, but these arcs needs to stay small because we are using small angle linear approximation, for collisions
+ this.waves.push({
+ position: where,
+ angle: angle - halfArc, //used in drawing ctx.arc
+ unit1: { x: Math.cos(angle - halfArc), y: Math.sin(angle - halfArc) }, //used for collision
+ unit2: { x: Math.cos(angle + halfArc), y: Math.sin(angle + halfArc) }, //used for collision
+ arc: halfArc * 2,
+ radius: 25,
+ resonanceCount: 0,
+ dmg: (tech.isUpgraded ? 9 : 1.5) * m.dmgScale * tech.wavePacketDamage * tech.waveBeamDamage * (tech.isBulletTeleport ? 1.5 : 1),
+ })
+ },
+ fire() {
+ if (!(simulation.cycle % 6)) {
+ this.fireCount++
+ if (this.fireCount > this.fireLimit) {
+ this.fireCount = 0
+ this.cd = simulation.cycle + this.delay;
+ }
+ this.addWave({ x: this.position.x, y: this.position.y }, Math.atan2(this.fireTarget.y - this.position.y, this.fireTarget.x - this.position.x) + tech.isBulletTeleport * 0.3 * (Math.random() - 0.5)) //add wave to waves array
+ //face target
+ Matter.Body.setAngle(this, Vector.angle(this.position, this.fireTarget));
+ }
+ },
+ do() {
+ if (this.fireCount === 0) { //passive mode: look for targets and following player
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, m.pos))
+ if (distanceToPlayer > this.range) { //if far away move towards player
+ this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, this.position)), this.mass * this.acceleration)
+ } else { //close to player
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+ }
+ if (this.cd < simulation.cycle && !m.isCloak && !(simulation.cycle % this.lookFrequency)) {
+ for (let i = 0, len = mob.length; i < len; i++) {
+ const dist2 = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
+ if (dist2 < 1300000 && !mob[i].isBadTarget && (Matter.Query.ray(map, this.position, mob[i].position).length === 0 || dist2 < 300000) && !mob[i].isInvulnerable) {
+ this.fireTarget = Vector.add(mob[i].position, Vector.mult(mob[i].velocity, Math.sqrt(dist2) / 60)) //set target to where the mob will be in 1 second
+ this.fire()
+ break;
+ }
+ }
+ }
+ } else { //fire mode: quickly fire at targets and doesn't follow player
+ this.fire()
+ }
+ if (!m.isTimeDilated) { //update current waves
+ ctx.strokeStyle = "rgba(0,0,0,0.6)" //"000";
+ ctx.lineWidth = 2 * tech.wavePacketDamage
+ ctx.beginPath();
+ const end = 1200 * Math.sqrt(tech.bulletsLastLonger)
+ //this does less damage than the player phonon waves 2.3 -> 2
+ for (let i = this.waves.length - 1; i > -1; i--) {
+ const v1 = Vector.add(this.waves[i].position, Vector.mult(this.waves[i].unit1, this.waves[i].radius))
+ const v2 = Vector.add(this.waves[i].position, Vector.mult(this.waves[i].unit2, this.waves[i].radius))
+ //draw wave
+ ctx.moveTo(v1.x, v1.y)
+ ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, this.waves[i].angle, this.waves[i].angle + this.waves[i].arc);
+ //using small angle linear approximation of circle arc, this will not work if the arc gets large // https://stackoverflow.com/questions/13652518/efficiently-find-points-inside-a-circle-sector
+ let hits = Matter.Query.ray(mob, v1, v2, 50)
+ for (let j = 0; j < hits.length; j++) {
+ const who = hits[j].body
+ if (!who.isShielded) {
+ who.force.x += 0.01 * (Math.random() - 0.5) * who.mass
+ who.force.y += 0.01 * (Math.random() - 0.5) * who.mass
+ Matter.Body.setVelocity(who, { x: who.velocity.x * 0.98, y: who.velocity.y * 0.98 });
+ let vertices = who.vertices;
+ const vibe = 50 + who.radius * 0.15
+ ctx.moveTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ for (let j = 1; j < vertices.length; j++) ctx.lineTo(vertices[j].x + vibe * (Math.random() - 0.5), vertices[j].y + vibe * (Math.random() - 0.5));
+ ctx.lineTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ who.locatePlayer();
+ who.damage(this.waves[i].dmg / Math.pow(who.radius, 0.33));
+
+
+ if (tech.isPhononWave && this.phononWaveCD < m.cycle) {
+ this.phononWaveCD = m.cycle + 10 * (1 + this.waves[i].resonanceCount)
+ let closestMob, dist
+ let range = end - 30 * this.waves[i].resonanceCount
+ for (let i = 0, len = mob.length; i < len; i++) {
+ if (who !== mob[i] && !mob[i].isBadTarget && !mob[i].isInvulnerable) {
+ dist = Vector.magnitude(Vector.sub(who.position, mob[i].position));
+ if (dist < range) {
+ closestMob = mob[i]
+ range = dist
+ }
+ }
+ }
+ if (closestMob) { //add wave to waves array
+ this.addWave(who.position, Math.atan2(closestMob.position.y - who.position.y, closestMob.position.x - who.position.x) + tech.isBulletTeleport * 0.3 * (Math.random() - 0.5))
+ } else {
+ this.addWave(who.position, Math.random() * Math.PI)
+ }
+ this.waves[this.waves.length - 1].resonanceCount = this.waves[i].resonanceCount + 1
+ break
+ }
+ }
+ }
+
+ hits = Matter.Query.ray(body, v1, v2, 50) //Matter.Query.ray(bodies, startPoint, endPoint, [rayWidth])
+ for (let j = 0, len = Math.min(30, hits.length); j < len; j++) {
+ const who = hits[j].body
+ //make them shake around
+ who.force.x += 0.005 * (Math.random() - 0.5) * who.mass
+ who.force.y += (0.005 * (Math.random() - 0.5) - simulation.g * 0.1) * who.mass //remove force of gravity
+ let vertices = who.vertices;
+ const vibe = 25
+ ctx.moveTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ for (let j = 1; j < vertices.length; j++) {
+ ctx.lineTo(vertices[j].x + vibe * (Math.random() - 0.5), vertices[j].y + vibe * (Math.random() - 0.5));
+ }
+ ctx.lineTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+
+ if (tech.isPhononBlock && !who.isNotHoldable && who.speed < 5 && who.angularSpeed < 0.1) {
+ if (Math.random() < 0.5) b.targetedBlock(who, 50 - Math.min(25, who.mass * 3)) // targetedBlock(who, speed = 50 - Math.min(20, who.mass * 2), range = 1600) {
+ // Matter.Body.setAngularVelocity(who, (0.25 + 0.12 * Math.random()) * (Math.random() < 0.5 ? -1 : 1));
+ who.torque += who.inertia * 0.001 * (Math.random() - 0.5)
+ }
+ }
+
+ this.waves[i].radius += tech.waveBeamSpeed * 2
+ if (this.waves[i].radius > end - 30 * this.waves[i].resonanceCount) {
+ this.waves.splice(i, 1) //end
+ }
+ }
+ ctx.stroke();
+ }
+
+
+
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ laserBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isKeep = true) {
+ const me = bullet.length;
+ const dir = m.angle;
+ const RADIUS = (14 + 6 * Math.random())
+ bullet[me] = Bodies.polygon(position.x, position.y, 3, RADIUS, {
+ botType: "laser",
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.008 * (1 + 0.3 * Math.random()),
+ restitution: 0.5 * (1 + 0.5 * Math.random()),
+ acceleration: 0.0015 * (1 + 0.3 * Math.random()),
+ playerRange: 140 + Math.floor(30 * Math.random()) + 2 * b.totalBots(),
+ offPlayer: { x: 0, y: 0, },
+ dmg: 0, //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ lookFrequency: 20 + Math.floor(7 * Math.random()) - 13 * tech.isLaserBotUpgrade,
+ range: (600 + 375 * tech.isLaserBotUpgrade) * (1 + 0.12 * Math.random()),
+ drainThreshold: 0.15 + 0.5 * Math.random() + (tech.isEnergyHealth ? 0.3 : 0),// laser bot will not attack if the player is below this energy
+ drain: (0.57 - 0.43 * tech.isLaserBotUpgrade + isKeep * 0.08) * tech.laserDrain,
+ laserDamage: 0.75 + 0.75 * tech.isLaserBotUpgrade,
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: b.totalBots() < 50 ? cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield : cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield //if over 50 bots, they no longer collide with each other
+ },
+ lockedOn: null,
+ beforeDmg() {
+ this.lockedOn = null
+ },
+ onEnd() { },
+ do() {
+ const playerPos = Vector.add(Vector.add(this.offPlayer, m.pos), Vector.mult(player.velocity, 20)) //also include an offset unique to this bot to keep many bots spread out
+ const farAway = Math.max(0, (Vector.magnitude(Vector.sub(this.position, playerPos))) / this.playerRange) //linear bounding well
+ const mag = Math.min(farAway, 4) * this.mass * this.acceleration
+ this.force = Vector.mult(Vector.normalise(Vector.sub(playerPos, this.position)), mag)
+ //manual friction to not lose rotational velocity
+ Matter.Body.setVelocity(this, { x: this.velocity.x * 0.95, y: this.velocity.y * 0.95 });
+ //find targets
+ if (!(simulation.cycle % this.lookFrequency)) {
+ this.lockedOn = null;
+ if (!m.isCloak) {
+ let closeDist = this.range;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ const DIST = Vector.magnitude(Vector.sub(this.vertices[0], mob[i].position));
+ if (
+ DIST - mob[i].radius < closeDist &&
+ !mob[i].isShielded &&
+ (!mob[i].isBadTarget || mob[i].isMobBullet) &&
+ Matter.Query.ray(map, this.vertices[0], mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.vertices[0], mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ //randomize position relative to player
+ if (Math.random() < 0.1) {
+ if (isKeep) {
+ const range = 110 + 4 * b.totalBots()
+ this.offPlayer = { x: range * (Math.random() - 0.5), y: range * (Math.random() - 0.5) - 20, }
+ } else {
+ const range = 110 + 4 * b.totalBots() + 100 * Math.random()
+ this.offPlayer = Vector.mult(Vector.rotate({ x: 1, y: 0 }, 6.28 * Math.random()), range)
+ }
+ }
+ }
+ //hit target with laser
+ if (this.lockedOn && this.lockedOn.alive && m.energy > this.drainThreshold) {
+ m.energy -= this.drain
+ this.laser();
+ // b.laser(this.vertices[0], this.lockedOn.position, m.dmgScale * this.laserDamage * tech.laserDamage, tech.laserReflections, false, 0.4) //tech.laserDamage = 0.16
+ }
+ },
+ laser() {
+ const push = 0.4
+ const reflectivity = 1 - 1 / (tech.laserReflections * 3)
+ let damage = m.dmgScale * this.laserDamage * tech.laserDamage
+ //make the laser wiggle as it aims at the target
+ let best = { x: 1, y: 1, dist2: Infinity, who: null, v1: 1, v2: 1 };
+ const perp2 = Vector.mult(Vector.rotate({ x: 1, y: 0 }, m.angle + Math.PI / 2), 0.6 * this.lockedOn.radius * Math.sin(simulation.cycle / this.lookFrequency))
+ const path = [{ x: this.vertices[0].x, y: this.vertices[0].y }, Vector.add(this.lockedOn.position, perp2)];
+
+ const checkForCollisions = function () {
+ best = { x: 1, y: 1, dist2: Infinity, who: null, v1: 1, v2: 1 };
+ best = vertexCollision(path[path.length - 2], path[path.length - 1], [mob, map, body]);
+ };
+ const laserHitMob = function () {
+ if (best.who.alive) {
+ best.who.locatePlayer();
+ if (best.who.damageReduction) {
+ if ( //iridescence
+ tech.laserCrit && !best.who.shield &&
+ Vector.dot(Vector.normalise(Vector.sub(best.who.position, path[path.length - 1])), Vector.normalise(Vector.sub(path[path.length - 1], path[path.length - 2]))) > 0.999 - 0.5 / best.who.radius
+ ) {
+ damage *= 1 + tech.laserCrit
+ simulation.drawList.push({ //add dmg to draw queue
+ x: path[path.length - 1].x,
+ y: path[path.length - 1].y,
+ radius: Math.sqrt(2500 * damage * best.who.damageReduction) + 5,
+ color: `hsla(${60 + 283 * Math.random()},100%,70%,0.5)`, // random hue, but not red
+ time: 16
+ });
+ } else {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: path[path.length - 1].x,
+ y: path[path.length - 1].y,
+ radius: Math.sqrt(2000 * damage * best.who.damageReduction) + 2,
+ color: tech.laserColorAlpha,
+ time: simulation.drawTime
+ });
+ }
+ best.who.damage(damage);
+ }
+ if (tech.isLaserPush) { //push mobs away
+ const index = path.length - 1
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.97, y: best.who.velocity.y * 0.97 });
+ const force = Vector.mult(Vector.normalise(Vector.sub(path[index], path[Math.max(0, index - 1)])), 0.003 * push * Math.min(6, best.who.mass))
+ Matter.Body.applyForce(best.who, path[index], force)
+ }
+ } else if (tech.isLaserPush && best.who.classType === "body") {
+ const index = path.length - 1
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.97, y: best.who.velocity.y * 0.97 });
+ const force = Vector.mult(Vector.normalise(Vector.sub(path[index], path[Math.max(0, index - 1)])), 0.003 * push * Math.min(6, best.who.mass))
+ Matter.Body.applyForce(best.who, path[index], force)
+ }
+ };
+ const reflection = function () { // https://math.stackexchange.com/questions/13261/how-to-get-a-reflection-vector
+ const n = Vector.perp(Vector.normalise(Vector.sub(best.v1, best.v2)));
+ const d = Vector.sub(path[path.length - 1], path[path.length - 2]);
+ const nn = Vector.mult(n, 2 * Vector.dot(d, n));
+ const r = Vector.normalise(Vector.sub(d, nn));
+ path[path.length] = Vector.add(Vector.mult(r, 3000), path[path.length - 1]);
+ };
+
+ checkForCollisions();
+ let lastBestOdd
+ let lastBestEven = best.who //used in hack below
+ if (best.dist2 !== Infinity) { //if hitting something
+ path[path.length - 1] = { x: best.x, y: best.y };
+ laserHitMob();
+ for (let i = 0; i < tech.laserReflections; i++) {
+ reflection();
+ checkForCollisions();
+ if (best.dist2 !== Infinity) { //if hitting something
+ lastReflection = best
+ path[path.length - 1] = { x: best.x, y: best.y };
+ damage *= reflectivity
+ laserHitMob();
+ //I'm not clear on how this works, but it gets rid of a bug where the laser reflects inside a block, often vertically.
+ //I think it checks to see if the laser is reflecting off a different part of the same block, if it is "inside" a block
+ if (i % 2) {
+ if (lastBestOdd === best.who) break
+ } else {
+ lastBestOdd = best.who
+ if (lastBestEven === best.who) break
+ }
+ } else {
+ break
+ }
+ }
+ }
+ ctx.strokeStyle = tech.laserColor;
+ ctx.lineWidth = 2
+ ctx.lineDashOffset = 900 * Math.random()
+ ctx.setLineDash([50 + 120 * Math.random(), 50 * Math.random()]);
+ for (let i = 1, len = path.length; i < len; ++i) {
+ ctx.beginPath();
+ ctx.moveTo(path[i - 1].x, path[i - 1].y);
+ ctx.lineTo(path[i].x, path[i].y);
+ ctx.stroke();
+ ctx.globalAlpha *= reflectivity; //reflections are less intense
+ }
+ ctx.setLineDash([]);
+ ctx.globalAlpha = 1;
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ boomBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isKeep = true) {
+ const me = bullet.length;
+ const dir = m.angle;
+ const RADIUS = (7 + 2 * Math.random())
+ bullet[me] = Bodies.polygon(position.x, position.y, 4, RADIUS, {
+ isUpgraded: tech.isBoomBotUpgrade,
+ botType: "boom",
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.05,
+ restitution: 1,
+ dmg: 0,
+ minDmgSpeed: 0,
+ lookFrequency: 43 + Math.floor(7 * Math.random()) - 15 * tech.isBoomBotUpgrade,
+ acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
+ attackAcceleration: 0.012 + 0.005 * tech.isBoomBotUpgrade,
+ range: 500 * (1 + 0.1 * Math.random()) + 250 * tech.isBoomBotUpgrade + !isKeep * 100,
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: b.totalBots() < 50 ? cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield : cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield //if over 50 bots, they no longer collide with each other
+ },
+ lockedOn: null,
+ explode: 0,
+ beforeDmg() {
+ if (this.lockedOn) {
+ const explosionRadius = Math.min(136 + 230 * this.isUpgraded, Vector.magnitude(Vector.sub(this.position, m.pos)) - 30)
+ if (explosionRadius > 60) {
+ this.explode = explosionRadius
+ //
+ //push away from player, because normal explosion knock doesn't do much
+ // const sub = Vector.sub(this.lockedOn.position, m.pos)
+ // mag = Math.min(35, 20 / Math.sqrt(this.lockedOn.mass))
+ // Matter.Body.setVelocity(this.lockedOn, Vector.mult(Vector.normalise(sub), mag))
+ }
+ this.lockedOn = null //lose target so bot returns to player
+ }
+ },
+ onEnd() { },
+ do() {
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, player.position))
+ if (distanceToPlayer > 100) { //if far away move towards player
+ if (this.explode) {
+ // if (tech.isImmuneExplosion && m.energy > 1.43) {
+ // b.explosion(this.position, this.explode);
+ // } else {
+ // }
+ b.explosion(this.position, Math.max(0, Math.min(this.explode, (distanceToPlayer - 70) / b.explosionRange())));
+ this.explode = 0;
+ }
+ this.force = Vector.mult(Vector.normalise(Vector.sub(player.position, this.position)), this.mass * this.acceleration)
+ } else if (distanceToPlayer < 250) { //close to player
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+ //find targets
+ if (!(simulation.cycle % this.lookFrequency) && !m.isCloak) {
+ this.lockedOn = null;
+ let closeDist = this.range;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
+ if (
+ DIST < closeDist &&
+ !mob[i].isBadTarget &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ }
+ //punch target
+ if (this.lockedOn && this.lockedOn.alive && !m.isCloak) {
+ const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position));
+ if (DIST - this.lockedOn.radius < this.range &&
+ Matter.Query.ray(map, this.position, this.lockedOn.position).length === 0) {
+ //move towards the target
+ this.force = Vector.add(this.force, Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), this.attackAcceleration * this.mass))
+ }
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ plasmaBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isKeep = true) {
+ const me = bullet.length;
+ const dir = m.angle;
+ const RADIUS = 21
+ bullet[me] = Bodies.polygon(position.x, position.y, 5, RADIUS, {
+ botType: "plasma",
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.05,
+ restitution: 1,
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ lookFrequency: 25,
+ cd: 0,
+ acceleration: 0.009,
+ endCycle: Infinity,
+ drainThreshold: tech.isEnergyHealth ? 0.5 : 0.05,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: b.totalBots() < 50 ? cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield : cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield //if over 50 bots, they no longer collide with each other
+ },
+ lockedOn: null,
+ beforeDmg() {
+ this.lockedOn = null
+ },
+ onEnd() { },
+ do() {
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, m.pos))
+ if (distanceToPlayer > 150) this.force = Vector.mult(Vector.normalise(Vector.sub(m.pos, this.position)), this.mass * this.acceleration) //if far away move towards player
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+
+ if (!(simulation.cycle % this.lookFrequency)) { //find closest
+ this.lockedOn = null;
+ if (!m.isCloak) {
+ let closeDist = tech.isPlasmaRange * 1000;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
+ if (
+ DIST < closeDist && (!mob[i].isBadTarget || mob[i].isMobBullet) &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0 &&
+ !mob[i].isInvulnerable
+ ) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ }
+ //fire plasma at target
+ if (this.lockedOn && this.lockedOn.alive && m.fieldCDcycle < m.cycle) {
+ const sub = Vector.sub(this.lockedOn.position, this.position)
+ const DIST = Vector.magnitude(sub);
+ const unit = Vector.normalise(sub)
+ if (DIST < tech.isPlasmaRange * 450 && m.energy > this.drainThreshold) {
+ m.energy -= 0.001
+ //calculate laser collision
+ let best;
+ let range = tech.isPlasmaRange * (120 + 300 * Math.sqrt(Math.random()))
+ const path = [{ x: this.position.x, y: this.position.y }, { x: this.position.x + range * unit.x, y: this.position.y + range * unit.y }];
+ //check for collisions
+ best = { x: null, y: null, dist2: Infinity, who: null, v1: null, v2: null };
+ best = vertexCollision(path[0], path[1], [mob, map, body]);
+ if (best.dist2 != Infinity) { //if hitting something
+ path[path.length - 1] = { x: best.x, y: best.y };
+ if (best.who.alive) {
+ const dmg = 1.4 * m.dmgScale; //********** SCALE DAMAGE HERE *********************
+ best.who.damage(dmg);
+ best.who.locatePlayer();
+ //push mobs away
+ // const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.007 * Math.min(5, best.who.mass))
+ // Matter.Body.applyForce(best.who, path[1], force)
+ //push mobs away
+ if (best.who.speed > 3) {
+ const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.004 * Math.min(5, best.who.mass))
+ Matter.Body.applyForce(best.who, path[1], force)
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.5, y: best.who.velocity.y * 0.5 });
+ } else {
+ const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.01 * Math.min(5, best.who.mass))
+ Matter.Body.applyForce(best.who, path[1], force)
+ Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.7, y: best.who.velocity.y * 0.7 });
+ }
+
+ if (best.who.speed > 2.5) Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.75, y: best.who.velocity.y * 0.75 });
+ //draw mob damage circle
+ if (best.who.damageReduction) {
+ simulation.drawList.push({
+ x: path[1].x,
+ y: path[1].y,
+ // radius: Math.sqrt(dmg) * 50 * mob[k].damageReduction,
+ // radius: 600 * dmg * best.who.damageReduction,
+ radius: Math.sqrt(2000 * dmg * best.who.damageReduction) + 2,
+ color: "rgba(255,0,255,0.2)",
+ time: simulation.drawTime * 4
+ });
+ }
+ } else if (!best.who.isStatic) {
+ //push blocks away
+ const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.007 * Math.sqrt(Math.sqrt(best.who.mass)))
+ Matter.Body.applyForce(best.who, path[1], force)
+ }
+ }
+ //draw blowtorch laser beam
+ ctx.beginPath();
+ ctx.moveTo(path[0].x, path[0].y);
+ ctx.lineTo(path[1].x, path[1].y);
+ ctx.strokeStyle = "rgba(255,0,255,0.1)"
+ ctx.lineWidth = 14
+ ctx.stroke();
+ ctx.strokeStyle = "#f0f";
+ ctx.lineWidth = 2
+ ctx.stroke();
+ //draw electricity
+ let x = this.position.x + 20 * unit.x;
+ let y = this.position.y + 20 * unit.y;
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ const step = Vector.magnitude(Vector.sub(path[0], path[1])) / 5
+ for (let i = 0; i < 4; i++) {
+ x += step * (unit.x + 1.5 * (Math.random() - 0.5))
+ y += step * (unit.y + 1.5 * (Math.random() - 0.5))
+ ctx.lineTo(x, y);
+ }
+ ctx.lineWidth = 2 * Math.random();
+ ctx.stroke();
+ }
+ }
+ }
+ })
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ },
+ orbitBot(position = player.position, isKeep = true) {
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(position.x, position.y, 9, 12, {
+ isUpgraded: tech.isOrbitBotUpgrade,
+ botType: "orbit",
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 1,
+ isStatic: true,
+ isSensor: true,
+ isKeep: isKeep,
+ restitution: 0,
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 0,
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: 0 //cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ beforeDmg() { },
+ onEnd() {
+ //reorder orbital bot positions around a circle
+ let totalOrbitalBots = 0
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType === 'orbit' && bullet[i] !== this && bullet[i].isKeep) totalOrbitalBots++
+ }
+ let index = 0
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType === 'orbit' && bullet[i] !== this && bullet[i].isKeep) {
+ bullet[i].phase = (index / totalOrbitalBots) * 2 * Math.PI
+ index++
+ }
+ }
+ },
+ range: 160 + 170 * tech.isOrbitBotUpgrade + !isKeep * 100 * (0.5 - Math.random()), //range is set in bot upgrade too!
+ orbitalSpeed: 0,
+ phase: 2 * Math.PI * Math.random(),
+ do() {
+ if (!m.isCloak) { //if time dilation isn't active
+ const size = 40
+ q = Matter.Query.region(mob, {
+ min: {
+ x: this.position.x - size,
+ y: this.position.y - size
+ },
+ max: {
+ x: this.position.x + size,
+ y: this.position.y + size
+ }
+ })
+ for (let i = 0; i < q.length; i++) {
+ if (!q[i].isShielded) {
+ mobs.statusStun(q[i], 210 + 90 * this.isUpgraded)
+ const dmg = 0.4 * m.dmgScale * (this.isUpgraded ? 4.5 : 1) * (tech.isCrit ? 4 : 1)
+ q[i].damage(dmg);
+ if (q[i].alive) q[i].foundPlayer();
+ if (q[i].damageReduction) {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ // radius: 600 * dmg * q[i].damageReduction,
+ radius: Math.sqrt(2000 * dmg * q[i].damageReduction) + 2,
+ color: 'rgba(0,0,0,0.4)',
+ time: simulation.drawTime
+ });
+ }
+ }
+ }
+ }
+ //orbit player
+ const time = simulation.cycle * this.orbitalSpeed + this.phase
+ const orbit = { x: Math.cos(time), y: Math.sin(time) }
+ Matter.Body.setPosition(this, Vector.add(m.pos, Vector.mult(orbit, this.range))) //bullets move with player
+ }
+ })
+ // bullet[me].orbitalSpeed = Math.sqrt(0.7 / bullet[me].range)
+ bullet[me].orbitalSpeed = Math.sqrt(0.25 / bullet[me].range) //also set in bot upgrade too!
+ // bullet[me].phase = (index / tech.orbitBotCount) * 2 * Math.PI
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+
+ //reorder orbital bot positions around a circle
+ let totalOrbitalBots = 0
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType === 'orbit' && bullet[i].isKeep) totalOrbitalBots++
+ }
+ let index = 0
+ for (let i = 0; i < bullet.length; i++) {
+ if (bullet[i].botType === 'orbit' && bullet[i].isKeep) {
+ bullet[i].phase = (index / totalOrbitalBots) * 2 * Math.PI
+ index++
+ }
+ }
+ },
+ // **************************************************************************************************
+ // **************************************************************************************************
+ // ******************************** Guns *********************************************
+ // **************************************************************************************************
+ // **************************************************************************************************
+ //0 nail gun
+ //1 shotgun
+ //2 super balls
+ //3 wave
+ //4 missiles
+ //5 grenades
+ //6 spores
+ //7 drones
+ //8 foam
+ //9 harpoon
+ //10 mine
+ //11 laser
+ guns: [
+ {
+ name: "nail gun", // 0
+ // description: `use compressed air to shoot a stream of nails fire rateincreases the longer you fire 60 nails per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `use compressed air to rapidly drive nails fire rateincreases the longer you fire ${this.ammoPack.toFixed(0)} nails per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 27,
+ defaultAmmoPack: 27,
+ recordedAmmo: 0,
+ have: false,
+ nextFireCycle: 0, //use to remember how longs its been since last fire, used to reset count
+ startingHoldCycle: 0,
+ chooseFireMethod() { //set in simulation.startGame
+ if (tech.nailRecoil) {
+ if (tech.isRivets) {
+ this.fire = this.fireRecoilRivets
+ } else {
+ this.fire = this.fireRecoilNails
+ }
+ } else if (tech.isRivets) {
+ this.fire = this.fireRivets
+ } else if (tech.isNeedles) {
+ this.fire = this.fireNeedles
+ } else if (tech.nailInstantFireRate) {
+ this.fire = this.fireInstantFireRate
+ // } else if (tech.nailFireRate) {
+ // this.fire = this.fireNailFireRate
+ } else {
+ this.fire = this.fireNormal
+ }
+ },
+ do() { },
+ fire() { },
+ fireRecoilNails() {
+ if (this.nextFireCycle + 1 < m.cycle) this.startingHoldCycle = m.cycle //reset if not constantly firing
+ const CD = Math.max(11 - 0.06 * (m.cycle - this.startingHoldCycle), 0.99) //CD scales with cycles fire is held down
+ this.nextFireCycle = m.cycle + CD * b.fireCDscale //predict next fire cycle if the fire button is held down
+
+ m.fireCDcycle = m.cycle + Math.floor(CD * b.fireCDscale); // cool down
+ this.baseFire(m.angle + (Math.random() - 0.5) * (m.crouch ? 0.04 : 0.13) / CD, 45 + 6 * Math.random())
+ //very complex recoil system
+ if (m.onGround) {
+ if (m.crouch) {
+ const KNOCK = 0.006
+ player.force.x -= KNOCK * Math.cos(m.angle)
+ player.force.y -= KNOCK * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ Matter.Body.setVelocity(player, {
+ x: player.velocity.x * 0.5,
+ y: player.velocity.y * 0.5
+ });
+ } else {
+ const KNOCK = 0.03
+ player.force.x -= KNOCK * Math.cos(m.angle)
+ player.force.y -= KNOCK * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ Matter.Body.setVelocity(player, {
+ x: player.velocity.x * 0.8,
+ y: player.velocity.y * 0.8
+ });
+ }
+ } else {
+ player.force.x -= 0.06 * Math.cos(m.angle) * Math.min(1, 3 / (0.1 + Math.abs(player.velocity.x)))
+ player.force.y -= 0.006 * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ }
+ },
+ fireNormal() {
+ if (this.nextFireCycle + 1 < m.cycle) this.startingHoldCycle = m.cycle //reset if not constantly firing
+ const CD = Math.max(11 - 0.06 * (m.cycle - this.startingHoldCycle), 1) //CD scales with cycles fire is held down
+ this.nextFireCycle = m.cycle + CD * b.fireCDscale //predict next fire cycle if the fire button is held down
+
+ m.fireCDcycle = m.cycle + Math.floor(CD * b.fireCDscale); // cool down
+ this.baseFire(m.angle + (Math.random() - 0.5) * (m.crouch ? 0.05 : 0.3) / CD)
+ },
+ fireNeedles() {
+ if (m.crouch) {
+ m.fireCDcycle = m.cycle + 30 * b.fireCDscale; // cool down
+ b.needle()
+
+ function cycle() {
+ if (simulation.paused || m.isTimeDilated) {
+ requestAnimationFrame(cycle)
+ } else {
+ count++
+ if (count % 2) b.needle()
+ if (count < 7 && m.alive) requestAnimationFrame(cycle);
+ }
+ }
+ let count = -1
+ requestAnimationFrame(cycle);
+ } else {
+ m.fireCDcycle = m.cycle + 22 * b.fireCDscale; // cool down
+ b.needle()
+
+ function cycle() {
+ if (simulation.paused || m.isTimeDilated) {
+ requestAnimationFrame(cycle)
+ } else {
+ count++
+ if (count % 2) b.needle()
+ if (count < 3 && m.alive) requestAnimationFrame(cycle);
+ }
+ }
+ let count = -1
+ requestAnimationFrame(cycle);
+ }
+ },
+ fireRivets() {
+ m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 22 : 14) * b.fireCDscale); // cool down
+ const me = bullet.length;
+ const size = tech.bulletSize * 8
+ bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 5 * size, size, b.fireAttributes(m.angle));
+ bullet[me].dmg = tech.isNailRadiation ? 0 : 2.75
+ Matter.Body.setDensity(bullet[me], 0.002);
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ const SPEED = m.crouch ? 60 : 44
+ Matter.Body.setVelocity(bullet[me], {
+ x: SPEED * Math.cos(m.angle),
+ y: SPEED * Math.sin(m.angle)
+ });
+ bullet[me].endCycle = simulation.cycle + 180
+
+ bullet[me].beforeDmg = function (who) { //beforeDmg is rewritten with ice crystal tech
+ if (tech.isIncendiary) {
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ b.explosion(this.position, 100 + (Math.random() - 0.5) * 20); //makes bullet do explosive damage at end
+ }
+ if (tech.isNailCrit) {
+ if (!who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.97 - 1 / who.radius) {
+ b.explosion(this.position, 300 + 40 * Math.random()); //makes bullet do explosive damage at end
+ }
+ } else if (tech.isCritKill) b.crit(who, this)
+ if (tech.isNailRadiation) mobs.statusDoT(who, 7 * (tech.isFastRadiation ? 0.7 : 0.24), tech.isSlowRadiation ? 360 : (tech.isFastRadiation ? 60 : 180)) // one tick every 30 cycles
+ if (this.speed > 4 && tech.fragments) {
+ b.targetedNail(this.position, 1.25 * tech.fragments * tech.bulletSize)
+ this.endCycle = 0 //triggers despawn
+ }
+ };
+
+ bullet[me].minDmgSpeed = 10
+ bullet[me].frictionAir = 0.006;
+ bullet[me].rotateToVelocity = function () { //rotates bullet to face current velocity?
+ if (this.speed > 7) {
+ const facing = {
+ x: Math.cos(this.angle),
+ y: Math.sin(this.angle)
+ }
+ const mag = 0.002 * this.mass
+ if (Vector.cross(Vector.normalise(this.velocity), facing) < 0) {
+ this.torque += mag
+ } else {
+ this.torque -= mag
+ }
+ }
+ };
+ if (tech.isIncendiary) {
+ bullet[me].do = function () {
+ this.force.y += this.mass * 0.0008
+ this.rotateToVelocity()
+ //collide with map
+ if (Matter.Query.collides(this, map).length) { //penetrate walls
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ b.explosion(this.position, 300 + 40 * Math.random()); //makes bullet do explosive damage at end
+ }
+ };
+ } else {
+ bullet[me].do = function () {
+ this.force.y += this.mass * 0.0008
+ this.rotateToVelocity()
+ };
+ }
+ b.muzzleFlash();
+ //very complex recoil system
+ if (m.onGround) {
+ if (m.crouch) {
+ const KNOCK = 0.01
+ player.force.x -= KNOCK * Math.cos(m.angle)
+ player.force.y -= KNOCK * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ } else {
+ const KNOCK = 0.02
+ player.force.x -= KNOCK * Math.cos(m.angle)
+ player.force.y -= KNOCK * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ }
+ } else {
+ const KNOCK = 0.01
+ player.force.x -= KNOCK * Math.cos(m.angle)
+ player.force.y -= KNOCK * Math.sin(m.angle) * 0.5 //reduce knock back in vertical direction to stop super jumps
+ }
+ },
+ fireRecoilRivets() {
+ // m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 25 : 17) * b.fireCDscale); // cool down
+ if (this.nextFireCycle + 1 < m.cycle) this.startingHoldCycle = m.cycle //reset if not constantly firing
+ const CD = Math.max(25 - 0.14 * (m.cycle - this.startingHoldCycle), 5) //CD scales with cycles fire is held down
+ this.nextFireCycle = m.cycle + CD * b.fireCDscale //predict next fire cycle if the fire button is held down
+ m.fireCDcycle = m.cycle + Math.floor(CD * b.fireCDscale); // cool down
+
+ const me = bullet.length;
+ const size = tech.bulletSize * 8
+ bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 5 * size, size, b.fireAttributes(m.angle));
+ bullet[me].dmg = tech.isNailRadiation ? 0 : 2.75
+ Matter.Body.setDensity(bullet[me], 0.002);
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ const SPEED = m.crouch ? 62 : 52
+ Matter.Body.setVelocity(bullet[me], {
+ x: SPEED * Math.cos(m.angle),
+ y: SPEED * Math.sin(m.angle)
+ });
+ bullet[me].endCycle = simulation.cycle + 180
+ bullet[me].beforeDmg = function (who) { //beforeDmg is rewritten with ice crystal tech
+ if (tech.isIncendiary) {
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ b.explosion(this.position, 100 + (Math.random() - 0.5) * 20); //makes bullet do explosive damage at end
+ }
+ if (tech.isNailCrit) {
+ if (!who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.97 - 1 / who.radius) {
+ b.explosion(this.position, 300 + 40 * Math.random()); //makes bullet do explosive damage at end
+ }
+ } else if (tech.isCritKill) b.crit(who, this)
+ if (tech.isNailRadiation) mobs.statusDoT(who, 7 * (tech.isFastRadiation ? 0.7 : 0.24), tech.isSlowRadiation ? 360 : (tech.isFastRadiation ? 60 : 180)) // one tick every 30 cycles
+ if (this.speed > 4 && tech.fragments) {
+ b.targetedNail(this.position, 1.25 * tech.fragments * tech.bulletSize)
+ this.endCycle = 0 //triggers despawn
+ }
+ };
+
+ bullet[me].minDmgSpeed = 10
+ bullet[me].frictionAir = 0.006;
+ bullet[me].rotateToVelocity = function () { //rotates bullet to face current velocity?
+ if (this.speed > 7) {
+ const facing = {
+ x: Math.cos(this.angle),
+ y: Math.sin(this.angle)
+ }
+ const mag = 0.002 * this.mass
+ if (Vector.cross(Vector.normalise(this.velocity), facing) < 0) {
+ this.torque += mag
+ } else {
+ this.torque -= mag
+ }
+ }
+ };
+ if (tech.isIncendiary) {
+ bullet[me].do = function () {
+ this.force.y += this.mass * 0.0008
+ this.rotateToVelocity()
+ //collide with map
+ if (Matter.Query.collides(this, map).length) { //penetrate walls
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ b.explosion(this.position, 100 + (Math.random() - 0.5) * 20); //makes bullet do explosive damage at end
+ }
+ };
+ } else {
+ bullet[me].do = function () {
+ this.force.y += this.mass * 0.0008
+ this.rotateToVelocity()
+ };
+ }
+
+ b.muzzleFlash();
+ //very complex recoil system
+ if (m.onGround) {
+ if (m.crouch) {
+ const KNOCK = 0.03
+ player.force.x -= KNOCK * Math.cos(m.angle)
+ player.force.y -= KNOCK * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ Matter.Body.setVelocity(player, {
+ x: player.velocity.x * 0.4,
+ y: player.velocity.y * 0.4
+ });
+ } else {
+ const KNOCK = 0.1
+ player.force.x -= KNOCK * Math.cos(m.angle)
+ player.force.y -= KNOCK * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ Matter.Body.setVelocity(player, {
+ x: player.velocity.x * 0.7,
+ y: player.velocity.y * 0.7
+ });
+ }
+ } else {
+ player.force.x -= 0.2 * Math.cos(m.angle) * Math.min(1, 3 / (0.1 + Math.abs(player.velocity.x)))
+ // player.force.x -= 0.06 * Math.cos(m.angle) * Math.min(1, 3 / (0.1 + Math.abs(player.velocity.x)))
+
+ player.force.y -= 0.02 * Math.sin(m.angle) //reduce knock back in vertical direction to stop super jumps
+ }
+ },
+ fireInstantFireRate() {
+ m.fireCDcycle = m.cycle + Math.floor(1 * b.fireCDscale); // cool down
+ this.baseFire(m.angle + (Math.random() - 0.5) * (Math.random() - 0.5) * (m.crouch ? 1.15 : 2) / 2)
+ },
+ baseFire(angle, speed = 30 + 6 * Math.random()) {
+ b.nail({
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, {
+ x: 0.8 * player.velocity.x + speed * Math.cos(angle),
+ y: 0.5 * player.velocity.y + speed * Math.sin(angle)
+ }) //position, velocity, damage
+ if (tech.isIceCrystals) {
+ bullet[bullet.length - 1].beforeDmg = function (who) {
+ mobs.statusSlow(who, 60)
+ if (tech.isNailRadiation) mobs.statusDoT(who, 1 * (tech.isFastRadiation ? 1.3 : 0.44), tech.isSlowRadiation ? 360 : (tech.isFastRadiation ? 60 : 180)) // one tick every 30 cycles
+ if (tech.isNailCrit) {
+ if (!who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.97 - 1 / who.radius) {
+ b.explosion(this.position, 150 + 30 * Math.random()); //makes bullet do explosive damage at end
+ }
+ }
+ this.ricochet(who)
+ };
+ if (m.energy < 0.01) {
+ m.fireCDcycle = m.cycle + 60; // cool down
+ } else {
+ m.energy -= 0.01
+ }
+ }
+ },
+ },
+ {
+ name: "shotgun", //1
+ // description: `fire a wide burst of short range bullets with a low fire rate 3-4 nails per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `fire a wide burst of short range pellets has a slow fire rate ${this.ammoPack.toFixed(1)} shots per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 1.6,
+ defaultAmmoPack: 1.6,
+ have: false,
+ do() {
+ //fade cross hairs
+
+
+
+ // draw loop around player head
+ // const left = m.fireCDcycle !== Infinity ? 0.05 * Math.max(m.fireCDcycle - m.cycle, 0) : 0
+ // if (left > 0) {
+ // ctx.beginPath();
+ // // ctx.arc(simulation.mouseInGame.x, simulation.mouseInGame.y, 30, 0, left);
+ // ctx.arc(m.pos.x, m.pos.y, 28, m.angle - left, m.angle);
+ // // ctx.fillStyle = "rgba(0,0,0,0.3)" //"#333"
+ // // ctx.fill();
+ // ctx.strokeStyle = "#333";
+ // ctx.lineWidth = 2;
+ // ctx.stroke();
+ // }
+
+
+ //draw hip circle
+ // ctx.beginPath();
+ // ctx.arc(m.pos.x + m.hip.x, m.pos.y + m.hip.y, 11, 0, 2 * Math.PI);
+ // ctx.fillStyle = "rgba(0,0,0,0.3)" //"#333"
+ // ctx.fill();
+ },
+ fire() {
+ let knock, spread
+ const coolDown = function () {
+ if (m.crouch) {
+ spread = 0.65
+ m.fireCDcycle = m.cycle + Math.floor((73 + 36 * tech.shotgunExtraShots) * b.fireCDscale) // cool down
+ if (tech.isShotgunImmune && m.immuneCycle < m.cycle + Math.floor(60 * b.fireCDscale)) m.immuneCycle = m.cycle + Math.floor(60 * b.fireCDscale); //player is immune to damage for 30 cycles
+ knock = 0.01
+ } else {
+ m.fireCDcycle = m.cycle + Math.floor((56 + 28 * tech.shotgunExtraShots) * b.fireCDscale) // cool down
+ if (tech.isShotgunImmune && m.immuneCycle < m.cycle + Math.floor(47 * b.fireCDscale)) m.immuneCycle = m.cycle + Math.floor(47 * b.fireCDscale); //player is immune to damage for 30 cycles
+ spread = 1.3
+ knock = 0.1
+ }
+
+ if (tech.isShotgunReversed) {
+ player.force.x += 1.5 * knock * Math.cos(m.angle)
+ player.force.y += 1.5 * knock * Math.sin(m.angle) - 3 * player.mass * simulation.g
+ } else if (tech.isShotgunRecoil) {
+ m.fireCDcycle -= 0.66 * (56 * b.fireCDscale)
+ player.force.x -= 2 * knock * Math.cos(m.angle)
+ player.force.y -= 2 * knock * Math.sin(m.angle)
+ } else {
+ player.force.x -= knock * Math.cos(m.angle)
+ player.force.y -= knock * Math.sin(m.angle) * 0.5 //reduce knock back in vertical direction to stop super jumps
+ }
+ }
+ const spray = (num) => {
+ const side = 22
+ for (let i = 0; i < num; i++) {
+ const me = bullet.length;
+ const dir = m.angle + (Math.random() - 0.5) * spread
+ bullet[me] = Bodies.rectangle(m.pos.x, m.pos.y, side, side, b.fireAttributes(dir));
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ const SPEED = 52 + Math.random() * 8
+ Matter.Body.setVelocity(bullet[me], {
+ x: SPEED * Math.cos(dir),
+ y: SPEED * Math.sin(dir)
+ });
+ bullet[me].endCycle = simulation.cycle + 40 * tech.bulletsLastLonger
+ bullet[me].minDmgSpeed = 15
+ if (tech.isShotgunReversed) Matter.Body.setDensity(bullet[me], 0.0015)
+ // bullet[me].restitution = 0.4
+ bullet[me].frictionAir = 0.034;
+ bullet[me].do = function () {
+ const scale = 1 - 0.034 / tech.bulletsLastLonger
+ Matter.Body.scale(this, scale, scale);
+ };
+ }
+ }
+ const chooseBulletType = function () {
+ if (tech.isRivets) {
+ const me = bullet.length;
+ // const dir = m.angle + 0.02 * (Math.random() - 0.5)
+ bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 56 * tech.bulletSize, 25 * tech.bulletSize, b.fireAttributes(m.angle));
+
+ Matter.Body.setDensity(bullet[me], 0.005 * (tech.isShotgunReversed ? 1.5 : 1));
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ const SPEED = (m.crouch ? 50 : 43)
+ Matter.Body.setVelocity(bullet[me], {
+ x: SPEED * Math.cos(m.angle),
+ y: SPEED * Math.sin(m.angle)
+ });
+ if (tech.isIncendiary) {
+ bullet[me].endCycle = simulation.cycle + 60
+ bullet[me].onEnd = function () {
+ b.explosion(this.position, 400 + (Math.random() - 0.5) * 60); //makes bullet do explosive damage at end
+ }
+ bullet[me].beforeDmg = function () {
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ };
+ } else {
+ bullet[me].endCycle = simulation.cycle + 180
+ }
+ bullet[me].minDmgSpeed = 7
+ // bullet[me].restitution = 0.4
+ bullet[me].frictionAir = 0.004;
+ bullet[me].turnMag = 0.04 * Math.pow(tech.bulletSize, 3.75)
+ bullet[me].do = function () {
+ this.force.y += this.mass * 0.002
+ if (this.speed > 6) { //rotates bullet to face current velocity?
+ const facing = {
+ x: Math.cos(this.angle),
+ y: Math.sin(this.angle)
+ }
+ if (Vector.cross(Vector.normalise(this.velocity), facing) < 0) {
+ this.torque += this.turnMag
+ } else {
+ this.torque -= this.turnMag
+ }
+ }
+ if (tech.isIncendiary && Matter.Query.collides(this, map).length) {
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ }
+ };
+ bullet[me].beforeDmg = function (who) {
+ if (this.speed > 4) {
+ if (tech.fragments) {
+ b.targetedNail(this.position, 6 * tech.fragments * tech.bulletSize)
+ this.endCycle = 0 //triggers despawn
+ }
+ if (tech.isIncendiary) this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ if (tech.isCritKill) b.crit(who, this)
+ }
+ }
+ spray(12); //fires normal shotgun bullets
+ } else if (tech.isIncendiary) {
+ spread *= 0.15
+ const END = Math.floor(m.crouch ? 8 : 5);
+ const totalBullets = 9
+ const angleStep = (m.crouch ? 0.3 : 0.8) / totalBullets
+ let dir = m.angle - angleStep * totalBullets / 2;
+ for (let i = 0; i < totalBullets; i++) { //5 -> 7
+ dir += angleStep
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(m.pos.x + 50 * Math.cos(m.angle), m.pos.y + 50 * Math.sin(m.angle), 17, 4, b.fireAttributes(dir));
+ const end = END + Math.random() * 4
+ bullet[me].endCycle = 2 * end * tech.bulletsLastLonger + simulation.cycle
+ const speed = 25 * end / END
+ const dirOff = dir + (Math.random() - 0.5) * spread
+ Matter.Body.setVelocity(bullet[me], {
+ x: speed * Math.cos(dirOff),
+ y: speed * Math.sin(dirOff)
+ });
+ bullet[me].onEnd = function () {
+ b.explosion(this.position, 180 * (tech.isShotgunReversed ? 1.4 : 1) + (Math.random() - 0.5) * 30); //makes bullet do explosive damage at end
+ }
+ bullet[me].beforeDmg = function () {
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ };
+ bullet[me].do = function () {
+ if (Matter.Query.collides(this, map).length) this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ }
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ }
+ } else if (tech.isNailShot) {
+ spread *= 0.65
+ const dmg = 2 * (tech.isShotgunReversed ? 1.5 : 1)
+ if (m.crouch) {
+ for (let i = 0; i < 17; i++) {
+ speed = 38 + 15 * Math.random()
+ const dir = m.angle + (Math.random() - 0.5) * spread
+ const pos = {
+ x: m.pos.x + 35 * Math.cos(m.angle) + 15 * (Math.random() - 0.5),
+ y: m.pos.y + 35 * Math.sin(m.angle) + 15 * (Math.random() - 0.5)
+ }
+ b.nail(pos, {
+ x: speed * Math.cos(dir),
+ y: speed * Math.sin(dir)
+ }, dmg)
+ }
+ } else {
+ for (let i = 0; i < 17; i++) {
+ speed = 38 + 15 * Math.random()
+ const dir = m.angle + (Math.random() - 0.5) * spread
+ const pos = {
+ x: m.pos.x + 35 * Math.cos(m.angle) + 15 * (Math.random() - 0.5),
+ y: m.pos.y + 35 * Math.sin(m.angle) + 15 * (Math.random() - 0.5)
+ }
+ b.nail(pos, {
+ x: speed * Math.cos(dir),
+ y: speed * Math.sin(dir)
+ }, dmg)
+ }
+ }
+ } else if (tech.isSporeFlea) {
+ const where = {
+ x: m.pos.x + 35 * Math.cos(m.angle),
+ y: m.pos.y + 35 * Math.sin(m.angle)
+ }
+ const number = 2 * (tech.isShotgunReversed ? 1.5 : 1)
+ for (let i = 0; i < number; i++) {
+ const angle = m.angle + 0.2 * (Math.random() - 0.5)
+ const speed = (m.crouch ? 35 * (1 + 0.05 * Math.random()) : 30 * (1 + 0.15 * Math.random()))
+ b.flea(where, {
+ x: speed * Math.cos(angle),
+ y: speed * Math.sin(angle)
+ })
+ bullet[bullet.length - 1].setDamage()
+ }
+ spray(10); //fires normal shotgun bullets
+ } else if (tech.isSporeWorm) {
+ const where = {
+ x: m.pos.x + 35 * Math.cos(m.angle),
+ y: m.pos.y + 35 * Math.sin(m.angle)
+ }
+ const spread = (m.crouch ? 0.02 : 0.07)
+ const number = 3 * (tech.isShotgunReversed ? 1.5 : 1)
+ let angle = m.angle - (number - 1) * spread * 0.5
+ for (let i = 0; i < number; i++) {
+ b.worm(where)
+ const SPEED = (30 + 10 * m.crouch) * (1 + 0.2 * Math.random())
+ Matter.Body.setVelocity(bullet[bullet.length - 1], {
+ x: player.velocity.x * 0.5 + SPEED * Math.cos(angle),
+ y: player.velocity.y * 0.5 + SPEED * Math.sin(angle)
+ });
+ angle += spread
+ }
+ spray(7); //fires normal shotgun bullets
+ } else if (tech.isIceShot) {
+ const spread = (m.crouch ? 0.7 : 1.2)
+ for (let i = 0, len = 10 * (tech.isShotgunReversed ? 1.5 : 1); i < len; i++) {
+ b.iceIX(23 + 10 * Math.random(), m.angle + spread * (Math.random() - 0.5))
+ }
+ spray(10); //fires normal shotgun bullets
+ } else if (tech.isFoamShot) {
+ const spread = (m.crouch ? 0.15 : 0.4)
+ const where = {
+ x: m.pos.x + 25 * Math.cos(m.angle),
+ y: m.pos.y + 25 * Math.sin(m.angle)
+ }
+ const number = 16 * (tech.isShotgunReversed ? 1.5 : 1)
+ for (let i = 0; i < number; i++) {
+ const SPEED = 13 + 4 * Math.random();
+ const angle = m.angle + spread * (Math.random() - 0.5)
+ b.foam(where, {
+ x: 0.6 * player.velocity.x + SPEED * Math.cos(angle),
+ y: 0.5 * player.velocity.y + SPEED * Math.sin(angle)
+ }, 8 + 7 * Math.random())
+ }
+ } else if (tech.isNeedles) {
+ const number = 9 * (tech.isShotgunReversed ? 1.5 : 1)
+ const spread = (m.crouch ? 0.03 : 0.05)
+ let angle = m.angle - (number - 1) * spread * 0.5
+ for (let i = 0; i < number; i++) {
+ b.needle(angle)
+ angle += spread
+ }
+ } else {
+ spray(16); //fires normal shotgun bullets
+ }
+ }
+
+
+ coolDown();
+ b.muzzleFlash(35);
+ chooseBulletType();
+
+ if (tech.shotgunExtraShots) {
+ const delay = 7
+ let count = tech.shotgunExtraShots * delay
+
+ function cycle() {
+ count--
+ if (!(count % delay)) {
+ coolDown();
+ b.muzzleFlash(35);
+ chooseBulletType();
+ }
+ if (count > 0) {
+ requestAnimationFrame(cycle);
+ }
+ }
+ requestAnimationFrame(cycle);
+ }
+ }
+ }, {
+ name: "super balls", //2
+ descriptionFunction() {
+ return `fire 3 balls that retain momentum and kinetic energy after collisions ${this.ammoPack.toFixed(0)} balls per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 4.05,
+ defaultAmmoPack: 4.05,
+ have: false,
+ // num: 5,
+ do() { },
+ foamBall() { },
+ fireOne() {
+ m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 27 : 19) * b.fireCDscale); // cool down
+ const speed = m.crouch ? 43 : 36
+ b.superBall({
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, {
+ x: speed * Math.cos(m.angle),
+ y: speed * Math.sin(m.angle)
+ }, 21 * tech.bulletSize)
+ },
+ fireMulti() {
+ m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 23 : 15) * b.fireCDscale); // cool down
+ const SPREAD = m.crouch ? 0.08 : 0.13
+ const num = 3 + Math.floor(tech.extraSuperBalls * Math.random())
+ const speed = m.crouch ? 43 : 36
+ if (tech.isBulletTeleport) {
+ for (let i = 0; i < num; i++) {
+ b.superBall({
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, {
+ x: speed * Math.cos(m.angle),
+ y: speed * Math.sin(m.angle)
+ }, 11 * tech.bulletSize)
+ }
+ } else {
+ let dir = m.angle - SPREAD * (num - 1) / 2;
+ for (let i = 0; i < num; i++) {
+ b.superBall({
+ x: m.pos.x + 30 * Math.cos(dir),
+ y: m.pos.y + 30 * Math.sin(dir)
+ }, {
+ x: speed * Math.cos(dir),
+ y: speed * Math.sin(dir)
+ }, 11 * tech.bulletSize)
+ dir += SPREAD;
+ }
+ }
+ },
+ fireQueue() {
+ m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 23 : 15) * b.fireCDscale); // cool down
+ const num = 2 + 3 + Math.floor(tech.extraSuperBalls * Math.random()) //2 extra
+ const speed = m.crouch ? 43 : 36
+
+ const delay = Math.floor((m.crouch ? 18 : 12) * b.fireCDscale)
+ m.fireCDcycle = m.cycle + delay; // cool down
+ function cycle() {
+ count++
+ b.superBall({
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }, {
+ x: speed * Math.cos(m.angle),
+ y: speed * Math.sin(m.angle)
+ }, 11 * tech.bulletSize)
+ if (count < num && m.alive) requestAnimationFrame(cycle);
+ m.fireCDcycle = m.cycle + delay; // cool down
+ }
+ let count = 0
+ requestAnimationFrame(cycle);
+ },
+ chooseFireMethod() { //set in simulation.startGame
+ if (tech.oneSuperBall) {
+ this.fire = this.fireOne
+ } else if (tech.superBallDelay) {
+ this.fire = this.fireQueue
+ } else {
+ this.fire = this.fireMulti
+ }
+ },
+ fire() { }
+ },
+ {
+ name: "wave", //3
+ // description: `emit wave packets that propagate through solids waves slow mobs 115 packets per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `emit wave packets that propagate through solids waves slow mobs ${this.ammoPack.toFixed(0)} wave packets per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 60,
+ defaultAmmoPack: 60,
+ have: false,
+ wavePacketCycle: 0,
+ delay: 40,
+ phononWaveCD: 0,
+ waves: [], //used in longitudinal mode
+ chooseFireMethod() { //set in simulation.startGame
+ this.waves = [];
+ if (tech.isLongitudinal) {
+ if (tech.is360Longitudinal) {
+ this.fire = this.fire360Longitudinal
+ this.do = this.do360Longitudinal
+ } else {
+ this.fire = this.fireLongitudinal
+ this.do = this.doLongitudinal
+ }
+ } else {
+ this.fire = this.fireTransverse
+ this.do = this.doTransverse
+ }
+ },
+ do() { },
+ do360Longitudinal() {
+ if (!m.isTimeDilated) {
+ ctx.strokeStyle = "rgba(0,0,0,0.6)" //"000";
+ ctx.lineWidth = 2 * tech.wavePacketDamage
+ ctx.beginPath();
+ const end = 700 * Math.sqrt(tech.bulletsLastLonger)
+ const damage = 2.3 * m.dmgScale * tech.wavePacketDamage * tech.waveBeamDamage * (tech.isBulletTeleport ? 1.43 : 1) * (tech.isInfiniteWaveAmmo ? 0.75 : 1) //damage is lower for large radius mobs, since they feel the waves longer
+
+ for (let i = this.waves.length - 1; i > -1; i--) {
+ //draw wave
+ ctx.moveTo(this.waves[i].position.x + this.waves[i].radius, this.waves[i].position.y)
+ ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, 0, 2 * Math.PI);
+ // collisions
+ // if (tech.isBulletTeleport && Math.random() < 0.04) {
+ // const scale = 400 * Math.random()
+ // this.waves[i].position = Vector.add(this.waves[i].position, { x: scale * (Math.random() - 0.5), y: scale * (Math.random() - 0.5) })
+ // }
+ for (let j = 0, len = mob.length; j < len; j++) {
+ if (!mob[j].isShielded) {
+ const dist = Vector.magnitude(Vector.sub(this.waves[i].position, mob[j].position))
+ const r = mob[j].radius + 30
+ if (dist + r > this.waves[i].radius && dist - r < this.waves[i].radius) {
+ //make them shake around
+ if (!mob[j].isBadTarget) {
+ mob[j].force.x += 0.01 * (Math.random() - 0.5) * mob[j].mass
+ mob[j].force.y += 0.01 * (Math.random() - 0.5) * mob[j].mass
+ }
+ // if (!mob[j].isShielded) {
+ Matter.Body.setVelocity(mob[j], { //friction
+ x: mob[j].velocity.x * 0.95,
+ y: mob[j].velocity.y * 0.95
+ });
+ //draw vibes
+ let vertices = mob[j].vertices;
+ const vibe = 50 + mob[j].radius * 0.15
+ ctx.moveTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ for (let k = 1; k < vertices.length; k++) {
+ ctx.lineTo(vertices[k].x + vibe * (Math.random() - 0.5), vertices[k].y + vibe * (Math.random() - 0.5));
+ }
+ ctx.lineTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ //damage
+ mob[j].locatePlayer();
+ mob[j].damage(damage / Math.sqrt(mob[j].radius));
+ // }
+ if (tech.isPhononWave && this.phononWaveCD < m.cycle) {
+ this.phononWaveCD = m.cycle + 8 * (1 + this.waves[i].resonanceCount)
+ this.waves.push({
+ position: mob[j].position,
+ radius: 25,
+ resonanceCount: this.waves[i].resonanceCount + 1,
+ })
+ }
+ }
+ }
+ }
+ // for (let j = 0, len = body.length; j < len; j++) {
+ for (let j = 0, len = Math.min(30, body.length); j < len; j++) {
+ const dist = Vector.magnitude(Vector.sub(this.waves[i].position, body[j].position))
+ const r = 20
+ if (dist + r > this.waves[i].radius && dist - r < this.waves[i].radius) {
+ const who = body[j]
+ //make them shake around
+ who.force.x += 0.01 * (Math.random() - 0.5) * who.mass
+ who.force.y += (0.01 * (Math.random() - 0.5) - simulation.g * 0.25) * who.mass //remove force of gravity
+ //draw vibes
+ let vertices = who.vertices;
+ const vibe = 25
+ ctx.moveTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ for (let k = 1; k < vertices.length; k++) {
+ ctx.lineTo(vertices[k].x + vibe * (Math.random() - 0.5), vertices[k].y + vibe * (Math.random() - 0.5));
+ }
+ ctx.lineTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+
+ if (tech.isPhononBlock && !who.isNotHoldable && who.speed < 5 && who.angularSpeed < 0.1) {
+ if (Math.random() < 0.5) b.targetedBlock(who, 50 - Math.min(25, who.mass * 3)) // targetedBlock(who, speed = 50 - Math.min(20, who.mass * 2), range = 1600) {
+ // Matter.Body.setAngularVelocity(who, (0.25 + 0.1 * Math.random()) * (Math.random() < 0.5 ? -1 : 1));
+ who.torque += who.inertia * 0.001 * (Math.random() - 0.5)
+ }
+ }
+ }
+ this.waves[i].radius += 0.9 * tech.waveBeamSpeed //expand / move
+ // if (this.waves[i].radius > end) this.waves.splice(i, 1) //end
+ if (this.waves[i].radius > end - 30 * this.waves[i].resonanceCount) { //* Math.pow(0.9, this.waves[i].resonanceCount)
+ this.waves.splice(i, 1) //end
+ }
+ }
+ ctx.stroke();
+ }
+ },
+ fire360Longitudinal() {
+ m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 4 : 8) * b.fireCDscale); // cool down
+ this.waves.push({
+ position: { x: m.pos.x, y: m.pos.y, },
+ radius: 25,
+ resonanceCount: 0 //used with tech.isPhononWave
+ })
+ },
+ doLongitudinal() {
+ if (!m.isTimeDilated) {
+ ctx.strokeStyle = "rgba(0,0,0,0.6)" //"000";
+ ctx.lineWidth = 2 * tech.wavePacketDamage
+ ctx.beginPath();
+ const end = 1100 * tech.bulletsLastLonger
+ const damage = 2.3 * m.dmgScale * tech.wavePacketDamage * tech.waveBeamDamage * (tech.isBulletTeleport ? 1.4 : 1) * (tech.isInfiniteWaveAmmo ? 0.75 : 1) //damage is lower for large radius mobs, since they feel the waves longer
+ for (let i = this.waves.length - 1; i > -1; i--) {
+ const v1 = Vector.add(this.waves[i].position, Vector.mult(this.waves[i].unit1, this.waves[i].radius))
+ const v2 = Vector.add(this.waves[i].position, Vector.mult(this.waves[i].unit2, this.waves[i].radius))
+ //draw wave
+ ctx.moveTo(v1.x, v1.y)
+ ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, this.waves[i].angle, this.waves[i].angle + this.waves[i].arc);
+ //using small angle linear approximation of circle arc, this will not work if the arc gets large // https://stackoverflow.com/questions/13652518/efficiently-find-points-inside-a-circle-sector
+ let hits = Matter.Query.ray(mob, v1, v2, 50) //Matter.Query.ray(bodies, startPoint, endPoint, [rayWidth])
+ for (let j = 0; j < hits.length; j++) {
+ const who = hits[j].body
+ if (!who.isShielded) {
+ who.force.x += 0.01 * (Math.random() - 0.5) * who.mass
+ who.force.y += 0.01 * (Math.random() - 0.5) * who.mass
+ Matter.Body.setVelocity(who, { x: who.velocity.x * 0.95, y: who.velocity.y * 0.95 });
+ let vertices = who.vertices;
+ const vibe = 50 + who.radius * 0.15
+ ctx.moveTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ for (let j = 1; j < vertices.length; j++) ctx.lineTo(vertices[j].x + vibe * (Math.random() - 0.5), vertices[j].y + vibe * (Math.random() - 0.5));
+ ctx.lineTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ who.locatePlayer();
+ who.damage(damage / Math.sqrt(who.radius));
+
+ if (tech.isPhononWave && this.phononWaveCD < m.cycle) {
+ this.phononWaveCD = m.cycle + 8 * (1 + this.waves[i].resonanceCount)
+ const halfArc = 0.27 //6.28 is a full circle, but these arcs needs to stay small because we are using small angle linear approximation, for collisions
+ let closestMob, dist
+ let range = end - 30 * this.waves[i].resonanceCount
+ for (let i = 0, len = mob.length; i < len; i++) {
+ if (who !== mob[i] && !mob[i].isBadTarget && !mob[i].isInvulnerable) {
+ dist = Vector.magnitude(Vector.sub(who.position, mob[i].position));
+ if (dist < range) {
+ closestMob = mob[i]
+ range = dist
+ }
+ }
+ }
+ if (closestMob) {
+ const dir = Vector.normalise(Vector.sub(closestMob.position, who.position))
+ var angle = Math.atan2(dir.y, dir.x)
+ } else {
+ var angle = 2 * Math.PI * Math.random()
+ }
+ this.waves.push({
+ position: who.position,
+ angle: angle - halfArc, //used in drawing ctx.arc
+ unit1: { x: Math.cos(angle - halfArc), y: Math.sin(angle - halfArc) }, //used for collision
+ unit2: { x: Math.cos(angle + halfArc), y: Math.sin(angle + halfArc) }, //used for collision
+ arc: halfArc * 2,
+ radius: 25,
+ resonanceCount: this.waves[i].resonanceCount + 1
+ })
+ }
+ }
+ }
+
+ hits = Matter.Query.ray(body, v1, v2, 50) //Matter.Query.ray(bodies, startPoint, endPoint, [rayWidth])
+ for (let j = 0, len = Math.min(30, hits.length); j < len; j++) {
+ const who = hits[j].body
+ //make them shake around
+ who.force.x += 0.01 * (Math.random() - 0.5) * who.mass
+ who.force.y += (0.01 * (Math.random() - 0.5) - simulation.g * 0.25) * who.mass //remove force of gravity
+ let vertices = who.vertices;
+ const vibe = 25
+ ctx.moveTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+ for (let j = 1; j < vertices.length; j++) {
+ ctx.lineTo(vertices[j].x + vibe * (Math.random() - 0.5), vertices[j].y + vibe * (Math.random() - 0.5));
+ }
+ ctx.lineTo(vertices[0].x + vibe * (Math.random() - 0.5), vertices[0].y + vibe * (Math.random() - 0.5));
+
+ if (tech.isPhononBlock && !who.isNotHoldable && who.speed < 5 && who.angularSpeed < 0.1) {
+ if (Math.random() < 0.5) b.targetedBlock(who, 50 - Math.min(25, who.mass * 3)) // targetedBlock(who, speed = 50 - Math.min(20, who.mass * 2), range = 1600) {
+ // Matter.Body.setAngularVelocity(who, (0.25 + 0.12 * Math.random()) * (Math.random() < 0.5 ? -1 : 1));
+ who.torque += who.inertia * 0.001 * (Math.random() - 0.5)
+ }
+ }
+
+ this.waves[i].radius += tech.waveBeamSpeed * 1.8 //expand / move
+ if (this.waves[i].radius > end - 30 * this.waves[i].resonanceCount) {
+ this.waves.splice(i, 1) //end
+ }
+ }
+ ctx.stroke();
+ }
+ },
+ fireLongitudinal() {
+ m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 4 : 8) * b.fireCDscale); // cool down
+ const halfArc = (m.crouch ? 0.0785 : 0.275) * (tech.isBulletTeleport ? 0.66 + (Math.random() - 0.5) : 1) //6.28 is a full circle, but these arcs needs to stay small because we are using small angle linear approximation, for collisions
+ const angle = m.angle + tech.isBulletTeleport * 0.3 * (Math.random() - 0.5)
+ this.waves.push({
+ position: { x: m.pos.x + 25 * Math.cos(m.angle), y: m.pos.y + 25 * Math.sin(m.angle), },
+ angle: angle - halfArc, //used in drawing ctx.arc
+ unit1: { x: Math.cos(angle - halfArc), y: Math.sin(angle - halfArc) }, //used for collision
+ unit2: { x: Math.cos(angle + halfArc), y: Math.sin(angle + halfArc) }, //used for collision
+ arc: halfArc * 2,
+ radius: 25,
+ resonanceCount: 0
+ })
+ },
+ doTransverse() {
+ // if (this.wavePacketCycle && !input.fire) {
+ // this.wavePacketCycle = 0;
+ // m.fireCDcycle = m.cycle + Math.floor(this.delay * b.fireCDscale); // cool down
+ // }
+ },
+ fireTransverse() {
+ totalCycles = Math.floor((3.5) * 35 * tech.waveReflections * tech.bulletsLastLonger / Math.sqrt(tech.waveReflections * 0.5))
+ const me = bullet.length;
+ bullet[me] = Bodies.polygon(m.pos.x + 25 * Math.cos(m.angle), m.pos.y + 25 * Math.sin(m.angle), 5, 4, {
+ angle: m.angle,
+ cycle: -0.5,
+ endCycle: simulation.cycle + totalCycles,
+ inertia: Infinity,
+ frictionAir: 0,
+ slow: 0,
+ // amplitude: (m.crouch ? 5 : 10) * ((this.wavePacketCycle % 2) ? -1 : 1) * Math.sin((this.wavePacketCycle + 1) * 0.088), //0.0968 //0.1012 //0.11 //0.088 //shorten wave packet
+ amplitude: (m.crouch ? 6 : 12) * ((this.wavePacketCycle % 2) ? -1 : 1) * Math.sin(this.wavePacketCycle * 0.088) * Math.sin(this.wavePacketCycle * 0.04), //0.0968 //0.1012 //0.11 //0.088 //shorten wave packet
+ minDmgSpeed: 0,
+ dmg: m.dmgScale * tech.waveBeamDamage * tech.wavePacketDamage * (tech.isBulletTeleport ? 1.43 : 1) * (tech.isInfiniteWaveAmmo ? 0.75 : 1), //also control damage when you divide by mob.mass
+ dmgCoolDown: 0,
+ classType: "bullet",
+ collisionFilter: {
+ category: 0,
+ mask: 0, //cat.mob | cat.mobBullet | cat.mobShield
+ },
+ beforeDmg() { },
+ onEnd() { },
+ do() { },
+ query() {
+ let slowCheck = 1
+ if (Matter.Query.point(map, this.position).length) { //check if inside map
+ slowCheck = waveSpeedMap
+ } else { //check if inside a body
+ let q = Matter.Query.point(body, this.position)
+ if (q.length) {
+ slowCheck = waveSpeedBody
+ Matter.Body.setPosition(this, Vector.add(this.position, q[0].velocity)) //move with the medium
+ }
+ }
+ if (slowCheck !== this.slow) { //toggle velocity based on inside and outside status change
+ this.slow = slowCheck
+ Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), tech.waveBeamSpeed * slowCheck));
+ }
+
+ if (this.dmgCoolDown < 1) {
+ q = Matter.Query.point(mob, this.position) // check if inside a mob
+ for (let i = 0; i < q.length; i++) {
+ this.dmgCoolDown = 5 + Math.floor(8 * Math.random() * b.fireCDscale);
+ let dmg = this.dmg
+ q[i].damage(dmg);
+ if (q[i].alive) {
+ q[i].foundPlayer();
+ Matter.Body.setVelocity(q[i], Vector.mult(q[i].velocity, 0.9))
+ }
+ // this.endCycle = 0; //bullet ends cycle after doing damage
+ if (q[i].damageReduction) {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: this.position.x,
+ y: this.position.y,
+ radius: Math.log(dmg + 1.1) * 40 * q[i].damageReduction + 3,
+ color: 'rgba(0,0,0,0.4)',
+ time: simulation.drawTime
+ });
+ }
+ }
+ } else {
+ this.dmgCoolDown--
+ }
+ },
+ wiggle() {
+ this.cycle++
+ const where = Vector.mult(transverse, this.amplitude * Math.cos(this.cycle * tech.waveFrequency))
+ Matter.Body.setPosition(this, Vector.add(this.position, where))
+ }
+ });
+ if (tech.isBulletTeleport) {
+ bullet[me].wiggle = function () {
+ this.cycle++
+ const where = Vector.mult(transverse, this.amplitude * Math.cos(this.cycle * tech.waveFrequency))
+ if (Math.random() < 0.005) {
+ if (Math.random() < 0.33) { //randomize position
+ const scale = 500 * Math.random()
+ Matter.Body.setPosition(this, Vector.add({
+ x: scale * (Math.random() - 0.5),
+ y: scale * (Math.random() - 0.5)
+ }, Vector.add(this.position, where)))
+ } else { //randomize position in velocity direction
+ const velocityScale = Vector.mult(this.velocity, 50 * (Math.random() - 0.5))
+ Matter.Body.setPosition(this, Vector.add(velocityScale, Vector.add(this.position, where)))
+ }
+
+ } else {
+ Matter.Body.setPosition(this, Vector.add(this.position, where))
+ }
+ }
+ }
+ let waveSpeedMap = 0.13
+ let waveSpeedBody = 0.3
+ if (tech.isPhaseVelocity) {
+ waveSpeedMap = 3.5
+ waveSpeedBody = 2
+ bullet[me].dmg *= 1.5
+ }
+ if (tech.waveReflections) {
+ bullet[me].reflectCycle = totalCycles / tech.waveReflections //tech.waveLengthRange
+ bullet[me].do = function () {
+ this.query()
+ if (this.cycle > this.reflectCycle) {
+ this.reflectCycle += totalCycles / tech.waveReflections
+ Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1));
+ // if (this.reflectCycle > tech.waveLengthRange * (1 + tech.waveReflections)) this.endCycle = 0;
+ }
+ this.wiggle()
+ }
+ } else {
+ bullet[me].do = function () {
+ this.query()
+ this.wiggle();
+ }
+ }
+ Composite.add(engine.world, bullet[me]); //add bullet to world
+ Matter.Body.setVelocity(bullet[me], {
+ x: tech.waveBeamSpeed * Math.cos(m.angle),
+ y: tech.waveBeamSpeed * Math.sin(m.angle)
+ });
+ const transverse = Vector.normalise(Vector.perp(bullet[me].velocity))
+ this.wavePacketCycle++
+ },
+ fire() { }
+ },
+ {
+ name: "missiles", //6
+ // description: `launch homing missiles that target mobs missiles explode on contact with mobs 5 missiles per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `launch homing missiles that target mobs missiles explode on contact with mobs ${this.ammoPack.toFixed(1)} missiles per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 2.3,
+ defaultAmmoPack: 2.3,
+ have: false,
+ fireCycle: 0,
+ do() { },
+ fire() {
+ const countReduction = Math.pow(0.86, tech.missileCount)
+ // if (m.crouch) {
+ // m.fireCDcycle = m.cycle + tech.missileFireCD * b.fireCDscale / countReduction; // cool down
+ // // for (let i = 0; i < tech.missileCount; i++) {
+ // // b.missile(where, -Math.PI / 2 + 0.2 * (Math.random() - 0.5) * Math.sqrt(tech.missileCount), -2, Math.sqrt(countReduction))
+ // // bullet[bullet.length - 1].force.x += 0.004 * countReduction * (i - (tech.missileCount - 1) / 2);
+ // // }
+
+ // if (tech.missileCount > 1) {
+ // for (let i = 0; i < tech.missileCount; i++) {
+ // setTimeout(() => {
+ // const where = { x: m.pos.x, y: m.pos.y - 40 }
+ // b.missile(where, -Math.PI / 2 + 0.2 * (Math.random() - 0.5) * Math.sqrt(tech.missileCount), -2, Math.sqrt(countReduction))
+ // bullet[bullet.length - 1].force.x += 0.025 * countReduction * (i - (tech.missileCount - 1) / 2);
+ // }, 20 * tech.missileCount * Math.random());
+ // }
+ // } else {
+ // const where = {
+ // x: m.pos.x,
+ // y: m.pos.y - 40
+ // }
+ // b.missile(where, -Math.PI / 2 + 0.2 * (Math.random() - 0.5), -2)
+ // }
+ // } else {
+ m.fireCDcycle = m.cycle + tech.missileFireCD * b.fireCDscale / countReduction; // cool down
+ const direction = { x: Math.cos(m.angle), y: Math.sin(m.angle) }
+ // const where = {
+ // x: m.pos.x + 30 * direction.x,
+ // y: m.pos.y + 30 * direction.y
+ // }
+ if (tech.missileCount > 1) {
+ const push = Vector.mult(Vector.perp(direction), 0.2 * countReduction / Math.sqrt(tech.missileCount))
+ const sqrtCountReduction = Math.sqrt(countReduction)
+ // for (let i = 0; i < tech.missileCount; i++) {
+ // setTimeout(() => {
+ // if (m.crouch) {
+ // b.missile(where, m.angle, 20, sqrtCountReduction)
+ // // bullet[bullet.length - 1].force.x += 0.7 * push.x * (i - (tech.missileCount - 1) / 2);
+ // // bullet[bullet.length - 1].force.y += 0.7 * push.y * (i - (tech.missileCount - 1) / 2);
+ // } else {
+ // b.missile(where, m.angle, -10, sqrtCountReduction)
+ // bullet[bullet.length - 1].force.x += push.x * (i - (tech.missileCount - 1) / 2);
+ // bullet[bullet.length - 1].force.y += 0.005 + push.y * (i - (tech.missileCount - 1) / 2);
+ // }
+
+ // }, 1 + i * 10 * tech.missileCount);
+ // }
+ const launchDelay = 4
+ let count = 0
+ const fireMissile = () => {
+ if (m.crouch) {
+ b.missile({ x: m.pos.x + 30 * direction.x, y: m.pos.y + 30 * direction.y }, m.angle, 20, sqrtCountReduction)
+ bullet[bullet.length - 1].force.x += 0.5 * push.x * (Math.random() - 0.5)
+ bullet[bullet.length - 1].force.y += 0.004 + 0.5 * push.y * (Math.random() - 0.5)
+ } else {
+ b.missile({ x: m.pos.x + 30 * direction.x, y: m.pos.y + 30 * direction.y }, m.angle, -15, sqrtCountReduction)
+ bullet[bullet.length - 1].force.x += push.x * (Math.random() - 0.5)
+ bullet[bullet.length - 1].force.y += 0.005 + push.y * (Math.random() - 0.5)
+ }
+ }
+ const cycle = () => {
+ if ((simulation.paused) && m.alive) {
+ requestAnimationFrame(cycle)
+ } else {
+ count++
+ if (!(count % launchDelay)) {
+ fireMissile()
+ }
+ if (count < tech.missileCount * launchDelay && m.alive) requestAnimationFrame(cycle);
+ }
+ }
+ requestAnimationFrame(cycle);
+ } else {
+ if (m.crouch) {
+ b.missile({ x: m.pos.x + 40 * direction.x, y: m.pos.y + 40 * direction.y }, m.angle, 25)
+ } else {
+ b.missile({ x: m.pos.x + 40 * direction.x, y: m.pos.y + 40 * direction.y }, m.angle, -12)
+ bullet[bullet.length - 1].force.y += 0.04 * (Math.random() - 0.2)
+ }
+ }
+ }
+ }, {
+ name: "grenades", //5
+ // description: `lob a single bouncy projectile explodes on contact or after one second 7 grenades per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `lob a single bouncy projectile explodes on contact or after 1.5 seconds ${this.ammoPack.toFixed(0)} grenades per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 3.2,
+ defaultAmmoPack: 3.2,
+ have: false,
+ do() { }, //do is set in b.setGrenadeMode()
+ fire() {
+ const countReduction = Math.pow(0.93, tech.missileCount)
+ m.fireCDcycle = m.cycle + Math.floor((m.crouch ? 35 : 27) * b.fireCDscale / countReduction); // cool down
+ const where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }
+ const SPREAD = m.crouch ? 0.12 : 0.2
+ let angle = m.angle - SPREAD * (tech.missileCount - 1) / 2;
+ for (let i = 0; i < tech.missileCount; i++) {
+ b.grenade(where, angle, countReduction) //function(where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle, size = 1)
+ angle += SPREAD
+ }
+ },
+ }, {
+ name: "spores", //6
+ // description: `toss a sporangium that discharges spores spores seek out nearby mobs 2-3 sporangium per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `toss a sporangium that discharges ${b.guns[6].nameString("s")} ${b.guns[6].nameString("s")} seek out nearby mobs ${this.ammoPack.toFixed(1)} sporangium per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 1.22,
+ defaultAmmoPack: 1.22,
+ have: false,
+ nameString(suffix = "") {
+ if (tech.isSporeFlea) {
+ return `flea${suffix}`
+ } else if (tech.isSporeWorm) {
+ return `worm${suffix}`
+ } else {
+ return `spore${suffix}`
+ }
+ },
+ do() { },
+ fire() {
+ const me = bullet.length;
+ const dir = m.angle;
+ bullet[me] = Bodies.polygon(m.pos.x + 30 * Math.cos(m.angle), m.pos.y + 30 * Math.sin(m.angle), 20, 4.5, b.fireAttributes(dir, false));
+ b.fireProps(m.crouch ? 40 : 20, m.crouch ? 30 : 16, dir, me); //cd , speed
+ Matter.Body.setDensity(bullet[me], 0.000001);
+ bullet[me].endCycle = simulation.cycle + 480 + Math.max(0, 120 - 2 * bullet.length);
+ bullet[me].frictionAir = 0;
+ bullet[me].friction = 0.5;
+ bullet[me].radius = 4.5;
+ bullet[me].maxRadius = 30;
+ bullet[me].restitution = 0.3;
+ bullet[me].minDmgSpeed = 0;
+ bullet[me].totalSpores = 8 + 2 * tech.isSporeFreeze + 5 * tech.isSporeColony
+ bullet[me].stuck = function () { };
+ bullet[me].beforeDmg = function () { };
+ bullet[me].do = function () {
+ function onCollide(that) {
+ that.collisionFilter.mask = 0; //non collide with everything
+ Matter.Body.setVelocity(that, { x: 0, y: 0 });
+ that.do = that.grow;
+ }
+ const mobCollisions = Matter.Query.collides(this, mob)
+ if (mobCollisions.length) {
+ onCollide(this)
+ this.stuckTo = mobCollisions[0].bodyA
+ if (tech.isZombieMobs) this.stuckTo.isSoonZombie = true
+ if (this.stuckTo.isVerticesChange) {
+ this.stuckToRelativePosition = { x: 0, y: 0 }
+ } else {
+ //find the relative position for when the mob is at angle zero by undoing the mobs rotation
+ this.stuckToRelativePosition = Vector.rotate(Vector.sub(this.position, this.stuckTo.position), -this.stuckTo.angle)
+ }
+ this.stuck = function () {
+ if (this.stuckTo && this.stuckTo.alive) {
+ const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
+ Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
+ Matter.Body.setVelocity(this, this.stuckTo.velocity); //so that it will move properly if it gets unstuck
+ } else {
+ this.collisionFilter.mask = cat.map; //non collide with everything but map
+ this.stuck = function () {
+ this.force.y += this.mass * 0.0006;
+ }
+ }
+ }
+ } else {
+ const bodyCollisions = Matter.Query.collides(this, body)
+ if (bodyCollisions.length) {
+ if (!bodyCollisions[0].bodyA.isNonStick) {
+ onCollide(this)
+ this.stuckTo = bodyCollisions[0].bodyA
+ //find the relative position for when the mob is at angle zero by undoing the mobs rotation
+ this.stuckToRelativePosition = Vector.rotate(Vector.sub(this.position, this.stuckTo.position), -this.stuckTo.angle)
+ } else {
+ this.do = this.grow;
+ }
+ this.stuck = function () {
+ if (this.stuckTo) {
+ const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
+ Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
+ // Matter.Body.setVelocity(this, this.stuckTo.velocity); //so that it will move properly if it gets unstuck
+ } else {
+ this.force.y += this.mass * 0.0006;
+ }
+ }
+ } else {
+ if (Matter.Query.collides(this, map).length) {
+ onCollide(this)
+ } else { //if colliding with nothing just fall
+ this.force.y += this.mass * 0.0006;
+ simulation.mouseInGame.x
+ }
+ }
+ }
+ //draw green glow
+ ctx.fillStyle = "rgba(0,200,125,0.16)";
+ ctx.beginPath();
+ ctx.arc(this.position.x, this.position.y, this.maxRadius, 0, 2 * Math.PI);
+ ctx.fill();
+ }
+ bullet[me].grow = function () {
+ this.stuck(); //runs different code based on what the bullet is stuck to
+ let scale = 1.01
+ if (tech.isSporeGrowth && !(simulation.cycle % 40)) { //release a spore
+ if (tech.isSporeFlea) {
+ if (!(simulation.cycle % 80)) {
+ const speed = 10 + 5 * Math.random()
+ const angle = 2 * Math.PI * Math.random()
+ b.flea(this.position, {
+ x: speed * Math.cos(angle),
+ y: speed * Math.sin(angle)
+ })
+ }
+ } else if (tech.isSporeWorm) {
+ if (!(simulation.cycle % 80)) b.worm(this.position)
+ } else {
+ b.spore(this.position)
+ }
+ scale = 0.96
+ if (this.stuckTo && this.stuckTo.alive) scale = 0.9
+ Matter.Body.scale(this, scale, scale);
+ this.radius *= scale
+ } else {
+ if (this.stuckTo && this.stuckTo.alive) scale = 1.03
+ Matter.Body.scale(this, scale, scale);
+ this.radius *= scale
+ if (this.radius > this.maxRadius) this.endCycle = 0;
+ }
+ //draw green glow
+ ctx.fillStyle = "rgba(0,200,125,0.16)";
+ ctx.beginPath();
+ ctx.arc(this.position.x, this.position.y, this.maxRadius, 0, 2 * Math.PI);
+ ctx.fill();
+ };
+ //spawn bullets on end
+ bullet[me].onEnd = function () {
+ let count = 0 //used in for loop below
+ const things = [
+ () => { //spore
+ b.spore(this.position)
+ },
+ () => { //worm
+ count++ //count as 2 things
+ b.worm(this.position)
+ },
+ () => { //flea
+ count++ //count as 2 things
+ const speed = 10 + 5 * Math.random()
+ const angle = 2 * Math.PI * Math.random()
+ b.flea(this.position, {
+ x: speed * Math.cos(angle),
+ y: speed * Math.sin(angle)
+ })
+ },
+ () => { // drones
+ b.drone(this.position)
+ },
+ () => { // ice IX
+ b.iceIX(1, Math.random() * 2 * Math.PI, this.position)
+ },
+ () => { //missile
+ count++ //count as 2 things
+ b.missile(this.position, -Math.PI / 2 + 0.5 * (Math.random() - 0.5), 0, 1)
+ },
+ () => { //nail
+ b.targetedNail(this.position, 1, 39 + 6 * Math.random())
+ },
+ () => { //super ball
+ const speed = 36
+ const angle = 2 * Math.PI * Math.random()
+ b.superBall(this.position, {
+ x: speed * Math.cos(angle),
+ y: speed * Math.sin(angle)
+ }, 11 * tech.bulletSize)
+ },
+ ]
+
+ for (len = this.totalSpores; count < len; count++) {
+ if (tech.isSporeColony && Math.random() < 0.33) {
+ things[Math.floor(Math.random() * things.length)]()
+ } else if (tech.isSporeFlea) {
+ things[2]()
+ } else if (tech.isSporeWorm) {
+ things[1]()
+ } else {
+ things[0]() //spores
+ }
+ }
+ // } else if (tech.isSporeFlea) {
+ // for (let i = 0, len = this.totalSpores; i < len; i++) things[2]()
+ // } else if (tech.isSporeWorm) {
+ // for (let i = 0, len = this.totalSpores; i < len; i++) things[1]()
+ // } else {
+ // for (let i = 0; i < this.totalSpores; i++) things[0]()
+ // }
+ if (tech.isStun) b.AoEStunEffect(this.position, 600, 270 + 120 * Math.random()); //AoEStunEffect(where, range, cycles = 120 + 60 * Math.random()) {
+ }
+ }
+ }, {
+ name: "drones", //7
+ // description: `deploy autonomous drones that smash into mobs and collect nearby power ups 16 drones per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `deploy autonomousdrones that smash into mobs drones collect nearby power ups ${this.ammoPack.toFixed(0)} drones per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 7.3,
+ defaultAmmoPack: 7.3,
+ have: false,
+ do() { },
+ fire() {
+ if (tech.isDroneRadioactive) {
+ if (m.crouch) {
+ b.droneRadioactive({
+ x: m.pos.x + 30 * Math.cos(m.angle) + 10 * (Math.random() - 0.5),
+ y: m.pos.y + 30 * Math.sin(m.angle) + 10 * (Math.random() - 0.5)
+ }, 45)
+ m.fireCDcycle = m.cycle + Math.floor(45 * b.fireCDscale); // cool down
+ } else {
+ b.droneRadioactive({
+ x: m.pos.x + 30 * Math.cos(m.angle) + 10 * (Math.random() - 0.5),
+ y: m.pos.y + 30 * Math.sin(m.angle) + 10 * (Math.random() - 0.5)
+ }, 10)
+ m.fireCDcycle = m.cycle + Math.floor(25 * b.fireCDscale); // cool down
+ }
+ } else {
+ if (m.crouch) {
+ b.drone({
+ x: m.pos.x + 30 * Math.cos(m.angle) + 5 * (Math.random() - 0.5),
+ y: m.pos.y + 30 * Math.sin(m.angle) + 5 * (Math.random() - 0.5)
+ }, 50)
+ m.fireCDcycle = m.cycle + Math.floor(7 * b.fireCDscale); // cool down
+ } else {
+ b.drone({
+ x: m.pos.x + 30 * Math.cos(m.angle) + 10 * (Math.random() - 0.5),
+ y: m.pos.y + 30 * Math.sin(m.angle) + 10 * (Math.random() - 0.5)
+ }, 15)
+ m.fireCDcycle = m.cycle + Math.floor(4 * b.fireCDscale); // cool down
+ }
+ }
+ }
+ },
+ {
+ name: "foam", //8
+ descriptionFunction() {
+ return `spray bubbly foam that sticks to mobs slows mobs and does damage over time ${this.ammoPack.toFixed(0)} bubbles per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 12.6,
+ defaultAmmoPack: 12.6,
+ have: false,
+ charge: 0,
+ isDischarge: false,
+ knockBack: 0.0005, //set in tech: cavitation
+ applyKnock(velocity) {
+ player.force.x -= this.knockBack * velocity.x
+ player.force.y -= 2 * this.knockBack * velocity.y
+ },
+ chooseFireMethod() {
+ if (tech.isFoamPressure) {
+ this.do = this.doCharges
+ this.fire = this.fireCharges
+ } else {
+ this.do = this.doStream
+ this.fire = this.fireStream
+ }
+ },
+ doStream() { },
+ fireStream() {
+ const spread = (m.crouch ?
+ 0.04 * (Math.random() - 0.5) + 0.09 * Math.sin(m.cycle * 0.12) :
+ 0.23 * (Math.random() - 0.5) + 0.15 * Math.sin(m.cycle * 0.12)
+ )
+ const radius = 5 + 8 * Math.random() + (tech.isAmmoFoamSize && this.ammo < 300) * 12
+ const SPEED = (m.crouch ? 1.2 : 1) * Math.max(2, 14 - radius * 0.25)
+ const dir = m.angle + 0.15 * (Math.random() - 0.5)
+ const velocity = {
+ x: 0.7 * player.velocity.x + SPEED * Math.cos(dir),
+ y: 0.5 * player.velocity.y + SPEED * Math.sin(dir)
+ }
+ const position = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }
+ b.foam(position, Vector.rotate(velocity, spread), radius)
+ // this.applyKnock(velocity)
+ m.fireCDcycle = m.cycle + Math.floor(1.5 * b.fireCDscale);
+ },
+ doCharges() {
+ if (this.charge > 0) {
+ //draw charge level
+ ctx.fillStyle = "rgba(0,50,50,0.3)";
+ ctx.beginPath();
+ const radius = 5 * Math.sqrt(this.charge)
+ const mag = 11 + radius
+ ctx.arc(m.pos.x + mag * Math.cos(m.angle), m.pos.y + mag * Math.sin(m.angle), radius, 0, 2 * Math.PI);
+ ctx.fill();
+
+ if (this.isDischarge && m.cycle % 2) {
+ const spread = (m.crouch ? 0.04 : 0.5) * (Math.random() - 0.5)
+ const radius = 5 + 8 * Math.random() + (tech.isAmmoFoamSize && this.ammo < 300) * 12
+ const SPEED = (m.crouch ? 1.2 : 1) * 10 - radius * 0.4 + Math.min(5, Math.sqrt(this.charge));
+ const dir = m.angle + 0.15 * (Math.random() - 0.5)
+ const velocity = {
+ x: 0.7 * player.velocity.x + SPEED * Math.cos(dir),
+ y: 0.5 * player.velocity.y + SPEED * Math.sin(dir)
+ }
+ const position = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }
+ b.foam(position, Vector.rotate(velocity, spread), radius)
+ // this.applyKnock(velocity)
+ this.charge -= 0.75
+ m.fireCDcycle = m.cycle + 2; //disable firing and adding more charge until empty
+ } else if (!input.fire) {
+ this.isDischarge = true;
+ }
+ } else {
+ if (this.isDischarge) {
+ m.fireCDcycle = m.cycle + Math.floor(25 * b.fireCDscale);
+ }
+ this.isDischarge = false
+ }
+ },
+ fireCharges() {
+ const spread = (m.crouch ?
+ 0.04 * (Math.random() - 0.5) + 0.09 * Math.sin(m.cycle * 0.12) :
+ 0.23 * (Math.random() - 0.5) + 0.15 * Math.sin(m.cycle * 0.12)
+ )
+ const radius = 5 + 8 * Math.random() + (tech.isAmmoFoamSize && this.ammo < 300) * 12
+ const SPEED = (m.crouch ? 1.2 : 1) * Math.max(2, 14 - radius * 0.25)
+ const dir = m.angle + 0.15 * (Math.random() - 0.5)
+ const velocity = {
+ x: 0.7 * player.velocity.x + SPEED * Math.cos(dir),
+ y: 0.5 * player.velocity.y + SPEED * Math.sin(dir)
+ }
+ const position = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }
+
+ b.foam(position, Vector.rotate(velocity, spread), radius)
+ // this.applyKnock(velocity)
+ m.fireCDcycle = m.cycle + Math.floor(1.5 * b.fireCDscale);
+ this.charge += 1 + tech.isCapacitor
+ },
+ fire() { },
+ do() { },
+ },
+ {
+ name: "harpoon", //9
+ // description: `throw a self-steering harpoon that uses energy to retract and refund its ammo cost 1-2 harpoons per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `throw a harpoon that uses energy to retract harpoons refund ammo ${this.ammoPack.toFixed(1)} harpoons per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 0.77, //update this in railgun tech
+ defaultAmmoPack: 0.77,
+ have: false,
+ fire() { },
+ do() { },
+ chooseFireMethod() {
+ if (tech.isRailGun) {
+ this.do = this.railDo
+ this.fire = this.railFire
+ // } else if (tech.isGrapple) {
+ // this.do = () => { }
+ // this.fire = this.grappleFire
+ } else {
+ this.do = () => { }
+ this.fire = this.harpoonFire
+ }
+ },
+ charge: 0,
+ railDo() {
+ if (this.charge > 0) {
+ const DRAIN = (tech.isRailEnergy ? 0 : 0.002)
+ //exit railgun charging without firing
+ if (m.energy < DRAIN) {
+ m.fireCDcycle = m.cycle + 120; // cool down if out of energy
+ this.endCycle = 0;
+ this.charge = 0
+ b.refundAmmo()
+ return
+ }
+ //fire
+ if ((!input.fire && this.charge > 0.6)) {
+ const where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }
+ const closest = {
+ distance: 10000,
+ target: null
+ }
+ //push away blocks and mobs
+ const range = 600 + 500 * this.charge
+ for (let i = 0, len = mob.length; i < len; ++i) { //push away mobs when firing
+ if (!mob[i].isUnblockable) {
+ const SUB = Vector.sub(mob[i].position, m.pos)
+ const DISTANCE = Vector.magnitude(SUB)
+ if (DISTANCE < range + mob[i].radius) {
+ const DEPTH = 100 + Math.min(range - DISTANCE + mob[i].radius, 1500)
+ const FORCE = Vector.mult(Vector.normalise(SUB), 0.0015 * Math.sqrt(DEPTH) * mob[i].mass)
+ mob[i].force.x += FORCE.x;
+ mob[i].force.y += FORCE.y;
+
+ let dmg = m.dmgScale * (mob[i].isDropPowerUp ? 350 : 1100) * tech.harpoonDensity * this.charge
+ simulation.drawList.push({ //add dmg to draw queue
+ x: mob[i].position.x,
+ y: mob[i].position.y,
+ radius: Math.log(dmg + 1.1) * 40 * mob[i].damageReduction + 3,
+ color: 'rgba(100, 0, 200, 0.4)',
+ time: 15
+ });
+ mob[i].damage(dmg);
+ }
+ }
+ }
+ for (let i = 0, len = body.length; i < len; ++i) { //push away blocks when firing
+ const SUB = Vector.sub(body[i].position, m.pos)
+ const DISTANCE = Vector.magnitude(SUB)
+ if (DISTANCE < range) {
+ const DEPTH = Math.min(range - DISTANCE, 500)
+ const FORCE = Vector.mult(Vector.normalise(SUB), 0.003 * Math.sqrt(DEPTH) * body[i].mass)
+ body[i].force.x += FORCE.x;
+ body[i].force.y += FORCE.y - body[i].mass * simulation.g * 1.5; //kick up a bit to give them some arc
+ }
+ }
+ for (let i = 0, len = powerUp.length; i < len; ++i) { //push away blocks when firing
+ const SUB = Vector.sub(powerUp[i].position, m.pos)
+ const DISTANCE = Vector.magnitude(SUB)
+ if (DISTANCE < range) {
+ const DEPTH = Math.min(range - DISTANCE, 500)
+ const FORCE = Vector.mult(Vector.normalise(SUB), 0.002 * Math.sqrt(DEPTH) * powerUp[i].mass)
+ powerUp[i].force.x += FORCE.x;
+ powerUp[i].force.y += FORCE.y - powerUp[i].mass * simulation.g * 1.5; //kick up a bit to give them some arc
+ }
+ }
+ //draw little dots near the edge of range
+ for (let i = 0, len = 10 + 25 * this.charge; i < len; i++) {
+ const unit = Vector.rotate({
+ x: 1,
+ y: 0
+ }, 6.28 * Math.random())
+ const where = Vector.add(m.pos, Vector.mult(unit, range * (0.6 + 0.3 * Math.random())))
+ simulation.drawList.push({
+ x: where.x,
+ y: where.y,
+ radius: 5 + 12 * Math.random(),
+ color: "rgba(100, 0, 200, 0.1)",
+ time: Math.floor(5 + 35 * Math.random())
+ });
+ }
+
+ const recoil = Vector.mult(Vector.normalise(Vector.sub(where, m.pos)), m.crouch ? 0.03 : 0.06)
+ player.force.x -= recoil.x
+ player.force.y -= recoil.y
+ const harpoonSize = tech.isLargeHarpoon ? 1 + 0.07 * Math.sqrt(this.ammo) : 1
+ const thrust = 0.15 * (this.charge)
+ if (tech.extraHarpoons) {
+ let targetCount = 0
+ const SPREAD = 0.06 + 0.05 * (!m.crouch)
+ let angle = m.angle - SPREAD * tech.extraHarpoons / 2;
+ const dir = {
+ x: Math.cos(angle),
+ y: Math.sin(angle)
+ }; //make a vector for the player's direction of length 1; used in dot product
+
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (mob[i].alive && !mob[i].isBadTarget && !mob[i].shield && Matter.Query.ray(map, m.pos, mob[i].position).length === 0 && !mob[i].isInvulnerable) {
+ const dot = Vector.dot(dir, Vector.normalise(Vector.sub(mob[i].position, m.pos))) //the dot product of diff and dir will return how much over lap between the vectors
+ const dist = Vector.magnitude(Vector.sub(where, mob[i].position))
+ if (dot > 0.95 - Math.min(dist * 0.00015, 0.3)) { //lower dot product threshold for targeting then if you only have one harpoon //target closest mob that player is looking at and isn't too close to target
+ // if (this.ammo > -1) {
+ // this.ammo--
+ b.harpoon(where, m.crouch ? null : mob[i], angle, harpoonSize, false, 35, false, thrust) //harpoon(where, target, angle = m.angle, harpoonSize = 1, isReturn = false, totalCycles = 35, isReturnAmmo = true, thrust = 0.1) {
+ angle += SPREAD
+ targetCount++
+ if (targetCount > tech.extraHarpoons) break
+ // }
+ }
+ }
+ }
+ //if more harpoons and no targets left
+ if (targetCount < tech.extraHarpoons + 1) {
+ const num = tech.extraHarpoons + 1 - targetCount
+ for (let i = 0; i < num; i++) {
+ b.harpoon(where, null, angle, harpoonSize, false, 35, false, thrust)
+ angle += SPREAD
+ }
+ }
+ simulation.updateGunHUD();
+ } else {
+ //look for closest mob in player's LoS
+ const dir = {
+ x: Math.cos(m.angle),
+ y: Math.sin(m.angle)
+ }; //make a vector for the player's direction of length 1; used in dot product
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (mob[i].alive && !mob[i].isBadTarget && Matter.Query.ray(map, m.pos, mob[i].position).length === 0 && !mob[i].isInvulnerable) {
+ const dot = Vector.dot(dir, Vector.normalise(Vector.sub(mob[i].position, m.pos))) //the dot product of diff and dir will return how much over lap between the vectors
+ const dist = Vector.magnitude(Vector.sub(where, mob[i].position))
+ if (dist < closest.distance && dot > 0.98 - Math.min(dist * 0.00014, 0.3)) { //target closest mob that player is looking at and isn't too close to target
+ closest.distance = dist
+ closest.target = mob[i]
+ }
+ }
+ }
+ b.harpoon(where, closest.target, m.angle, harpoonSize, false, 35, false, thrust)
+ }
+
+ this.charge = 0;
+ } else { //charging
+ if (tech.isFireMoveLock) {
+ Matter.Body.setVelocity(player, {
+ x: 0,
+ y: -55 * player.mass * simulation.g //undo gravity before it is added
+ });
+ player.force.x = 0
+ player.force.y = 0
+ }
+ m.fireCDcycle = m.cycle + 10 //can't fire until mouse is released
+ // const previousCharge = this.charge
+
+ //small b.fireCDscale = faster shots, b.fireCDscale=1 = normal shot, big b.fireCDscale = slower chot
+ // let smoothRate = tech.isCapacitor ? 0.85 : Math.min(0.998, 0.985 * (0.98 + 0.02 * b.fireCDscale))
+ const rate = Math.sqrt(b.fireCDscale) * tech.railChargeRate * (tech.isCapacitor ? 0.6 : 1) * (m.crouch ? 0.8 : 1)
+ let smoothRate = Math.min(0.998, 0.94 + 0.05 * rate)
+
+
+ this.charge = 1 - smoothRate + this.charge * smoothRate
+ if (m.energy > DRAIN) m.energy -= DRAIN
+
+ //draw magnetic field
+ const X = m.pos.x
+ const Y = m.pos.y
+ const unitVector = {
+ x: Math.cos(m.angle),
+ y: Math.sin(m.angle)
+ }
+ const unitVectorPerp = Vector.perp(unitVector)
+
+ function magField(mag, arc) {
+ ctx.moveTo(X, Y);
+ ctx.bezierCurveTo(
+ X + unitVector.x * mag, Y + unitVector.y * mag,
+ X + unitVector.x * mag + unitVectorPerp.x * arc, Y + unitVector.y * mag + unitVectorPerp.y * arc,
+ X + unitVectorPerp.x * arc, Y + unitVectorPerp.y * arc)
+ ctx.bezierCurveTo(
+ X - unitVector.x * mag + unitVectorPerp.x * arc, Y - unitVector.y * mag + unitVectorPerp.y * arc,
+ X - unitVector.x * mag, Y - unitVector.y * mag,
+ X, Y)
+ }
+ ctx.fillStyle = `rgba(50,0,100,0.05)`;
+ const magSize = 8 * this.charge * tech.railChargeRate ** 3
+ const arcSize = 6 * this.charge * tech.railChargeRate ** 3
+ for (let i = 3; i < 7; i++) {
+ const MAG = magSize * i * i * (0.93 + 0.07 * Math.random())
+ const ARC = arcSize * i * i * (0.93 + 0.07 * Math.random())
+ ctx.beginPath();
+ magField(MAG, ARC)
+ magField(MAG, -ARC)
+ ctx.fill();
+ }
+ }
+ }
+ },
+ railFire() {
+ m.fireCDcycle = m.cycle + 10 //can't fire until mouse is released
+ this.charge += 0.00001
+ },
+ // grappleFire() {
+ // const harpoonSize = (tech.isLargeHarpoon ? 1 + 0.1 * Math.sqrt(this.ammo) : 1) //* (m.crouch ? 0.7 : 1)
+ // const where = {
+ // x: m.pos.x + harpoonSize * 40 * Math.cos(m.angle),
+ // y: m.pos.y + harpoonSize * 40 * Math.sin(m.angle)
+ // }
+ // const num = Math.min(this.ammo, tech.extraHarpoons + 1)
+ // if (!m.crouch && num > 1) { //multiple harpoons
+ // const SPREAD = 0.06
+ // let angle = m.angle - SPREAD * num / 2;
+ // for (let i = 0; i < num; i++) {
+ // if (this.ammo > 0) {
+ // this.ammo--
+ // b.grapple(where, angle, true, harpoonSize)
+ // angle += SPREAD
+ // }
+ // }
+ // this.ammo++ //make up for the ammo used up in fire()
+ // simulation.updateGunHUD();
+ // m.fireCDcycle = m.cycle + Math.floor(75 * b.fireCDscale) // cool down
+ // // } else if (m.crouch) {
+ // // b.harpoon(where, null, m.angle, harpoonSize, false, 70)
+ // } else {
+ // if (tech.crouchAmmoCount) tech.crouchAmmoCount = 1
+ // b.grapple(where, m.angle, harpoonSize)
+ // }
+ // // m.fireCDcycle = m.cycle + Math.floor(75 * b.fireCDscale) // cool down
+ // m.fireCDcycle = m.cycle + 5 + 40 * b.fireCDscale + 60 * (m.energy < 0.05)
+
+ // },
+ harpoonFire() {
+ const where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }
+ const closest = {
+ distance: 10000,
+ target: null
+ }
+ //look for closest mob in player's LoS
+ const harpoonSize = (tech.isLargeHarpoon ? 1 + 0.1 * Math.sqrt(this.ammo) : 1) //* (m.crouch ? 0.7 : 1)
+ const totalCycles = 6.5 * (tech.isFilament ? 1 + 0.013 * Math.min(110, this.ammo) : 1) * Math.sqrt(harpoonSize)
+
+ if (tech.extraHarpoons && !m.crouch) { //multiple harpoons
+ const SPREAD = 0.2
+ let angle = m.angle - SPREAD * tech.extraHarpoons / 2;
+ const dir = { x: Math.cos(angle), y: Math.sin(angle) }; //make a vector for the player's direction of length 1; used in dot product
+ const range = 450 * (tech.isFilament ? 1 + 0.012 * Math.min(110, this.ammo) : 1)
+ let targetCount = 0
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (mob[i].alive && !mob[i].isBadTarget && !mob[i].shield && Matter.Query.ray(map, m.pos, mob[i].position).length === 0 && !mob[i].isInvulnerable) {
+ const dot = Vector.dot(dir, Vector.normalise(Vector.sub(mob[i].position, m.pos))) //the dot product of diff and dir will return how much over lap between the vectors
+ const dist = Vector.magnitude(Vector.sub(where, mob[i].position))
+ if (dist < range && dot > 0.9) { //lower dot product threshold for targeting then if you only have one harpoon //target closest mob that player is looking at and isn't too close to target
+ if (this.ammo > 0) {
+ this.ammo--
+ b.harpoon(where, mob[i], angle, harpoonSize, true, totalCycles) //Vector.angle(Vector.sub(where, mob[i].position), { x: 0, y: 0 })
+ angle += SPREAD
+ targetCount++
+ if (targetCount > tech.extraHarpoons) break
+ }
+ }
+ }
+ }
+ //if more harpoons and no targets left
+ if (targetCount < tech.extraHarpoons + 1) {
+ const num = tech.extraHarpoons - targetCount
+ const delay = 1 //Math.floor(Math.max(4, 8 - 0.5 * tech.extraHarpoons))
+ let angle = m.angle - SPREAD * tech.extraHarpoons / 2;
+ let count = -1
+ let harpoonDelay = () => {
+ if (simulation.paused) {
+ requestAnimationFrame(harpoonDelay)
+ } else {
+ count++
+ if (!(count % delay) && this.ammo > 0) {
+ this.ammo--
+ b.harpoon({ x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, null, angle, harpoonSize, true, totalCycles)
+ angle += SPREAD
+ }
+ if (count < num * delay && m.alive) requestAnimationFrame(harpoonDelay);
+ }
+ }
+ requestAnimationFrame(harpoonDelay)
+ }
+ this.ammo++ //make up for the ammo used up in fire()
+ simulation.updateGunHUD();
+
+ } else { //m.crouch makes a single harpoon with longer range
+ const dir = {
+ x: Math.cos(m.angle),
+ y: Math.sin(m.angle)
+ }; //make a vector for the player's direction of length 1; used in dot product
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ if (mob[i].alive && !mob[i].isBadTarget && Matter.Query.ray(map, m.pos, mob[i].position).length === 0 && !mob[i].isInvulnerable) {
+ const dot = Vector.dot(dir, Vector.normalise(Vector.sub(mob[i].position, m.pos))) //the dot product of diff and dir will return how much over lap between the vectors
+ const dist = Vector.magnitude(Vector.sub(where, mob[i].position))
+ if (dist < closest.distance && dot > 0.98 - Math.min(dist * 0.00014, 0.3)) { //target closest mob that player is looking at and isn't too close to target
+ closest.distance = dist
+ closest.target = mob[i]
+ }
+ }
+ }
+ if (m.crouch && m.onGround) {
+ b.harpoon(where, null, m.angle, harpoonSize, true, 1.6 * totalCycles, (m.crouch && tech.crouchAmmoCount && (tech.crouchAmmoCount - 1) % 2) ? false : true) // harpoon(where, target, angle = m.angle, harpoonSize = 1, isReturn = false, totalCycles = 35, isReturnAmmo = true) {
+ } else {
+ b.harpoon(where, closest.target, m.angle, harpoonSize, true, totalCycles)
+ }
+ }
+ m.fireCDcycle = m.cycle + 5 + 35 * b.fireCDscale + 60 * (m.energy < 0.05) + tech.extraHarpoons // cool down is set when harpoon bullet returns to player
+ const recoil = Vector.mult(Vector.normalise(Vector.sub(where, m.pos)), m.crouch ? 0.015 : 0.035)
+ player.force.x -= recoil.x
+ player.force.y -= recoil.y
+ },
+ }, {
+ name: "mine", //10
+ // description: `toss a proximity mine that sticks to walls refund undetonated mines on exiting a level 1-2 mines per ${powerUps.orb.ammo()}`,
+ descriptionFunction() {
+ return `toss a proximity mine that sticks to walls refund undetonated mines on exiting a level ${this.ammoPack.toFixed(1)} mines per ${powerUps.orb.ammo()}`
+ },
+ ammo: 0,
+ ammoPack: 0.77,
+ defaultAmmoPack: 0.77,
+ have: false,
+ nameString(suffix = "") {
+ if (tech.isFoamMine) {
+ return `foam`
+ } else if (tech.isSuperMine) {
+ return `super ball${suffix}`
+ } else {
+ return `nail${suffix}`
+ }
+ },
+ do() {
+ if (!input.field && m.crouch && !tech.isLaserMine) {
+ const cycles = 60 //30
+ const speed = 40
+ const v = {
+ x: speed * Math.cos(m.angle),
+ y: speed * Math.sin(m.angle)
+ } //m.Vy / 2 + removed to make the path less jerky
+ ctx.strokeStyle = "rgba(68, 68, 68, 0.2)" //color.map
+ ctx.lineWidth = 2
+ ctx.beginPath()
+ for (let i = 1.5, len = 19; i < len + 1; i++) {
+ const time = cycles * i / len
+ ctx.lineTo(m.pos.x + time * v.x, m.pos.y + time * v.y + 0.34 * time * time)
+ }
+ ctx.stroke()
+ }
+ },
+ fire() {
+ if (m.crouch) {
+ if (tech.isLaserMine) {
+ const speed = 30
+ const velocity = {
+ x: speed * Math.cos(m.angle),
+ y: speed * Math.sin(m.angle)
+ }
+ b.laserMine(m.pos, velocity)
+ m.fireCDcycle = m.cycle + Math.floor(65 * b.fireCDscale); // cool down
+ } else {
+ const pos = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }
+ let speed = 36
+ if (Matter.Query.point(map, pos).length > 0) speed = -2 //don't launch if mine will spawn inside map
+ b.mine(pos, { x: speed * Math.cos(m.angle), y: speed * Math.sin(m.angle) }, 0)
+ m.fireCDcycle = m.cycle + Math.floor(55 * b.fireCDscale); // cool down
+ }
+ } else {
+ const pos = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }
+ let speed = 23
+ if (Matter.Query.point(map, pos).length > 0) speed = -2 //don't launch if mine will spawn inside map
+ b.mine(pos, { x: speed * Math.cos(m.angle), y: speed * Math.sin(m.angle) }, 0)
+ m.fireCDcycle = m.cycle + Math.floor(35 * b.fireCDscale); // cool down
+ }
+ }
+ },
+ {
+ name: "laser", //11
+ descriptionFunction() {
+ return `emit a beam of collimated coherent light reflects off map, blocks, and mobs ${(tech.isWideLaser || tech.isPulseLaser) ? 0 : tech.laserReflections} times costs ${(tech.laserDrain * 6000).toFixed(1)}energy per second and 0 ammo`
+ },
+ ammo: 0,
+ ammoPack: Infinity,
+ defaultAmmoPack: Infinity,
+ have: false,
+ charge: 0,
+ isStuckOn: false,
+ angle: 0,
+ isInsideArc(angle) {
+ const mod = (a, n) => {
+ return a - Math.floor(a / n) * n
+ }
+ let diff = mod(angle - this.angle + Math.PI, 2 * Math.PI) - Math.PI
+ return Math.abs(diff) < this.arcRange
+ },
+ arcRange: 0.78, //1.57,
+ lensDamage: 1,
+ lensDamageOn: 0, //set in tech
+ lens() {
+ this.stuckOn();
+ this.angle += 0.03
+ if (this.isInsideArc(m.angle)) {
+ this.lensDamage = this.lensDamageOn
+ ctx.lineWidth = 6 + this.lensDamageOn
+ } else {
+ this.lensDamage = 1
+ ctx.lineWidth = 2
+ }
+ ctx.beginPath();
+ ctx.arc(m.pos.x, m.pos.y, 60, this.angle - this.arcRange, this.angle + this.arcRange);
+ ctx.strokeStyle = '#fff' //'rgba(255,255,255,0.9)' //'hsl(189, 100%, 95%)'
+ ctx.stroke();
+ },
+ stuckOn() {
+ if (tech.isStuckOn) {
+ if (this.isStuckOn) {
+ if (!input.fire) this.fire();
+ if (m.energy < tech.laserDrain + 0.06) this.isStuckOn = false
+ } else if (input.fire) {
+ this.isStuckOn = true
+ }
+ // console.log(this.isStuckOn)
+ }
+ },
+ do() { },
+ fire() { },
+ chooseFireMethod() {
+ this.lensDamage = 1
+ if (tech.isLaserLens) {
+ this.do = this.lens
+ } else {
+ this.do = this.stuckOn
+ }
+ if (tech.isPulseLaser) {
+ this.fire = () => {
+ const drain = Math.min(0.9 * m.maxEnergy, 0.01 * (tech.isCapacitor ? 10 : 1) / b.fireCDscale)
+ if (m.energy > drain && this.charge < 50 * m.maxEnergy) {
+ m.energy -= drain
+ this.charge += drain * 100
+ }
+ }
+ if (tech.historyLaser) {
+ const len = 1 + tech.historyLaser
+ const spacing = Math.ceil(30 - 2 * tech.historyLaser)
+ this.do = () => {
+ if (tech.isLaserLens) this.lens()
+ if (this.charge > 0) {
+ //draw charge level
+ const mag = 4.1 * Math.sqrt(this.charge)
+ ctx.beginPath();
+ for (let i = 0; i < len; i++) {
+ const history = m.history[(m.cycle - i * spacing) % 600]
+ const off = history.yOff - 24.2859
+ ctx.moveTo(history.position.x, history.position.y - off);
+ ctx.ellipse(history.position.x, history.position.y - off, mag, mag * 0.65, history.angle, 0, 2 * Math.PI)
+ }
+ ctx.fillStyle = `rgba(255,0,0,${0.09 * Math.sqrt(this.charge)})`;
+ ctx.fill();
+ //fire
+ if (!input.fire) {
+ if (this.charge > 5) {
+ m.fireCDcycle = m.cycle + Math.floor(35 * b.fireCDscale); // cool down
+ for (let i = 0; i < len; i++) {
+ const history = m.history[(m.cycle - i * spacing) % 600]
+ const off = history.yOff - 24.2859
+ b.pulse(1.65 * this.charge * this.lensDamage, history.angle, {
+ x: history.position.x,
+ y: history.position.y - off
+ })
+ }
+ }
+ this.charge = 0;
+ }
+ }
+ };
+ } else {
+ this.do = () => {
+ if (tech.isLaserLens) this.lens()
+ if (this.charge > 0) {
+ //draw charge level
+ ctx.beginPath();
+ ctx.arc(m.pos.x, m.pos.y, 4.2 * Math.sqrt(this.charge), 0, 2 * Math.PI);
+ // ctx.fillStyle = `rgba(255,0,0,${0.09 * Math.sqrt(this.charge)})`;
+ ctx.fillStyle = `rgba(255,0,0,${0.09 * Math.sqrt(this.charge)})`;
+ ctx.fill();
+ //fire
+ if (!input.fire) {
+ if (this.charge > 5) {
+ m.fireCDcycle = m.cycle + Math.floor(35 * b.fireCDscale); // cool down
+ if (tech.beamSplitter) {
+ const divergence = m.crouch ? 0.15 : 0.35
+ const angle = m.angle - tech.beamSplitter * divergence / 2
+ for (let i = 0; i < 1 + tech.beamSplitter; i++) b.pulse(this.charge, angle + i * divergence)
+ } else {
+ b.pulse(1.8 * this.charge * this.lensDamage, m.angle)
+ }
+ }
+ this.charge = 0;
+ }
+ }
+ };
+ }
+
+ } else if (tech.beamSplitter) {
+ this.fire = this.fireSplit
+ } else if (tech.historyLaser) {
+ this.fire = this.fireHistory
+ } else if (tech.isWideLaser) {
+ this.fire = this.fireWideBeam
+ } else {
+ this.fire = this.fireLaser
+ }
+ // this.fire = this.firePhoton
+ },
+ fireLaser() {
+ const drain = tech.laserDrain / b.fireCDscale
+ if (m.energy < drain) {
+ m.fireCDcycle = m.cycle + 100; // cool down if out of energy
+ } else {
+ m.fireCDcycle = m.cycle
+ m.energy -= drain
+ const where = { x: m.pos.x + 20 * Math.cos(m.angle), y: m.pos.y + 20 * Math.sin(m.angle) }
+ b.laser(where, {
+ x: where.x + 3000 * Math.cos(m.angle),
+ y: where.y + 3000 * Math.sin(m.angle)
+ }, tech.laserDamage / b.fireCDscale * this.lensDamage);
+ }
+ },
+ firePulse() { },
+ fireSplit() {
+ const drain = tech.laserDrain / b.fireCDscale
+ if (m.energy < drain) {
+ m.fireCDcycle = m.cycle + 100; // cool down if out of energy
+ } else {
+ m.fireCDcycle = m.cycle
+ m.energy -= drain
+ // const divergence = m.crouch ? 0.15 : 0.2
+ // const scale = Math.pow(0.9, tech.beamSplitter)
+ // const pushScale = scale * scale
+ let dmg = tech.laserDamage / b.fireCDscale * this.lensDamage // * scale //Math.pow(0.9, tech.laserDamage)
+ const where = { x: m.pos.x + 20 * Math.cos(m.angle), y: m.pos.y + 20 * Math.sin(m.angle) }
+ const divergence = m.crouch ? 0.15 : 0.35
+ const angle = m.angle - tech.beamSplitter * divergence / 2
+ for (let i = 0; i < 1 + tech.beamSplitter; i++) {
+ b.laser(where, {
+ x: where.x + 3000 * Math.cos(angle + i * divergence),
+ y: where.y + 3000 * Math.sin(angle + i * divergence)
+ }, dmg, tech.laserReflections, false)
+ }
+ }
+ },
+ fireWideBeam() {
+ const drain = tech.laserDrain / b.fireCDscale
+ if (m.energy < drain) {
+ m.fireCDcycle = m.cycle + 100; // cool down if out of energy
+ } else {
+ m.fireCDcycle = m.cycle
+ m.energy -= drain
+ const range = {
+ x: 5000 * Math.cos(m.angle),
+ y: 5000 * Math.sin(m.angle)
+ }
+ const rangeOffPlus = {
+ x: 7.5 * Math.cos(m.angle + Math.PI / 2),
+ y: 7.5 * Math.sin(m.angle + Math.PI / 2)
+ }
+ const rangeOffMinus = {
+ x: 7.5 * Math.cos(m.angle - Math.PI / 2),
+ y: 7.5 * Math.sin(m.angle - Math.PI / 2)
+ }
+ const dmg = 0.70 * tech.laserDamage / b.fireCDscale * this.lensDamage // 3.5 * 0.55 = 200% more damage
+ const where = {
+ x: m.pos.x + 30 * Math.cos(m.angle),
+ y: m.pos.y + 30 * Math.sin(m.angle)
+ }
+ const eye = {
+ x: m.pos.x + 15 * Math.cos(m.angle),
+ y: m.pos.y + 15 * Math.sin(m.angle)
+ }
+ ctx.strokeStyle = tech.laserColor;
+ ctx.lineWidth = 8
+ ctx.globalAlpha = 0.5;
+ ctx.beginPath();
+ if (Matter.Query.ray(map, eye, where).length === 0 && Matter.Query.ray(body, eye, where).length === 0) {
+ b.laser(eye, {
+ x: eye.x + range.x,
+ y: eye.y + range.y
+ }, dmg, 0, true, 0.3)
+ }
+ for (let i = 1; i < tech.wideLaser; i++) {
+ let whereOff = Vector.add(where, {
+ x: i * rangeOffPlus.x,
+ y: i * rangeOffPlus.y
+ })
+ if (Matter.Query.ray(map, eye, whereOff).length === 0 && Matter.Query.ray(body, eye, whereOff).length === 0) {
+ ctx.moveTo(eye.x, eye.y)
+ ctx.lineTo(whereOff.x, whereOff.y)
+ b.laser(whereOff, {
+ x: whereOff.x + range.x,
+ y: whereOff.y + range.y
+ }, dmg, 0, true, 0.3)
+ }
+ whereOff = Vector.add(where, {
+ x: i * rangeOffMinus.x,
+ y: i * rangeOffMinus.y
+ })
+ if (Matter.Query.ray(map, eye, whereOff).length === 0 && Matter.Query.ray(body, eye, whereOff).length === 0) {
+ ctx.moveTo(eye.x, eye.y)
+ ctx.lineTo(whereOff.x, whereOff.y)
+ b.laser(whereOff, {
+ x: whereOff.x + range.x,
+ y: whereOff.y + range.y
+ }, dmg, 0, true, 0.3)
+ }
+ }
+ ctx.stroke();
+ if (tech.isLaserLens && b.guns[11].lensDamage !== 1) {
+ ctx.lineWidth = 20 + 3 * b.guns[11].lensDamageOn
+ ctx.globalAlpha = 0.3
+ ctx.stroke();
+ }
+ ctx.globalAlpha = 1;
+ }
+ },
+ fireHistory() {
+ drain = tech.laserDrain / b.fireCDscale
+ if (m.energy < drain) {
+ m.fireCDcycle = m.cycle + 100; // cool down if out of energy
+ } else {
+ m.fireCDcycle = m.cycle
+ m.energy -= drain
+ const dmg = tech.laserDamage / b.fireCDscale * this.lensDamage
+ const spacing = Math.ceil(23 - tech.historyLaser)
+ ctx.beginPath();
+ b.laser({
+ x: m.pos.x + 20 * Math.cos(m.angle),
+ y: m.pos.y + 20 * Math.sin(m.angle)
+ }, {
+ x: m.pos.x + 3000 * Math.cos(m.angle),
+ y: m.pos.y + 3000 * Math.sin(m.angle)
+ }, dmg);
+
+ for (let i = 1, len = 1 + tech.historyLaser; i < len; i++) {
+ const history = m.history[(m.cycle - i * spacing) % 600]
+ const off = history.yOff - 24.2859 + 2 * i
+ // ctx.globalAlpha = 0.13
+ b.laser({
+ x: history.position.x + 20 * Math.cos(history.angle),
+ y: history.position.y + 20 * Math.sin(history.angle) - off
+ }, {
+ x: history.position.x + 3000 * Math.cos(history.angle),
+ y: history.position.y + 3000 * Math.sin(history.angle) - off
+ }, 0.7 * dmg, tech.laserReflections, true);
+ }
+ // ctx.globalAlpha = 1
+ ctx.strokeStyle = tech.laserColor;
+ ctx.lineWidth = 1
+ ctx.stroke();
+ if (tech.isLaserLens && b.guns[11].lensDamage !== 1) {
+ ctx.strokeStyle = tech.laserColor;
+ ctx.lineWidth = 10 + 2 * b.guns[11].lensDamageOn
+ ctx.globalAlpha = 0.2
+ ctx.stroke(); //glow
+ ctx.globalAlpha = 1;
+ }
+ }
+ },
+ },
+ ],
+};
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/n-gon-master/js/engine.js b/WebGames-master/WebGames-master/n-gon-master/js/engine.js
new file mode 100644
index 00000000..dc9b6e3d
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/js/engine.js
@@ -0,0 +1,290 @@
+//matter.js ***********************************************************
+// module aliases
+const Engine = Matter.Engine,
+ Events = Matter.Events,
+ Composites = Matter.Composites,
+ Composite = Matter.Composite,
+ Constraint = Matter.Constraint,
+ Vertices = Matter.Vertices,
+ Query = Matter.Query,
+ Body = Matter.Body,
+ Bodies = Matter.Bodies,
+ Vector = Matter.Vector;
+
+// create an engine
+const engine = Engine.create();
+engine.world.gravity.scale = 0; //turn off gravity (it's added back in later)
+// engine.velocityIterations = 100
+// engine.positionIterations = 100
+// engine.enableSleeping = true
+
+// matter events
+function playerOnGroundCheck(event) {
+ //runs on collisions events
+ function enter() {
+ m.numTouching++;
+ if (!m.onGround) {
+ m.onGround = true;
+ if (m.crouch) {
+ if (m.checkHeadClear()) {
+ m.undoCrouch();
+ } else {
+ m.yOffGoal = m.yOffWhen.crouch;
+ }
+ } else {
+ //sets a hard land where player stays in a crouch for a bit and can't jump
+ //crouch is forced in groundControl below
+ const momentum = player.velocity.y * player.mass //player mass is 5 so this triggers at 26 down velocity, unless the player is holding something
+ if (momentum > m.hardLanding) {
+ m.doCrouch();
+ m.yOff = m.yOffWhen.jump;
+ m.hardLandCD = m.cycle + m.hardLandCDScale * Math.min(momentum / 6.5 - 6, 40)
+ //falling damage
+ if (tech.isFallingDamage && m.immuneCycle < m.cycle && momentum > 150) {
+ m.damage(Math.min(Math.sqrt(momentum - 133) * 0.01, 0.25));
+ if (m.immuneCycle < m.cycle + m.collisionImmuneCycles) m.immuneCycle = m.cycle + m.collisionImmuneCycles; //player is immune to damage for 30 cycles
+ }
+ } else {
+ m.yOffGoal = m.yOffWhen.stand;
+ }
+ }
+ }
+ }
+
+ const pairs = event.pairs;
+ for (let i = 0, j = pairs.length; i != j; ++i) {
+ let pair = pairs[i];
+ if (pair.bodyA === jumpSensor) {
+ m.standingOn = pair.bodyB; //keeping track to correctly provide recoil on jump
+ if (m.standingOn.alive !== true || m.immuneCycle > m.cycle) enter();
+ } else if (pair.bodyB === jumpSensor) {
+ m.standingOn = pair.bodyA; //keeping track to correctly provide recoil on jump
+ if (m.standingOn.alive !== true || m.immuneCycle > m.cycle) enter();
+ }
+ }
+ m.numTouching = 0;
+}
+
+function playerOffGroundCheck(event) {
+ //runs on collisions events
+ const pairs = event.pairs;
+ for (let i = 0, j = pairs.length; i != j; ++i) {
+ if (pairs[i].bodyA === jumpSensor || pairs[i].bodyB === jumpSensor) {
+ if (m.onGround && m.numTouching === 0) {
+ m.onGround = false;
+ m.lastOnGroundCycle = m.cycle;
+ m.hardLandCD = 0 // disable hard landing
+ if (m.checkHeadClear()) {
+ if (m.crouch) {
+ m.undoCrouch();
+ }
+ m.yOffGoal = m.yOffWhen.jump;
+ }
+ }
+ }
+ }
+}
+
+function collisionChecks(event) {
+ const pairs = event.pairs;
+ for (let i = 0, j = pairs.length; i != j; i++) {
+ //mob + (player,bullet,body) collisions
+ for (let k = 0; k < mob.length; k++) {
+ if (mob[k].alive) {
+ if (pairs[i].bodyA === mob[k]) {
+ collideMob(pairs[i].bodyB);
+ break;
+ } else if (pairs[i].bodyB === mob[k]) {
+ collideMob(pairs[i].bodyA);
+ break;
+ }
+
+ function collideMob(obj) {
+ //player + mob collision
+ if (
+ m.immuneCycle < m.cycle &&
+ (obj === playerBody || obj === playerHead) &&
+ !mob[k].isSlowed && !mob[k].isStunned
+ ) {
+ let dmg = Math.min(Math.max(0.025 * Math.sqrt(mob[k].mass), 0.05), 0.3) * simulation.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0
+ // if (m.isCloak) dmg *= 0.5
+ mob[k].foundPlayer();
+ if (tech.isRewindAvoidDeath && m.energy > 0.85 * Math.min(1, m.maxEnergy) && dmg > 0.01) { //CPT reversal runs in m.damage, but it stops the rest of the collision code here too
+ m.damage(dmg);
+ return
+ }
+ m.damage(dmg); //normal damage
+
+ if (tech.isCollisionRealitySwitch && m.alive) {
+ m.switchWorlds("Hilbert space")
+ simulation.trails(90)
+ simulation.inGameConsole(`simulation.amplitude = ${Math.random()}`);
+ }
+ if (tech.isPiezo) m.energy += 20.48 * level.isReducedRegen;
+ if (tech.isCouplingNoHit && m.coupling > 0) {
+ m.couplingChange(-3)
+
+ const unit = Vector.rotate({ x: 1, y: 0 }, 6.28 * Math.random())
+ let where = Vector.add(m.pos, Vector.mult(unit, 17))
+ simulation.drawList.push({ //add dmg to draw queue
+ x: where.x,
+ y: where.y,
+ radius: 22,
+ color: 'rgba(0, 171, 238, 0.33)',
+ time: 8
+ });
+ where = Vector.add(m.pos, Vector.mult(unit, 60))
+ simulation.drawList.push({ //add dmg to draw queue
+ x: where.x,
+ y: where.y,
+ radius: 18,
+ color: 'rgba(0, 171, 238, 0.5)',
+ time: 16
+ });
+ where = Vector.add(m.pos, Vector.mult(unit, 100))
+ simulation.drawList.push({ //add dmg to draw queue
+ x: where.x,
+ y: where.y,
+ radius: 14,
+ color: 'rgba(0, 171, 238, 0.6)',
+ time: 24
+ });
+ where = Vector.add(m.pos, Vector.mult(unit, 135))
+ simulation.drawList.push({ //add dmg to draw queue
+ x: where.x,
+ y: where.y,
+ radius: 10,
+ color: 'rgba(0, 171, 238, 0.7)',
+ time: 32
+ });
+ }
+ if (tech.isHarpoonDefense) { //fire harpoons at mobs after getting hit
+ const maxCount = 10 + 3 * tech.extraHarpoons //scale the number of hooks fired
+ let count = maxCount - 1
+ const angle = Math.atan2(mob[k].position.y - player.position.y, mob[k].position.x - player.position.x);
+ const mass = 0.75 * ((tech.isLargeHarpoon) ? 1 + Math.min(0.05 * Math.sqrt(b.guns[9].ammo), 10) : 1)
+ b.harpoon(m.pos, mob[k], angle, mass, true, 7, false) // harpoon(where, target, angle = m.angle, harpoonSize = 1, isReturn = false, totalCycles = 35, isReturnAmmo = true, thrust = 0.1) {
+ bullet[bullet.length - 1].drain = 0
+ for (; count > 0; count--) {
+ b.harpoon(m.pos, mob[k], angle + count * 2 * Math.PI / maxCount, mass, true, 7, false)
+ bullet[bullet.length - 1].drain = 0
+ }
+ }
+ if (tech.isStimulatedEmission) powerUps.ejectTech()
+ if (mob[k].onHit) mob[k].onHit();
+ if (m.immuneCycle < m.cycle + m.collisionImmuneCycles) m.immuneCycle = m.cycle + m.collisionImmuneCycles; //player is immune to damage for 30 cycles
+ //extra kick between player and mob //this section would be better with forces but they don't work...
+ let angle = Math.atan2(player.position.y - mob[k].position.y, player.position.x - mob[k].position.x);
+ Matter.Body.setVelocity(player, { x: player.velocity.x + 8 * Math.cos(angle), y: player.velocity.y + 8 * Math.sin(angle) });
+ Matter.Body.setVelocity(mob[k], { x: mob[k].velocity.x - 8 * Math.cos(angle), y: mob[k].velocity.y - 8 * Math.sin(angle) });
+ if (tech.isAnnihilation && !mob[k].shield && !mob[k].isShielded && !mob[k].isBoss && mob[k].isDropPowerUp && m.energy > 0.1 && mob[k].damageReduction > 0) {
+ m.energy -= 0.1 //* Math.max(m.maxEnergy, m.energy) //0.33 * m.energy
+ if (m.immuneCycle === m.cycle + m.collisionImmuneCycles) m.immuneCycle = 0; //player doesn't go immune to collision damage
+ mob[k].death();
+ simulation.drawList.push({ //add dmg to draw queue
+ x: pairs[i].activeContacts[0].vertex.x,
+ y: pairs[i].activeContacts[0].vertex.y,
+ radius: Math.sqrt(dmg) * 500,
+ color: "rgba(255,0,255,0.2)",
+ time: simulation.drawTime
+ });
+ } else {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: pairs[i].activeContacts[0].vertex.x,
+ y: pairs[i].activeContacts[0].vertex.y,
+ radius: Math.sqrt(dmg) * 200,
+ color: simulation.mobDmgColor,
+ time: simulation.drawTime
+ });
+ }
+ // return;
+ // }
+ } else {
+ //mob + bullet collisions
+ if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) {
+ obj.beforeDmg(mob[k]); //some bullets do actions when they hits things, like despawn //forces don't seem to work here
+ let dmg = m.dmgScale * (obj.dmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)))
+ if (tech.isCrit && mob[k].isStunned) dmg *= 4
+ // console.log(dmg) //remove this
+ mob[k].damage(dmg);
+ if (mob[k].alive) mob[k].foundPlayer();
+ if (mob[k].damageReduction) {
+ simulation.drawList.push({ //add dmg to draw queue
+ x: pairs[i].activeContacts[0].vertex.x,
+ y: pairs[i].activeContacts[0].vertex.y,
+ radius: Math.log(dmg + 1.1) * 40 * mob[k].damageReduction + 3,
+ color: simulation.playerDmgColor,
+ time: simulation.drawTime
+ });
+ }
+ if (tech.isLessDamageReduction && !mob[k].shield) mob[k].damageReduction *= mob[k].isBoss ? (mob[k].isFinalBoss ? 1.0005 : 1.0025) : 1.05
+ return;
+ }
+ //mob + body collisions
+ if (obj.classType === "body" && obj.speed > 9) {
+ const v = Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity));
+ if (v > 11) {
+ if (tech.blockDmg) { //electricity
+ Matter.Body.setVelocity(mob[k], { x: 0.5 * mob[k].velocity.x, y: 0.5 * mob[k].velocity.y });
+ if (tech.isBlockRadiation && !mob[k].isShielded && !mob[k].isMobBullet) {
+ mobs.statusDoT(mob[k], tech.blockDmg * 0.42, 180) //200% increase -> x (1+2) //over 7s -> 360/30 = 12 half seconds -> 3/12
+ } else {
+ mob[k].damage(tech.blockDmg * m.dmgScale)
+ simulation.drawList.push({
+ x: pairs[i].activeContacts[0].vertex.x,
+ y: pairs[i].activeContacts[0].vertex.y,
+ radius: 28 * mob[k].damageReduction + 3,
+ color: "rgba(255,0,255,0.8)",
+ time: 4
+ });
+ }
+ }
+
+ let dmg = tech.blockDamage * m.dmgScale * v * obj.mass * (tech.isMobBlockFling ? 2.5 : 1) * (tech.isBlockRestitution ? 2.5 : 1) * ((m.fieldMode === 0 || m.fieldMode === 8) ? 1 + 0.05 * m.coupling : 1);
+ if (mob[k].isShielded) dmg *= 0.7
+
+ mob[k].damage(dmg, true);
+ if (tech.isBlockPowerUps && !mob[k].alive && mob[k].isDropPowerUp && Math.random() < 0.5) {
+ options = ["coupling", "boost", "heal", "research", "ammo"]
+ powerUps.spawn(mob[k].position.x, mob[k].position.y, options[Math.floor(Math.random() * options.length)]);
+ }
+
+ const stunTime = dmg / Math.sqrt(obj.mass)
+ if (stunTime > 0.5 && mob[k].memory !== Infinity) mobs.statusStun(mob[k], 60 + 60 * Math.sqrt(stunTime))
+ if (mob[k].alive && mob[k].distanceToPlayer2() < 1000000 && !m.isCloak) mob[k].foundPlayer();
+ if (tech.fragments && obj.speed > 10 && !obj.hasFragmented) {
+ obj.hasFragmented = true;
+ b.targetedNail(obj.position, tech.fragments * 4)
+ }
+ if (mob[k].damageReduction) {
+ simulation.drawList.push({
+ x: pairs[i].activeContacts[0].vertex.x,
+ y: pairs[i].activeContacts[0].vertex.y,
+ radius: Math.log(dmg + 1.1) * 40 * mob[k].damageReduction + 3,
+ color: simulation.playerDmgColor,
+ time: simulation.drawTime
+ });
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//determine if player is on the ground
+Events.on(engine, "collisionStart", function (event) {
+ playerOnGroundCheck(event);
+ // playerHeadCheck(event);
+ collisionChecks(event);
+});
+Events.on(engine, "collisionActive", function (event) {
+ playerOnGroundCheck(event);
+ // playerHeadCheck(event);
+});
+Events.on(engine, "collisionEnd", function (event) {
+ playerOffGroundCheck(event);
+});
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/n-gon-master/js/index.js b/WebGames-master/WebGames-master/n-gon-master/js/index.js
new file mode 100644
index 00000000..ec4aaa94
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/js/index.js
@@ -0,0 +1,2134 @@
+"use strict";
+
+//convert text into numbers for seed
+Math.hash = s => {
+ for (var i = 0, h = 9; i < s.length;) h = Math.imul(h ^ s.charCodeAt(i++), 9 ** 9);
+ return h ^ h >>> 9
+}
+
+// const date1 = new Date()
+// console.log(date1.getUTCHours())
+// document.getElementById("seed").placeholder = Math.initialSeed = String(date1.getUTCDate() * date1.getUTCFullYear()) // daily seed, day + year
+
+// document.getElementById("seed").placeholder = Math.initialSeed = Math.floor(Date.now() % 100000) //random every time: just the time in milliseconds UTC
+
+window.addEventListener('error', error => {
+ // simulation.inGameConsole(`ERROR: ${error.message} ${error.filename}:${error.lineno}`)
+ simulation.inGameConsole(`ERROR: ${(error.stack && error.stack.replace(/\n/g, " ")) || (error.message + ` ${error.filename}:${error.lineno}`)}`);
+
+});
+
+document.getElementById("seed").placeholder = Math.initialSeed = String(Math.floor(Date.now() % 100000))
+Math.seed = Math.abs(Math.hash(Math.initialSeed)) //update randomizer seed in case the player changed it
+Math.seededRandom = function (min = 0, max = 1) { // in order to work 'Math.seed' must NOT be undefined
+ Math.seed = (Math.seed * 9301 + 49297) % 233280;
+ return min + Math.seed / 233280 * (max - min);
+}
+//Math.seed is set to document.getElementById("seed").value in level.populate level at the start of runs
+// console.log(Math.seed)
+
+
+function shuffle(array) {
+ var currentIndex = array.length,
+ temporaryValue,
+ randomIndex;
+ // While there remain elements to shuffle...
+ while (0 !== currentIndex) {
+ // Pick a remaining element...
+ // randomIndex = Math.floor(Math.random() * currentIndex);
+ randomIndex = Math.floor(Math.seededRandom(0, currentIndex)) //Math.floor(Math.random() * currentIndex);
+ currentIndex -= 1;
+ // And swap it with the current element.
+ temporaryValue = array[currentIndex];
+ array[currentIndex] = array[randomIndex];
+ array[randomIndex] = temporaryValue;
+ }
+ return array;
+}
+// function vertexCollision(v1, v1End, domain, best) {
+// let results
+// for (let i = 0; i < domain.length; ++i) {
+// let vertices = domain[i].vertices;
+// const len = vertices.length - 1;
+// for (let j = 0; j < len; j++) {
+// results = simulation.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]);
+// if (results.onLine1 && results.onLine2) {
+// const dx = v1.x - results.x;
+// const dy = v1.y - results.y;
+// const dist2 = dx * dx + dy * dy;
+// if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) {
+// best = {
+// x: results.x,
+// y: results.y,
+// dist2: dist2,
+// who: domain[i],
+// v1: vertices[j],
+// v2: vertices[j + 1]
+// };
+// }
+// }
+// }
+// results = simulation.checkLineIntersection(v1, v1End, vertices[0], vertices[len]);
+// if (results.onLine1 && results.onLine2) {
+// const dx = v1.x - results.x;
+// const dy = v1.y - results.y;
+// const dist2 = dx * dx + dy * dy;
+// if (dist2 < best.dist2) {
+// best = {
+// x: results.x,
+// y: results.y,
+// dist2: dist2,
+// who: domain[i],
+// v1: vertices[0],
+// v2: vertices[len]
+// };
+// }
+// }
+// }
+// return best
+// }
+//this function is used for finding the point where a ray hits things, used for lasers mostly
+function vertexCollision(v1, v1End, domains) { //= [map, body, [playerBody, playerHead]] //m.isCloak ? [map, body] : [map, body, [playerBody, playerHead]]
+ let results
+ let best = { x: null, y: null, dist2: Infinity, who: null, v1: null, v2: null };
+ for (let j = 0; j < domains.length; j++) {
+ let domain = domains[j]
+ for (let i = 0; i < domain.length; ++i) {
+ let vertices = domain[i].vertices;
+ const len = vertices.length - 1;
+ for (let j = 0; j < len; j++) {
+ results = simulation.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]);
+ if (results.onLine1 && results.onLine2) {
+ const dx = v1.x - results.x;
+ const dy = v1.y - results.y;
+ const dist2 = dx * dx + dy * dy;
+ if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) {
+ best = {
+ x: results.x,
+ y: results.y,
+ dist2: dist2,
+ who: domain[i],
+ v1: vertices[j],
+ v2: vertices[j + 1]
+ };
+ }
+ }
+ }
+ results = simulation.checkLineIntersection(v1, v1End, vertices[0], vertices[len]);
+ if (results.onLine1 && results.onLine2) {
+ const dx = v1.x - results.x;
+ const dy = v1.y - results.y;
+ const dist2 = dx * dx + dy * dy;
+ if (dist2 < best.dist2) {
+ best = {
+ x: results.x,
+ y: results.y,
+ dist2: dist2,
+ who: domain[i],
+ v1: vertices[0],
+ v2: vertices[len]
+ };
+ }
+ }
+ }
+ }
+ return best
+}
+
+// prompts to reload and exit for JUNK tech named "beforeunload"
+function beforeUnloadEventListener(event) {
+ event.preventDefault();
+ if (tech.isExitPrompt) {
+ tech.damage *= 1.25
+ // simulation.inGameConsole(`damage*= ${1.25}`)
+ simulation.inGameConsole(`tech.damage *= ${1.25} //beforeunload`);
+ if (Math.random() < 0.25) {
+ removeEventListener('beforeunload', beforeUnloadEventListener);
+ }
+ }
+}
+// addEventListener('beforeunload', beforeUnloadEventListener);
+
+
+//collision groups
+// cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet | cat.mobShield | cat.phased
+const cat = {
+ player: 0x1,
+ map: 0x10,
+ body: 0x100,
+ bullet: 0x1000,
+ powerUp: 0x10000,
+ mob: 0x100000,
+ mobBullet: 0x1000000,
+ mobShield: 0x10000000,
+ phased: 0x100000000,
+}
+
+let color = { //light
+ // background: "#ddd", // used instead: document.body.style.backgroundColor
+ block: "rgba(140,140,140,0.85)",
+ blockS: "#222",
+ map: "#444",
+ bullet: "#000"
+}
+
+// const color = { //dark
+// background: "#333",
+// block: "#444",
+// blockS: "#aab",
+// map: "#556",
+// bullet: "#fff"
+// }
+
+// const color = { //dark
+// background: "#999",
+// block: "#888",
+// blockS: "#111",
+// map: "#444",
+// }
+
+// shrink power up selection menu
+// if (screen.height < 800) {
+// document.getElementById("choose-grid").style.fontSize = "1em"; //1.3em is normal
+// if (screen.height < 600) document.getElementById("choose-grid").style.fontSize = "0.8em"; //1.3em is normal
+// }
+
+
+//**********************************************************************
+// check for URL parameters to load an experimental game
+//**********************************************************************
+
+//example https://landgreen.github.io/n-gon/index.html?
+// &gun1=minigun&gun2=laser
+// &tech1=laser-bot&tech2=mass%20driver&tech3=overcharge&tech4=laser-bot&tech5=laser-bot&field=phase%20decoherence%20field&difficulty=2
+//add ? to end of url then for each power up add
+// &gun1=name&gun2=name
+// &tech1=laser-bot&tech2=mass%20driver&tech3=overcharge&tech4=laser-bot&tech5=laser-bot
+// &field=phase%20decoherence%20field
+// &difficulty=2
+//use %20 for spaces
+//difficulty is 0 easy, 1 normal, 2 hard, 4 why
+function getUrlVars() {
+ let vars = {};
+ window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, k, v) {
+ vars[k] = v;
+ });
+ return vars;
+}
+window.addEventListener('load', () => {
+ const set = getUrlVars()
+ if (Object.keys(set).length !== 0) {
+ // build.populateGrid() //trying to solve a bug with this, but maybe it doesn't help
+ openExperimentMenu();
+ //add experimental selections based on url
+ for (const property in set) {
+ set[property] = set[property].replace(/%20/g, " ")
+ set[property] = set[property].replace(/%27/g, "'")
+ set[property] = set[property].replace(/%CE%A8/g, "Ψ")
+ if (property === "field") {
+ let found = false
+ let index
+ for (let i = 0; i < m.fieldUpgrades.length; i++) {
+ if (set[property] === m.fieldUpgrades[i].name) {
+ index = i;
+ found = true;
+ break;
+ }
+ }
+ if (found) build.choosePowerUp(index, 'field')
+ }
+ if (property.substring(0, 3) === "gun") {
+ let found = false
+ let index
+ for (let i = 0; i < b.guns.length; i++) {
+ if (set[property] === b.guns[i].name) {
+ index = i;
+ found = true;
+ break;
+ }
+ }
+ if (found) build.choosePowerUp(index, 'gun')
+ }
+ if (property.substring(0, 4) === "tech") {
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (set[property] === tech.tech[i].name) {
+ build.choosePowerUp(i, 'tech', true)
+ break;
+ }
+ }
+ }
+
+ // if (property === "difficulty") {
+ // simulation.difficultyMode = Number(set[property])
+ // lore.setTechGoal()
+ // document.getElementById("difficulty-select-experiment").value = Number(set[property])
+ // }
+ if (property === "molMode") {
+ simulation.molecularMode = Number(set[property])
+ const i = 4 //update experiment text
+ m.fieldUpgrades[i].description = m.fieldUpgrades[i].setDescription()
+ document.getElementById(`field-${i}`).innerHTML = `
+
${build.nameLink(m.fieldUpgrades[i].name)}
+ ${m.fieldUpgrades[i].description}
`
+ }
+ // if (property === "seed") {
+ // document.getElementById("seed").placeholder = Math.initialSeed = String(set[property])
+ // Math.seed = Math.abs(Math.hash(Math.initialSeed))
+ // level.populateLevels()
+ // }
+ requestAnimationFrame(() => { build.sortTech('have', true) });
+
+ }
+ } else if (localSettings.isTrainingNotAttempted && localSettings.runCount < 30) { //make training button more obvious for new players
+ // document.getElementById("training-button").style.border = "0px #333 solid";
+ // document.getElementById("training-button").style.fill = "rgb(0, 150, 235)" //"#fff";
+ // document.getElementById("training-button").style.background = "rgb(0, 200, 255)";
+
+ //css classes not working for some reason
+ // document.getElementById("training-button").classList.add('lore-text');
+
+ let myanim = document.createElementNS("http://www.w3.org/2000/svg", 'animate');
+ myanim.setAttribute("id", "myAnimation");
+ myanim.setAttribute("attributeType", "XML");
+ myanim.setAttribute("attributeName", "fill");
+ // myanim.setAttribute("values", "#f55;#cc5;#5c5;#5dd;#66f;#5dd;#5c5;#cc5;#f55"); //rainbow
+ myanim.setAttribute("values", "#5dd;#66f;#5dd");
+ // myanim.setAttribute("values", "#333;rgb(0, 170, 255);#333");
+ myanim.setAttribute("dur", "3s");
+ myanim.setAttribute("repeatCount", "indefinite");
+ document.getElementById("training-button").appendChild(myanim);
+ document.getElementById("myAnimation").beginElement();
+ }
+});
+
+
+//**********************************************************************
+//set up canvas
+//**********************************************************************
+const canvas = document.getElementById("canvas");
+//using "const" causes problems in safari when an ID shares the same name.
+const ctx = canvas.getContext("2d");
+// const ctx = canvas.getContext('2d', { alpha: false }); //optimization, this works if you wipe with the background color of each level
+
+document.body.style.backgroundColor = "#fff";
+
+//disable pop up menu on right click
+document.oncontextmenu = function () {
+ return false;
+}
+
+function setupCanvas() {
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+ canvas.width2 = canvas.width / 2; //precalculated because I use this often (in mouse look)
+ canvas.height2 = canvas.height / 2;
+ ctx.font = "25px Arial";
+ ctx.lineJoin = "round";
+ ctx.lineCap = "round";
+ simulation.setZoom();
+
+ if (simulation.isInvertedVertical) {
+ ctx.translate(0, canvas.height); // Move the origin down to the bottom
+ ctx.scale(1, -1); // Flip vertically
+ }
+}
+setupCanvas();
+window.onresize = () => {
+ setupCanvas();
+};
+
+//**********************************************************************
+// experimental build grid display and pause
+//**********************************************************************
+//set wikipedia link
+for (let i = 0, len = tech.tech.length; i < len; i++) {
+ if (!tech.tech[i].link) tech.tech[i].link = `${tech.tech[i].name}`
+}
+const build = {
+ pixelDraw() {
+ let count = 0
+ let imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
+ let data = imgData.data;
+
+ function loop() {
+ count++
+ if (!(count % 2)) {
+ for (let y = 0; y < canvas.height; ++y) {
+ for (let x = 0; x < canvas.width; x += 1) {
+ const index = (y * canvas.width + x) * 4;
+ // let mag = 0;
+ // for (let j = 0, len = who.length; j < len; j++) {
+ // const dx = who[j].position.x - x;
+ // const dy = who[j].position.y - y;
+ // mag -= who[j].charge / (Math.sqrt(dx * dx + dy * dy) + 1);
+ // }
+
+ //get dark
+ // data[index + 0] *= 0.96
+ // data[index + 1] *= 0.96
+ // data[index + 2] *= 0.96
+ // data[index + 3] -= 1; // alpha
+
+ //invert
+ data[index + 0] = 255 - data[index + 0] // red
+ data[index + 1] = 255 - data[index + 1] // green
+ data[index + 2] = 255 - data[index + 2] // blue
+ }
+ }
+
+ // fade alpha for all pixels
+ // for (let i = 0; i < data.length; i += 4) {
+ // if (data[i + 3] > 0) {
+ // data[i + 3]--;
+ // }
+ // }
+
+ //add random speckles
+ // for (let i = 0, len = Math.floor(data.length / 15000); i < len; ++i) {
+ // const index = Math.floor((Math.random() * data.length) / 4) * 4;
+ // data[index + 0] = 255; // red
+ // data[index + 1] = 255; // green
+ // data[index + 2] = 255; // blue
+ // data[index + 3] = Math.floor(Math.random() * Math.random() * 155); // alpha
+ // }
+
+ // ctx.putImageData(imgData, 0, 1); //pixels fall because of the 1 in third parameter
+ ctx.putImageData(imgData, 0, 0);
+ }
+ if (simulation.paused && m.alive) requestAnimationFrame(loop);
+ }
+ requestAnimationFrame(loop);
+ },
+ showImages(from) { //on click event: from all 3 different places to hide / show images
+ localSettings.isHideImages = !localSettings.isHideImages
+ if (localSettings.isAllowed) localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
+ if (from === 'experiment') {
+ build.reset();
+ } else if (from === 'pause') {
+ build.unPauseGrid()
+ build.pauseGrid() //redraw pause text with images
+ }
+ if (localSettings.isHideImages) {
+ document.getElementById("choose-grid").classList.add('choose-grid-no-images');
+ document.getElementById("choose-grid").classList.remove('choose-grid');
+ } else {
+ document.getElementById("choose-grid").classList.add('choose-grid');
+ document.getElementById("choose-grid").classList.remove('choose-grid-no-images');
+ }
+ document.getElementById("hide-images").checked = localSettings.isHideImages
+ // console.log(localSettings.isHideImages, from)
+ },
+ hideHUD() {
+ if (simulation.isTraining) {
+ localSettings.isHideHUD = false
+ } else {
+ localSettings.isHideHUD = !localSettings.isHideHUD
+ }
+ if (localSettings.isAllowed) localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
+ document.getElementById("hide-hud").checked = localSettings.isHideHUD
+ document.getElementById("hide-hud").classList.toggle("ticked")
+ simulation.removeEphemera("dmgDefBars")
+ if (!localSettings.isHideHUD) {
+ simulation.ephemera.push({
+ name: "dmgDefBars", count: 0, do() {
+ if (!(m.cycle % 15)) { //4 times a second
+ const defense = m.defense() //update defense bar
+ if (m.lastCalculatedDefense !== defense) {
+ document.getElementById("defense-bar").style.width = Math.floor(300 * m.maxHealth * (1 - defense)) + "px";
+ m.lastCalculatedDefense = defense
+ }
+ const damage = tech.damageFromTech() //update damage bar
+ if (m.lastCalculatedDamage !== damage) {
+ document.getElementById("damage-bar").style.height = Math.floor((Math.atan(0.25 * damage - 0.25) + 0.25) * 0.53 * canvas.height) + "px";
+ m.lastCalculatedDamage = damage
+ }
+ }
+ },
+ })
+ }
+ },
+ pauseGrid() {
+ build.generatePauseLeft() //makes the left side of the pause menu with the tech
+ build.generatePauseRight() //makes the right side of the pause menu with the tech
+ // build.sortTech('') //sorts tech into the order the player got them using tech.tech[i].cycle = m.cycle
+ document.getElementById("right-HUD").style.display = "none"
+ document.getElementById("guns").style.display = "none"
+ document.getElementById("field").style.display = "none"
+ document.getElementById("health").style.display = "none"
+ document.getElementById("health-bg").style.display = "none"
+ document.getElementById("defense-bar").style.display = "none"
+ document.getElementById("damage-bar").style.display = "none"
+ //show in game console
+ simulation.lastLogTime = m.cycle //hide in game console
+ },
+ generatePauseLeft() {
+ //left side
+ let botText = ""
+ if (tech.nailBotCount) botText += ` nail-bots ${tech.nailBotCount}`
+ if (tech.orbitBotCount) botText += ` orbital-bots ${tech.orbitBotCount}`
+ if (tech.boomBotCount) botText += ` boom-bots ${tech.boomBotCount}`
+ if (tech.laserBotCount) botText += ` laser-bots ${tech.laserBotCount}`
+ if (tech.foamBotCount) botText += ` foam-bots ${tech.foamBotCount}`
+ if (tech.soundBotCount) botText += ` sound-bots ${tech.soundBotCount}`
+ if (tech.dynamoBotCount) botText += ` dynamo-bots ${tech.dynamoBotCount}`
+ if (tech.plasmaBotCount) botText += ` plasma-bots ${tech.plasmaBotCount}`
+ if (tech.missileBotCount) botText += ` missile-bots ${tech.missileBotCount}`
+
+ // ${b.activeGun === null || b.activeGun === undefined ? "undefined" : b.guns[b.activeGun].name} (${b.activeGun === null || b.activeGun === undefined ? "0" : b.guns[b.activeGun].ammo})
+
+ //
+ //
+ //
+
+ let text = `
+PAUSED
+press ${input.key.pause} to resume
+
+
+
+
+
n-gon: todo list and complete change-log`
+ document.getElementById("updates-div").innerHTML = text
+
+ /// https://api.github.com/repos/landgreen/n-gon/stats/commit_activity
+ loadJSON('https://api.github.com/repos/landgreen/n-gon/commits',
+ function (data) {
+ // console.log(data[0].sha) //unique code for most recent commit
+ for (let i = 0, len = 20; i < len; i++) {
+ text += "" + data[i].commit.author.date.substr(0, 10) + " - "; //+ " "
+ text += data[i].commit.message
+ if (i < len - 1) text += ""
+ }
+ text += "
"
+ document.getElementById("updates-div").innerHTML = text.replace(/\n/g, " ")
+ },
+ function (xhr) {
+ console.error(xhr);
+ }
+ );
+})
+const sound = {
+ tone(frequency, end = 1000, gain = 0.05) {
+ const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); //setup audio context
+ const oscillator = audioCtx.createOscillator();
+ const gainNode = audioCtx.createGain();
+ gainNode.gain.value = gain; //controls volume
+ oscillator.connect(gainNode);
+ gainNode.connect(audioCtx.destination);
+ oscillator.type = "sine"; // 'sine' 'square', 'sawtooth', 'triangle' and 'custom'
+ oscillator.frequency.value = frequency; // value in hertz
+ oscillator.start();
+ setTimeout(() => {
+ audioCtx.suspend()
+ audioCtx.close()
+ }, end)
+ // return audioCtx
+ },
+ portamento(frequency, end = 1000, shiftRate = 10, gain = 0.05) {
+ const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); //setup audio context
+ const oscillator = audioCtx.createOscillator();
+ const gainNode = audioCtx.createGain();
+ gainNode.gain.value = gain; //controls volume
+ oscillator.connect(gainNode);
+ gainNode.connect(audioCtx.destination);
+ oscillator.type = "sine"; // 'sine' 'square', 'sawtooth', 'triangle' and 'custom'
+ oscillator.frequency.value = frequency; // value in hertz
+ oscillator.start();
+ for (let i = 0, len = end * 0.1; i < len; i++) oscillator.frequency.setValueAtTime(frequency + i * shiftRate, audioCtx.currentTime + i * 0.01);
+ setTimeout(() => {
+ audioCtx.suspend()
+ audioCtx.close()
+ }, end)
+ // return audioCtx
+ }
+}
+
+// preload images so they load cleaner
+// MDN Scripting and preloads - https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload
+// if (!localSettings.isHideImages) {
+// for (let i = 0, len = b.guns.length; i < len; i++) {
+// const preloadLink = document.createElement("link");
+// preloadLink.href = "img/gun/" + b.guns[i].name + ".webp";
+// preloadLink.rel = "preload";
+// preloadLink.as = "image";
+// document.head.appendChild(preloadLink);
+// }
+// for (let i = 1, len = m.fieldUpgrades.length; i < len; i++) {
+// const preloadLink = document.createElement("link");
+// preloadLink.href = "img/field/" + m.fieldUpgrades[i].name + ".webp";
+// preloadLink.rel = "preload";
+// preloadLink.as = "image";
+// document.head.appendChild(preloadLink);
+// }
+// for (let i = 0, len = tech.tech.length; i < len; i++) {
+// if (!tech.tech[i].isJunk) {
+// const preloadLink = document.createElement("link");
+// preloadLink.href = "img/" + tech.tech[i].name + ".webp";
+// preloadLink.rel = "preload";
+// preloadLink.as = "image";
+// document.head.appendChild(preloadLink);
+// }
+// }
+// }
+
+
+//preload images early
+if (!localSettings.isHideImages) {
+ addEventListener("load", () => {
+ let urls = new Array()
+ for (let i = 0, len = b.guns.length; i < len; i++) urls.push("img/gun/" + b.guns[i].name + ".webp")
+ for (let i = 1, len = m.fieldUpgrades.length; i < len; i++) urls.push("img/field/" + m.fieldUpgrades[i].name + ".webp")
+ for (let i = 0, len = tech.tech.length; i < len; i++) {
+ if (!tech.tech[i].isJunk && !tech.tech[i].isLore) urls.push("img/" + tech.tech[i].name + ".webp")
+ }
+ let images = new Array()
+ for (let i = 0; i < urls.length; i++) {
+ images[i] = new Image()
+ images[i].src = urls[i]
+ }
+ // console.log(urls, images)
+ });
+ document.getElementById("choose-grid").classList.add('choose-grid');
+} else {
+ document.getElementById("choose-grid").classList.add('choose-grid-no-images');
+}
+
+
+//**********************************************************************
+// main loop
+//**********************************************************************
+simulation.loop = simulation.normalLoop;
+
+function cycle() {
+ if (!simulation.paused) requestAnimationFrame(cycle);
+ const now = Date.now();
+ const elapsed = now - simulation.then; // calc elapsed time since last loop
+ if (elapsed > simulation.fpsInterval) { // if enough time has elapsed, draw the next frame
+ simulation.then = now - (elapsed % simulation.fpsInterval); // Get ready for next frame by setting then=now. Also, adjust for fpsInterval not being multiple of 16.67
+
+ simulation.cycle++; //tracks game cycles
+ m.cycle++; //tracks player cycles //used to alow time to stop for everything, but the player
+ if (simulation.clearNow) {
+ simulation.clearNow = false;
+ simulation.clearMap();
+ level.start();
+ }
+ simulation.loop();
+ }
+}
+
+// function cycle() {
+// if (!simulation.paused) requestAnimationFrame(cycle);
+// const now = Date.now();
+// const elapsed = now - simulation.then; // calc elapsed time since last loop
+// if (elapsed > simulation.fpsInterval) { // if enough time has elapsed, draw the next frame
+// simulation.then = now - (elapsed % simulation.fpsInterval); // Get ready for next frame by setting then=now. Also, adjust for fpsInterval not being multiple of 16.67
+
+// simulation.cycle++; //tracks game cycles
+// m.cycle++; //tracks player cycles //used to alow time to stop for everything, but the player
+// if (simulation.clearNow) {
+// simulation.clearNow = false;
+// simulation.clearMap();
+// level.start();
+// }
+// simulation.loop();
+// }
+// }
+
+// let timeStart = performance.now()
+// //0, 16.6666666666, 33.333333333333, 50.000000000
+// function cycle(timestamp) {
+// if (!simulation.paused) requestAnimationFrame(cycle);
+// if (timestamp - timeStart > 0) { //simulation.fpsInterval) { // if enough time has elapsed, draw the next frame
+// console.log(timestamp - timeStart)
+// timeStart = timestamp
+// simulation.cycle++; //tracks game cycles
+// m.cycle++; //tracks player cycles //used to alow time to stop for everything, but the player
+// if (simulation.clearNow) {
+// simulation.clearNow = false;
+// simulation.clearMap();
+// level.start();
+// }
+// simulation.loop();
+// }
+// }
+
+// let count = 1
+// let timeStart = performance.now()
+// const cycle = (timestamp) => {
+// // if (timeStart === undefined) timeStart = timestamp
+// // console.log(timestamp, timeStart)
+// if (timestamp - timeStart > tech.brainStormDelay * count) {
+// count++
+// powerUps.tech.effect();
+// document.getElementById("choose-grid").style.pointerEvents = "auto"; //turn off the normal 500ms delay
+// document.body.style.cursor = "auto";
+// document.getElementById("choose-grid").style.transitionDuration = "0s";
+// }
+// if (count < 5 && simulation.isChoosing) {
+// requestAnimationFrame(cycle);
+// } else {
+// tech.isBrainstormActive = false
+// }
+// }
+// requestAnimationFrame(cycle);
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/n-gon-master/js/level.js b/WebGames-master/WebGames-master/n-gon-master/js/level.js
new file mode 100644
index 00000000..13083688
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/js/level.js
@@ -0,0 +1,39026 @@
+let body = []; //non static bodies
+let map = []; //all static bodies
+let cons = []; //all constraints between a point and a body
+let consBB = []; //all constraints between two bodies
+let composite = [] //rotors and other map elements that don't fit
+const level = {
+ fallMode: "",
+ defaultZoom: 1400,
+ onLevel: -1,
+ levelsCleared: 0,
+ isFlipped: false,
+ uniqueLevels: ["initial", "reservoir", "factory", "interferometer", "reactor", "subway", "final"], //see level.populateLevels: (initial, ... , (reservoir, factory, or interferometer), reactor, ... , subway, final) added later
+ playableLevels: ["labs", "rooftops", "skyscrapers", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber", "pavilion", "lock", "towers", "flocculation", "gravitron", "substructure", "corridor"],
+ communityLevels: ["gauntlet", "stronghold", "basement", "crossfire", "vats", "run", "ngon", "house", "perplex", "coliseum", "tunnel", "islands", "temple", "dripp", "biohazard", "stereoMadness", "yingYang", "staircase", "fortress", "commandeer", "clock", "buttonbutton", "downpour", "superNgonBros", "underpass", "cantilever", "tlinat", "ruins", "ace", "crimsonTowers", "LaunchSite", "shipwreck", "unchartedCave", "dojo", "arena", "soft", "flappyGon", "rings", "trial"],
+ trainingLevels: ["walk", "crouch", "jump", "hold", "throw", "throwAt", "deflect", "heal", "fire", "nailGun", "shotGun", "superBall", "matterWave", "missile", "stack", "mine", "grenades", "harpoon"],
+ levels: [],
+ start() {
+ if (level.levelsCleared === 0) { //this code only runs on the first level
+ // simulation.enableConstructMode() //tech.giveTech('motion sickness') //used to build maps in testing mode
+ // simulation.isHorizontalFlipped = true
+ // spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
+ // spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
+ // level.levelsCleared = 10
+ // level.updateDifficulty()
+ // tech.giveTech("performance")
+ // m.maxHealth = m.health = 100000000
+ // m.maxEnergy = m.energy = 10000000
+ // tech.isRerollDamage = true
+ // powerUps.research.changeRerolls(99999)
+ // m.immuneCycle = Infinity //you can't take damage
+ // tech.tech[297].frequency = 100
+ // tech.addJunkTechToPool(0.5)
+ // m.couplingChange(10)
+ // m.setField("time dilation") //1 standing wave 2 perfect diamagnetism 3 negative mass 4 molecular assembler 5 plasma torch 6 time dilation 7 metamaterial cloaking 8 pilot wave 9 wormhole 10 grappling hook
+ // m.energy = 0
+ // powerUps.research.count = 3
+ // tech.isHookWire = true
+ // m.energy = 0
+ // simulation.molecularMode = 2
+ // m.damage(0.1);
+ // b.giveGuns("nail gun") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
+ // b.giveGuns("harpoon") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
+ // b.giveGuns("laser") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
+ // tech.laserColor = "#fff"
+ // tech.laserColorAlpha = "rgba(255, 255, 255, 0.5)"
+
+ // b.guns[8].ammo = 100000000
+ // requestAnimationFrame(() => { tech.giveTech("non-renewables") });
+ // tech.giveTech("dark matter")
+ // tech.addJunkTechToPool(0.5)
+ // for (let i = 0; i < 1; ++i) tech.giveTech("pigeonhole principle")
+ // for (let i = 0; i < 1; ++i) tech.giveTech("generalist")
+ // m.skin.egg();
+
+ // for (let i = 0; i < 1; ++i) tech.giveTech("many-worlds")
+ // requestAnimationFrame(() => { for (let i = 0; i < 1; i++) tech.giveTech("quasiparticles") });
+ // requestAnimationFrame(() => { for (let i = 0; i < 1; i++) tech.giveTech("interest") });
+ // for (let i = 0; i < 1; i++) tech.giveTech("interest")
+ // m.lastKillCycle = m.cycle
+ // for (let i = 0; i < 1; i++) powerUps.directSpawn(450, -50, "warp");
+ // for (let i = 0; i < 7; i++) powerUps.directSpawn(m.pos.x + 200, m.pos.y - 250, "research", false);
+ // spawn.bodyRect(575, -700, 150, 150); //block mob line of site on testing
+ // level.corridor();
+
+ level[simulation.isTraining ? "walk" : "initial"]() //normal starting level **************************************************
+
+
+ // for (let i = 0; i < 1; ++i) spawn.powerUpBossBaby(1900, -500)
+ // for (let i = 0; i < 1; i++) spawn.mantisBoss(1900, -500)
+
+ // for (let i = 0; i < 1; ++i) powerUps.directSpawn(m.pos.x + 50 * Math.random(), m.pos.y + 50 * Math.random(), "entanglement");
+ // for (let i = 0; i < 2; ++i) powerUps.directSpawn(m.pos.x + 450, m.pos.y + 50 * Math.random(), "boost");
+ // for (let i = 0; i < 100; ++i) powerUps.directSpawn(m.pos.x + 50 * Math.random(), m.pos.y + 50 * Math.random(), "ammo");
+ // for (let i = 0; i < 2; i++) powerUps.spawn(player.position.x + Math.random() * 50, player.position.y - Math.random() * 50, "field", false);
+ //lore testing
+ // localSettings.isTrainingNotAttempted = true
+ // simulation.isCheating = false //true;
+ // for (let i = 0; i < 5; i++) tech.giveTech("undefined")
+ // lore.techCount = 1
+ // level.levelsCleared = 10
+ // localSettings.loreCount = 1 //this sets what conversation is heard
+ // localSettings.levelsClearedLastGame = 10
+ // if (localSettings.isAllowed) localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
+ // level.onLevel = -1 //this sets level.levels[level.onLevel] = undefined which is required to run the conversation
+ // level.null()
+ // localSettings.isHuman = true
+ // tech.isNoDraftPause = false //disable pause
+ // mobs.mobDeaths = 200 //to prevent pacifist mode
+ // for (let i = 0; i < 13; i++) level.nextLevel(); //jump to final boss
+ // lore.unlockTesting();
+ // tech.giveTech("tinker"); //show junk tech in experiment mode
+ // m.storeTech()
+ // powerUps.spawn(m.pos.x, m.pos.y, "entanglement", false);
+ // for (let i = 0; i < 4; i++) localSettings.difficultyCompleted[i] = true
+ // localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
+ } else {
+ spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
+ // spawn.pickList = ["focuser", "focuser"]
+ level[level.levels[level.onLevel]](); //picks the current map from the the levels array
+ if (!simulation.isCheating && !build.isExperimentRun && !simulation.isTraining) {
+ localSettings.runCount += level.levelsCleared //track the number of total runs locally
+ localSettings.levelsClearedLastGame = level.levelsCleared
+ if (localSettings.isAllowed) localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
+ }
+ }
+ setupCanvas()
+ simulation.setupCamera(player.position);
+ simulation.setZoom();
+ level.addToWorld(); //add bodies to game engine
+ simulation.draw.setPaths();
+ b.respawnBots();
+ m.resetHistory();
+
+ if (tech.isForeverDrones) {
+ if (tech.isDroneRadioactive) {
+ for (let i = 0; i < tech.isForeverDrones * 0.25; i++) {
+ b.droneRadioactive({ x: m.pos.x + 30 * (Math.random() - 0.5), y: m.pos.y + 30 * (Math.random() - 0.5) }, 5)
+ bullet[bullet.length - 1].endCycle = Infinity
+ }
+ } else {
+ for (let i = 0; i < tech.isForeverDrones; i++) {
+ b.drone({ x: m.pos.x + 30 * (Math.random() - 0.5), y: m.pos.y + 30 * (Math.random() - 0.5) }, 5)
+ bullet[bullet.length - 1].endCycle = Infinity
+ }
+ }
+ }
+ if (tech.isDarkMatter) spawn.darkMatter()
+ for (let i = 0; i < tech.wimpCount; i++) {
+ spawn.WIMP()
+ mob[mob.length - 1].isDecoupling = true //so you can find it to remove
+ for (let j = 0, len = 4; j < len; j++) powerUps.spawn(level.exit.x + 100 * (Math.random() - 0.5), level.exit.y - 100 + 100 * (Math.random() - 0.5), "research", false)
+ }
+
+ if (m.plasmaBall) m.plasmaBall.fire()
+ if (localSettings.entanglement && localSettings.entanglement.levelName === level.levels[level.onLevel]) {
+ const flip = localSettings.entanglement.isHorizontalFlipped === simulation.isHorizontalFlipped ? 1 : -1
+ powerUps.directSpawn(flip * localSettings.entanglement.position.x, localSettings.entanglement.position.y, "entanglement", false);
+ }
+ level.newLevelOrPhase()
+ if (simulation.isTraining) {
+ simulation.difficultyMode = 1
+ } else {
+ simulation.inGameConsole(`level.onLevel = "${level.levels[level.onLevel]}"`);
+ document.title = "n-gon: " + level.levelAnnounce();
+ }
+
+ level.setConstraints()
+ if (!localSettings.isHideHUD) {
+ requestAnimationFrame(() => {
+ //grow and get bright
+ document.getElementById("right-HUD-constraint").style.opacity = 1
+ document.getElementById("right-HUD-constraint").style.fontSize = "23px"
+ document.getElementById("right-HUD-constraint").style.top = simulation.difficultyMode > 6 ? "6px" : "9px"
+ setTimeout(() => {
+ if (m.alive) {
+ //fade to background
+ document.getElementById("right-HUD-constraint").style.opacity = 0.35
+ document.getElementById("right-HUD-constraint").style.fontSize = "20px"
+ document.getElementById("right-HUD-constraint").style.top = "12px"
+ }
+ }, 5000);
+ });
+ }
+ },
+ newLevelOrPhase() { //runs on each new level but also on final boss phases
+ //used for generalist and pigeonhole principle
+ tech.cancelTechCount = 0
+ tech.tokamakHealCount = 0
+ tech.buffedGun++
+ if (tech.buffedGun > b.inventory.length - 1) tech.buffedGun = 0;
+ if ((tech.isGunCycle || tech.isGunChoice) && (b.activeGun !== null && b.activeGun !== undefined) && b.inventory.length) {
+ b.inventoryGun = tech.buffedGun;
+ simulation.switchGun();
+ }
+ // if (tech.isGunChoice && Number.isInteger(tech.buffedGun) && b.inventory.length) {
+ // var gun = b.guns[b.inventory[tech.buffedGun]].name
+ // simulation.inGameConsole(`pigeonhole principle: ${(1 + 0.4 * Math.max(0, b.inventory.length)).toFixed(2)}xdamage for ${gun}`, 600);
+ // }
+ if (tech.isSwitchReality && level.levelsCleared !== 0) {
+ simulation.inGameConsole(`simulation.amplitude = ${Math.random()}`);
+ m.switchWorlds("many-worlds")
+ simulation.trails()
+ powerUps.spawn(player.position.x + 50, player.position.y - Math.random() * 50, "tech", false);
+ }
+ if (tech.isHealLowHealth) {
+ const len = tech.isEnergyHealth ? 5 * Math.max(0, m.maxEnergy - m.energy) : 5 * Math.max(0, m.maxHealth - m.health)
+ for (let i = 0; i < len; i++) powerUps.spawn(player.position.x + 90 * (Math.random() - 0.5), player.position.y + 90 * (Math.random() - 0.5), "heal", false);
+ }
+ if (tech.interestRate > 0) {
+ // const rate = ((level[level.levels[level.onLevel]].name === "final" || level[level.levels[level.onLevel]].name === "subway") ? 1 / 3 : 1) * tech.interestRate //this effect triggers extra times on these final levels
+ let rate = tech.interestRate
+ if (level.onLevel < level.levels.length - 1) {//make sure it's not on the lore level which has an undefined name
+ const levelName = level.levels[level.onLevel]
+ if (levelName === "final" || levelName === "subway") rate *= 1 / 3
+ }
+
+ let ammoSum = 0
+ for (let i = 0; i < b.inventory.length; i++) {
+ if (b.guns[b.inventory[i]].ammo !== Infinity) ammoSum += b.guns[b.inventory[i]].ammo / b.guns[b.inventory[i]].ammoPack
+ }
+ if (ammoSum > 0 && b.inventory.length > 0) {
+ const amount = Math.ceil(rate * ammoSum / b.inventory.length)
+ powerUps.spawnDelay("ammo", amount, 4);
+ simulation.inGameConsole(`${(rate * 100).toFixed(0)}%interest on ammo= ${amount > 20 ? amount + powerUps.orb.ammo(1) : powerUps.orb.ammo(amount)}`)
+ }
+
+ // if (b.activeGun !== null && b.activeGun !== undefined && b.guns[b.activeGun].ammo !== Infinity) {
+ // const ammoPerOrb = b.guns[b.activeGun].ammoPack
+ // const a = Math.ceil(rate * b.guns[b.activeGun].ammo / ammoPerOrb)
+ // powerUps.spawnDelay("ammo", a, 4);
+ // simulation.inGameConsole(`${(rate * 100).toFixed(0)}%interest on ammo= ${a > 20 ? a + powerUps.orb.ammo(1) : powerUps.orb.ammo(a)}`)
+ // }
+ if (powerUps.research.count > 0) {
+ const r = Math.ceil(rate * powerUps.research.count)
+ simulation.inGameConsole(`${(rate * 100).toFixed(0)}%interest on research= ${r > 20 ? r + powerUps.orb.research(1) : powerUps.orb.research(r)}`)
+ powerUps.spawnDelay("research", r, 4);
+ }
+ if (m.coupling > 0) {
+ const c = Math.ceil(rate * m.coupling)
+ powerUps.spawnDelay("coupling", c, 4);
+ simulation.inGameConsole(`${(rate * 100).toFixed(0)}%interest on coupling= ${c > 20 ? c + powerUps.orb.coupling(1) : powerUps.orb.coupling(c)}`)
+ }
+ const healPerOrb = (powerUps.heal.size() / 40 / (simulation.healScale ** 0.25)) ** 2
+ const h = Math.ceil(rate * m.health / healPerOrb)
+ powerUps.spawnDelay("heal", h, 4);
+ simulation.inGameConsole(`${(rate * 100).toFixed(0)}%interest on health= ${h > 20 ? h + powerUps.orb.heal(1) : powerUps.orb.heal(h)}`)
+
+ // trying to spawn smaller heals
+ // const healPerOrb = (powerUps.heal.size() / 40 / (simulation.healScale ** 0.25)) ** 2
+ // console.log(healPerOrb)
+ // let h = tech.interestRate * m.health / healPerOrb
+ // console.log(tech.interestRate, m.health, healPerOrb, h)
+ // const overHeal = h - Math.floor(h)
+ // powerUps.spawn(m.pos.x, m.pos.y, "heal", true, null, Math.max(0.25, overHeal) * 40 * (simulation.healScale ** 0.25))
+ // if (h > healPerOrb) powerUps.spawnDelay("heal", h);
+ // simulation.inGameConsole(`${(Math.ceil(tech.interestRate * 100)).toFixed(0)}%interest on health= ${h > 20 ? h + powerUps.orb.heal(1) : powerUps.orb.heal(h)}`)
+ }
+ if (tech.isEjectOld) {
+ let index = null //find oldest tech that you have
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (tech.tech[i].count > 0 && !tech.tech[i].isInstant) {
+ index = i
+ }
+ }
+ if (index) { //eject it
+ const effect = Math.pow(1.1, tech.tech[index].count)
+ simulation.inGameConsole(`${(effect).toFixed(2)}xdamage//from obsolescence`, 360)
+ tech.damage *= effect
+ powerUps.ejectTech(index)
+ }
+ }
+ },
+ trainingText(say) {
+ simulation.lastLogTime = 0; //clear previous messages
+ simulation.isTextLogOpen = true
+ simulation.inGameConsole(`supervised.learning(${(Date.now() / 1000).toFixed(0)} s): ${say}`, Infinity)
+ simulation.isTextLogOpen = false
+ },
+ trainingBackgroundColor: "#e1e1e1",
+ custom() { },
+ customTopLayer() { },
+ updateDifficulty() {
+ simulation.difficulty = level.levelsCleared * simulation.difficultyMode
+ if (simulation.isTraining) {
+ simulation.difficulty = 1
+ simulation.difficultyMode = 1
+ m.dmgScale = 1
+ simulation.dmgScale = 1//Math.max(0.1, 0.25 * level.levelsCleared * scale) //damage done by mobs scales with total levels //a bigger number means the player takes more damage
+ } else {
+ const scale = simulation.difficultyMode > 3 ? 2 : 1
+ m.dmgScale = Math.pow(0.85, level.levelsCleared * scale)
+ simulation.dmgScale = Math.max(0.1, 0.25 * level.levelsCleared * scale) //damage done by mobs scales with total levels //a bigger number means the player takes more damage
+ if (simulation.difficultyMode > 5) {
+ m.dmgScale *= 0.5
+ simulation.dmgScale *= 2
+ }
+ }
+ simulation.healScale = 1 / (1 + simulation.difficulty * 0.043) //a higher denominator makes for lower heals // m.health += heal * simulation.healScale;
+ if (simulation.difficultyMode === 1) {
+ simulation.accelScale = 1.1
+ simulation.CDScale = 0.9
+ } else {
+ simulation.accelScale = Math.min(6, Math.pow(1.024, simulation.difficulty))
+ simulation.CDScale = Math.max(0.15, Math.pow(0.964, simulation.difficulty))
+ }
+ },
+ constraintIndex: 0,
+ setConstraints() {
+ //populate array with possible constraints and reset constraints
+ level.constraintDescription1 = level.constraintDescription2 = ""
+ const possible = []
+ for (let i = 0; i < level.constraint.length; i++) {
+ level.constraint[i].remove()
+ possible.push(i)
+ }
+ if (level.levels[level.onLevel] !== "final" && level.levels[level.onLevel] !== "null" && level.levels[level.onLevel] !== "initial" && !simulation.isTraining && m.alive && level.levelsCleared) {
+ if (simulation.difficultyMode > 4 && possible.length) {
+ //choose a random constraint from possible array and remove it from that array
+ // level.constraintIndex = 0 //REMOVE THIS FROM LIVE GAME
+ level.constraint[level.constraintIndex].effect()
+ possible.splice(level.constraintIndex, 1)
+ //generate text to describe the active constraints for the pause menu
+ level.constraintDescription1 = level.constraint[level.constraintIndex].description
+ level.constraintIndex++
+ if (level.constraintIndex > level.constraint.length - 1) level.constraintIndex = 0
+
+ if (simulation.difficultyMode > 6 && possible.length) {
+ level.constraint[level.constraintIndex].effect()
+ possible.splice(level.constraintIndex, 1)
+ level.constraintDescription2 += level.constraint[level.constraintIndex].description
+ level.constraintIndex++
+ if (level.constraintIndex > level.constraint.length - 1) level.constraintIndex = 0
+ }
+ document.getElementById("right-HUD-constraint").style.display = "block";
+ } else {
+ document.getElementById("right-HUD-constraint").style.display = "none";
+ }
+ } else {
+ document.getElementById("right-HUD-constraint").style.display = "none";
+ }
+ //update HUD with constraints
+ let text = `${level.constraintDescription1}`
+ if (level.constraintDescription1) simulation.inGameConsole(`constraint: ${level.constraintDescription1}`)
+ if (simulation.difficultyMode > 6 && level.constraintDescription2) {
+ text += ` ${level.constraintDescription2}`
+ if (level.constraintDescription2) simulation.inGameConsole(`constraint: ${level.constraintDescription2}`)
+ }
+ document.getElementById("right-HUD-constraint").innerHTML = text
+
+ if (level.constraintDescription1) {
+ if (level.constraintDescription2) {
+ document.getElementById("right-HUD").style.top = "80px";
+ } else {
+ document.getElementById("right-HUD").style.top = "57px"; //make room for tech list in "right-HUD"
+ }
+ } else {
+ document.getElementById("right-HUD").style.top = "15px";
+ }
+ },
+ constraintDescription1: "", //used in pause menu and console
+ constraintDescription2: "",
+ constraint: [
+ {
+ description: "0.5x healing",
+ effect() {
+ level.isLowHeal = true
+ },
+ remove() {
+ level.isLowHeal = false
+ }
+ },
+ {
+ description: "no pause while choosing",
+ effect() {
+ level.isNoPause = true
+ },
+ remove() {
+ level.isNoPause = false
+ }
+ },
+ {
+ description: "no health bars",
+ effect() {
+ mobs.healthBar = () => { }
+ level.isHideHealth = true
+ document.getElementById("health").style.display = "none"
+ document.getElementById("health-bg").style.display = "none"
+ },
+ remove() {
+ mobs.healthBar = mobs.defaultHealthBar
+ level.isHideHealth = false
+ if (tech.isEnergyHealth) {
+ document.getElementById("health").style.display = "none"
+ document.getElementById("health-bg").style.display = "none"
+ } else if (!level.isHideHealth) {
+ document.getElementById("health").style.display = "inline"
+ document.getElementById("health-bg").style.display = "inline"
+ }
+ }
+ },
+ {
+ description: "0.5x energy regen",
+ effect() {
+ level.isReducedRegen = 0.5
+ },
+ remove() {
+ level.isReducedRegen = 1
+ }
+ },
+ {
+ description: "0.5x max health",
+ effect() {
+ level.isReducedHealth = true
+ m.setMaxHealth()
+ },
+ remove() {
+ if (level.isReducedHealth) {
+ level.isReducedHealth = false
+ m.setMaxHealth()
+ m.addHealth(level.reducedHealthLost);
+ level.reducedHealthLost = 0
+ } else {
+ level.isReducedHealth = false
+ }
+
+ }
+ },
+ {
+ description: "after 40 seconds spawn WIMPs",
+ effect() {
+ simulation.ephemera.push({
+ name: "WIMPS",
+ time: 0,
+ levelName: level.levels[level.onLevel],
+ do() {
+ this.time++
+ if (level.levels[level.onLevel] === this.levelName) {
+ if (this.time > 2400 && !(this.time % 420)) spawn.WIMP(level.enter.x, level.enter.y)
+ } else {
+ simulation.removeEphemera(this.name);
+ }
+ },
+ })
+ },
+ remove() {
+
+ }
+ },
+ {
+ description: "0.3x damage after getting power ups",
+ effect() {
+ level.isNoDamage = true
+ level.noDamageCycle = 0
+ },
+ remove() {
+ level.isNoDamage = false
+ level.noDamageCycle = 0
+ }
+ },
+ {
+ description: "mobs heal after you take damage",
+ effect() {
+ level.isMobHealPlayerDamage = true
+ },
+ remove() {
+ level.isMobHealPlayerDamage = false
+ }
+ },
+ {
+ description: "mob death heals nearby mobs",
+ effect() {
+ level.isMobDeathHeal = true
+ },
+ remove() {
+ level.isMobDeathHeal = false
+ }
+ },
+ // {
+ // description: "full damage taken after boss dies",
+ // // description: "after boss dies damage taken = 1",
+ // effect() {
+ // level.noDefenseSetting = 1 //defense goes to zero once equal to 2
+ // },
+ // remove() {
+ // level.noDefenseSetting = 0
+ // }
+ // },
+ {
+ description: "4x shielded mobs",
+ effect() {
+ level.isMobShields = true
+ },
+ remove() {
+ level.isMobShields = false
+ }
+ },
+ {
+ description: "40% JUNK chance",
+ effect() {
+ level.junkAdded = 0.4
+ },
+ remove() {
+ level.junkAdded = 0
+ }
+ },
+ {
+ description: "-1 choice",
+ effect() {
+ level.fewerChoices = true
+ },
+ remove() {
+ level.fewerChoices = false
+ }
+ },
+ {
+ description: "power ups in stasis",
+ effect() {
+ level.isNextLevelPowerUps = true
+ //remove all current power ups
+ for (let i = powerUp.length - 1; i > -1; i--) {
+ powerUps.powerUpStorage.push({ name: powerUp[i].name, size: powerUp[i].size })
+ Matter.Composite.remove(engine.world, powerUp[i]);
+ powerUp.splice(i, 1)
+ }
+ },
+ remove() {
+ level.isNextLevelPowerUps = false
+ if (powerUps.powerUpStorage.length) {
+ const delay = 5
+ let i = 0
+ let cycle = () => {
+ if (powerUps.powerUpStorage.length && m.alive && powerUp.length < 300) {
+ requestAnimationFrame(cycle);
+ if (!simulation.paused && !simulation.isChoosing) {
+ if (!(simulation.cycle % delay)) {
+ const where = { x: m.pos.x + 70 * (Math.random() - 0.5), y: m.pos.y + 70 * (Math.random() - 0.5) }
+ powerUps.directSpawn(where.x, where.y, powerUps.powerUpStorage[i].name, true, powerUps.powerUpStorage[i].size);
+ powerUps.powerUpStorage.splice(i, 1);
+ }
+ }
+ } else {
+ powerUps.powerUpStorage = []
+ }
+ }
+ requestAnimationFrame(cycle);
+ }
+ }
+ },
+ {
+ description: "33% of mobs respawn",
+ effect() {
+ level.isMobRespawn = true
+ },
+ remove() {
+ level.isMobRespawn = false
+ }
+ },
+ {
+ description: "0 duplication",
+ effect() {
+ level.isNoDuplicate = true
+ },
+ remove() {
+ level.isNoDuplicate = false
+ }
+ },
+ {
+ description: "2x ammo cost",
+ effect() {
+ level.is2xAmmo = true
+ },
+ remove() {
+ level.is2xAmmo = false
+ }
+ },
+ {
+ description: "0.5x max energy",
+ effect() {
+ level.isReducedEnergy = true
+ m.setMaxEnergy()
+ },
+ remove() {
+ if (level.isReducedEnergy) {
+ level.isReducedEnergy = false
+ m.setMaxEnergy()
+ } else {
+ level.isReducedEnergy = false
+ }
+
+ }
+ },
+ {
+ description: "slow bots",
+ effect() {
+ level.isSlowBots = true
+ b.clearPermanentBots();
+ b.respawnBots();
+ },
+ remove() {
+ if (level.isSlowBots) {
+ level.isSlowBots = false
+ b.clearPermanentBots();
+ b.respawnBots();
+ } else {
+ level.isSlowBots = false
+ }
+
+ }
+ },
+ ],
+ isMobShields: false,
+ junkAdded: 0,
+ isNextLevelPowerUps: false,
+ isMobRespawn: false,
+ fewerChoices: false,
+ isNoDuplicate: false,
+ is2xAmmo: false,
+ isReducedEnergy: false,
+ isSlowBots: false,
+ // noDefenseSetting: 0,
+ isMobDeathHeal: false,
+ isMobHealPlayerDamage: false,
+ isNoDamage: false,
+ noDamageCycle: 0,
+ reducedHealthLost: 0,
+ isReducedHealth: false,
+ isReducedRegen: 1,
+ isHideHealth: false,
+ isNoPause: false,
+ isLowHeal: false,
+ levelAnnounce() {
+ const cheating = simulation.isCheating ? "(testing)" : ""
+ if (level.levelsCleared === 0) {
+ return `initial ${cheating}`;
+ } else {
+ return `${level.levelsCleared} ${level.levels[level.onLevel]} ${cheating}`
+ }
+ },
+ announceMobTypes() {
+ simulation.inGameConsole(`spawn.${spawn.pickList[0]}(x,y)`)
+ simulation.inGameConsole(`spawn.${spawn.pickList[1]}(x,y)`)
+ },
+ disableExit: false,
+ nextLevel() {
+ if (!level.disableExit) {
+ level.levelsCleared++;
+ level.onLevel++; //cycles map to next level
+ level.updateDifficulty()
+
+ if (simulation.isTraining) {
+ if (level.onLevel > level.levels.length - 1) { //if all training levels are completed
+ level.disableExit = true
+ document.getElementById("health").style.display = "none"
+ document.getElementById("health-bg").style.display = "none"
+ document.getElementById("defense-bar").style.display = "none"
+ document.getElementById("damage-bar").style.display = "none"
+ document.getElementById("text-log").style.display = "none"
+ document.getElementById("fade-out").style.opacity = 1; //slowly fades out
+ setTimeout(function () {
+ simulation.paused = true;
+ level.disableExit = false;
+ engine.world.bodies.forEach((body) => {
+ Matter.Composite.remove(engine.world, body)
+ })
+ Engine.clear(engine);
+ simulation.splashReturn();
+ }, 6000);
+ return
+ }
+ } else {
+ if (level.onLevel > level.levels.length - 1) level.onLevel = 0;
+ }
+ //reset lost tech display
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (tech.tech[i].isLost) tech.tech[i].isLost = false;
+ }
+ tech.isDeathAvoidedThisLevel = false;
+ simulation.updateTechHUD();
+ simulation.clearNow = true; //triggers in simulation.clearMap to remove all physics bodies and setup for new map
+
+ //pop up new level info screen for a few seconds //|| level.levels[level.onLevel] === "subway"
+ if (!localSettings.isHideHUD && m.alive && (level.levels[level.onLevel] === "final" || level.levels[level.onLevel] === "reactor")) {
+ // if (!localSettings.isHideHUD && m.alive) {
+ //pause
+ if (!simulation.paused) {
+ simulation.paused = true;
+ simulation.isChoosing = true; //stops p from un pausing on key down
+ }
+ //build level info
+ document.getElementById("choose-grid").style.gridTemplateColumns = "250px"
+ //onclick="level.unPause()"
+ // if (level.levels[level.onLevel] === "final") { //|| level.levels[level.onLevel] === "reactor"
+ let text = `
`
+ for (let i = 0; i < level.levels.length; i++) {
+ if (i < level.levelsCleared) {
+ text += `
${level.levels[i]}
`
+ } else if (i === level.levelsCleared) {
+ // text += `
${level.levels[i]}
`
+ text += `
${level.levels[i]}
`
+ } else {
+ text += `
${level.levels[i]}
` //blurry text
+ // ???????? text
+ // text += `
`
+ // for (let j = 0; j < level.levels[i].length; j++) text += `?`
+ // text += `
`
+ }
+ }
+ text += `
`
+
+ document.getElementById("choose-grid").innerHTML = text
+ //show level info
+ document.getElementById("choose-grid").style.opacity = "1"
+ document.getElementById("choose-grid").style.transitionDuration = "0.25s"; //how long is the fade in on
+ document.getElementById("choose-grid").style.visibility = "visible"
+ // }
+ simulation.draw.cons();
+ simulation.draw.body();
+ level.customTopLayer();
+ let count = countMax = simulation.testing ? 0 : 240
+ let newLevelDraw = () => {
+ count--
+ if (count > 0) {
+ requestAnimationFrame(newLevelDraw);
+ } else { //unpause
+ // document.body.style.cursor = "none";
+ if (m.immuneCycle < m.cycle + 15) m.immuneCycle = m.cycle + 30; //player is immune to damage for 30 cycles
+ if (simulation.paused) requestAnimationFrame(cycle);
+ if (m.alive) simulation.paused = false;
+ simulation.isChoosing = false; //stops p from un pausing on key down
+ build.unPauseGrid()
+ document.getElementById("choose-grid").style.opacity = "0"
+ setTimeout(() => {
+ document.getElementById("choose-grid").style.visibility = "hidden"
+ }, 1000);
+ }
+ //draw
+ simulation.wipe();
+ m.look();
+ simulation.camera();
+ const scale = 15
+ ctx.setLineDash([scale * (countMax - count), scale * count]);
+ simulation.draw.wireFrame();
+ ctx.setLineDash([]);
+ ctx.restore();
+ simulation.drawCursor();
+ }
+ requestAnimationFrame(newLevelDraw);
+ }
+ }
+ },
+ unPause() {
+ if (m.immuneCycle < m.cycle + 15) m.immuneCycle = m.cycle + 30; //player is immune to damage for 30 cycles
+ if (simulation.paused) requestAnimationFrame(cycle);
+ if (m.alive) simulation.paused = false;
+ simulation.isChoosing = false; //stops p from un pausing on key down
+ build.unPauseGrid()
+ document.getElementById("choose-grid").style.opacity = "0"
+ document.getElementById("choose-grid").style.visibility = "hidden"
+ // setTimeout(() => {
+ // }, 1000);
+ },
+ populateLevels() { //run a second time if URL is loaded
+ if (document.getElementById("banned").value) { //remove levels from ban list in settings
+ const banList = document.getElementById("banned").value.replace(/,/g, ' ').replace(/\s\s+/g, ' ').replace(/[^\w\s]/g, '') //replace commas with spaces, replace double spaces with single, remove strange symbols
+ const remove = banList.split(" ");
+ // console.log('remove these', remove)
+ // console.log('community levels before', level.communityLevels)
+ for (let i = 0; i < remove.length; i++) {
+ const index = level.communityLevels.indexOf(remove[i])
+ if (index !== -1) {
+ level.communityLevels.splice(index, 1);
+ // console.log('removed level:', remove[i])
+ requestAnimationFrame(() => { simulation.inGameConsole(`banned level: ${remove[i]}`); });
+ }
+ }
+ // console.log('community levels after', level.communityLevels)
+ // console.log('Landgreen levels before', level.playableLevels)
+ for (let i = 0; i < remove.length; i++) {
+ if (level.playableLevels.length + level.communityLevels.length * simulation.isCommunityMaps < 10) break //can't remove too many levels
+ const index = level.playableLevels.indexOf(remove[i])
+ if (index !== -1) {
+ level.playableLevels.splice(index, 1);
+ // console.log('removed level:', remove[i])
+ requestAnimationFrame(() => { simulation.inGameConsole(`banned level: ${remove[i]}`); });
+ }
+ }
+ // console.log('Landgreen levels after', level.playableLevels)
+ }
+
+ if (document.getElementById("seed").value) { //check for player entered seed in settings
+ Math.initialSeed = String(document.getElementById("seed").value)
+ Math.seed = Math.abs(Math.hash(Math.initialSeed)) //update randomizer seed in case the player changed it
+ }
+
+ if (simulation.isTraining) {
+ simulation.isHorizontalFlipped = false
+ level.levels = level.trainingLevels.slice(0) //copy array, not by just by assignment
+ if (simulation.isCommunityMaps) level.trainingLevels.push("diamagnetism")
+ } else { //add remove and shuffle levels for the normal game (not training levels)
+ level.levels = level.playableLevels.slice(0) //copy array, not by just by assignment
+ if (simulation.isCommunityMaps) {
+ level.levels = level.levels.concat(level.communityLevels)
+ simulation.isHorizontalFlipped = false;
+ } else {
+ simulation.isHorizontalFlipped = (Math.seededRandom() < 0.5) ? true : false //if true, some maps are flipped horizontally
+ }
+ level.levels = shuffle(level.levels); //shuffles order of maps with seeded random
+ level.levels.length = 9 //remove any extra levels past 9
+ pick = ["interferometer", "factory", "reservoir"]
+ level.levels.splice(Math.floor(Math.seededRandom(level.levels.length * 0.6, level.levels.length)), 0, pick[Math.floor(Math.random() * pick.length)]); //add level to the back half of the randomized levels list
+
+ level.levels.splice(Math.floor(Math.seededRandom(level.levels.length * 0.6, level.levels.length)), 0, "reactor"); //add level to the back half of the randomized levels list
+ if (!build.isExperimentSelection || (build.hasExperimentalMode && !simulation.isCheating)) { //experimental mode is endless, unless you only have an experiment Tech
+ level.levels.unshift("initial"); //add level to the start of the randomized levels list
+ level.levels.push("subway"); //add level to the end of the randomized levels list
+ level.levels.push("final"); //add level to the end of the randomized levels list
+ }
+ }
+ //set seeded random lists of mobs and bosses
+ spawn.mobTypeSpawnOrder = []
+ for (let i = 0; i < level.levels.length; i++) spawn.mobTypeSpawnOrder.push(spawn.fullPickList[Math.floor(Math.seededRandom(0, spawn.fullPickList.length))])
+ spawn.bossTypeSpawnOrder = []
+ for (let i = 0; i < level.levels.length * 2; i++) spawn.bossTypeSpawnOrder.push(spawn.randomBossList[Math.floor(Math.seededRandom(0, spawn.randomBossList.length))])
+ },
+ flipHorizontal() {
+ const flipX = (who) => {
+ for (let i = 0, len = who.length; i < len; i++) {
+ Matter.Body.setPosition(who[i], {
+ x: -who[i].position.x,
+ y: who[i].position.y
+ })
+ }
+ }
+ flipX(map)
+ flipX(body)
+ flipX(mob)
+ flipX(powerUp)
+ for (let i = 0, len = cons.length; i < len; i++) {
+ cons[i].pointA.x *= -1
+ cons[i].pointB.x *= -1
+ }
+ for (let i = 0, len = consBB.length; i < len; i++) {
+ consBB[i].pointA.x *= -1
+ consBB[i].pointB.x *= -1
+ }
+ level.exit.x = -level.exit.x - 100 //minus the 100 because of the width of the graphic
+ },
+ flipVertical() {
+ const flipY = (who) => {
+ for (let i = 0, len = who.length; i < len; i++) {
+ Matter.Body.setPosition(who[i], { x: who[i].position.x, y: -who[i].position.y - player.position.y })
+ }
+ }
+ flipY(map)
+ flipY(body)
+ flipY(mob)
+ flipY(powerUp)
+ Matter.Body.setPosition(player, { x: player.position.x, y: -2 * player.position.y })
+
+ // for (let i = 0, len = cons.length; i < len; i++) {
+ // cons[i].pointA.x *= -1
+ // cons[i].pointB.x *= -1
+ // }
+ // for (let i = 0, len = consBB.length; i < len; i++) {
+ // consBB[i].pointA.x *= -1
+ // consBB[i].pointB.x *= -1
+ // }
+ // level.exit.x = -level.exit.x - 100 //minus the 100 because of the width of the graphic
+ },
+ exitCount: 0,
+ setPosToSpawn(xPos, yPos) {
+ m.spawnPos.x = m.pos.x = xPos;
+ m.spawnPos.y = m.pos.y = yPos;
+ level.enter.x = m.spawnPos.x - 50;
+ level.enter.y = m.spawnPos.y + 20;
+ m.transX = m.transSmoothX = canvas.width2 - m.pos.x;
+ m.transY = m.transSmoothY = canvas.height2 - m.pos.y;
+ m.Vx = m.spawnVel.x;
+ m.Vy = m.spawnVel.y;
+ player.force.x = 0;
+ player.force.y = 0;
+ Matter.Body.setPosition(player, m.spawnPos);
+ Matter.Body.setVelocity(player, m.spawnVel);
+ //makes perfect diamagnetism tech: Lenz's law show up in the right spot at the start of a level
+ m.fieldPosition = {
+ x: m.pos.x,
+ y: m.pos.y
+ }
+ m.fieldAngle = m.angle
+ },
+ enter: {
+ x: 0,
+ y: 0,
+ draw() {
+ ctx.beginPath();
+ ctx.moveTo(level.enter.x, level.enter.y + 30);
+ ctx.lineTo(level.enter.x, level.enter.y - 80);
+ ctx.bezierCurveTo(level.enter.x, level.enter.y - 170, level.enter.x + 100, level.enter.y - 170, level.enter.x + 100, level.enter.y - 80);
+ ctx.lineTo(level.enter.x + 100, level.enter.y + 30);
+ ctx.lineTo(level.enter.x, level.enter.y + 30);
+ ctx.fillStyle = "#ccc";
+ ctx.fill();
+ }
+ },
+ exit: {
+ x: 0,
+ y: 0,
+ drawAndCheck() {
+ if ( //check
+ player.position.x > level.exit.x &&
+ player.position.x < level.exit.x + 100 &&
+ player.position.y > level.exit.y - 150 &&
+ player.position.y < level.exit.y - 0 &&
+ player.velocity.y < 0.15
+ ) {
+ // level.exitCount += input.down ? 8 : 2
+ level.exitCount += 3
+ } else if (level.exitCount > 0) {
+ level.exitCount -= 3
+ }
+
+ ctx.beginPath();
+ ctx.moveTo(level.exit.x, level.exit.y + 30);
+ ctx.lineTo(level.exit.x, level.exit.y - 80);
+ ctx.bezierCurveTo(level.exit.x, level.exit.y - 170, level.exit.x + 100, level.exit.y - 170, level.exit.x + 100, level.exit.y - 80);
+ ctx.lineTo(level.exit.x + 100, level.exit.y + 30);
+ ctx.lineTo(level.exit.x, level.exit.y + 30);
+ ctx.fillStyle = "#0ff";
+ ctx.fill();
+
+ if (level.exitCount > 0) { //stroke outline of door from 2 sides, grows with count
+ ctx.beginPath();
+ ctx.moveTo(level.exit.x, level.exit.y + 40);
+ ctx.lineTo(level.exit.x, level.exit.y - 80);
+ ctx.bezierCurveTo(level.exit.x, level.exit.y - 148, level.exit.x + 50, level.exit.y - 148, level.exit.x + 50, level.exit.y - 148);
+ ctx.moveTo(level.exit.x + 100, level.exit.y + 40);
+ ctx.lineTo(level.exit.x + 100, level.exit.y - 80);
+ ctx.bezierCurveTo(level.exit.x + 100, level.exit.y - 148, level.exit.x + 50, level.exit.y - 148, level.exit.x + 50, level.exit.y - 148);
+ ctx.setLineDash([200, 200]);
+ ctx.lineDashOffset = Math.max(-15, 185 - 2.1 * level.exitCount)
+ ctx.strokeStyle = "#444"
+ ctx.lineWidth = 2
+ ctx.stroke();
+ ctx.setLineDash([0, 0]);
+
+ if (level.exitCount > 100) {
+ level.exitCount = 0
+
+ //prompt an option to do the training levels or continue to the normal game
+ if (!simulation.isChoosing && m.alive && !simulation.isTraining && !simulation.isCheating && b.inventory.length === 0 && level.levelsCleared === 0 && localSettings.isTrainingNotAttempted) {
+ //pause
+ if (!simulation.paused) {
+ simulation.paused = true;
+ simulation.isChoosing = true; //stops p from un pausing on key down
+
+ document.body.style.cursor = "auto";
+ document.getElementById("choose-grid").style.pointerEvents = "auto";
+ document.getElementById("choose-grid").style.transitionDuration = "0s";
+ }
+ //build level info
+ document.getElementById("choose-grid").classList.add('choose-grid-no-images');
+ document.getElementById("choose-grid").classList.remove('choose-grid');
+ document.getElementById("choose-grid").style.gridTemplateColumns = "350px"
+ let text = `
+
+
training
+ Begin the guided tutorial that shows you how to use your ${powerUps.orb.field()} and ${powerUps.orb.gun()}.
+
+
+
play
+ Begin the standard game where you progress through 13 random levels and beat the final boss.
+
`
+ for (let i = 0, len = Math.min(powerUps.research.count, 30); i < len; i++) text += ``
+ text += `${tech.isResearchReality ? "alternate reality" : "research"}
`
+ } else {
+ text += ``
+ }
+ return text
+ },
+ researchAndCancelText(type) {
+ let text = `
`
+ if (type === "entanglement") {
+ text += `entanglement`
+ } else if (tech.isJunkResearch && powerUps.research.currentRerollCount < 2) {
+ text += `` // style = "margin-left: 192px; margin-right: -192px;"
+ text += `
`
+ text += ``
+ text += `${tech.isResearchReality ? "alternate reality" : "research"}
`
+ } else if (powerUps.research.count > 0) {
+ text += `` // style = "margin-left: 192px; margin-right: -192px;"
+ text += `
`
+ let researchCap = 18
+ if (tech.isCancelTech && tech.cancelTechCount === 0) researchCap -= 2
+ if (canvas.width < 1951) researchCap -= 3
+ if (canvas.width < 1711) researchCap -= 4
+ for (let i = 0, len = Math.min(powerUps.research.count, researchCap); i < len; i++) {
+ text += ``
+ }
+ text += `${tech.isResearchReality ? "alternate reality" : "research"}
`
+ } else {
+ text += `research` //
+ }
+ if (tech.isSuperDeterminism) {
+ text += `cancel`
+ } else if (tech.isCancelTech && tech.cancelTechCount === 0) {
+ text += `randomize`
+ } else if (level.levelsCleared === 0 && localSettings.isTrainingNotAttempted && b.inventory.length === 0) {
+ text += `cancel` //don't show cancel if on initial level and haven't done tutorial
+ } else {
+ text += `cancel`
+ }
+ return text + "
"
+ },
+ buildColumns(totalChoices, type) {
+ let width
+ if (canvas.width < 1710) {
+ width = "285px"
+ } else if (canvas.width < 1950) {
+ width = "340px"
+ } else {
+ width = "384px"
+ }
+
+ let text = ""
+ if (localSettings.isHideImages) {
+ document.getElementById("choose-grid").style.gridTemplateColumns = width
+ text += powerUps.researchAndCancelText(type)
+ } else if (totalChoices === 0) {
+ document.getElementById("choose-grid").style.gridTemplateColumns = width
+ text += powerUps.researchAndCancelText(type)
+ } else if (totalChoices === 1 || canvas.width < 1200) {
+ document.getElementById("choose-grid").style.gridTemplateColumns = width
+ text += powerUps.researchAndCancelText(type)
+ // console.log('hi')
+ // text += powerUps.cancelText(type)
+ // text += powerUps.researchText(type)
+ } else if (totalChoices === 2) {
+ document.getElementById("choose-grid").style.gridTemplateColumns = `repeat(2, ${width})`
+ text += powerUps.researchText(type)
+ text += powerUps.cancelText(type)
+ } else {
+ document.getElementById("choose-grid").style.gridTemplateColumns = `repeat(3, ${width})`
+ text += ""
+ text += powerUps.researchText(type)
+ text += powerUps.cancelText(type)
+ }
+ return text
+ },
+ hideStyle: `style="height:auto; border: none; background-color: transparent;"`,
+ gunText(choose, click) {
+ const style = localSettings.isHideImages ? powerUps.hideStyle : `style="background-image: url('img/gun/${b.guns[choose].name}.webp');"`
+ return `
`
+ },
+ gun: {
+ name: "gun",
+ color: "#26a",
+ size() {
+ return 35;
+ },
+ effect() {
+ if (m.alive) {
+ let options = [];
+ for (let i = 0; i < b.guns.length; i++) {
+ if (!b.guns[i].have) options.push(i);
+ }
+ // console.log(options.length)
+ if (options.length > 0 || !tech.isSuperDeterminism) {
+ let totalChoices = 2 + tech.extraChoices + 3 * (m.fieldMode === 8) - level.fewerChoices
+ if (tech.isCancelTech && tech.cancelTechCount === 1) {
+ totalChoices *= 3
+ tech.cancelTechCount++
+ }
+ if (tech.isDeterminism) totalChoices = 1
+ totalChoices = Math.min(totalChoices, options.length)
+ function removeOption(index) {
+ for (let i = 0; i < options.length; i++) {
+ if (options[i] === index) {
+ options.splice(i, 1) //remove a previous choice from option pool
+ return
+ }
+ }
+ }
+ //check for guns that were a choice last time and remove them
+ for (let i = 0; i < b.guns.length; i++) {
+ if (options.length - 1 < totalChoices) break //you have to repeat choices if there are not enough choices left to display
+ if (b.guns[i].isRecentlyShown) removeOption(i)
+ }
+ for (let i = 0; i < b.guns.length; i++) b.guns[i].isRecentlyShown = false //reset recently shown back to zero
+ // if (options.length > 0) {
+ let text = powerUps.buildColumns(totalChoices, "gun")
+ for (let i = 0; i < totalChoices; i++) {
+ const choose = options[Math.floor(Math.seededRandom(0, options.length))] //pick an element from the array of options
+ // text += `
${b.guns[choose].name}
${b.guns[choose].description}
`
+ text += powerUps.gunText(choose, `powerUps.choose('gun',${choose})`)
+
+ b.guns[choose].isRecentlyShown = true
+ removeOption(choose)
+ if (options.length < 1) break
+ }
+ if (tech.isExtraBotOption) {
+ const botTech = [] //make an array of bot options
+ for (let i = 0, len = tech.tech.length; i < len; i++) {
+ if (tech.tech[i].isBotTech && tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed()) botTech.push(i)
+ }
+ if (botTech.length > 0) { //pick random bot tech
+ const choose = botTech[Math.floor(Math.random() * botTech.length)];
+ const techCountText = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count + 1}x)` : "";
+ const style = localSettings.isHideImages ? powerUps.hideStyle : `style="background-image: url('img/${tech.tech[choose].name}.webp');"`
+ text += `
`
+ }
+ }
+ if (tech.isOneGun && b.inventory.length > 0) text += `
replaces your current gun
`
+ document.getElementById("choose-grid").innerHTML = text
+ powerUps.showDraft();
+ }
+ // }
+ }
+ },
+ },
+ field: {
+ name: "field",
+ color: "#0cf",
+ size() {
+ return 45;
+ },
+ effect() {
+ if (m.alive) {
+ let options = [];
+ for (let i = 1; i < m.fieldUpgrades.length; i++) { //skip field emitter
+ if (i !== m.fieldMode) options.push(i);
+ }
+ let totalChoices = 2 + tech.extraChoices + 3 * (m.fieldMode === 8) - level.fewerChoices
+ if (tech.isCancelTech && tech.cancelTechCount === 1) {
+ totalChoices *= 3
+ tech.cancelTechCount++
+ }
+ if (tech.isDeterminism) totalChoices = 1
+ totalChoices = Math.max(1, Math.min(totalChoices, options.length))
+ function removeOption(index) {
+ for (let i = 0; i < options.length; i++) {
+ if (options[i] === index) {
+ options.splice(i, 1) //remove a previous choice from option pool
+ return
+ }
+ }
+ }
+ //check for fields that were a choice last time and remove them
+ for (let i = 0; i < m.fieldUpgrades.length; i++) {
+ if (options.length - 1 < totalChoices) break //you have to repeat choices if there are not enough choices left to display
+ if (m.fieldUpgrades[i].isRecentlyShown) removeOption(i)
+ }
+ for (let i = 0; i < m.fieldUpgrades.length; i++) m.fieldUpgrades[i].isRecentlyShown = false //reset recently shown back to zero
+
+ if (options.length > 0 || tech.isExtraBotOption) {
+ let text = powerUps.buildColumns(totalChoices, "field")
+ for (let i = 0; i < totalChoices; i++) {
+ const choose = options[Math.floor(Math.seededRandom(0, options.length))] //pick an element from the array of options
+ //text += `
${m.fieldUpgrades[choose].name}
${m.fieldUpgrades[choose].description}
` //default
+ text += powerUps.fieldText(choose, `powerUps.choose('field',${choose})`)
+ m.fieldUpgrades[choose].isRecentlyShown = true
+ removeOption(choose)
+ if (options.length < 1) break
+ }
+ if (tech.isExtraBotOption) {
+ const botTech = [] //make an array of bot options
+ for (let i = 0, len = tech.tech.length; i < len; i++) {
+ if (tech.tech[i].isBotTech && tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed()) botTech.push(i)
+ }
+ if (botTech.length > 0) { //pick random bot tech
+ const choose = botTech[Math.floor(Math.random() * botTech.length)];
+ const techCountText = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count + 1}x)` : "";
+ const style = localSettings.isHideImages ? powerUps.hideStyle : `style="background-image: url('img/${tech.tech[choose].name}.webp');"`
+ text += `
`
+ }
+ }
+ document.getElementById("choose-grid").innerHTML = text
+ powerUps.showDraft();
+ }
+ }
+ },
+ },
+ tech: {
+ name: "tech",
+ color: "hsl(246,100%,77%)", //"#a8f",
+ size() {
+ return 42;
+ },
+ effect() {
+ if (m.alive) {
+ // powerUps.animatePowerUpGrab('hsla(246, 100%, 77%,0.5)')
+ let options = []; //generate all options
+ optionLengthNoDuplicates = 0
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed() && !tech.tech[i].isBanished) {
+ if (tech.tech[i].frequency > 0) optionLengthNoDuplicates++
+ for (let j = 0, len = tech.tech[i].frequency; j < len; j++) options.push(i);
+ }
+ }
+ function removeOption(index) {
+ for (let i = options.length - 1; i > -1; i--) {
+ if (index === options[i]) {
+ options.splice(i, 1) //remove all copies of that option form the options array (some tech are in the options array multiple times because of frequency)
+ optionLengthNoDuplicates--
+ }
+ if (options.length < 1) return;
+ }
+ }
+ //set total choices
+ let totalChoices = 3 + tech.extraChoices + 3 * (m.fieldMode === 8) - level.fewerChoices
+ if (tech.isCancelTech && tech.cancelTechCount === 1) {
+ totalChoices *= 3
+ tech.cancelTechCount++
+ }
+ if (tech.isDeterminism) totalChoices = 1
+ totalChoices = Math.max(1, Math.min(totalChoices, options.length))
+
+ if (optionLengthNoDuplicates < totalChoices + 1) { //if not enough options for all the choices
+ totalChoices = optionLengthNoDuplicates
+ if (tech.isBanish) { //when you run out of options eject banish
+ for (let i = 0, len = tech.tech.length; i < len; i++) {
+ if (tech.tech[i].name === "decoherence") powerUps.ejectTech(i, true)
+ }
+ simulation.inGameConsole(`decoherence tech ejected options reset`)
+ }
+ }
+ if (tech.tooManyTechChoices) {
+ tech.tooManyTechChoices = false
+ totalChoices = optionLengthNoDuplicates
+ }
+ if (optionLengthNoDuplicates > totalChoices) { //check for tech that were a choice last time and remove them
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (optionLengthNoDuplicates > totalChoices) {
+ if (tech.tech[i].isRecentlyShown) removeOption(i)
+ } else {
+ break //you have to repeat choices if there are not enough choices left to display
+ }
+
+ }
+ }
+ for (let i = 0; i < tech.tech.length; i++) tech.tech[i].isRecentlyShown = false //reset recently shown back to zero
+ if (options.length > 0) {
+ let text = powerUps.buildColumns(totalChoices, "tech")
+
+ addTech = (choose) => {
+ if (tech.tech[choose].isFieldTech) {
+ text += powerUps.fieldTechText(choose, `powerUps.choose('tech',${choose})`)
+ } else if (tech.tech[choose].isGunTech) {
+ text += powerUps.gunTechText(choose, `powerUps.choose('tech',${choose})`)
+ } else if (tech.tech[choose].isJunk) {
+ text += powerUps.junkTechText(choose, `powerUps.choose('tech',${choose})`)
+ } else if (tech.tech[choose].isSkin) {
+ text += powerUps.skinTechText(choose, `powerUps.choose('tech',${choose})`)
+ } else if (tech.tech[choose].isInstant) {
+ text += powerUps.instantTechText(choose, `powerUps.choose('tech',${choose})`)
+ } else { //normal tech
+ text += powerUps.techText(choose, `powerUps.choose('tech',${choose})`)
+ }
+ }
+ if (tech.isRetain) {
+ for (let i = 0, len = powerUps.retainList.length; i < len; i++) {
+ //find index from name and add tech to options
+ for (let j = 0, len = tech.tech.length; j < len; j++) {
+ if (tech.tech[j].name === powerUps.retainList[i] && tech.tech[j].count < tech.tech[j].maxCount && tech.tech[j].allowed() && tech.tech[j].frequency > 0) { //&& !tech.tech[j].isRecentlyShown
+ addTech(j)
+ }
+ }
+ }
+ }
+ for (let i = 0; i < totalChoices; i++) {
+ if (options.length < 1) break
+ if (Math.random() < tech.junkChance + level.junkAdded) { // choose is set to a random JUNK tech
+ const list = []
+ for (let i = 0; i < tech.tech.length; i++) {
+ if (tech.tech[i].isJunk) list.push(i)
+ }
+ chooseJUNK = list[Math.floor(Math.random() * list.length)]
+ if (tech.isRetain) powerUps.retainList.push(tech.tech[chooseJUNK].name)
+ text += powerUps.junkTechText(chooseJUNK, `powerUps.choose('tech',${chooseJUNK})`)
+ } else {
+ const choose = options[Math.floor(Math.seededRandom(0, options.length))] //pick an element from the array of options
+ if (tech.isBanish) {
+ tech.tech[choose].isBanished = true
+ if (i === 0) simulation.inGameConsole(`options.length = ${optionLengthNoDuplicates} //removed from pool by decoherence`)
+ }
+ removeOption(choose) //remove from future options pool to avoid repeats on this selection
+
+ //this flag prevents this option from being shown the next time you pick up a tech power up
+ //check if not extra choices from "path integral"
+ tech.tech[choose].isRecentlyShown = true
+ if (tech.isRetain && !powerUps.retainList.includes(tech.tech[choose].name)) powerUps.retainList.push(tech.tech[choose].name)
+ addTech(choose)
+ }
+ }
+ if (tech.isExtraBotOption) {
+ const botTech = [] //make an array of bot options
+ for (let i = 0, len = tech.tech.length; i < len; i++) {
+ if (tech.tech[i].isBotTech && tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed() && !tech.tech[i].isRecentlyShown) botTech.push(i)
+ }
+ if (botTech.length > 0) { //pick random bot tech
+ // const choose = botTech[Math.floor(Math.random() * botTech.length)];
+ // const isCount = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count+1}x)` : "";
+ // text += `
`
+ }
+ }
+ }
+ if (tech.isExtraGunField) {
+ if (Math.random() > 0.5 && b.inventory.length < b.guns.length) {
+ let gunOptions = [];
+ for (let i = 0; i < b.guns.length; i++) {
+ if (!b.guns[i].have) gunOptions.push(i);
+ }
+ const pick = gunOptions[Math.floor(Math.seededRandom(0, gunOptions.length))] //pick an element from the array of options
+ // text += `
${b.guns[pick].name}
${b.guns[pick].description}
`
+ text += powerUps.gunText(pick, `powerUps.choose('gun',${pick})`)
+ } else {
+ let fieldOptions = [];
+ for (let i = 1; i < m.fieldUpgrades.length; i++) { //skip field emitter
+ if (i !== m.fieldMode) fieldOptions.push(i);
+ }
+ const pick = fieldOptions[Math.floor(Math.seededRandom(0, fieldOptions.length))] //pick an element from the array of options
+ // text += `
"
+ for (let j = 0; j < this.state.length; j++) {
+ // text += "
"
+ text += "
"
+ for (let i = 0; i < this.state[j].length; i++) {
+ if (this.state[j][i]) {
+ text += "■" //"☻" //"⬛" //"█" //"■"
+ } else {
+ text += " " //"□" //"☺" //"⬜" //" " //"□"
+ }
+ }
+ text += "
"
+ }
+ text += "
"
+ return text
+ },
+ },
+ {
+ name: "rule 90",
+ maxCount: 1,
+ count: 0,
+ frequency: 0,
+ isJunk: true,
+ allowed() {
+ return !build.isExperimentSelection
+ },
+ requires: "NOT EXPERIMENT MODE",
+ effect() { },
+ remove() { },
+ state: [
+ [false, false, false, Math.random() > 0.8, false, false, false, Math.random() > 0.8, false, false, false, false, false, false, false, false, false, true, true, false, false, false, Math.random() > 0.8, false, false, false, Math.random() > 0.8, false, false, false, false, Math.random() > 0.8, false, Math.random() > 0.8, false, false, false, Math.random() > 0.8, false, false, false, false, false, false, false, false]
+ ],
+ rule(state, a, b, c) { //90
+ if (state[a] && state[b] && state[c]) return false; // TTT => F
+ if (state[a] && state[b] && !state[c]) return true; // TTF => T
+ if (state[a] && !state[b] && state[c]) return false; //TFT => F
+ if (state[a] && !state[b] && !state[c]) return true; //TFF => T
+ if (!state[a] && state[b] && state[c]) return true; //FTT => T
+ if (!state[a] && state[b] && !state[c]) return false; //FTF => F
+ if (!state[a] && !state[b] && state[c]) return true; //FFT => T
+ if (!state[a] && !state[b] && !state[c]) return false; //FFF => F
+ },
+ id: 90,
+ researchSpawned: 0,
+ descriptionFunction() {
+ const loop = () => {
+ if ((simulation.paused || simulation.isChoosing) && m.alive && !build.isExperimentSelection) { //&& (!simulation.isChoosing || this.count === 0)
+ let b = []; //produce next row
+ b.push(this.rule(this.state[this.state.length - 1], this.state[this.state.length - 1].length - 1, 0, 1)); //left edge wrap around
+ for (let i = 1; i < this.state[this.state.length - 1].length - 1; i++) { //apply rule to the rest of the array
+ b.push(this.rule(this.state[this.state.length - 1], i - 1, i, i + 1));
+ }
+ b.push(this.rule(this.state[this.state.length - 1], this.state[this.state.length - 1].length - 2, this.state[this.state.length - 1].length - 1, 0)); //right edge wrap around
+ this.state.push(b)
+ if (document.getElementById(`cellular-rule-id${this.id}`)) document.getElementById(`cellular-rule-id${this.id}`).innerHTML = this.outputText() //convert to squares and send HTML
+ if (this.count && this.researchSpawned < 12 && !(this.state.length % 10)) {
+ this.researchSpawned++
+ powerUps.spawn(m.pos.x - 50 + 100 * (Math.random() - 0.5), m.pos.y + 100 * (Math.random() - 0.5), "research");
+ }
+ setTimeout(() => {
+ loop()
+ }, 300 + 5 * this.state.length);
+ }
+ }
+ setTimeout(() => {
+ loop()
+ }, 300);
+ this.id++
+ return `${this.outputText()}`
+ },
+ outputText() {
+ let text = "
"
+ for (let j = 0; j < this.state.length; j++) {
+ // text += "
"
+ text += "
"
+ for (let i = 0; i < this.state[j].length; i++) {
+ if (this.state[j][i]) {
+ text += "■" //"☻" //"⬛" //"█" //"■"
+ } else {
+ text += " " //"□" //"☺" //"⬜" //" " //"□"
+ }
+ }
+ text += "
"
+ }
+ text += "
"
+ return text
+ },
+ },
+ {
+ name: "wikipedia",
+ description: `After you get ${powerUps.orb.tech()} you have 7 seconds to study for a quiz. If you ace the quiz you get ${powerUps.orb.research(4)}`,
+ maxCount: 1,
+ count: 0,
+ frequency: 0,
+ isJunk: true,
+ allowed() {
+ return true
+ },
+ requires: "",
+ effect() {
+ tech.isWiki = true;
+ },
+ remove() {
+ tech.isWiki = false;
+ }
+ },
+ {
+ name: "cosmogonic myth",
+ description: `open a portal to a primordial version of reality in 5 minutes close the portal, spawn 1 of each power up`,
+ maxCount: 1,
+ count: 0,
+ frequency: 0,
+ isInstant: true,
+ isJunk: true,
+ allowed() {
+ return true
+ },
+ requires: "",
+ effect() {
+ const urls = ["https://scratch.mit.edu/projects/14005697/fullscreen/", "https://scratch.mit.edu/projects/22573757/fullscreen/", "https://scratch.mit.edu/projects/41429974/fullscreen/", "https://scratch.mit.edu/projects/43690666/fullscreen/", "https://codepen.io/lilgreenland/full/ozXNWZ", "https://codepen.io/lilgreenland/full/wzARJY", "classic/7-1-2017/", "classic/4-15-2018/", "classic/7-11-2019/", "classic/9-8-2019/", "classic/7-15-2020/", "classic/6-1-2021/"]
+ const choose = urls[Math.floor(Math.random() * urls.length)]
+ console.log(`opening new tab" ${choose}`)
+ let tab = window.open(choose, "_blank");
+ setTimeout(() => {
+ tab.close();
+ powerUps.spawn(m.pos.x, m.pos.y, "gun");
+ setTimeout(() => {
+ powerUps.spawn(m.pos.x, m.pos.y - 50, "ammo")
+ }, 250);
+ setTimeout(() => {
+ powerUps.spawn(m.pos.x + 50, m.pos.y, "field");
+ }, 500);
+ setTimeout(() => {
+ powerUps.spawn(m.pos.x + 50, m.pos.y - 50, "heal");
+ }, 750);
+ setTimeout(() => {
+ powerUps.spawn(m.pos.x - 50, m.pos.y, "tech");
+ }, 1000);
+ setTimeout(() => {
+ powerUps.spawn(m.pos.x - 50, m.pos.y - 50, "research");
+ }, 1250);
+ }, 1000 * 5 * 60);
+ },
+ remove() { }
+ },
+ {
+ name: "beforeunload",
+ description: "75% of the time when you attempt to exit n-gon you are prompted to cancel or continue. Each time you cancel gain 1.25xdamage.",
+ maxCount: 1,
+ count: 0,
+ frequency: 1,
+ isJunk: true,
+ allowed() {
+ return tech.totalCount > 9
+ },
+ requires: "at least 10 tech",
+ effect() {
+ tech.isExitPrompt = true
+ addEventListener('beforeunload', beforeUnloadEventListener);
+ },
+ remove() {
+ tech.isExitPrompt = false
+ if (this.count > 0) removeEventListener('beforeunload', beforeUnloadEventListener);
+ }
+ },
+ {
+ name: "planetesimals",
+ description: `play planetesimals(an asteroids-like game) clear levels in planetesimals to spawn ${powerUps.orb.tech()} if you die in planetesimals you die in n-gon`,
+ maxCount: 1,
+ count: 0,
+ frequency: 0,
+ isInstant: true,
+ isJunk: true,
+ allowed() {
+ return true
+ },
+ requires: "",
+ effect() {
+ window.open('../../planetesimals/index.html', '_blank')
+ // powerUps.spawn(m.pos.x, m.pos.y, "tech");
+
+ // for communicating to other tabs, like planetesimals
+ // Connection to a broadcast channel
+ const bc = new BroadcastChannel('planetesimals');
+ bc.activated = false
+
+ bc.onmessage = function (ev) {
+ if (ev.data === 'tech') powerUps.spawn(m.pos.x, m.pos.y, "tech");
+ if (ev.data === 'death') {
+ m.death()
+ bc.close(); //end session
+ }
+ if (ev.data === 'ready' && !bc.activated) {
+ bc.activated = true //prevents n-gon from activating multiple copies of planetesimals
+ bc.postMessage("activate");
+ }
+ }
+ },
+ remove() { }
+ },
+ {
+ name: "tinker",
+ description: `permanently unlock JUNK${powerUps.orb.tech()} in experiment mode this effect is stored for future visits`,
+ maxCount: 1,
+ count: 0,
+ frequency: 0,
+ frequencyDefault: 0,
+ isJunk: true,
+ isInstant: true,
+ allowed() {
+ return !localSettings.isJunkExperiment
+ },
+ requires: "",
+ effect() {
+ localSettings.isJunkExperiment = true
+ if (localSettings.isAllowed) localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
+ },
+ remove() { }
+ },
+ {
+ name: "NFT",
+ descriptionFunction() {
+ return `buy your current game seed: ${Math.initialSeed} no one is allowed to use your seeds if they use them they are gonna get in trouble your seeds: ${localSettings.personalSeeds.join(", ")}`
+ },
+ maxCount: 1,
+ count: 0,
+ frequency: 0,
+ isJunk: true,
+ isInstant: true,
+ allowed: () => true,
+ requires: "",
+ effect() {
+ localSettings.personalSeeds.push(Math.initialSeed)
+ if (localSettings.isAllowed) localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
+ },
+ remove() { }
+ },
+ // {
+ // name: "rule 90",
+ // maxCount: 1,
+ // count: 0,
+ // frequency: 0,
+ // isJunk: true,
+ // allowed() {
+ // return true
+ // },
+ // requires: "",
+ // effect() {},
+ // remove() {},
+ // state: [
+ // [false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false]
+ // ],
+ // rule(state, a, b, c) {
+ // if (state[a] && state[b] && state[c]) return false; // TTT => F
+ // if (state[a] && state[b] && !state[c]) return true; // TTF => T
+ // if (state[a] && !state[b] && state[c]) return false; //TFT => F
+ // if (state[a] && !state[b] && !state[c]) return true; //TFF => T
+ // if (!state[a] && state[b] && state[c]) return true; //FTT => T
+ // if (!state[a] && state[b] && !state[c]) return false; //FTF => F
+ // if (!state[a] && !state[b] && state[c]) return true; //FFT => T
+ // if (!state[a] && !state[b] && !state[c]) return false; //FFF => F
+ // },
+ // id: 0,
+ // descriptionFunction() {
+ // const loop = () => {
+ // if ((simulation.paused || simulation.isChoosing) && m.alive && !build.isExperimentSelection) { //&& (!simulation.isChoosing || this.count === 0)
+ // let b = []; //produce next row
+ // b.push(this.rule(this.state[this.state.length - 1], this.state[this.state.length - 1].length - 1, 0, 1)); //left edge wrap around
+ // for (let i = 1; i < this.state[this.state.length - 1].length - 1; i++) { //apply rule to the rest of the array
+ // b.push(this.rule(this.state[this.state.length - 1], i - 1, i, i + 1));
+ // }
+ // b.push(this.rule(this.state[this.state.length - 1], this.state[this.state.length - 1].length - 2, this.state[this.state.length - 1].length - 1, 0)); //right edge wrap around
+ // this.state.push(b)
+ // if (document.getElementById(`cellular-rule-id${this.id}`)) document.getElementById(`cellular-rule-id${this.id}`).innerHTML = this.outputText() //convert to squares and send HTML
+ // if (this.count && this.state.length < 120 && !(this.state.length % 10)) powerUps.spawn(m.pos.x - 50 + 100 * (Math.random() - 0.5), m.pos.y + 100 * (Math.random() - 0.5), "research");
+ // setTimeout(() => { loop() }, 400);
+ // }
+ // }
+ // setTimeout(() => { loop() }, 400);
+ // // if (this.id === 0) {
+ // // for (let i = 0; i < 29; i++) this.state[0][i] = Math.random() < 0.5 //randomize seed
+ // // }
+ // this.id++
+ // return `${this.outputText()}`
+ // },
+ // outputText() {
+ // let text = ""
+ // for (let j = 0; j < this.state.length; j++) {
+ // text += "
"
+ // for (let i = 0; i < this.state[j].length; i++) {
+ // if (this.state[j][i]) {
+ // text += "⬛" //"█" //"■"
+ // } else {
+ // text += "⬜" //" " //"□"
+ // }
+ // }
+ // text += "
"
+ // }
+ // return text
+ // },
+ // },
+
+ //**************************************************
+ //************************************************** undefined / lore
+ //************************************************** tech
+ //**************************************************
+ {
+ name: `undefined`,
+ description: `this `,
+ maxCount: 1,
+ count: 0,
+ frequency: 2,
+ frequencyDefault: 2,
+ isLore: true,
+ // isExperimentHide: true,
+ allowed() { return !build.isExperimentSelection },
+ requires: "NOT EXPERIMENT MODE",
+ effect() {
+ if (localSettings.loreCount > lore.conversation.length - 1) { //reward for people done with lore chapters (or on the final chapter)
+ for (let i = mob.length - 1; i > -1; i--) { //replace mobs with starters
+ if (!mob[i].isBoss && mob[i].isDropPowerUp && mob[i].alive) {
+ spawn.starter(mob[i].position.x, mob[i].position.y)
+ mob[i].leaveBody = false
+ mob[i].isDropPowerUp = false
+ mob[i].death()
+
+ //spawn a random power up
+ // if (Math.random() < 1 / 5) {
+ // powerUps.spawn(mob[i].position.x, mob[i].position.y, "research")
+ // } else
+ if (Math.random() < 1 / 4) {
+ powerUps.spawn(mob[i].position.x, mob[i].position.y, "ammo")
+ } else if (Math.random() < 1 / 3) {
+ powerUps.spawn(mob[i].position.x, mob[i].position.y, "heal")
+ } else if (Math.random() < 1 / 2) {
+ powerUps.spawn(mob[i].position.x, mob[i].position.y, "boost")
+ } else {
+ powerUps.spawn(mob[i].position.x, mob[i].position.y, "coupling")
+ }
+ }
+ }
+ }
+
+ setTimeout(() => { //a short delay, I can't remember why
+ lore.techCount++
+ if (lore.techCount === lore.techGoal) {
+ // tech.removeLoreTechFromPool();
+ this.frequency = 0;
+ this.description = `null is open at level.final() `
+ } else {
+ this.frequency += lore.techGoal * 2
+ this.description = `uncaught error: ${Math.max(0, lore.techGoal - lore.techCount)} more required for access to null`
+ }
+ }, 1);
+ },
+ remove() {
+ lore.techCount = 0;
+ this.maxCount = lore.techGoal;
+ this.description = `this `
+ }
+ }
+ ],
+ //variables use for gun tech upgrades
+ fireRate: 1, //initializes to 1
+ bulletSize: null,
+ energySiphon: null,
+ healSpawn: null,
+ crouchAmmoCount: null,
+ bulletsLastLonger: null,
+ isImmortal: null,
+ sporesOnDeath: null,
+ isImmuneExplosion: null,
+ isExplodeMob: null,
+ isDroneOnDamage: null,
+ isAcidDmg: null,
+ isAnnihilation: null,
+ largerHeals: null,
+ isCrit: null,
+ isLowHealthDmg: null,
+ isLowHealthDefense: null,
+ isLowHealthFireRate: null,
+ isFarAwayDmg: null,
+ isFirstDer: null,
+ isMassEnergy: null,
+ extraChoices: null,
+ laserBotCount: null,
+ dynamoBotCount: null,
+ nailBotCount: null,
+ foamBotCount: null,
+ soundBotCount: null,
+ boomBotCount: null,
+ plasmaBotCount: null,
+ missileBotCount: null,
+ orbitBotCount: null,
+ blockDmg: null,
+ isBlockRadiation: null,
+ isPiezo: null,
+ isFastDrones: null,
+ oneSuperBall: null,
+ laserReflections: null,
+ laserDamage: null,
+ isAmmoFromHealth: null,
+ mobSpawnWithHealth: null,
+ isEnergyRecovery: null,
+ isHealthRecovery: null,
+ isEnergyLoss: null,
+ isDeathAvoid: null,
+ isDeathAvoidedThisLevel: null,
+ isPlasmaRange: null,
+ isFreezeMobs: null,
+ isIceCrystals: null,
+ blockDamage: null,
+ isBlockStun: null,
+ isStunField: null,
+ isHarmDamage: null,
+ isVacuumBomb: null,
+ renormalization: null,
+ fragments: null,
+ energyDamage: null,
+ botSpawner: null,
+ isBotSpawnerReset: null,
+ isSporeFollow: null,
+ isNailRadiation: null,
+ isEnergyHealth: null,
+ isStun: null,
+ restDamage: null,
+ isRPG: null,
+ missileCount: null,
+ isDeterminism: null,
+ isSuperDeterminism: null,
+ isHarmReduce: null,
+ nailsDeathMob: null,
+ isSlowFPS: null,
+ isNeutronStun: null,
+ isAnsatz: null,
+ isDamageFromBulletCount: null,
+ laserDrain: null,
+ isNailShot: null,
+ slowFire: null,
+ fastTime: null,
+ isFastRadiation: null,
+ isAmmoForGun: null,
+ isRapidPulse: null,
+ isSporeFreeze: null,
+ isShotgunRecoil: null,
+ isHealLowHealth: null,
+ isAoESlow: null,
+ isHarmArmor: null,
+ isTurret: null,
+ isRerollDamage: null,
+ isHarmFreeze: null,
+ isBotArmor: null,
+ isRerollHaste: null,
+ researchHaste: null,
+ isMineDrop: null,
+ isRerollBots: null,
+ isNailBotUpgrade: null,
+ isFoamBotUpgrade: null,
+ isSoundBotUpgrade: null,
+ isLaserBotUpgrade: null,
+ isBoomBotUpgrade: null,
+ isOrbitBotUpgrade: null,
+ isDroneGrab: null,
+ isOneGun: null,
+ isDamageForGuns: null,
+ isGunCycle: null,
+ isFastFoam: null,
+ isSporeGrowth: null,
+ isStimulatedEmission: null,
+ // nailGun: null,
+ nailInstantFireRate: null,
+ isCapacitor: null,
+ isEnergyNoAmmo: null,
+ // isFreezeHarmImmune: null,
+ isSmallExplosion: null,
+ isExplosionHarm: null,
+ extraMaxHealth: null,
+ // bonusHealth: null,
+ isIntangible: null,
+ isCloakStun: null,
+ bonusEnergy: null,
+ // healGiveMaxEnergy: null,
+ healMaxEnergyBonus: 0, //not null
+ aimDamage: null,
+ isNoFireDefense: null,
+ isNoFireDamage: null,
+ duplicateChance: null,
+ beamSplitter: null,
+ iceEnergy: null,
+ isPerfectBrake: null,
+ explosiveRadius: null,
+ // isWormholeEnergy: null,
+ isWormholeDamage: null,
+ isNailCrit: null,
+ isFlechetteExplode: null,
+ isWormholeWorms: null,
+ isWormHoleBullets: null,
+ isWideLaser: null,
+ wideLaser: null,
+ isPulseLaser: null,
+ isRadioactive: null,
+ radioactiveDamage: null,
+ isRailEnergy: null,
+ isMineSentry: null,
+ isIncendiary: null,
+ overfillDrain: null,
+ isNeutronSlow: null,
+ // isRailAreaDamage: null,
+ historyLaser: null,
+ isSpeedHarm: null,
+ isSpeedDamage: null,
+ speedAdded: null,
+ isTimeSkip: null,
+ isCancelDuplication: null,
+ duplication: null,
+ isCancelRerolls: null,
+ isCancelTech: null,
+ cancelTechCount: null,
+ isBotDamage: null,
+ isBanish: null,
+ isRetain: null,
+ isMaxEnergyTech: null,
+ isLowEnergyDamage: null,
+ isRewindBot: null,
+ isRewindGrenade: null,
+ isExtruder: null,
+ isEndLevelPowerUp: null,
+ isMissileBig: null,
+ isMissileBiggest: null,
+ isLaserMine: null,
+ isFoamMine: null,
+ isAmmoFoamSize: null,
+ isIceIX: null,
+ isDupDamage: null,
+ isDupEnergy: null,
+ isFireRateForGuns: null,
+ cyclicImmunity: null,
+ isTechDamage: null,
+ isRestHarm: null,
+ isFireMoveLock: null,
+ isRivets: null,
+ isNeedles: null,
+ isExplodeRadio: null,
+ isPauseSwitchField: null,
+ isPauseEjectTech: null,
+ pauseEjectTech: null,
+ isShieldPierce: null,
+ isDuplicateMobs: null,
+ isDynamoBotUpgrade: null,
+ isBlockPowerUps: null,
+ isDamageAfterKillNoRegen: null,
+ isHarmReduceNoKill: null,
+ isSwitchReality: null,
+ isResearchReality: null,
+ isAnthropicDamage: null,
+ isMetaAnalysis: null,
+ isFoamAttract: null,
+ droneCycleReduction: null,
+ droneEnergyReduction: null,
+ isHalfHeals: null,
+ isAlwaysFire: null,
+ isDroneRespawn: null,
+ deathSpawns: null,
+ isMobBlockFling: null,
+ isPhaseVelocity: null,
+ waveBeamSpeed: null,
+ wavePacketAmplitude: null,
+ isCollisionRealitySwitch: null,
+ iceIXOnDeath: null,
+ wimpCount: null,
+ isAddBlockMass: null,
+ isDarkMatter: null,
+ isHarmDarkMatter: null,
+ isMoveDarkMatter: null,
+ isNotDarkMatter: null,
+ isSneakAttack: null,
+ isFallingDamage: null,
+ harmonics: null,
+ isStandingWaveExpand: null,
+ isTokamak: null,
+ isTokamakHeal: null,
+ tokamakHealCount: null,
+ isTokamakFly: null,
+ deflectEnergy: null,
+ superBallDelay: null,
+ isBlockExplode: null,
+ isOverHeal: null,
+ isDroneRadioactive: null,
+ droneRadioDamage: null,
+ isDroneTeleport: null,
+ isDroneFastLook: null,
+ isBulletTeleport: null,
+ isJunkResearch: null,
+ laserColor: null,
+ laserColorAlpha: null,
+ isLongitudinal: null,
+ is360Longitudinal: null,
+ isShotgunReversed: null,
+ fieldDuplicate: null,
+ isCloakingDamage: null,
+ harmonicEnergy: null,
+ isFieldHarmReduction: null,
+ isFastTime: null,
+ isAnthropicTech: null,
+ isSporeWorm: null,
+ isSporeFlea: null,
+ isFoamShot: null,
+ isIceShot: null,
+ isBlockRestitution: null,
+ isZeno: null,
+ isFieldFree: null,
+ isExtraGunField: null,
+ isBigField: null,
+ isSmartRadius: null,
+ isFilament: null,
+ isLargeHarpoon: null,
+ extraHarpoons: null,
+ ammoCap: null,
+ isHarpoonPowerUp: null,
+ harpoonDensity: null,
+ isAddRemoveMaxHealth: null,
+ cloakDuplication: null,
+ extruderRange: null,
+ isForeverDrones: null,
+ nailRecoil: null,
+ baseJumpForce: null,
+ baseFx: null,
+ isNeutronium: null,
+ isFreeWormHole: null,
+ isRewindField: null,
+ isCrouchRegen: null,
+ isAxion: null,
+ isDarkEnergy: null,
+ isDarkStar: null,
+ isWormholeMapIgnore: null,
+ isLessDamageReduction: null,
+ needleTunnel: null,
+ isBrainstorm: null,
+ isBrainstormActive: null,
+ brainStormDelay: null,
+ wormSize: null,
+ extraSuperBalls: null,
+ isTimeCrystals: null,
+ isGroundState: null,
+ isRailGun: null,
+ isDronesTravel: null,
+ isTechDebt: null,
+ isPlasmaBall: null,
+ plasmaDischarge: null,
+ missileFireCD: null,
+ isBotField: null,
+ isFoamBall: null,
+ isNoDraftPause: null,
+ isFoamPressure: null,
+ foamDamage: null,
+ isClusterExplode: null,
+ isCircleExplode: null,
+ isPetalsExplode: null,
+ isVerlet: null,
+ isIceMaxHealthLoss: null,
+ isIceKill: null,
+ isCritKill: null,
+ isQuantumEraser: null,
+ isPhononBlock: null,
+ isPhononWave: null,
+ isLaserLens: null,
+ laserCrit: null,
+ isSporeColony: null,
+ isExtraBotOption: null,
+ isLastHitDamage: null,
+ isCloakHealLastHit: null,
+ isRicochet: null,
+ isCancelCouple: null,
+ isCouplingPowerUps: null,
+ isBoostPowerUps: null,
+ isBoostReplaceAmmo: null,
+ isInfiniteWaveAmmo: null,
+ isJunkDNA: null,
+ buffedGun: 0,
+ isGunChoice: null,
+ railChargeRate: null,
+ isSuperHarm: null,
+ isZombieMobs: null,
+ isSuperMine: null,
+ sentryAmmo: null,
+ collidePowerUps: null,
+ isDilate: null,
+ isDiaphragm: null,
+ isNoGroundDamage: null,
+ isSuperBounce: null,
+ isDivisor: null,
+ isFoamCavitation: null,
+ isHealAttract: null,
+ isLaserField: null,
+ isHealBrake: null,
+ isMassProduction: null,
+ isPrinter: null,
+ isHookDefense: null,
+ hookNails: null,
+ isHarpoonDefense: null,
+ isReel: null,
+ harpoonPowerUpCycle: null,
+ isHarpoonFullHealth: null,
+ isMobFullHealthCloak: null,
+ isMobLowHealth: null,
+ isDamageCooldown: null,
+ isDamageCooldownTime: null,
+ isPowerUpDamage: null,
+ isExitPrompt: null,
+ isResearchDamage: null,
+ interestRate: null,
+ isImmunityDamage: null,
+ isMobDeathImmunity: null,
+ isMaxHealthDefense: null,
+ noDefenseSettingDamage: null,
+ isMaxHealthDamage: null,
+ isEjectOld: null,
+ isWiki: null,
+ isStaticBlock: null,
+ isDamageFieldTech: null,
+}
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/n-gon-master/lib/matter.min.js b/WebGames-master/WebGames-master/n-gon-master/lib/matter.min.js
new file mode 100644
index 00000000..d93e50fe
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/lib/matter.min.js
@@ -0,0 +1,714 @@
+/*!
+ * matter-js 0.18.0-alpha+0eeceb5 by @liabru
+ * Experimental pre-release build.
+ * http://brm.io/matter-js/
+ * License MIT
+ */
+! function(e, t) { "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define("Matter", [], t) : "object" == typeof exports ? exports.Matter = t() : e.Matter = t() }(this, (function() { return function(e) { var t = {};
+
+ function n(i) { if (t[i]) return t[i].exports; var o = t[i] = { i: i, l: !1, exports: {} }; return e[i].call(o.exports, o, o.exports, n), o.l = !0, o.exports } return n.m = e, n.c = t, n.d = function(e, t, i) { n.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: i }) }, n.r = function(e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, n.t = function(e, t) { if (1 & t && (e = n(e)), 8 & t) return e; if (4 & t && "object" == typeof e && e && e.__esModule) return e; var i = Object.create(null); if (n.r(i), Object.defineProperty(i, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e)
+ for (var o in e) n.d(i, o, function(t) { return e[t] }.bind(null, o)); return i }, n.n = function(e) { var t = e && e.__esModule ? function() { return e.default } : function() { return e }; return n.d(t, "a", t), t }, n.o = function(e, t) { return Object.prototype.hasOwnProperty.call(e, t) }, n.p = "", n(n.s = 21) }([function(e, t) { var n = {};
+ e.exports = n,
+ function() { n._nextId = 0, n._seed = 0, n._nowStartTime = +new Date, n._warnedOnce = {}, n._decomp = null, n.extend = function(e, t) { var i, o; "boolean" == typeof t ? (i = 2, o = t) : (i = 1, o = !0); for (var r = i; r < arguments.length; r++) { var a = arguments[r]; if (a)
+ for (var s in a) o && a[s] && a[s].constructor === Object ? e[s] && e[s].constructor !== Object ? e[s] = a[s] : (e[s] = e[s] || {}, n.extend(e[s], o, a[s])) : e[s] = a[s] } return e }, n.clone = function(e, t) { return n.extend({}, t, e) }, n.keys = function(e) { if (Object.keys) return Object.keys(e); var t = []; for (var n in e) t.push(n); return t }, n.values = function(e) { var t = []; if (Object.keys) { for (var n = Object.keys(e), i = 0; i < n.length; i++) t.push(e[n[i]]); return t } for (var o in e) t.push(e[o]); return t }, n.get = function(e, t, n, i) { t = t.split(".").slice(n, i); for (var o = 0; o < t.length; o += 1) e = e[t[o]]; return e }, n.set = function(e, t, i, o, r) { var a = t.split(".").slice(o, r); return n.get(e, t, 0, -1)[a[a.length - 1]] = i, i }, n.shuffle = function(e) { for (var t = e.length - 1; t > 0; t--) { var i = Math.floor(n.random() * (t + 1)),
+ o = e[t];
+ e[t] = e[i], e[i] = o } return e }, n.choose = function(e) { return e[Math.floor(n.random() * e.length)] }, n.isElement = function(e) { return "undefined" != typeof HTMLElement ? e instanceof HTMLElement : !!(e && e.nodeType && e.nodeName) }, n.isArray = function(e) { return "[object Array]" === Object.prototype.toString.call(e) }, n.isFunction = function(e) { return "function" == typeof e }, n.isPlainObject = function(e) { return "object" == typeof e && e.constructor === Object }, n.isString = function(e) { return "[object String]" === toString.call(e) }, n.clamp = function(e, t, n) { return e < t ? t : e > n ? n : e }, n.sign = function(e) { return e < 0 ? -1 : 1 }, n.now = function() { if ("undefined" != typeof window && window.performance) { if (window.performance.now) return window.performance.now(); if (window.performance.webkitNow) return window.performance.webkitNow() } return Date.now ? Date.now() : new Date - n._nowStartTime }, n.random = function(t, n) { return n = void 0 !== n ? n : 1, (t = void 0 !== t ? t : 0) + e() * (n - t) }; var e = function() { return n._seed = (9301 * n._seed + 49297) % 233280, n._seed / 233280 };
+ n.colorToNumber = function(e) { return 3 == (e = e.replace("#", "")).length && (e = e.charAt(0) + e.charAt(0) + e.charAt(1) + e.charAt(1) + e.charAt(2) + e.charAt(2)), parseInt(e, 16) }, n.logLevel = 1, n.log = function() { console && n.logLevel > 0 && n.logLevel <= 3 && console.log.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments))) }, n.info = function() { console && n.logLevel > 0 && n.logLevel <= 2 && console.info.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments))) }, n.warn = function() { console && n.logLevel > 0 && n.logLevel <= 3 && console.warn.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments))) }, n.warnOnce = function() { var e = Array.prototype.slice.call(arguments).join(" ");
+ n._warnedOnce[e] || (n.warn(e), n._warnedOnce[e] = !0) }, n.deprecated = function(e, t, i) { e[t] = n.chain((function() { n.warnOnce("🔅 deprecated 🔅", i) }), e[t]) }, n.nextId = function() { return n._nextId++ }, n.indexOf = function(e, t) { if (e.indexOf) return e.indexOf(t); for (var n = 0; n < e.length; n++)
+ if (e[n] === t) return n; return -1 }, n.map = function(e, t) { if (e.map) return e.map(t); for (var n = [], i = 0; i < e.length; i += 1) n.push(t(e[i])); return n }, n.topologicalSort = function(e) { var t = [],
+ i = [],
+ o = []; for (var r in e) i[r] || o[r] || n._topologicalSort(r, i, o, e, t); return t }, n._topologicalSort = function(e, t, i, o, r) { var a = o[e] || [];
+ i[e] = !0; for (var s = 0; s < a.length; s += 1) { var l = a[s];
+ i[l] || (t[l] || n._topologicalSort(l, t, i, o, r)) } i[e] = !1, t[e] = !0, r.push(e) }, n.chain = function() { for (var e = [], t = 0; t < arguments.length; t += 1) { var n = arguments[t];
+ n._chained ? e.push.apply(e, n._chained) : e.push(n) } var i = function() { for (var t, n = new Array(arguments.length), i = 0, o = arguments.length; i < o; i++) n[i] = arguments[i]; for (i = 0; i < e.length; i += 1) { var r = e[i].apply(t, n);
+ void 0 !== r && (t = r) } return t }; return i._chained = e, i }, n.chainPathBefore = function(e, t, i) { return n.set(e, t, n.chain(i, n.get(e, t))) }, n.chainPathAfter = function(e, t, i) { return n.set(e, t, n.chain(n.get(e, t), i)) }, n.setDecomp = function(e) { n._decomp = e }, n.getDecomp = function() { var e = n._decomp; try { e || "undefined" == typeof window || (e = window.decomp), e || "undefined" == typeof global || (e = global.decomp) } catch (t) { e = null } return e } }() }, function(e, t) { var n = {};
+ e.exports = n, n.create = function(e) { var t = { min: { x: 0, y: 0 }, max: { x: 0, y: 0 } }; return e && n.update(t, e), t }, n.update = function(e, t, n) { e.min.x = 1 / 0, e.max.x = -1 / 0, e.min.y = 1 / 0, e.max.y = -1 / 0; for (var i = 0; i < t.length; i++) { var o = t[i];
+ o.x > e.max.x && (e.max.x = o.x), o.x < e.min.x && (e.min.x = o.x), o.y > e.max.y && (e.max.y = o.y), o.y < e.min.y && (e.min.y = o.y) } n && (n.x > 0 ? e.max.x += n.x : e.min.x += n.x, n.y > 0 ? e.max.y += n.y : e.min.y += n.y) }, n.contains = function(e, t) { return t.x >= e.min.x && t.x <= e.max.x && t.y >= e.min.y && t.y <= e.max.y }, n.overlaps = function(e, t) { return e.min.x <= t.max.x && e.max.x >= t.min.x && e.max.y >= t.min.y && e.min.y <= t.max.y }, n.translate = function(e, t) { e.min.x += t.x, e.max.x += t.x, e.min.y += t.y, e.max.y += t.y }, n.shift = function(e, t) { var n = e.max.x - e.min.x,
+ i = e.max.y - e.min.y;
+ e.min.x = t.x, e.max.x = t.x + n, e.min.y = t.y, e.max.y = t.y + i } }, function(e, t) { var n = {};
+ e.exports = n, n.create = function(e, t) { return { x: e || 0, y: t || 0 } }, n.clone = function(e) { return { x: e.x, y: e.y } }, n.magnitude = function(e) { return Math.sqrt(e.x * e.x + e.y * e.y) }, n.magnitudeSquared = function(e) { return e.x * e.x + e.y * e.y }, n.rotate = function(e, t, n) { var i = Math.cos(t),
+ o = Math.sin(t);
+ n || (n = {}); var r = e.x * i - e.y * o; return n.y = e.x * o + e.y * i, n.x = r, n }, n.rotateAbout = function(e, t, n, i) { var o = Math.cos(t),
+ r = Math.sin(t);
+ i || (i = {}); var a = n.x + ((e.x - n.x) * o - (e.y - n.y) * r); return i.y = n.y + ((e.x - n.x) * r + (e.y - n.y) * o), i.x = a, i }, n.normalise = function(e) { var t = n.magnitude(e); return 0 === t ? { x: 0, y: 0 } : { x: e.x / t, y: e.y / t } }, n.dot = function(e, t) { return e.x * t.x + e.y * t.y }, n.cross = function(e, t) { return e.x * t.y - e.y * t.x }, n.cross3 = function(e, t, n) { return (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x) }, n.add = function(e, t, n) { return n || (n = {}), n.x = e.x + t.x, n.y = e.y + t.y, n }, n.sub = function(e, t, n) { return n || (n = {}), n.x = e.x - t.x, n.y = e.y - t.y, n }, n.mult = function(e, t) { return { x: e.x * t, y: e.y * t } }, n.div = function(e, t) { return { x: e.x / t, y: e.y / t } }, n.perp = function(e, t) { return { x: (t = !0 === t ? -1 : 1) * -e.y, y: t * e.x } }, n.neg = function(e) { return { x: -e.x, y: -e.y } }, n.angle = function(e, t) { return Math.atan2(t.y - e.y, t.x - e.x) }, n._temp = [n.create(), n.create(), n.create(), n.create(), n.create(), n.create()] }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(2),
+ r = n(0);
+ i.create = function(e, t) { for (var n = [], i = 0; i < e.length; i++) { var o = e[i],
+ r = { x: o.x, y: o.y, index: i, body: t, isInternal: !1 };
+ n.push(r) } return n }, i.fromPath = function(e, t) { var n = []; return e.replace(/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/gi, (function(e, t, i) { n.push({ x: parseFloat(t), y: parseFloat(i) }) })), i.create(n, t) }, i.centre = function(e) { for (var t, n, r, a = i.area(e, !0), s = { x: 0, y: 0 }, l = 0; l < e.length; l++) r = (l + 1) % e.length, t = o.cross(e[l], e[r]), n = o.mult(o.add(e[l], e[r]), t), s = o.add(s, n); return o.div(s, 6 * a) }, i.mean = function(e) { for (var t = { x: 0, y: 0 }, n = 0; n < e.length; n++) t.x += e[n].x, t.y += e[n].y; return o.div(t, e.length) }, i.area = function(e, t) { for (var n = 0, i = e.length - 1, o = 0; o < e.length; o++) n += (e[i].x - e[o].x) * (e[i].y + e[o].y), i = o; return t ? n / 2 : Math.abs(n) / 2 }, i.inertia = function(e, t) { for (var n, i, r = 0, a = 0, s = e, l = 0; l < s.length; l++) i = (l + 1) % s.length, r += (n = Math.abs(o.cross(s[i], s[l]))) * (o.dot(s[i], s[i]) + o.dot(s[i], s[l]) + o.dot(s[l], s[l])), a += n; return t / 6 * (r / a) }, i.translate = function(e, t, n) { n = void 0 !== n ? n : 1; var i, o = e.length,
+ r = t.x * n,
+ a = t.y * n; for (i = 0; i < o; i++) e[i].x += r, e[i].y += a; return e }, i.rotate = function(e, t, n) { if (0 !== t) { var i, o, r, a, s = Math.cos(t),
+ l = Math.sin(t),
+ c = n.x,
+ u = n.y,
+ d = e.length; for (a = 0; a < d; a++) o = (i = e[a]).x - c, r = i.y - u, i.x = c + (o * s - r * l), i.y = u + (o * l + r * s); return e } }, i.contains = function(e, t) { for (var n, i = t.x, o = t.y, r = e.length, a = e[r - 1], s = 0; s < r; s++) { if (n = e[s], (i - a.x) * (n.y - a.y) + (o - a.y) * (a.x - n.x) > 0) return !1;
+ a = n } return !0 }, i.scale = function(e, t, n, r) { if (1 === t && 1 === n) return e; var a, s;
+ r = r || i.centre(e); for (var l = 0; l < e.length; l++) a = e[l], s = o.sub(a, r), e[l].x = r.x + s.x * t, e[l].y = r.y + s.y * n; return e }, i.chamfer = function(e, t, n, i, a) { t = "number" == typeof t ? [t] : t || [8], n = void 0 !== n ? n : -1, i = i || 2, a = a || 14; for (var s = [], l = 0; l < e.length; l++) { var c = e[l - 1 >= 0 ? l - 1 : e.length - 1],
+ u = e[l],
+ d = e[(l + 1) % e.length],
+ p = t[l < t.length ? l : t.length - 1]; if (0 !== p) { var f = o.normalise({ x: u.y - c.y, y: c.x - u.x }),
+ v = o.normalise({ x: d.y - u.y, y: u.x - d.x }),
+ y = Math.sqrt(2 * Math.pow(p, 2)),
+ m = o.mult(r.clone(f), p),
+ g = o.normalise(o.mult(o.add(f, v), .5)),
+ x = o.sub(u, o.mult(g, y)),
+ h = n; - 1 === n && (h = 1.75 * Math.pow(p, .32)), (h = r.clamp(h, i, a)) % 2 == 1 && (h += 1); for (var b = Math.acos(o.dot(f, v)) / h, S = 0; S < h; S++) s.push(o.add(o.rotate(m, b * S), x)) } else s.push(u) } return s }, i.clockwiseSort = function(e) { var t = i.mean(e); return e.sort((function(e, n) { return o.angle(t, e) - o.angle(t, n) })), e }, i.isConvex = function(e) { var t, n, i, o, r = 0,
+ a = e.length; if (a < 3) return null; for (t = 0; t < a; t++)
+ if (i = (t + 2) % a, o = (e[n = (t + 1) % a].x - e[t].x) * (e[i].y - e[n].y), (o -= (e[n].y - e[t].y) * (e[i].x - e[n].x)) < 0 ? r |= 1 : o > 0 && (r |= 2), 3 === r) return !1; return 0 !== r || null }, i.hull = function(e) { var t, n, i = [],
+ r = []; for ((e = e.slice(0)).sort((function(e, t) { var n = e.x - t.x; return 0 !== n ? n : e.y - t.y })), n = 0; n < e.length; n += 1) { for (t = e[n]; r.length >= 2 && o.cross3(r[r.length - 2], r[r.length - 1], t) <= 0;) r.pop();
+ r.push(t) } for (n = e.length - 1; n >= 0; n -= 1) { for (t = e[n]; i.length >= 2 && o.cross3(i[i.length - 2], i[i.length - 1], t) <= 0;) i.pop();
+ i.push(t) } return i.pop(), r.pop(), i.concat(r) } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(0);
+ i.on = function(e, t, n) { for (var i, o = t.split(" "), r = 0; r < o.length; r++) i = o[r], e.events = e.events || {}, e.events[i] = e.events[i] || [], e.events[i].push(n); return n }, i.off = function(e, t, n) { if (t) { "function" == typeof t && (n = t, t = o.keys(e.events).join(" ")); for (var i = t.split(" "), r = 0; r < i.length; r++) { var a = e.events[i[r]],
+ s = []; if (n && a)
+ for (var l = 0; l < a.length; l++) a[l] !== n && s.push(a[l]);
+ e.events[i[r]] = s } } else e.events = {} }, i.trigger = function(e, t, n) { var i, r, a, s, l = e.events; if (l && o.keys(l).length > 0) { n || (n = {}), i = t.split(" "); for (var c = 0; c < i.length; c++)
+ if (a = l[r = i[c]]) {
+ (s = o.clone(n, !1)).name = r, s.source = e; for (var u = 0; u < a.length; u++) a[u].apply(e, [s]) } } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(4),
+ r = n(0),
+ a = n(1),
+ s = n(6);
+ i.create = function(e) { return r.extend({ id: r.nextId(), type: "composite", parent: null, isModified: !1, bodies: [], constraints: [], composites: [], label: "Composite", plugin: {}, cache: { allBodies: null, allConstraints: null, allComposites: null } }, e) }, i.setModified = function(e, t, n, o) { if (e.isModified = t, t && e.cache && (e.cache.allBodies = null, e.cache.allConstraints = null, e.cache.allComposites = null), n && e.parent && i.setModified(e.parent, t, n, o), o)
+ for (var r = 0; r < e.composites.length; r++) { var a = e.composites[r];
+ i.setModified(a, t, n, o) } }, i.add = function(e, t) { var n = [].concat(t);
+ o.trigger(e, "beforeAdd", { object: t }); for (var a = 0; a < n.length; a++) { var s = n[a]; switch (s.type) {
+ case "body":
+ if (s.parent !== s) { r.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)"); break } i.addBody(e, s); break;
+ case "constraint":
+ i.addConstraint(e, s); break;
+ case "composite":
+ i.addComposite(e, s); break;
+ case "mouseConstraint":
+ i.addConstraint(e, s.constraint) } } return o.trigger(e, "afterAdd", { object: t }), e }, i.remove = function(e, t, n) { var r = [].concat(t);
+ o.trigger(e, "beforeRemove", { object: t }); for (var a = 0; a < r.length; a++) { var s = r[a]; switch (s.type) {
+ case "body":
+ i.removeBody(e, s, n); break;
+ case "constraint":
+ i.removeConstraint(e, s, n); break;
+ case "composite":
+ i.removeComposite(e, s, n); break;
+ case "mouseConstraint":
+ i.removeConstraint(e, s.constraint) } } return o.trigger(e, "afterRemove", { object: t }), e }, i.addComposite = function(e, t) { return e.composites.push(t), t.parent = e, i.setModified(e, !0, !0, !1), e }, i.removeComposite = function(e, t, n) { var o = r.indexOf(e.composites, t); if (-1 !== o && i.removeCompositeAt(e, o), n)
+ for (var a = 0; a < e.composites.length; a++) i.removeComposite(e.composites[a], t, !0); return e }, i.removeCompositeAt = function(e, t) { return e.composites.splice(t, 1), i.setModified(e, !0, !0, !1), e }, i.addBody = function(e, t) { return e.bodies.push(t), i.setModified(e, !0, !0, !1), e }, i.removeBody = function(e, t, n) { var o = r.indexOf(e.bodies, t); if (-1 !== o && (i.removeBodyAt(e, o), t.isSleeping = !1, t.sleepCounter = 0), n)
+ for (var a = 0; a < e.composites.length; a++) i.removeBody(e.composites[a], t, !0); return e }, i.removeBodyAt = function(e, t) { return e.bodies.splice(t, 1), i.setModified(e, !0, !0, !1), e }, i.addConstraint = function(e, t) { return e.constraints.push(t), i.setModified(e, !0, !0, !1), e }, i.removeConstraint = function(e, t, n) { var o = r.indexOf(e.constraints, t); if (-1 !== o && i.removeConstraintAt(e, o), n)
+ for (var a = 0; a < e.composites.length; a++) i.removeConstraint(e.composites[a], t, !0); return e }, i.removeConstraintAt = function(e, t) { return e.constraints.splice(t, 1), i.setModified(e, !0, !0, !1), e }, i.clear = function(e, t, n) { if (n)
+ for (var o = 0; o < e.composites.length; o++) i.clear(e.composites[o], t, !0); return t ? e.bodies = e.bodies.filter((function(e) { return e.isStatic })) : e.bodies.length = 0, e.constraints.length = 0, e.composites.length = 0, i.setModified(e, !0, !0, !1), e }, i.allBodies = function(e) { if (e.cache && e.cache.allBodies) return e.cache.allBodies; for (var t = [].concat(e.bodies), n = 0; n < e.composites.length; n++) t = t.concat(i.allBodies(e.composites[n])); return e.cache && (e.cache.allBodies = t), t }, i.allConstraints = function(e) { if (e.cache && e.cache.allConstraints) return e.cache.allConstraints; for (var t = [].concat(e.constraints), n = 0; n < e.composites.length; n++) t = t.concat(i.allConstraints(e.composites[n])); return e.cache && (e.cache.allConstraints = t), t }, i.allComposites = function(e) { if (e.cache && e.cache.allComposites) return e.cache.allComposites; for (var t = [].concat(e.composites), n = 0; n < e.composites.length; n++) t = t.concat(i.allComposites(e.composites[n])); return e.cache && (e.cache.allComposites = t), t }, i.get = function(e, t, n) { var o, r; switch (n) {
+ case "body":
+ o = i.allBodies(e); break;
+ case "constraint":
+ o = i.allConstraints(e); break;
+ case "composite":
+ o = i.allComposites(e).concat(e) } return o ? 0 === (r = o.filter((function(e) { return e.id.toString() === t.toString() }))).length ? null : r[0] : null }, i.move = function(e, t, n) { return i.remove(e, t), i.add(n, t), e }, i.rebase = function(e) { for (var t = i.allBodies(e).concat(i.allConstraints(e)).concat(i.allComposites(e)), n = 0; n < t.length; n++) t[n].id = r.nextId(); return e }, i.translate = function(e, t, n) { for (var o = n ? i.allBodies(e) : e.bodies, r = 0; r < o.length; r++) s.translate(o[r], t); return e }, i.rotate = function(e, t, n, o) { for (var r = Math.cos(t), a = Math.sin(t), l = o ? i.allBodies(e) : e.bodies, c = 0; c < l.length; c++) { var u = l[c],
+ d = u.position.x - n.x,
+ p = u.position.y - n.y;
+ s.setPosition(u, { x: n.x + (d * r - p * a), y: n.y + (d * a + p * r) }), s.rotate(u, t) } return e }, i.scale = function(e, t, n, o, r) { for (var a = r ? i.allBodies(e) : e.bodies, l = 0; l < a.length; l++) { var c = a[l],
+ u = c.position.x - o.x,
+ d = c.position.y - o.y;
+ s.setPosition(c, { x: o.x + u * t, y: o.y + d * n }), s.scale(c, t, n) } return e }, i.bounds = function(e) { for (var t = i.allBodies(e), n = [], o = 0; o < t.length; o += 1) { var r = t[o];
+ n.push(r.bounds.min, r.bounds.max) } return a.create(n) } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(3),
+ r = n(2),
+ a = n(7),
+ s = (n(16), n(0)),
+ l = n(1),
+ c = n(11);! function() { i._inertiaScale = 4, i._nextCollidingGroupId = 1, i._nextNonCollidingGroupId = -1, i._nextCategory = 1, i.create = function(t) { var n = { id: s.nextId(), type: "body", label: "Body", parts: [], plugin: {}, angle: 0, vertices: o.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"), position: { x: 0, y: 0 }, force: { x: 0, y: 0 }, torque: 0, positionImpulse: { x: 0, y: 0 }, constraintImpulse: { x: 0, y: 0, angle: 0 }, totalContacts: 0, speed: 0, angularSpeed: 0, velocity: { x: 0, y: 0 }, angularVelocity: 0, isSensor: !1, isStatic: !1, isSleeping: !1, motion: 0, sleepThreshold: 60, density: .001, restitution: 0, friction: .1, frictionStatic: .5, frictionAir: .01, collisionFilter: { category: 1, mask: 4294967295, group: 0 }, slop: .05, timeScale: 1, render: { visible: !0, opacity: 1, strokeStyle: null, fillStyle: null, lineWidth: null, sprite: { xScale: 1, yScale: 1, xOffset: 0, yOffset: 0 } }, events: null, bounds: null, chamfer: null, circleRadius: 0, positionPrev: null, anglePrev: 0, parent: null, axes: null, area: 0, mass: 0, inertia: 0, _original: null },
+ i = s.extend(n, t); return e(i, t), i }, i.nextGroup = function(e) { return e ? i._nextNonCollidingGroupId-- : i._nextCollidingGroupId++ }, i.nextCategory = function() { return i._nextCategory = i._nextCategory << 1, i._nextCategory }; var e = function(e, t) { t = t || {}, i.set(e, { bounds: e.bounds || l.create(e.vertices), positionPrev: e.positionPrev || r.clone(e.position), anglePrev: e.anglePrev || e.angle, vertices: e.vertices, parts: e.parts || [e], isStatic: e.isStatic, isSleeping: e.isSleeping, parent: e.parent || e }), o.rotate(e.vertices, e.angle, e.position), c.rotate(e.axes, e.angle), l.update(e.bounds, e.vertices, e.velocity), i.set(e, { axes: t.axes || e.axes, area: t.area || e.area, mass: t.mass || e.mass, inertia: t.inertia || e.inertia }); var n = e.isStatic ? "#14151f" : s.choose(["#f19648", "#f5d259", "#f55a3c", "#063e7b", "#ececd1"]),
+ a = e.isStatic ? "#555" : "#ccc",
+ u = e.isStatic && null === e.render.fillStyle ? 1 : 0;
+ e.render.fillStyle = e.render.fillStyle || n, e.render.strokeStyle = e.render.strokeStyle || a, e.render.lineWidth = e.render.lineWidth || u, e.render.sprite.xOffset += -(e.bounds.min.x - e.position.x) / (e.bounds.max.x - e.bounds.min.x), e.render.sprite.yOffset += -(e.bounds.min.y - e.position.y) / (e.bounds.max.y - e.bounds.min.y) };
+ i.set = function(e, t, n) { var o; for (o in "string" == typeof t && (o = t, (t = {})[o] = n), t)
+ if (Object.prototype.hasOwnProperty.call(t, o)) switch (n = t[o], o) {
+ case "isStatic":
+ i.setStatic(e, n); break;
+ case "isSleeping":
+ a.set(e, n); break;
+ case "mass":
+ i.setMass(e, n); break;
+ case "density":
+ i.setDensity(e, n); break;
+ case "inertia":
+ i.setInertia(e, n); break;
+ case "vertices":
+ i.setVertices(e, n); break;
+ case "position":
+ i.setPosition(e, n); break;
+ case "angle":
+ i.setAngle(e, n); break;
+ case "velocity":
+ i.setVelocity(e, n); break;
+ case "angularVelocity":
+ i.setAngularVelocity(e, n); break;
+ case "parts":
+ i.setParts(e, n); break;
+ case "centre":
+ i.setCentre(e, n); break;
+ default:
+ e[o] = n } }, i.setStatic = function(e, t) { for (var n = 0; n < e.parts.length; n++) { var i = e.parts[n];
+ i.isStatic = t, t ? (i._original = { restitution: i.restitution, friction: i.friction, mass: i.mass, inertia: i.inertia, density: i.density, inverseMass: i.inverseMass, inverseInertia: i.inverseInertia }, i.restitution = 0, i.friction = 1, i.mass = i.inertia = i.density = 1 / 0, i.inverseMass = i.inverseInertia = 0, i.positionPrev.x = i.position.x, i.positionPrev.y = i.position.y, i.anglePrev = i.angle, i.angularVelocity = 0, i.speed = 0, i.angularSpeed = 0, i.motion = 0) : i._original && (i.restitution = i._original.restitution, i.friction = i._original.friction, i.mass = i._original.mass, i.inertia = i._original.inertia, i.density = i._original.density, i.inverseMass = i._original.inverseMass, i.inverseInertia = i._original.inverseInertia, i._original = null) } }, i.setMass = function(e, t) { var n = e.inertia / (e.mass / 6);
+ e.inertia = n * (t / 6), e.inverseInertia = 1 / e.inertia, e.mass = t, e.inverseMass = 1 / e.mass, e.density = e.mass / e.area }, i.setDensity = function(e, t) { i.setMass(e, t * e.area), e.density = t }, i.setInertia = function(e, t) { e.inertia = t, e.inverseInertia = 1 / e.inertia }, i.setVertices = function(e, t) { t[0].body === e ? e.vertices = t : e.vertices = o.create(t, e), e.axes = c.fromVertices(e.vertices), e.area = o.area(e.vertices), i.setMass(e, e.density * e.area); var n = o.centre(e.vertices);
+ o.translate(e.vertices, n, -1), i.setInertia(e, i._inertiaScale * o.inertia(e.vertices, e.mass)), o.translate(e.vertices, e.position), l.update(e.bounds, e.vertices, e.velocity) }, i.setParts = function(e, t, n) { var r; for (t = t.slice(0), e.parts.length = 0, e.parts.push(e), e.parent = e, r = 0; r < t.length; r++) { var a = t[r];
+ a !== e && (a.parent = e, e.parts.push(a)) } if (1 !== e.parts.length) { if (n = void 0 === n || n) { var s = []; for (r = 0; r < t.length; r++) s = s.concat(t[r].vertices);
+ o.clockwiseSort(s); var l = o.hull(s),
+ c = o.centre(l);
+ i.setVertices(e, l), o.translate(e.vertices, c) } var u = i._totalProperties(e);
+ e.area = u.area, e.parent = e, e.position.x = u.centre.x, e.position.y = u.centre.y, e.positionPrev.x = u.centre.x, e.positionPrev.y = u.centre.y, i.setMass(e, u.mass), i.setInertia(e, u.inertia), i.setPosition(e, u.centre) } }, i.setCentre = function(e, t, n) { n ? (e.positionPrev.x += t.x, e.positionPrev.y += t.y, e.position.x += t.x, e.position.y += t.y) : (e.positionPrev.x = t.x - (e.position.x - e.positionPrev.x), e.positionPrev.y = t.y - (e.position.y - e.positionPrev.y), e.position.x = t.x, e.position.y = t.y) }, i.setPosition = function(e, t) { var n = r.sub(t, e.position);
+ e.positionPrev.x += n.x, e.positionPrev.y += n.y; for (var i = 0; i < e.parts.length; i++) { var a = e.parts[i];
+ a.position.x += n.x, a.position.y += n.y, o.translate(a.vertices, n), l.update(a.bounds, a.vertices, e.velocity) } }, i.setAngle = function(e, t) { var n = t - e.angle;
+ e.anglePrev += n; for (var i = 0; i < e.parts.length; i++) { var a = e.parts[i];
+ a.angle += n, o.rotate(a.vertices, n, e.position), c.rotate(a.axes, n), l.update(a.bounds, a.vertices, e.velocity), i > 0 && r.rotateAbout(a.position, n, e.position, a.position) } }, i.setVelocity = function(e, t) { e.positionPrev.x = e.position.x - t.x, e.positionPrev.y = e.position.y - t.y, e.velocity.x = t.x, e.velocity.y = t.y, e.speed = r.magnitude(e.velocity) }, i.setAngularVelocity = function(e, t) { e.anglePrev = e.angle - t, e.angularVelocity = t, e.angularSpeed = Math.abs(e.angularVelocity) }, i.translate = function(e, t) { i.setPosition(e, r.add(e.position, t)) }, i.rotate = function(e, t, n) { if (n) { var o = Math.cos(t),
+ r = Math.sin(t),
+ a = e.position.x - n.x,
+ s = e.position.y - n.y;
+ i.setPosition(e, { x: n.x + (a * o - s * r), y: n.y + (a * r + s * o) }), i.setAngle(e, e.angle + t) } else i.setAngle(e, e.angle + t) }, i.scale = function(e, t, n, r) { var a = 0,
+ s = 0;
+ r = r || e.position; for (var u = 0; u < e.parts.length; u++) { var d = e.parts[u];
+ o.scale(d.vertices, t, n, r), d.axes = c.fromVertices(d.vertices), d.area = o.area(d.vertices), i.setMass(d, e.density * d.area), o.translate(d.vertices, { x: -d.position.x, y: -d.position.y }), i.setInertia(d, i._inertiaScale * o.inertia(d.vertices, d.mass)), o.translate(d.vertices, { x: d.position.x, y: d.position.y }), u > 0 && (a += d.area, s += d.inertia), d.position.x = r.x + (d.position.x - r.x) * t, d.position.y = r.y + (d.position.y - r.y) * n, l.update(d.bounds, d.vertices, e.velocity) } e.parts.length > 1 && (e.area = a, e.isStatic || (i.setMass(e, e.density * a), i.setInertia(e, s))), e.circleRadius && (t === n ? e.circleRadius *= t : e.circleRadius = null) }, i.update = function(e, t, n, i) { var a = Math.pow(t * n * e.timeScale, 2),
+ s = 1 - e.frictionAir * n * e.timeScale,
+ u = e.position.x - e.positionPrev.x,
+ d = e.position.y - e.positionPrev.y;
+ e.velocity.x = u * s * i + e.force.x / e.mass * a, e.velocity.y = d * s * i + e.force.y / e.mass * a, e.positionPrev.x = e.position.x, e.positionPrev.y = e.position.y, e.position.x += e.velocity.x, e.position.y += e.velocity.y, e.angularVelocity = (e.angle - e.anglePrev) * s * i + e.torque / e.inertia * a, e.anglePrev = e.angle, e.angle += e.angularVelocity, e.speed = r.magnitude(e.velocity), e.angularSpeed = Math.abs(e.angularVelocity); for (var p = 0; p < e.parts.length; p++) { var f = e.parts[p];
+ o.translate(f.vertices, e.velocity), p > 0 && (f.position.x += e.velocity.x, f.position.y += e.velocity.y), 0 !== e.angularVelocity && (o.rotate(f.vertices, e.angularVelocity, e.position), c.rotate(f.axes, e.angularVelocity), p > 0 && r.rotateAbout(f.position, e.angularVelocity, e.position, f.position)), l.update(f.bounds, f.vertices, e.velocity) } }, i.applyForce = function(e, t, n) { e.force.x += n.x, e.force.y += n.y; var i = t.x - e.position.x,
+ o = t.y - e.position.y;
+ e.torque += i * n.y - o * n.x }, i._totalProperties = function(e) { for (var t = { mass: 0, area: 0, inertia: 0, centre: { x: 0, y: 0 } }, n = 1 === e.parts.length ? 0 : 1; n < e.parts.length; n++) { var i = e.parts[n],
+ o = i.mass !== 1 / 0 ? i.mass : 1;
+ t.mass += o, t.area += i.area, t.inertia += i.inertia, t.centre = r.add(t.centre, r.mult(i.position, o)) } return t.centre = r.div(t.centre, t.mass), t } }() }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(4);
+ i._motionWakeThreshold = .18, i._motionSleepThreshold = .08, i._minBias = .9, i.update = function(e, t) { for (var n = t * t * t, o = 0; o < e.length; o++) { var r = e[o],
+ a = r.speed * r.speed + r.angularSpeed * r.angularSpeed; if (0 === r.force.x && 0 === r.force.y) { var s = Math.min(r.motion, a),
+ l = Math.max(r.motion, a);
+ r.motion = i._minBias * s + (1 - i._minBias) * l, r.sleepThreshold > 0 && r.motion < i._motionSleepThreshold * n ? (r.sleepCounter += 1, r.sleepCounter >= r.sleepThreshold && i.set(r, !0)) : r.sleepCounter > 0 && (r.sleepCounter -= 1) } else i.set(r, !1) } }, i.afterCollisions = function(e, t) { for (var n = t * t * t, o = 0; o < e.length; o++) { var r = e[o]; if (r.isActive) { var a = r.collision,
+ s = a.bodyA.parent,
+ l = a.bodyB.parent; if (!(s.isSleeping && l.isSleeping || s.isStatic || l.isStatic) && (s.isSleeping || l.isSleeping)) { var c = s.isSleeping && !s.isStatic ? s : l,
+ u = c === s ? l : s;!c.isStatic && u.motion > i._motionWakeThreshold * n && i.set(c, !1) } } } }, i.set = function(e, t) { var n = e.isSleeping;
+ t ? (e.isSleeping = !0, e.sleepCounter = e.sleepThreshold, e.positionImpulse.x = 0, e.positionImpulse.y = 0, e.positionPrev.x = e.position.x, e.positionPrev.y = e.position.y, e.anglePrev = e.angle, e.speed = 0, e.angularSpeed = 0, e.motion = 0, n || o.trigger(e, "sleepStart")) : (e.isSleeping = !1, e.sleepCounter = 0, n && o.trigger(e, "sleepEnd")) } }, function(e, t, n) { var i = {};
+ e.exports = i; var o, r, a, s = n(3),
+ l = n(9);
+ o = [], r = { overlap: 0, axis: null }, a = { overlap: 0, axis: null }, i.create = function(e, t) { return { pair: null, collided: !1, bodyA: e, bodyB: t, parentA: e.parent, parentB: t.parent, depth: 0, normal: { x: 0, y: 0 }, tangent: { x: 0, y: 0 }, penetration: { x: 0, y: 0 }, supports: [] } }, i.collides = function(e, t, n) { if (i._overlapAxes(r, e.vertices, t.vertices, e.axes), r.overlap <= 0) return null; if (i._overlapAxes(a, t.vertices, e.vertices, t.axes), a.overlap <= 0) return null; var o, c, u = n && n.table[l.id(e, t)];
+ u ? o = u.collision : ((o = i.create(e, t)).collided = !0, o.bodyA = e.id < t.id ? e : t, o.bodyB = e.id < t.id ? t : e, o.parentA = o.bodyA.parent, o.parentB = o.bodyB.parent), e = o.bodyA, t = o.bodyB, c = r.overlap < a.overlap ? r : a; var d = o.normal,
+ p = o.supports,
+ f = c.axis,
+ v = f.x,
+ y = f.y;
+ v * (t.position.x - e.position.x) + y * (t.position.y - e.position.y) < 0 ? (d.x = v, d.y = y) : (d.x = -v, d.y = -y), o.tangent.x = -d.y, o.tangent.y = d.x, o.depth = c.overlap, o.penetration.x = d.x * o.depth, o.penetration.y = d.y * o.depth; var m = i._findSupports(e, t, d, 1),
+ g = 0; if (s.contains(e.vertices, m[0]) && (p[g++] = m[0]), s.contains(e.vertices, m[1]) && (p[g++] = m[1]), g < 2) { var x = i._findSupports(t, e, d, -1);
+ s.contains(t.vertices, x[0]) && (p[g++] = x[0]), g < 2 && s.contains(t.vertices, x[1]) && (p[g++] = x[1]) } return 0 === g && (p[g++] = m[0]), p.length = g, o }, i._overlapAxes = function(e, t, n, i) { var o, r, a, s, l, c, u = t.length,
+ d = n.length,
+ p = t[0].x,
+ f = t[0].y,
+ v = n[0].x,
+ y = n[0].y,
+ m = i.length,
+ g = Number.MAX_VALUE,
+ x = 0; for (l = 0; l < m; l++) { var h = i[l],
+ b = h.x,
+ S = h.y,
+ w = p * b + f * S,
+ A = v * b + y * S,
+ P = w,
+ C = A; for (c = 1; c < u; c += 1)(s = t[c].x * b + t[c].y * S) > P ? P = s : s < w && (w = s); for (c = 1; c < d; c += 1)(s = n[c].x * b + n[c].y * S) > C ? C = s : s < A && (A = s); if ((o = (r = P - A) < (a = C - w) ? r : a) < g && (g = o, x = l, o <= 0)) break } e.axis = i[x], e.overlap = g }, i._projectToAxis = function(e, t, n) { for (var i = t[0].x * n.x + t[0].y * n.y, o = i, r = 1; r < t.length; r += 1) { var a = t[r].x * n.x + t[r].y * n.y;
+ a > o ? o = a : a < i && (i = a) } e.min = i, e.max = o }, i._findSupports = function(e, t, n, i) { var r, a, s, l, c, u = t.vertices,
+ d = u.length,
+ p = e.position.x,
+ f = e.position.y,
+ v = n.x * i,
+ y = n.y * i,
+ m = Number.MAX_VALUE; for (c = 0; c < d; c += 1)(l = v * (p - (a = u[c]).x) + y * (f - a.y)) < m && (m = l, r = a); return m = v * (p - (s = u[(d + r.index - 1) % d]).x) + y * (f - s.y), v * (p - (a = u[(r.index + 1) % d]).x) + y * (f - a.y) < m ? (o[0] = r, o[1] = a, o) : (o[0] = r, o[1] = s, o) } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(17);
+ i.create = function(e, t) { var n = e.bodyA,
+ o = e.bodyB,
+ r = { id: i.id(n, o), bodyA: n, bodyB: o, collision: e, contacts: [], activeContacts: [], separation: 0, isActive: !0, confirmedActive: !0, isSensor: n.isSensor || o.isSensor, timeCreated: t, timeUpdated: t, inverseMass: 0, friction: 0, frictionStatic: 0, restitution: 0, slop: 0 }; return i.update(r, e, t), r }, i.update = function(e, t, n) { var i = e.contacts,
+ r = t.supports,
+ a = e.activeContacts,
+ s = t.parentA,
+ l = t.parentB,
+ c = s.vertices.length;
+ e.isActive = !0, e.timeUpdated = n, e.collision = t, e.separation = t.depth, e.inverseMass = s.inverseMass + l.inverseMass, e.friction = s.friction < l.friction ? s.friction : l.friction, e.frictionStatic = s.frictionStatic > l.frictionStatic ? s.frictionStatic : l.frictionStatic, e.restitution = s.restitution > l.restitution ? s.restitution : l.restitution, e.slop = s.slop > l.slop ? s.slop : l.slop, t.pair = e, a.length = 0; for (var u = 0; u < r.length; u++) { var d = r[u],
+ p = d.body === s ? d.index : c + d.index,
+ f = i[p];
+ f ? a.push(f) : a.push(i[p] = o.create(d)) } }, i.setActive = function(e, t, n) { t ? (e.isActive = !0, e.timeUpdated = n) : (e.isActive = !1, e.activeContacts.length = 0) }, i.id = function(e, t) { return e.id < t.id ? "A" + e.id + "B" + t.id : "A" + t.id + "B" + e.id } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(3),
+ r = n(2),
+ a = n(7),
+ s = n(1),
+ l = n(11),
+ c = n(0);
+ i._warming = .4, i._torqueDampen = 1, i._minLength = 1e-6, i.create = function(e) { var t = e;
+ t.bodyA && !t.pointA && (t.pointA = { x: 0, y: 0 }), t.bodyB && !t.pointB && (t.pointB = { x: 0, y: 0 }); var n = t.bodyA ? r.add(t.bodyA.position, t.pointA) : t.pointA,
+ i = t.bodyB ? r.add(t.bodyB.position, t.pointB) : t.pointB,
+ o = r.magnitude(r.sub(n, i));
+ t.length = void 0 !== t.length ? t.length : o, t.id = t.id || c.nextId(), t.label = t.label || "Constraint", t.type = "constraint", t.stiffness = t.stiffness || (t.length > 0 ? 1 : .7), t.damping = t.damping || 0, t.angularStiffness = t.angularStiffness || 0, t.angleA = t.bodyA ? t.bodyA.angle : t.angleA, t.angleB = t.bodyB ? t.bodyB.angle : t.angleB, t.plugin = {}; var a = { visible: !0, lineWidth: 2, strokeStyle: "#ffffff", type: "line", anchors: !0 }; return 0 === t.length && t.stiffness > .1 ? (a.type = "pin", a.anchors = !1) : t.stiffness < .9 && (a.type = "spring"), t.render = c.extend(a, t.render), t }, i.preSolveAll = function(e) { for (var t = 0; t < e.length; t += 1) { var n = e[t],
+ i = n.constraintImpulse;
+ n.isStatic || 0 === i.x && 0 === i.y && 0 === i.angle || (n.position.x += i.x, n.position.y += i.y, n.angle += i.angle) } }, i.solveAll = function(e, t) { for (var n = 0; n < e.length; n += 1) { var o = e[n],
+ r = !o.bodyA || o.bodyA && o.bodyA.isStatic,
+ a = !o.bodyB || o.bodyB && o.bodyB.isStatic;
+ (r || a) && i.solve(e[n], t) } for (n = 0; n < e.length; n += 1) r = !(o = e[n]).bodyA || o.bodyA && o.bodyA.isStatic, a = !o.bodyB || o.bodyB && o.bodyB.isStatic, r || a || i.solve(e[n], t) }, i.solve = function(e, t) { var n = e.bodyA,
+ o = e.bodyB,
+ a = e.pointA,
+ s = e.pointB; if (n || o) { n && !n.isStatic && (r.rotate(a, n.angle - e.angleA, a), e.angleA = n.angle), o && !o.isStatic && (r.rotate(s, o.angle - e.angleB, s), e.angleB = o.angle); var l = a,
+ c = s; if (n && (l = r.add(n.position, a)), o && (c = r.add(o.position, s)), l && c) { var u = r.sub(l, c),
+ d = r.magnitude(u);
+ d < i._minLength && (d = i._minLength); var p, f, v, y, m, g = (d - e.length) / d,
+ x = e.stiffness < 1 ? e.stiffness * t : e.stiffness,
+ h = r.mult(u, g * x),
+ b = (n ? n.inverseMass : 0) + (o ? o.inverseMass : 0),
+ S = b + ((n ? n.inverseInertia : 0) + (o ? o.inverseInertia : 0)); if (e.damping) { var w = r.create();
+ v = r.div(u, d), m = r.sub(o && r.sub(o.position, o.positionPrev) || w, n && r.sub(n.position, n.positionPrev) || w), y = r.dot(v, m) } n && !n.isStatic && (f = n.inverseMass / b, n.constraintImpulse.x -= h.x * f, n.constraintImpulse.y -= h.y * f, n.position.x -= h.x * f, n.position.y -= h.y * f, e.damping && (n.positionPrev.x -= e.damping * v.x * y * f, n.positionPrev.y -= e.damping * v.y * y * f), p = r.cross(a, h) / S * i._torqueDampen * n.inverseInertia * (1 - e.angularStiffness), n.constraintImpulse.angle -= p, n.angle -= p), o && !o.isStatic && (f = o.inverseMass / b, o.constraintImpulse.x += h.x * f, o.constraintImpulse.y += h.y * f, o.position.x += h.x * f, o.position.y += h.y * f, e.damping && (o.positionPrev.x += e.damping * v.x * y * f, o.positionPrev.y += e.damping * v.y * y * f), p = r.cross(s, h) / S * i._torqueDampen * o.inverseInertia * (1 - e.angularStiffness), o.constraintImpulse.angle += p, o.angle += p) } } }, i.postSolveAll = function(e) { for (var t = 0; t < e.length; t++) { var n = e[t],
+ c = n.constraintImpulse; if (!(n.isStatic || 0 === c.x && 0 === c.y && 0 === c.angle)) { a.set(n, !1); for (var u = 0; u < n.parts.length; u++) { var d = n.parts[u];
+ o.translate(d.vertices, c), u > 0 && (d.position.x += c.x, d.position.y += c.y), 0 !== c.angle && (o.rotate(d.vertices, c.angle, n.position), l.rotate(d.axes, c.angle), u > 0 && r.rotateAbout(d.position, c.angle, n.position, d.position)), s.update(d.bounds, d.vertices, n.velocity) } c.angle *= i._warming, c.x *= i._warming, c.y *= i._warming } } }, i.pointAWorld = function(e) { return { x: (e.bodyA ? e.bodyA.position.x : 0) + (e.pointA ? e.pointA.x : 0), y: (e.bodyA ? e.bodyA.position.y : 0) + (e.pointA ? e.pointA.y : 0) } }, i.pointBWorld = function(e) { return { x: (e.bodyB ? e.bodyB.position.x : 0) + (e.pointB ? e.pointB.x : 0), y: (e.bodyB ? e.bodyB.position.y : 0) + (e.pointB ? e.pointB.y : 0) } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(2),
+ r = n(0);
+ i.fromVertices = function(e) { for (var t = {}, n = 0; n < e.length; n++) { var i = (n + 1) % e.length,
+ a = o.normalise({ x: e[i].y - e[n].y, y: e[n].x - e[i].x }),
+ s = 0 === a.y ? 1 / 0 : a.x / a.y;
+ t[s = s.toFixed(3).toString()] = a } return r.values(t) }, i.rotate = function(e, t) { if (0 !== t)
+ for (var n = Math.cos(t), i = Math.sin(t), o = 0; o < e.length; o++) { var r, a = e[o];
+ r = a.x * n - a.y * i, a.y = a.x * i + a.y * n, a.x = r } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(3),
+ r = n(0),
+ a = n(6),
+ s = n(1),
+ l = n(2);
+ i.rectangle = function(e, t, n, i, s) { s = s || {}; var l = { label: "Rectangle Body", position: { x: e, y: t }, vertices: o.fromPath("L 0 0 L " + n + " 0 L " + n + " " + i + " L 0 " + i) }; if (s.chamfer) { var c = s.chamfer;
+ l.vertices = o.chamfer(l.vertices, c.radius, c.quality, c.qualityMin, c.qualityMax), delete s.chamfer } return a.create(r.extend({}, l, s)) }, i.trapezoid = function(e, t, n, i, s, l) { l = l || {}; var c, u = n * (s *= .5),
+ d = u + (1 - 2 * s) * n,
+ p = d + u;
+ c = s < .5 ? "L 0 0 L " + u + " " + -i + " L " + d + " " + -i + " L " + p + " 0" : "L 0 0 L " + d + " " + -i + " L " + p + " 0"; var f = { label: "Trapezoid Body", position: { x: e, y: t }, vertices: o.fromPath(c) }; if (l.chamfer) { var v = l.chamfer;
+ f.vertices = o.chamfer(f.vertices, v.radius, v.quality, v.qualityMin, v.qualityMax), delete l.chamfer } return a.create(r.extend({}, f, l)) }, i.circle = function(e, t, n, o, a) { o = o || {}; var s = { label: "Circle Body", circleRadius: n };
+ a = a || 25; var l = Math.ceil(Math.max(10, Math.min(a, n))); return l % 2 == 1 && (l += 1), i.polygon(e, t, l, n, r.extend({}, s, o)) }, i.polygon = function(e, t, n, s, l) { if (l = l || {}, n < 3) return i.circle(e, t, s, l); for (var c = 2 * Math.PI / n, u = "", d = .5 * c, p = 0; p < n; p += 1) { var f = d + p * c,
+ v = Math.cos(f) * s,
+ y = Math.sin(f) * s;
+ u += "L " + v.toFixed(3) + " " + y.toFixed(3) + " " } var m = { label: "Polygon Body", position: { x: e, y: t }, vertices: o.fromPath(u) }; if (l.chamfer) { var g = l.chamfer;
+ m.vertices = o.chamfer(m.vertices, g.radius, g.quality, g.qualityMin, g.qualityMax), delete l.chamfer } return a.create(r.extend({}, m, l)) }, i.fromVertices = function(e, t, n, i, c, u, d, p) { var f, v, y, m, g, x, h, b, S, w, A = r.getDecomp(); for (f = Boolean(A && A.quickDecomp), i = i || {}, y = [], c = void 0 !== c && c, u = void 0 !== u ? u : .01, d = void 0 !== d ? d : 10, p = void 0 !== p ? p : .01, r.isArray(n[0]) || (n = [n]), S = 0; S < n.length; S += 1)
+ if (g = n[S], !(m = o.isConvex(g)) && !f && r.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."), m || !f) g = m ? o.clockwiseSort(g) : o.hull(g), y.push({ position: { x: e, y: t }, vertices: g });
+ else { var P = g.map((function(e) { return [e.x, e.y] }));
+ A.makeCCW(P), !1 !== u && A.removeCollinearPoints(P, u), !1 !== p && A.removeDuplicatePoints && A.removeDuplicatePoints(P, p); var C = A.quickDecomp(P); for (x = 0; x < C.length; x++) { var B = C[x].map((function(e) { return { x: e[0], y: e[1] } }));
+ d > 0 && o.area(B) < d || y.push({ position: o.centre(B), vertices: B }) } } for (x = 0; x < y.length; x++) y[x] = a.create(r.extend(y[x], i)); if (c)
+ for (x = 0; x < y.length; x++) { var M = y[x]; for (h = x + 1; h < y.length; h++) { var k = y[h]; if (s.overlaps(M.bounds, k.bounds)) { var _ = M.vertices,
+ I = k.vertices; for (b = 0; b < M.vertices.length; b++)
+ for (w = 0; w < k.vertices.length; w++) { var T = l.magnitudeSquared(l.sub(_[(b + 1) % _.length], I[w])),
+ R = l.magnitudeSquared(l.sub(_[b], I[(w + 1) % I.length]));
+ T < 5 && R < 5 && (_[b].isInternal = !0, I[w].isInternal = !0) } } } }
+ return y.length > 1 ? (v = a.create(r.extend({ parts: y.slice(0) }, i)), a.setPosition(v, { x: e, y: t }), v) : y[0] } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(0);
+ i.create = function(e) { var t = {}; return e || o.log("Mouse.create: element was undefined, defaulting to document.body", "warn"), t.element = e || document.body, t.absolute = { x: 0, y: 0 }, t.position = { x: 0, y: 0 }, t.mousedownPosition = { x: 0, y: 0 }, t.mouseupPosition = { x: 0, y: 0 }, t.offset = { x: 0, y: 0 }, t.scale = { x: 1, y: 1 }, t.wheelDelta = 0, t.button = -1, t.pixelRatio = parseInt(t.element.getAttribute("data-pixel-ratio"), 10) || 1, t.sourceEvents = { mousemove: null, mousedown: null, mouseup: null, mousewheel: null }, t.mousemove = function(e) { var n = i._getRelativeMousePosition(e, t.element, t.pixelRatio);
+ e.changedTouches && (t.button = 0, e.preventDefault()), t.absolute.x = n.x, t.absolute.y = n.y, t.position.x = t.absolute.x * t.scale.x + t.offset.x, t.position.y = t.absolute.y * t.scale.y + t.offset.y, t.sourceEvents.mousemove = e }, t.mousedown = function(e) { var n = i._getRelativeMousePosition(e, t.element, t.pixelRatio);
+ e.changedTouches ? (t.button = 0, e.preventDefault()) : t.button = e.button, t.absolute.x = n.x, t.absolute.y = n.y, t.position.x = t.absolute.x * t.scale.x + t.offset.x, t.position.y = t.absolute.y * t.scale.y + t.offset.y, t.mousedownPosition.x = t.position.x, t.mousedownPosition.y = t.position.y, t.sourceEvents.mousedown = e }, t.mouseup = function(e) { var n = i._getRelativeMousePosition(e, t.element, t.pixelRatio);
+ e.changedTouches && e.preventDefault(), t.button = -1, t.absolute.x = n.x, t.absolute.y = n.y, t.position.x = t.absolute.x * t.scale.x + t.offset.x, t.position.y = t.absolute.y * t.scale.y + t.offset.y, t.mouseupPosition.x = t.position.x, t.mouseupPosition.y = t.position.y, t.sourceEvents.mouseup = e }, t.mousewheel = function(e) { t.wheelDelta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail)), e.preventDefault() }, i.setElement(t, t.element), t }, i.setElement = function(e, t) { e.element = t, t.addEventListener("mousemove", e.mousemove), t.addEventListener("mousedown", e.mousedown), t.addEventListener("mouseup", e.mouseup), t.addEventListener("mousewheel", e.mousewheel), t.addEventListener("DOMMouseScroll", e.mousewheel), t.addEventListener("touchmove", e.mousemove), t.addEventListener("touchstart", e.mousedown), t.addEventListener("touchend", e.mouseup) }, i.clearSourceEvents = function(e) { e.sourceEvents.mousemove = null, e.sourceEvents.mousedown = null, e.sourceEvents.mouseup = null, e.sourceEvents.mousewheel = null, e.wheelDelta = 0 }, i.setOffset = function(e, t) { e.offset.x = t.x, e.offset.y = t.y, e.position.x = e.absolute.x * e.scale.x + e.offset.x, e.position.y = e.absolute.y * e.scale.y + e.offset.y }, i.setScale = function(e, t) { e.scale.x = t.x, e.scale.y = t.y, e.position.x = e.absolute.x * e.scale.x + e.offset.x, e.position.y = e.absolute.y * e.scale.y + e.offset.y }, i._getRelativeMousePosition = function(e, t, n) { var i, o, r = t.getBoundingClientRect(),
+ a = document.documentElement || document.body.parentNode || document.body,
+ s = void 0 !== window.pageXOffset ? window.pageXOffset : a.scrollLeft,
+ l = void 0 !== window.pageYOffset ? window.pageYOffset : a.scrollTop,
+ c = e.changedTouches; return c ? (i = c[0].pageX - r.left - s, o = c[0].pageY - r.top - l) : (i = e.pageX - r.left - s, o = e.pageY - r.top - l), { x: i / (t.clientWidth / (t.width || t.clientWidth) * n), y: o / (t.clientHeight / (t.height || t.clientHeight) * n) } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(0),
+ r = n(8);
+ i.create = function(e) { return o.extend({ bodies: [], pairs: null }, e) }, i.setBodies = function(e, t) { e.bodies = t.slice(0) }, i.clear = function(e) { e.bodies = [] }, i.collisions = function(e) { var t, n, o = [],
+ a = e.pairs,
+ s = e.bodies,
+ l = s.length,
+ c = i.canCollide,
+ u = r.collides; for (s.sort(i._compareBoundsX), t = 0; t < l; t++) { var d = s[t],
+ p = d.bounds,
+ f = d.bounds.max.x,
+ v = d.bounds.max.y,
+ y = d.bounds.min.y,
+ m = d.isStatic || d.isSleeping,
+ g = d.parts.length,
+ x = 1 === g; for (n = t + 1; n < l; n++) { var h = s[n]; if ((M = h.bounds).min.x > f) break; if (!(v < M.min.y || y > M.max.y) && (!m || !h.isStatic && !h.isSleeping) && c(d.collisionFilter, h.collisionFilter)) { var b = h.parts.length; if (x && 1 === b)(C = u(d, h, a)) && o.push(C);
+ else
+ for (var S = b > 1 ? 1 : 0, w = g > 1 ? 1 : 0; w < g; w++)
+ for (var A = d.parts[w], P = (p = A.bounds, S); P < b; P++) { var C, B = h.parts[P],
+ M = B.bounds;
+ p.min.x > M.max.x || p.max.x < M.min.x || p.max.y < M.min.y || p.min.y > M.max.y || (C = u(A, B, a)) && o.push(C) } } } } return o }, i.canCollide = function(e, t) { return e.group === t.group && 0 !== e.group ? e.group > 0 : 0 != (e.mask & t.category) && 0 != (t.mask & e.category) }, i._compareBoundsX = function(e, t) { return e.bounds.min.x - t.bounds.min.x } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(0);
+ i._registry = {}, i.register = function(e) { if (i.isPlugin(e) || o.warn("Plugin.register:", i.toString(e), "does not implement all required fields."), e.name in i._registry) { var t = i._registry[e.name],
+ n = i.versionParse(e.version).number,
+ r = i.versionParse(t.version).number;
+ n > r ? (o.warn("Plugin.register:", i.toString(t), "was upgraded to", i.toString(e)), i._registry[e.name] = e) : n < r ? o.warn("Plugin.register:", i.toString(t), "can not be downgraded to", i.toString(e)) : e !== t && o.warn("Plugin.register:", i.toString(e), "is already registered to different plugin object") } else i._registry[e.name] = e; return e }, i.resolve = function(e) { return i._registry[i.dependencyParse(e).name] }, i.toString = function(e) { return "string" == typeof e ? e : (e.name || "anonymous") + "@" + (e.version || e.range || "0.0.0") }, i.isPlugin = function(e) { return e && e.name && e.version && e.install }, i.isUsed = function(e, t) { return e.used.indexOf(t) > -1 }, i.isFor = function(e, t) { var n = e.for && i.dependencyParse(e.for); return !e.for || t.name === n.name && i.versionSatisfies(t.version, n.range) }, i.use = function(e, t) { if (e.uses = (e.uses || []).concat(t || []), 0 !== e.uses.length) { for (var n = i.dependencies(e), r = o.topologicalSort(n), a = [], s = 0; s < r.length; s += 1)
+ if (r[s] !== e.name) { var l = i.resolve(r[s]);
+ l ? i.isUsed(e, l.name) || (i.isFor(l, e) || (o.warn("Plugin.use:", i.toString(l), "is for", l.for, "but installed on", i.toString(e) + "."), l._warned = !0), l.install ? l.install(e) : (o.warn("Plugin.use:", i.toString(l), "does not specify an install function."), l._warned = !0), l._warned ? (a.push("🔶 " + i.toString(l)), delete l._warned) : a.push("✅ " + i.toString(l)), e.used.push(l.name)) : a.push("❌ " + r[s]) } a.length > 0 && o.info(a.join(" ")) } else o.warn("Plugin.use:", i.toString(e), "does not specify any dependencies to install.") }, i.dependencies = function(e, t) { var n = i.dependencyParse(e),
+ r = n.name; if (!(r in (t = t || {}))) { e = i.resolve(e) || e, t[r] = o.map(e.uses || [], (function(t) { i.isPlugin(t) && i.register(t); var r = i.dependencyParse(t),
+ a = i.resolve(t); return a && !i.versionSatisfies(a.version, r.range) ? (o.warn("Plugin.dependencies:", i.toString(a), "does not satisfy", i.toString(r), "used by", i.toString(n) + "."), a._warned = !0, e._warned = !0) : a || (o.warn("Plugin.dependencies:", i.toString(t), "used by", i.toString(n), "could not be resolved."), e._warned = !0), r.name })); for (var a = 0; a < t[r].length; a += 1) i.dependencies(t[r][a], t); return t } }, i.dependencyParse = function(e) { return o.isString(e) ? (/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/.test(e) || o.warn("Plugin.dependencyParse:", e, "is not a valid dependency string."), { name: e.split("@")[0], range: e.split("@")[1] || "*" }) : { name: e.name, range: e.range || e.version } }, i.versionParse = function(e) { var t = /^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;
+ t.test(e) || o.warn("Plugin.versionParse:", e, "is not a valid version or range."); var n = t.exec(e),
+ i = Number(n[4]),
+ r = Number(n[5]),
+ a = Number(n[6]); return { isRange: Boolean(n[1] || n[2]), version: n[3], range: e, operator: n[1] || n[2] || "", major: i, minor: r, patch: a, parts: [i, r, a], prerelease: n[7], number: 1e8 * i + 1e4 * r + a } }, i.versionSatisfies = function(e, t) { t = t || "*"; var n = i.versionParse(t),
+ o = i.versionParse(e); if (n.isRange) { if ("*" === n.operator || "*" === e) return !0; if (">" === n.operator) return o.number > n.number; if (">=" === n.operator) return o.number >= n.number; if ("~" === n.operator) return o.major === n.major && o.minor === n.minor && o.patch >= n.patch; if ("^" === n.operator) return n.major > 0 ? o.major === n.major && o.number >= n.number : n.minor > 0 ? o.minor === n.minor && o.patch >= n.patch : o.patch === n.patch } return e === t || "*" === e } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(0),
+ r = n(5),
+ a = n(1),
+ s = n(4),
+ l = n(2),
+ c = n(13);! function() { var e, t; "undefined" != typeof window && (e = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function(e) { window.setTimeout((function() { e(o.now()) }), 1e3 / 60) }, t = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame), i._goodFps = 30, i._goodDelta = 1e3 / 60, i.create = function(e) { var t = { engine: null, element: null, canvas: null, mouse: null, frameRequestId: null, timing: { historySize: 60, delta: 0, deltaHistory: [], lastTime: 0, lastTimestamp: 0, lastElapsed: 0, timestampElapsed: 0, timestampElapsedHistory: [], engineDeltaHistory: [], engineElapsedHistory: [], elapsedHistory: [] }, options: { width: 800, height: 600, pixelRatio: 1, background: "#14151f", wireframeBackground: "#14151f", hasBounds: !!e.bounds, enabled: !0, wireframes: !0, showSleeping: !0, showDebug: !1, showStats: !1, showPerformance: !1, showBounds: !1, showVelocity: !1, showCollisions: !1, showSeparations: !1, showAxes: !1, showPositions: !1, showAngleIndicator: !1, showIds: !1, showVertexNumbers: !1, showConvexHulls: !1, showInternalEdges: !1, showMousePosition: !1 } },
+ n = o.extend(t, e); return n.canvas && (n.canvas.width = n.options.width || n.canvas.width, n.canvas.height = n.options.height || n.canvas.height), n.mouse = e.mouse, n.engine = e.engine, n.canvas = n.canvas || d(n.options.width, n.options.height), n.context = n.canvas.getContext("2d"), n.textures = {}, n.bounds = n.bounds || { min: { x: 0, y: 0 }, max: { x: n.canvas.width, y: n.canvas.height } }, n.controller = i, n.options.showBroadphase = !1, 1 !== n.options.pixelRatio && i.setPixelRatio(n, n.options.pixelRatio), o.isElement(n.element) && n.element.appendChild(n.canvas), n }, i.run = function(t) {! function o(r) { t.frameRequestId = e(o), n(t, r), i.world(t, r), (t.options.showStats || t.options.showDebug) && i.stats(t, t.context, r), (t.options.showPerformance || t.options.showDebug) && i.performance(t, t.context, r) }() }, i.stop = function(e) { t(e.frameRequestId) }, i.setPixelRatio = function(e, t) { var n = e.options,
+ i = e.canvas; "auto" === t && (t = p(i)), n.pixelRatio = t, i.setAttribute("data-pixel-ratio", t), i.width = n.width * t, i.height = n.height * t, i.style.width = n.width + "px", i.style.height = n.height + "px" }, i.lookAt = function(e, t, n, i) { i = void 0 === i || i, t = o.isArray(t) ? t : [t], n = n || { x: 0, y: 0 }; for (var r = { min: { x: 1 / 0, y: 1 / 0 }, max: { x: -1 / 0, y: -1 / 0 } }, a = 0; a < t.length; a += 1) { var s = t[a],
+ l = s.bounds ? s.bounds.min : s.min || s.position || s,
+ u = s.bounds ? s.bounds.max : s.max || s.position || s;
+ l && u && (l.x < r.min.x && (r.min.x = l.x), u.x > r.max.x && (r.max.x = u.x), l.y < r.min.y && (r.min.y = l.y), u.y > r.max.y && (r.max.y = u.y)) } var d = r.max.x - r.min.x + 2 * n.x,
+ p = r.max.y - r.min.y + 2 * n.y,
+ f = e.canvas.height,
+ v = e.canvas.width / f,
+ y = d / p,
+ m = 1,
+ g = 1;
+ y > v ? g = y / v : m = v / y, e.options.hasBounds = !0, e.bounds.min.x = r.min.x, e.bounds.max.x = r.min.x + d * m, e.bounds.min.y = r.min.y, e.bounds.max.y = r.min.y + p * g, i && (e.bounds.min.x += .5 * d - d * m * .5, e.bounds.max.x += .5 * d - d * m * .5, e.bounds.min.y += .5 * p - p * g * .5, e.bounds.max.y += .5 * p - p * g * .5), e.bounds.min.x -= n.x, e.bounds.max.x -= n.x, e.bounds.min.y -= n.y, e.bounds.max.y -= n.y, e.mouse && (c.setScale(e.mouse, { x: (e.bounds.max.x - e.bounds.min.x) / e.canvas.width, y: (e.bounds.max.y - e.bounds.min.y) / e.canvas.height }), c.setOffset(e.mouse, e.bounds.min)) }, i.startViewTransform = function(e) { var t = e.bounds.max.x - e.bounds.min.x,
+ n = e.bounds.max.y - e.bounds.min.y,
+ i = t / e.options.width,
+ o = n / e.options.height;
+ e.context.setTransform(e.options.pixelRatio / i, 0, 0, e.options.pixelRatio / o, 0, 0), e.context.translate(-e.bounds.min.x, -e.bounds.min.y) }, i.endViewTransform = function(e) { e.context.setTransform(e.options.pixelRatio, 0, 0, e.options.pixelRatio, 0, 0) }, i.world = function(e, t) { var n, u = o.now(),
+ d = e.engine,
+ p = d.world,
+ f = e.canvas,
+ y = e.context,
+ m = e.options,
+ g = e.timing,
+ x = r.allBodies(p),
+ h = r.allConstraints(p),
+ b = m.wireframes ? m.wireframeBackground : m.background,
+ S = [],
+ w = [],
+ A = { timestamp: d.timing.timestamp }; if (s.trigger(e, "beforeRender", A), e.currentBackground !== b && v(e, b), y.globalCompositeOperation = "source-in", y.fillStyle = "transparent", y.fillRect(0, 0, f.width, f.height), y.globalCompositeOperation = "source-over", m.hasBounds) { for (n = 0; n < x.length; n++) { var P = x[n];
+ a.overlaps(P.bounds, e.bounds) && S.push(P) } for (n = 0; n < h.length; n++) { var C = h[n],
+ B = C.bodyA,
+ M = C.bodyB,
+ k = C.pointA,
+ _ = C.pointB;
+ B && (k = l.add(B.position, C.pointA)), M && (_ = l.add(M.position, C.pointB)), k && _ && ((a.contains(e.bounds, k) || a.contains(e.bounds, _)) && w.push(C)) } i.startViewTransform(e), e.mouse && (c.setScale(e.mouse, { x: (e.bounds.max.x - e.bounds.min.x) / e.options.width, y: (e.bounds.max.y - e.bounds.min.y) / e.options.height }), c.setOffset(e.mouse, e.bounds.min)) } else w = h, S = x, 1 !== e.options.pixelRatio && e.context.setTransform(e.options.pixelRatio, 0, 0, e.options.pixelRatio, 0, 0);!m.wireframes || d.enableSleeping && m.showSleeping ? i.bodies(e, S, y) : (m.showConvexHulls && i.bodyConvexHulls(e, S, y), i.bodyWireframes(e, S, y)), m.showBounds && i.bodyBounds(e, S, y), (m.showAxes || m.showAngleIndicator) && i.bodyAxes(e, S, y), m.showPositions && i.bodyPositions(e, S, y), m.showVelocity && i.bodyVelocity(e, S, y), m.showIds && i.bodyIds(e, S, y), m.showSeparations && i.separations(e, d.pairs.list, y), m.showCollisions && i.collisions(e, d.pairs.list, y), m.showVertexNumbers && i.vertexNumbers(e, S, y), m.showMousePosition && i.mousePosition(e, e.mouse, y), i.constraints(w, y), m.hasBounds && i.endViewTransform(e), s.trigger(e, "afterRender", A), g.lastElapsed = o.now() - u }, i.stats = function(e, t, n) { for (var i = e.engine, o = i.world, a = r.allBodies(o), s = 0, l = 0, c = 0; c < a.length; c += 1) s += a[c].parts.length; var u = { Part: s, Body: a.length, Cons: r.allConstraints(o).length, Comp: r.allComposites(o).length, Pair: i.pairs.list.length }; for (var d in t.fillStyle = "#0e0f19", t.fillRect(l, 0, 302.5, 44), t.font = "12px Arial", t.textBaseline = "top", t.textAlign = "right", u) { var p = u[d];
+ t.fillStyle = "#aaa", t.fillText(d, l + 55, 8), t.fillStyle = "#eee", t.fillText(p, l + 55, 26), l += 55 } }, i.performance = function(e, t) { var n = e.engine,
+ o = e.timing,
+ r = o.deltaHistory,
+ a = o.elapsedHistory,
+ s = o.timestampElapsedHistory,
+ l = o.engineDeltaHistory,
+ c = o.engineElapsedHistory,
+ d = n.timing.lastDelta,
+ p = u(r),
+ f = u(a),
+ v = u(l),
+ y = u(c),
+ m = u(s) / p || 0,
+ g = 1e3 / p || 0;
+ t.fillStyle = "#0e0f19", t.fillRect(0, 50, 370, 34), i.status(t, 10, 69, 60, 4, r.length, Math.round(g) + " fps", g / i._goodFps, (function(e) { return r[e] / p - 1 })), i.status(t, 82, 69, 60, 4, l.length, d.toFixed(2) + " dt", i._goodDelta / d, (function(e) { return l[e] / v - 1 })), i.status(t, 154, 69, 60, 4, c.length, y.toFixed(2) + " ut", 1 - y / i._goodFps, (function(e) { return c[e] / y - 1 })), i.status(t, 226, 69, 60, 4, a.length, f.toFixed(2) + " rt", 1 - f / i._goodFps, (function(e) { return a[e] / f - 1 })), i.status(t, 298, 69, 60, 4, s.length, m.toFixed(2) + " x", m * m * m, (function(e) { return (s[e] / r[e] / m || 0) - 1 })) }, i.status = function(e, t, n, i, r, a, s, l, c) { e.strokeStyle = "#888", e.fillStyle = "#444", e.lineWidth = 1, e.fillRect(t, n + 7, i, 1), e.beginPath(), e.moveTo(t, n + 7 - r * o.clamp(.4 * c(0), -2, 2)); for (var u = 0; u < i; u += 1) e.lineTo(t + u, n + 7 - (u < a ? r * o.clamp(.4 * c(u), -2, 2) : 0));
+ e.stroke(), e.fillStyle = "hsl(" + o.clamp(25 + 95 * l, 0, 120) + ",100%,60%)", e.fillRect(t, n - 7, 4, 4), e.font = "12px Arial", e.textBaseline = "middle", e.textAlign = "right", e.fillStyle = "#eee", e.fillText(s, t + i, n - 5) }, i.constraints = function(e, t) { for (var n = t, i = 0; i < e.length; i++) { var r = e[i]; if (r.render.visible && r.pointA && r.pointB) { var a, s, c = r.bodyA,
+ u = r.bodyB; if (a = c ? l.add(c.position, r.pointA) : r.pointA, "pin" === r.render.type) n.beginPath(), n.arc(a.x, a.y, 3, 0, 2 * Math.PI), n.closePath();
+ else { if (s = u ? l.add(u.position, r.pointB) : r.pointB, n.beginPath(), n.moveTo(a.x, a.y), "spring" === r.render.type)
+ for (var d, p = l.sub(s, a), f = l.perp(l.normalise(p)), v = Math.ceil(o.clamp(r.length / 5, 12, 20)), y = 1; y < v; y += 1) d = y % 2 == 0 ? 1 : -1, n.lineTo(a.x + p.x * (y / v) + f.x * d * 4, a.y + p.y * (y / v) + f.y * d * 4);
+ n.lineTo(s.x, s.y) } r.render.lineWidth && (n.lineWidth = r.render.lineWidth, n.strokeStyle = r.render.strokeStyle, n.stroke()), r.render.anchors && (n.fillStyle = r.render.strokeStyle, n.beginPath(), n.arc(a.x, a.y, 3, 0, 2 * Math.PI), n.arc(s.x, s.y, 3, 0, 2 * Math.PI), n.closePath(), n.fill()) } } }, i.bodies = function(e, t, n) { var i, o, r, a, s = n,
+ l = (e.engine, e.options),
+ c = l.showInternalEdges || !l.wireframes; for (r = 0; r < t.length; r++)
+ if ((i = t[r]).render.visible)
+ for (a = i.parts.length > 1 ? 1 : 0; a < i.parts.length; a++)
+ if ((o = i.parts[a]).render.visible) { if (l.showSleeping && i.isSleeping ? s.globalAlpha = .5 * o.render.opacity : 1 !== o.render.opacity && (s.globalAlpha = o.render.opacity), o.render.sprite && o.render.sprite.texture && !l.wireframes) { var u = o.render.sprite,
+ d = f(e, u.texture);
+ s.translate(o.position.x, o.position.y), s.rotate(o.angle), s.drawImage(d, d.width * -u.xOffset * u.xScale, d.height * -u.yOffset * u.yScale, d.width * u.xScale, d.height * u.yScale), s.rotate(-o.angle), s.translate(-o.position.x, -o.position.y) } else { if (o.circleRadius) s.beginPath(), s.arc(o.position.x, o.position.y, o.circleRadius, 0, 2 * Math.PI);
+ else { s.beginPath(), s.moveTo(o.vertices[0].x, o.vertices[0].y); for (var p = 1; p < o.vertices.length; p++) !o.vertices[p - 1].isInternal || c ? s.lineTo(o.vertices[p].x, o.vertices[p].y) : s.moveTo(o.vertices[p].x, o.vertices[p].y), o.vertices[p].isInternal && !c && s.moveTo(o.vertices[(p + 1) % o.vertices.length].x, o.vertices[(p + 1) % o.vertices.length].y);
+ s.lineTo(o.vertices[0].x, o.vertices[0].y), s.closePath() } l.wireframes ? (s.lineWidth = 1, s.strokeStyle = "#bbb", s.stroke()) : (s.fillStyle = o.render.fillStyle, o.render.lineWidth && (s.lineWidth = o.render.lineWidth, s.strokeStyle = o.render.strokeStyle, s.stroke()), s.fill()) } s.globalAlpha = 1 } }, i.bodyWireframes = function(e, t, n) { var i, o, r, a, s, l = n,
+ c = e.options.showInternalEdges; for (l.beginPath(), r = 0; r < t.length; r++)
+ if ((i = t[r]).render.visible)
+ for (s = i.parts.length > 1 ? 1 : 0; s < i.parts.length; s++) { for (o = i.parts[s], l.moveTo(o.vertices[0].x, o.vertices[0].y), a = 1; a < o.vertices.length; a++) !o.vertices[a - 1].isInternal || c ? l.lineTo(o.vertices[a].x, o.vertices[a].y) : l.moveTo(o.vertices[a].x, o.vertices[a].y), o.vertices[a].isInternal && !c && l.moveTo(o.vertices[(a + 1) % o.vertices.length].x, o.vertices[(a + 1) % o.vertices.length].y);
+ l.lineTo(o.vertices[0].x, o.vertices[0].y) } l.lineWidth = 1, l.strokeStyle = "#bbb", l.stroke() }, i.bodyConvexHulls = function(e, t, n) { var i, o, r, a = n; for (a.beginPath(), o = 0; o < t.length; o++)
+ if ((i = t[o]).render.visible && 1 !== i.parts.length) { for (a.moveTo(i.vertices[0].x, i.vertices[0].y), r = 1; r < i.vertices.length; r++) a.lineTo(i.vertices[r].x, i.vertices[r].y);
+ a.lineTo(i.vertices[0].x, i.vertices[0].y) } a.lineWidth = 1, a.strokeStyle = "rgba(255,255,255,0.2)", a.stroke() }, i.vertexNumbers = function(e, t, n) { var i, o, r, a = n; for (i = 0; i < t.length; i++) { var s = t[i].parts; for (r = s.length > 1 ? 1 : 0; r < s.length; r++) { var l = s[r]; for (o = 0; o < l.vertices.length; o++) a.fillStyle = "rgba(255,255,255,0.2)", a.fillText(i + "_" + o, l.position.x + .8 * (l.vertices[o].x - l.position.x), l.position.y + .8 * (l.vertices[o].y - l.position.y)) } } }, i.mousePosition = function(e, t, n) { var i = n;
+ i.fillStyle = "rgba(255,255,255,0.8)", i.fillText(t.position.x + " " + t.position.y, t.position.x + 5, t.position.y - 5) }, i.bodyBounds = function(e, t, n) { var i = n,
+ o = (e.engine, e.options);
+ i.beginPath(); for (var r = 0; r < t.length; r++) { if (t[r].render.visible)
+ for (var a = t[r].parts, s = a.length > 1 ? 1 : 0; s < a.length; s++) { var l = a[s];
+ i.rect(l.bounds.min.x, l.bounds.min.y, l.bounds.max.x - l.bounds.min.x, l.bounds.max.y - l.bounds.min.y) } } o.wireframes ? i.strokeStyle = "rgba(255,255,255,0.08)" : i.strokeStyle = "rgba(0,0,0,0.1)", i.lineWidth = 1, i.stroke() }, i.bodyAxes = function(e, t, n) { var i, o, r, a, s = n,
+ l = (e.engine, e.options); for (s.beginPath(), o = 0; o < t.length; o++) { var c = t[o],
+ u = c.parts; if (c.render.visible)
+ if (l.showAxes)
+ for (r = u.length > 1 ? 1 : 0; r < u.length; r++)
+ for (i = u[r], a = 0; a < i.axes.length; a++) { var d = i.axes[a];
+ s.moveTo(i.position.x, i.position.y), s.lineTo(i.position.x + 20 * d.x, i.position.y + 20 * d.y) } else
+ for (r = u.length > 1 ? 1 : 0; r < u.length; r++)
+ for (i = u[r], a = 0; a < i.axes.length; a++) s.moveTo(i.position.x, i.position.y), s.lineTo((i.vertices[0].x + i.vertices[i.vertices.length - 1].x) / 2, (i.vertices[0].y + i.vertices[i.vertices.length - 1].y) / 2) } l.wireframes ? (s.strokeStyle = "indianred", s.lineWidth = 1) : (s.strokeStyle = "rgba(255, 255, 255, 0.4)", s.globalCompositeOperation = "overlay", s.lineWidth = 2), s.stroke(), s.globalCompositeOperation = "source-over" }, i.bodyPositions = function(e, t, n) { var i, o, r, a, s = n,
+ l = (e.engine, e.options); for (s.beginPath(), r = 0; r < t.length; r++)
+ if ((i = t[r]).render.visible)
+ for (a = 0; a < i.parts.length; a++) o = i.parts[a], s.arc(o.position.x, o.position.y, 3, 0, 2 * Math.PI, !1), s.closePath(); for (l.wireframes ? s.fillStyle = "indianred" : s.fillStyle = "rgba(0,0,0,0.5)", s.fill(), s.beginPath(), r = 0; r < t.length; r++)(i = t[r]).render.visible && (s.arc(i.positionPrev.x, i.positionPrev.y, 2, 0, 2 * Math.PI, !1), s.closePath());
+ s.fillStyle = "rgba(255,165,0,0.8)", s.fill() }, i.bodyVelocity = function(e, t, n) { var i = n;
+ i.beginPath(); for (var o = 0; o < t.length; o++) { var r = t[o];
+ r.render.visible && (i.moveTo(r.position.x, r.position.y), i.lineTo(r.position.x + 2 * (r.position.x - r.positionPrev.x), r.position.y + 2 * (r.position.y - r.positionPrev.y))) } i.lineWidth = 3, i.strokeStyle = "cornflowerblue", i.stroke() }, i.bodyIds = function(e, t, n) { var i, o, r = n; for (i = 0; i < t.length; i++)
+ if (t[i].render.visible) { var a = t[i].parts; for (o = a.length > 1 ? 1 : 0; o < a.length; o++) { var s = a[o];
+ r.font = "12px Arial", r.fillStyle = "rgba(255,255,255,0.5)", r.fillText(s.id, s.position.x + 10, s.position.y - 10) } } }, i.collisions = function(e, t, n) { var i, o, r, a, s = n,
+ l = e.options; for (s.beginPath(), r = 0; r < t.length; r++)
+ if ((i = t[r]).isActive)
+ for (o = i.collision, a = 0; a < i.activeContacts.length; a++) { var c = i.activeContacts[a].vertex;
+ s.rect(c.x - 1.5, c.y - 1.5, 3.5, 3.5) }
+ for (l.wireframes ? s.fillStyle = "rgba(255,255,255,0.7)" : s.fillStyle = "orange", s.fill(), s.beginPath(), r = 0; r < t.length; r++)
+ if ((i = t[r]).isActive && (o = i.collision, i.activeContacts.length > 0)) { var u = i.activeContacts[0].vertex.x,
+ d = i.activeContacts[0].vertex.y;
+ 2 === i.activeContacts.length && (u = (i.activeContacts[0].vertex.x + i.activeContacts[1].vertex.x) / 2, d = (i.activeContacts[0].vertex.y + i.activeContacts[1].vertex.y) / 2), o.bodyB === o.supports[0].body || !0 === o.bodyA.isStatic ? s.moveTo(u - 8 * o.normal.x, d - 8 * o.normal.y) : s.moveTo(u + 8 * o.normal.x, d + 8 * o.normal.y), s.lineTo(u, d) } l.wireframes ? s.strokeStyle = "rgba(255,165,0,0.7)" : s.strokeStyle = "orange", s.lineWidth = 1, s.stroke() }, i.separations = function(e, t, n) { var i, o, r, a, s, l = n,
+ c = e.options; for (l.beginPath(), s = 0; s < t.length; s++)
+ if ((i = t[s]).isActive) { r = (o = i.collision).bodyA; var u = 1;
+ (a = o.bodyB).isStatic || r.isStatic || (u = .5), a.isStatic && (u = 0), l.moveTo(a.position.x, a.position.y), l.lineTo(a.position.x - o.penetration.x * u, a.position.y - o.penetration.y * u), u = 1, a.isStatic || r.isStatic || (u = .5), r.isStatic && (u = 0), l.moveTo(r.position.x, r.position.y), l.lineTo(r.position.x + o.penetration.x * u, r.position.y + o.penetration.y * u) } c.wireframes ? l.strokeStyle = "rgba(255,165,0,0.5)" : l.strokeStyle = "orange", l.stroke() }, i.inspector = function(e, t) { e.engine; var n, i = e.selected,
+ o = e.render,
+ r = o.options; if (r.hasBounds) { var a = o.bounds.max.x - o.bounds.min.x,
+ s = o.bounds.max.y - o.bounds.min.y,
+ l = a / o.options.width,
+ c = s / o.options.height;
+ t.scale(1 / l, 1 / c), t.translate(-o.bounds.min.x, -o.bounds.min.y) } for (var u = 0; u < i.length; u++) { var d = i[u].data; switch (t.translate(.5, .5), t.lineWidth = 1, t.strokeStyle = "rgba(255,165,0,0.9)", t.setLineDash([1, 2]), d.type) {
+ case "body":
+ n = d.bounds, t.beginPath(), t.rect(Math.floor(n.min.x - 3), Math.floor(n.min.y - 3), Math.floor(n.max.x - n.min.x + 6), Math.floor(n.max.y - n.min.y + 6)), t.closePath(), t.stroke(); break;
+ case "constraint":
+ var p = d.pointA;
+ d.bodyA && (p = d.pointB), t.beginPath(), t.arc(p.x, p.y, 10, 0, 2 * Math.PI), t.closePath(), t.stroke() } t.setLineDash([]), t.translate(-.5, -.5) } null !== e.selectStart && (t.translate(.5, .5), t.lineWidth = 1, t.strokeStyle = "rgba(255,165,0,0.6)", t.fillStyle = "rgba(255,165,0,0.1)", n = e.selectBounds, t.beginPath(), t.rect(Math.floor(n.min.x), Math.floor(n.min.y), Math.floor(n.max.x - n.min.x), Math.floor(n.max.y - n.min.y)), t.closePath(), t.stroke(), t.fill(), t.translate(-.5, -.5)), r.hasBounds && t.setTransform(1, 0, 0, 1, 0, 0) }; var n = function(e, t) { var n = e.engine,
+ o = e.timing,
+ r = o.historySize,
+ a = n.timing.timestamp;
+ o.delta = t - o.lastTime || i._goodDelta, o.lastTime = t, o.timestampElapsed = a - o.lastTimestamp || 0, o.lastTimestamp = a, o.deltaHistory.unshift(o.delta), o.deltaHistory.length = Math.min(o.deltaHistory.length, r), o.engineDeltaHistory.unshift(n.timing.lastDelta), o.engineDeltaHistory.length = Math.min(o.engineDeltaHistory.length, r), o.timestampElapsedHistory.unshift(o.timestampElapsed), o.timestampElapsedHistory.length = Math.min(o.timestampElapsedHistory.length, r), o.engineElapsedHistory.unshift(n.timing.lastElapsed), o.engineElapsedHistory.length = Math.min(o.engineElapsedHistory.length, r), o.elapsedHistory.unshift(o.lastElapsed), o.elapsedHistory.length = Math.min(o.elapsedHistory.length, r) },
+ u = function(e) { for (var t = 0, n = 0; n < e.length; n += 1) t += e[n]; return t / e.length || 0 },
+ d = function(e, t) { var n = document.createElement("canvas"); return n.width = e, n.height = t, n.oncontextmenu = function() { return !1 }, n.onselectstart = function() { return !1 }, n },
+ p = function(e) { var t = e.getContext("2d"); return (window.devicePixelRatio || 1) / (t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1) },
+ f = function(e, t) { var n = e.textures[t]; return n || ((n = e.textures[t] = new Image).src = t, n) },
+ v = function(e, t) { var n = t; /(jpg|gif|png)$/.test(t) && (n = "url(" + t + ")"), e.canvas.style.background = n, e.canvas.style.backgroundSize = "contain", e.currentBackground = t } }() }, function(e, t) { var n = {};
+ e.exports = n, n.create = function(e) { return { vertex: e, normalImpulse: 0, tangentImpulse: 0 } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(7),
+ r = n(19),
+ a = n(14),
+ s = n(20),
+ l = n(4),
+ c = n(5),
+ u = n(10),
+ d = n(0),
+ p = n(6);
+ i.create = function(e) { e = e || {}; var t = d.extend({ positionIterations: 6, velocityIterations: 4, constraintIterations: 2, enableSleeping: !1, events: [], plugin: {}, gravity: { x: 0, y: 1, scale: .001 }, timing: { timestamp: 0, timeScale: 1, lastDelta: 0, lastElapsed: 0 } }, e); return t.world = e.world || c.create({ label: "World" }), t.pairs = e.pairs || s.create(), t.detector = e.detector || a.create(), t.grid = { buckets: [] }, t.world.gravity = t.gravity, t.broadphase = t.grid, t.metrics = {}, t }, i.update = function(e, t, n) { var p = d.now();
+ t = t || 1e3 / 60, n = n || 1; var f, v = e.world,
+ y = e.detector,
+ m = e.pairs,
+ g = e.timing,
+ x = g.timestamp;
+ g.timestamp += t * g.timeScale, g.lastDelta = t * g.timeScale; var h = { timestamp: g.timestamp };
+ l.trigger(e, "beforeUpdate", h); var b = c.allBodies(v),
+ S = c.allConstraints(v); for (v.isModified && a.setBodies(y, b), v.isModified && c.setModified(v, !1, !1, !0), e.enableSleeping && o.update(b, g.timeScale), i._bodiesApplyGravity(b, e.gravity), i._bodiesUpdate(b, t, g.timeScale, n, v.bounds), u.preSolveAll(b), f = 0; f < e.constraintIterations; f++) u.solveAll(S, g.timeScale);
+ u.postSolveAll(b), y.pairs = e.pairs; var w = a.collisions(y); for (s.update(m, w, x), e.enableSleeping && o.afterCollisions(m.list, g.timeScale), m.collisionStart.length > 0 && l.trigger(e, "collisionStart", { pairs: m.collisionStart }), r.preSolvePosition(m.list), f = 0; f < e.positionIterations; f++) r.solvePosition(m.list, g.timeScale); for (r.postSolvePosition(b), u.preSolveAll(b), f = 0; f < e.constraintIterations; f++) u.solveAll(S, g.timeScale); for (u.postSolveAll(b), r.preSolveVelocity(m.list), f = 0; f < e.velocityIterations; f++) r.solveVelocity(m.list, g.timeScale); return m.collisionActive.length > 0 && l.trigger(e, "collisionActive", { pairs: m.collisionActive }), m.collisionEnd.length > 0 && l.trigger(e, "collisionEnd", { pairs: m.collisionEnd }), i._bodiesClearForces(b), l.trigger(e, "afterUpdate", h), e.timing.lastElapsed = d.now() - p, e }, i.merge = function(e, t) { if (d.extend(e, t), t.world) { e.world = t.world, i.clear(e); for (var n = c.allBodies(e.world), r = 0; r < n.length; r++) { var a = n[r];
+ o.set(a, !1), a.id = d.nextId() } } }, i.clear = function(e) { s.clear(e.pairs), a.clear(e.detector) }, i._bodiesClearForces = function(e) { for (var t = 0; t < e.length; t++) { var n = e[t];
+ n.force.x = 0, n.force.y = 0, n.torque = 0 } }, i._bodiesApplyGravity = function(e, t) { var n = void 0 !== t.scale ? t.scale : .001; if ((0 !== t.x || 0 !== t.y) && 0 !== n)
+ for (var i = 0; i < e.length; i++) { var o = e[i];
+ o.isStatic || o.isSleeping || (o.force.y += o.mass * t.y * n, o.force.x += o.mass * t.x * n) } }, i._bodiesUpdate = function(e, t, n, i, o) { for (var r = 0; r < e.length; r++) { var a = e[r];
+ a.isStatic || a.isSleeping || p.update(a, t, n, i) } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(3),
+ r = n(1);
+ i._restingThresh = 4, i._restingThreshTangent = 6, i._positionDampen = .9, i._positionWarming = .8, i._frictionNormalMultiplier = 5, i.preSolvePosition = function(e) { var t, n, i, o = e.length; for (t = 0; t < o; t++)(n = e[t]).isActive && (i = n.activeContacts.length, n.collision.parentA.totalContacts += i, n.collision.parentB.totalContacts += i) }, i.solvePosition = function(e, t) { var n, o, r, a, s, l, c, u, d = i._positionDampen,
+ p = e.length; for (n = 0; n < p; n++)(o = e[n]).isActive && !o.isSensor && (a = (r = o.collision).parentA, s = r.parentB, l = r.normal, o.separation = l.x * (s.positionImpulse.x + r.penetration.x - a.positionImpulse.x) + l.y * (s.positionImpulse.y + r.penetration.y - a.positionImpulse.y)); for (n = 0; n < p; n++)(o = e[n]).isActive && !o.isSensor && (a = (r = o.collision).parentA, s = r.parentB, l = r.normal, u = (o.separation - o.slop) * t, (a.isStatic || s.isStatic) && (u *= 2), a.isStatic || a.isSleeping || (c = d / a.totalContacts, a.positionImpulse.x += l.x * u * c, a.positionImpulse.y += l.y * u * c), s.isStatic || s.isSleeping || (c = d / s.totalContacts, s.positionImpulse.x -= l.x * u * c, s.positionImpulse.y -= l.y * u * c)) }, i.postSolvePosition = function(e) { for (var t = i._positionWarming, n = e.length, a = o.translate, s = r.update, l = 0; l < n; l++) { var c = e[l],
+ u = c.positionImpulse,
+ d = u.x,
+ p = u.y,
+ f = c.velocity; if (c.totalContacts = 0, 0 !== d || 0 !== p) { for (var v = 0; v < c.parts.length; v++) { var y = c.parts[v];
+ a(y.vertices, u), s(y.bounds, y.vertices, f), y.position.x += d, y.position.y += p } c.positionPrev.x += d, c.positionPrev.y += p, d * f.x + p * f.y < 0 ? (u.x = 0, u.y = 0) : (u.x *= t, u.y *= t) } } }, i.preSolveVelocity = function(e) { var t, n, i = e.length; for (t = 0; t < i; t++) { var o = e[t]; if (o.isActive && !o.isSensor) { var r = o.activeContacts,
+ a = r.length,
+ s = o.collision,
+ l = s.parentA,
+ c = s.parentB,
+ u = s.normal,
+ d = s.tangent; for (n = 0; n < a; n++) { var p = r[n],
+ f = p.vertex,
+ v = p.normalImpulse,
+ y = p.tangentImpulse; if (0 !== v || 0 !== y) { var m = u.x * v + d.x * y,
+ g = u.y * v + d.y * y;
+ l.isStatic || l.isSleeping || (l.positionPrev.x += m * l.inverseMass, l.positionPrev.y += g * l.inverseMass, l.anglePrev += l.inverseInertia * ((f.x - l.position.x) * g - (f.y - l.position.y) * m)), c.isStatic || c.isSleeping || (c.positionPrev.x -= m * c.inverseMass, c.positionPrev.y -= g * c.inverseMass, c.anglePrev -= c.inverseInertia * ((f.x - c.position.x) * g - (f.y - c.position.y) * m)) } } } } }, i.solveVelocity = function(e, t) { var n, o, r, a, s = t * t,
+ l = i._restingThresh * s,
+ c = i._frictionNormalMultiplier,
+ u = i._restingThreshTangent * s,
+ d = Number.MAX_VALUE,
+ p = e.length; for (r = 0; r < p; r++) { var f = e[r]; if (f.isActive && !f.isSensor) { var v = f.collision,
+ y = v.parentA,
+ m = v.parentB,
+ g = y.velocity,
+ x = m.velocity,
+ h = v.normal.x,
+ b = v.normal.y,
+ S = v.tangent.x,
+ w = v.tangent.y,
+ A = f.activeContacts,
+ P = A.length,
+ C = 1 / P,
+ B = y.inverseMass + m.inverseMass,
+ M = f.friction * f.frictionStatic * c * s; for (g.x = y.position.x - y.positionPrev.x, g.y = y.position.y - y.positionPrev.y, x.x = m.position.x - m.positionPrev.x, x.y = m.position.y - m.positionPrev.y, y.angularVelocity = y.angle - y.anglePrev, m.angularVelocity = m.angle - m.anglePrev, a = 0; a < P; a++) { var k = A[a],
+ _ = k.vertex,
+ I = _.x - y.position.x,
+ T = _.y - y.position.y,
+ R = _.x - m.position.x,
+ E = _.y - m.position.y,
+ V = g.x - T * y.angularVelocity,
+ L = g.y + I * y.angularVelocity,
+ O = V - (x.x - E * m.angularVelocity),
+ D = L - (x.y + R * m.angularVelocity),
+ F = h * O + b * D,
+ H = S * O + w * D,
+ j = f.separation + F,
+ q = Math.min(j, 1),
+ W = (q = j < 0 ? 0 : q) * M;
+ H > W || -H > W ? (o = H > 0 ? H : -H, (n = f.friction * (H > 0 ? 1 : -1) * s) < -o ? n = -o : n > o && (n = o)) : (n = H, o = d); var G = I * b - T * h,
+ N = R * b - E * h,
+ U = C / (B + y.inverseInertia * G * G + m.inverseInertia * N * N),
+ z = (1 + f.restitution) * F * U; if (n *= U, F * F > l && F < 0) k.normalImpulse = 0;
+ else { var X = k.normalImpulse;
+ k.normalImpulse += z, k.normalImpulse = Math.min(k.normalImpulse, 0), z = k.normalImpulse - X } if (H * H > u) k.tangentImpulse = 0;
+ else { var Q = k.tangentImpulse;
+ k.tangentImpulse += n, k.tangentImpulse < -o && (k.tangentImpulse = -o), k.tangentImpulse > o && (k.tangentImpulse = o), n = k.tangentImpulse - Q } var Y = h * z + S * n,
+ Z = b * z + w * n;
+ y.isStatic || y.isSleeping || (y.positionPrev.x += Y * y.inverseMass, y.positionPrev.y += Z * y.inverseMass, y.anglePrev += (I * Z - T * Y) * y.inverseInertia), m.isStatic || m.isSleeping || (m.positionPrev.x -= Y * m.inverseMass, m.positionPrev.y -= Z * m.inverseMass, m.anglePrev -= (R * Z - E * Y) * m.inverseInertia) } } } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(9),
+ r = n(0);
+ i.create = function(e) { return r.extend({ table: {}, list: [], collisionStart: [], collisionActive: [], collisionEnd: [] }, e) }, i.update = function(e, t, n) { var i, r, a, s, l, c, u = e.list,
+ d = u.length,
+ p = e.table,
+ f = t.length,
+ v = e.collisionStart,
+ y = e.collisionEnd,
+ m = e.collisionActive; for (v.length = 0, y.length = 0, m.length = 0, c = 0; c < d; c++) u[c].confirmedActive = !1; for (c = 0; c < f; c++)(l = (i = t[c]).pair) ? (l.isActive ? m.push(l) : v.push(l), o.update(l, i, n), l.confirmedActive = !0) : (p[(l = o.create(i, n)).id] = l, v.push(l), u.push(l)); var g = []; for (d = u.length, c = 0; c < d; c++)(l = u[c]).confirmedActive || (r = l.collision.bodyA, a = l.collision.bodyB, (!r.isSleeping && !r.isStatic || !a.isSleeping && !a.isStatic || r.isStatic && a.isStatic) && (o.setActive(l, !1, n), y.push(l), g.push(c))); for (c = 0; c < g.length; c++) l = u[s = g[c] - c], u.splice(s, 1), delete p[l.id] }, i.clear = function(e) { return e.table = {}, e.list.length = 0, e.collisionStart.length = 0, e.collisionActive.length = 0, e.collisionEnd.length = 0, e } }, function(e, t, n) { var i = e.exports = n(22);
+ i.Axes = n(11), i.Bodies = n(12), i.Body = n(6), i.Bounds = n(1), i.Collision = n(8), i.Common = n(0), i.Composite = n(5), i.Composites = n(23), i.Constraint = n(10), i.Contact = n(17), i.Detector = n(14), i.Engine = n(18), i.Events = n(4), i.Grid = n(24), i.Mouse = n(13), i.MouseConstraint = n(25), i.Pair = n(9), i.Pairs = n(20), i.Plugin = n(15), i.Query = n(26), i.Render = n(16), i.Resolver = n(19), i.Runner = n(27), i.SAT = n(28), i.Sleeping = n(7), i.Svg = n(29), i.Vector = n(2), i.Vertices = n(3), i.World = n(30), i.Engine.run = i.Runner.run, i.Common.deprecated(i.Engine, "run", "Engine.run ➤ use Matter.Runner.run(engine) instead") }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(15),
+ r = n(0);
+ i.name = "matter-js", i.version = "0.18.0-alpha+0eeceb5", i.uses = [], i.used = [], i.use = function() { o.use(i, Array.prototype.slice.call(arguments)) }, i.before = function(e, t) { return e = e.replace(/^Matter./, ""), r.chainPathBefore(i, e, t) }, i.after = function(e, t) { return e = e.replace(/^Matter./, ""), r.chainPathAfter(i, e, t) } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(5),
+ r = n(10),
+ a = n(0),
+ s = n(6),
+ l = n(12),
+ c = a.deprecated;
+ i.stack = function(e, t, n, i, r, a, l) { for (var c, u = o.create({ label: "Stack" }), d = e, p = t, f = 0, v = 0; v < i; v++) { for (var y = 0, m = 0; m < n; m++) { var g = l(d, p, m, v, c, f); if (g) { var x = g.bounds.max.y - g.bounds.min.y,
+ h = g.bounds.max.x - g.bounds.min.x;
+ x > y && (y = x), s.translate(g, { x: .5 * h, y: .5 * x }), d = g.bounds.max.x + r, o.addBody(u, g), c = g, f += 1 } else d += r } p += y + a, d = e } return u }, i.chain = function(e, t, n, i, s, l) { for (var c = e.bodies, u = 1; u < c.length; u++) { var d = c[u - 1],
+ p = c[u],
+ f = d.bounds.max.y - d.bounds.min.y,
+ v = d.bounds.max.x - d.bounds.min.x,
+ y = p.bounds.max.y - p.bounds.min.y,
+ m = { bodyA: d, pointA: { x: v * t, y: f * n }, bodyB: p, pointB: { x: (p.bounds.max.x - p.bounds.min.x) * i, y: y * s } },
+ g = a.extend(m, l);
+ o.addConstraint(e, r.create(g)) } return e.label += " Chain", e }, i.mesh = function(e, t, n, i, s) { var l, c, u, d, p, f = e.bodies; for (l = 0; l < n; l++) { for (c = 1; c < t; c++) u = f[c - 1 + l * t], d = f[c + l * t], o.addConstraint(e, r.create(a.extend({ bodyA: u, bodyB: d }, s))); if (l > 0)
+ for (c = 0; c < t; c++) u = f[c + (l - 1) * t], d = f[c + l * t], o.addConstraint(e, r.create(a.extend({ bodyA: u, bodyB: d }, s))), i && c > 0 && (p = f[c - 1 + (l - 1) * t], o.addConstraint(e, r.create(a.extend({ bodyA: p, bodyB: d }, s)))), i && c < t - 1 && (p = f[c + 1 + (l - 1) * t], o.addConstraint(e, r.create(a.extend({ bodyA: p, bodyB: d }, s)))) } return e.label += " Mesh", e }, i.pyramid = function(e, t, n, o, r, a, l) { return i.stack(e, t, n, o, r, a, (function(t, i, a, c, u, d) { var p = Math.min(o, Math.ceil(n / 2)),
+ f = u ? u.bounds.max.x - u.bounds.min.x : 0; if (!(c > p || a < (c = p - c) || a > n - 1 - c)) return 1 === d && s.translate(u, { x: (a + (n % 2 == 1 ? 1 : -1)) * f, y: 0 }), l(e + (u ? a * f : 0) + a * r, i, a, c, u, d) })) }, i.newtonsCradle = function(e, t, n, i, a) { for (var s = o.create({ label: "Newtons Cradle" }), c = 0; c < n; c++) { var u = l.circle(e + c * (1.9 * i), t + a, i, { inertia: 1 / 0, restitution: 1, friction: 0, frictionAir: 1e-4, slop: 1 }),
+ d = r.create({ pointA: { x: e + c * (1.9 * i), y: t }, bodyB: u });
+ o.addBody(s, u), o.addConstraint(s, d) } return s }, c(i, "newtonsCradle", "Composites.newtonsCradle ➤ moved to newtonsCradle example"), i.car = function(e, t, n, i, a) { var c = s.nextGroup(!0),
+ u = .5 * -n + 20,
+ d = .5 * n - 20,
+ p = o.create({ label: "Car" }),
+ f = l.rectangle(e, t, n, i, { collisionFilter: { group: c }, chamfer: { radius: .5 * i }, density: 2e-4 }),
+ v = l.circle(e + u, t + 0, a, { collisionFilter: { group: c }, friction: .8 }),
+ y = l.circle(e + d, t + 0, a, { collisionFilter: { group: c }, friction: .8 }),
+ m = r.create({ bodyB: f, pointB: { x: u, y: 0 }, bodyA: v, stiffness: 1, length: 0 }),
+ g = r.create({ bodyB: f, pointB: { x: d, y: 0 }, bodyA: y, stiffness: 1, length: 0 }); return o.addBody(p, f), o.addBody(p, v), o.addBody(p, y), o.addConstraint(p, m), o.addConstraint(p, g), p }, c(i, "car", "Composites.car ➤ moved to car example"), i.softBody = function(e, t, n, o, r, s, c, u, d, p) { d = a.extend({ inertia: 1 / 0 }, d), p = a.extend({ stiffness: .2, render: { type: "line", anchors: !1 } }, p); var f = i.stack(e, t, n, o, r, s, (function(e, t) { return l.circle(e, t, u, d) })); return i.mesh(f, n, o, c, p), f.label = "Soft Body", f }, c(i, "softBody", "Composites.softBody ➤ moved to softBody and cloth examples") }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(9),
+ r = n(0),
+ a = r.deprecated;
+ i.create = function(e) { return r.extend({ buckets: {}, pairs: {}, pairsList: [], bucketWidth: 48, bucketHeight: 48 }, e) }, i.update = function(e, t, n, o) { var r, a, s, l, c, u = n.world,
+ d = e.buckets,
+ p = !1; for (r = 0; r < t.length; r++) { var f = t[r]; if ((!f.isSleeping || o) && (!u.bounds || !(f.bounds.max.x < u.bounds.min.x || f.bounds.min.x > u.bounds.max.x || f.bounds.max.y < u.bounds.min.y || f.bounds.min.y > u.bounds.max.y))) { var v = i._getRegion(e, f); if (!f.region || v.id !== f.region.id || o) { f.region && !o || (f.region = v); var y = i._regionUnion(v, f.region); for (a = y.startCol; a <= y.endCol; a++)
+ for (s = y.startRow; s <= y.endRow; s++) { l = d[c = i._getBucketId(a, s)]; var m = a >= v.startCol && a <= v.endCol && s >= v.startRow && s <= v.endRow,
+ g = a >= f.region.startCol && a <= f.region.endCol && s >= f.region.startRow && s <= f.region.endRow;!m && g && g && l && i._bucketRemoveBody(e, l, f), (f.region === v || m && !g || o) && (l || (l = i._createBucket(d, c)), i._bucketAddBody(e, l, f)) } f.region = v, p = !0 } } } p && (e.pairsList = i._createActivePairsList(e)) }, a(i, "update", "Grid.update ➤ replaced by Matter.Detector"), i.clear = function(e) { e.buckets = {}, e.pairs = {}, e.pairsList = [] }, a(i, "clear", "Grid.clear ➤ replaced by Matter.Detector"), i._regionUnion = function(e, t) { var n = Math.min(e.startCol, t.startCol),
+ o = Math.max(e.endCol, t.endCol),
+ r = Math.min(e.startRow, t.startRow),
+ a = Math.max(e.endRow, t.endRow); return i._createRegion(n, o, r, a) }, i._getRegion = function(e, t) { var n = t.bounds,
+ o = Math.floor(n.min.x / e.bucketWidth),
+ r = Math.floor(n.max.x / e.bucketWidth),
+ a = Math.floor(n.min.y / e.bucketHeight),
+ s = Math.floor(n.max.y / e.bucketHeight); return i._createRegion(o, r, a, s) }, i._createRegion = function(e, t, n, i) { return { id: e + "," + t + "," + n + "," + i, startCol: e, endCol: t, startRow: n, endRow: i } }, i._getBucketId = function(e, t) { return "C" + e + "R" + t }, i._createBucket = function(e, t) { return e[t] = [] }, i._bucketAddBody = function(e, t, n) { var i, r = e.pairs,
+ a = o.id,
+ s = t.length; for (i = 0; i < s; i++) { var l = t[i]; if (!(n.id === l.id || n.isStatic && l.isStatic)) { var c = a(n, l),
+ u = r[c];
+ u ? u[2] += 1 : r[c] = [n, l, 1] } } t.push(n) }, i._bucketRemoveBody = function(e, t, n) { var i, a = e.pairs,
+ s = o.id;
+ t.splice(r.indexOf(t, n), 1); var l = t.length; for (i = 0; i < l; i++) { var c = a[s(n, t[i])];
+ c && (c[2] -= 1) } }, i._createActivePairsList = function(e) { var t, n, i = e.pairs,
+ o = r.keys(i),
+ a = o.length,
+ s = []; for (n = 0; n < a; n++)(t = i[o[n]])[2] > 0 ? s.push(t) : delete i[o[n]]; return s } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(3),
+ r = n(7),
+ a = n(13),
+ s = n(4),
+ l = n(14),
+ c = n(10),
+ u = n(5),
+ d = n(0),
+ p = n(1);
+ i.create = function(e, t) { var n = (e ? e.mouse : null) || (t ? t.mouse : null);
+ n || (e && e.render && e.render.canvas ? n = a.create(e.render.canvas) : t && t.element ? n = a.create(t.element) : (n = a.create(), d.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected"))); var o = { type: "mouseConstraint", mouse: n, element: null, body: null, constraint: c.create({ label: "Mouse Constraint", pointA: n.position, pointB: { x: 0, y: 0 }, length: .01, stiffness: .1, angularStiffness: 1, render: { strokeStyle: "#90EE90", lineWidth: 3 } }), collisionFilter: { category: 1, mask: 4294967295, group: 0 } },
+ r = d.extend(o, t); return s.on(e, "beforeUpdate", (function() { var t = u.allBodies(e.world);
+ i.update(r, t), i._triggerEvents(r) })), r }, i.update = function(e, t) { var n = e.mouse,
+ i = e.constraint,
+ a = e.body; if (0 === n.button) { if (i.bodyB) r.set(i.bodyB, !1), i.pointA = n.position;
+ else
+ for (var c = 0; c < t.length; c++)
+ if (a = t[c], p.contains(a.bounds, n.position) && l.canCollide(a.collisionFilter, e.collisionFilter))
+ for (var u = a.parts.length > 1 ? 1 : 0; u < a.parts.length; u++) { var d = a.parts[u]; if (o.contains(d.vertices, n.position)) { i.pointA = n.position, i.bodyB = e.body = a, i.pointB = { x: n.position.x - a.position.x, y: n.position.y - a.position.y }, i.angleB = a.angle, r.set(a, !1), s.trigger(e, "startdrag", { mouse: n, body: a }); break } } } else i.bodyB = e.body = null, i.pointB = null, a && s.trigger(e, "enddrag", { mouse: n, body: a }) }, i._triggerEvents = function(e) { var t = e.mouse,
+ n = t.sourceEvents;
+ n.mousemove && s.trigger(e, "mousemove", { mouse: t }), n.mousedown && s.trigger(e, "mousedown", { mouse: t }), n.mouseup && s.trigger(e, "mouseup", { mouse: t }), a.clearSourceEvents(t) } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(2),
+ r = n(8),
+ a = n(1),
+ s = n(12),
+ l = n(3);
+ i.collides = function(e, t) { for (var n = [], i = t.length, o = e.bounds, s = r.collides, l = a.overlaps, c = 0; c < i; c++) { var u = t[c],
+ d = u.parts.length,
+ p = 1 === d ? 0 : 1; if (l(u.bounds, o))
+ for (var f = p; f < d; f++) { var v = u.parts[f]; if (l(v.bounds, o)) { var y = s(v, e); if (y) { n.push(y); break } } } } return n }, i.ray = function(e, t, n, r) { r = r || 1e-100; for (var a = o.angle(t, n), l = o.magnitude(o.sub(t, n)), c = .5 * (n.x + t.x), u = .5 * (n.y + t.y), d = s.rectangle(c, u, l, r, { angle: a }), p = i.collides(d, e), f = 0; f < p.length; f += 1) { var v = p[f];
+ v.body = v.bodyB = v.bodyA } return p }, i.region = function(e, t, n) { for (var i = [], o = 0; o < e.length; o++) { var r = e[o],
+ s = a.overlaps(r.bounds, t);
+ (s && !n || !s && n) && i.push(r) } return i }, i.point = function(e, t) { for (var n = [], i = 0; i < e.length; i++) { var o = e[i]; if (a.contains(o.bounds, t))
+ for (var r = 1 === o.parts.length ? 0 : 1; r < o.parts.length; r++) { var s = o.parts[r]; if (a.contains(s.bounds, t) && l.contains(s.vertices, t)) { n.push(o); break } } } return n } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(4),
+ r = n(18),
+ a = n(0);! function() { var e, t, n;
+ ("undefined" != typeof window && (e = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame, t = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame), e) || (e = function(e) { n = setTimeout((function() { e(a.now()) }), 1e3 / 60) }, t = function() { clearTimeout(n) });
+ i.create = function(e) { var t = a.extend({ fps: 60, correction: 1, deltaSampleSize: 60, counterTimestamp: 0, frameCounter: 0, deltaHistory: [], timePrev: null, timeScalePrev: 1, frameRequestId: null, isFixed: !1, enabled: !0 }, e); return t.delta = t.delta || 1e3 / t.fps, t.deltaMin = t.deltaMin || 1e3 / t.fps, t.deltaMax = t.deltaMax || 1e3 / (.5 * t.fps), t.fps = 1e3 / t.delta, t }, i.run = function(t, n) { return void 0 !== t.positionIterations && (n = t, t = i.create()),
+ function o(r) { t.frameRequestId = e(o), r && t.enabled && i.tick(t, n, r) }(), t }, i.tick = function(e, t, n) { var i, a = t.timing,
+ s = 1,
+ l = { timestamp: a.timestamp };
+ o.trigger(e, "beforeTick", l), e.isFixed ? i = e.delta : (i = n - e.timePrev || e.delta, e.timePrev = n, e.deltaHistory.push(i), e.deltaHistory = e.deltaHistory.slice(-e.deltaSampleSize), s = (i = (i = (i = Math.min.apply(null, e.deltaHistory)) < e.deltaMin ? e.deltaMin : i) > e.deltaMax ? e.deltaMax : i) / e.delta, e.delta = i), 0 !== e.timeScalePrev && (s *= a.timeScale / e.timeScalePrev), 0 === a.timeScale && (s = 0), e.timeScalePrev = a.timeScale, e.correction = s, e.frameCounter += 1, n - e.counterTimestamp >= 1e3 && (e.fps = e.frameCounter * ((n - e.counterTimestamp) / 1e3), e.counterTimestamp = n, e.frameCounter = 0), o.trigger(e, "tick", l), o.trigger(e, "beforeUpdate", l), r.update(t, i, s), o.trigger(e, "afterUpdate", l), o.trigger(e, "afterTick", l) }, i.stop = function(e) { t(e.frameRequestId) }, i.start = function(e, t) { i.run(e, t) } }() }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(8),
+ r = n(0).deprecated;
+ i.collides = function(e, t) { return o.collides(e, t) }, r(i, "collides", "SAT.collides ➤ replaced by Collision.collides") }, function(e, t, n) { var i = {};
+ e.exports = i;
+ n(1); var o = n(0);
+ i.pathToVertices = function(e, t) { "undefined" == typeof window || "SVGPathSeg" in window || o.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required."); var n, r, a, s, l, c, u, d, p, f, v, y = [],
+ m = 0,
+ g = 0,
+ x = 0;
+ t = t || 15; var h = function(e, t, n) { var i = n % 2 == 1 && n > 1; if (!p || e != p.x || t != p.y) { p && i ? (f = p.x, v = p.y) : (f = 0, v = 0); var o = { x: f + e, y: v + t };!i && p || (p = o), y.push(o), g = f + e, x = v + t } },
+ b = function(e) { var t = e.pathSegTypeAsLetter.toUpperCase(); if ("Z" !== t) { switch (t) {
+ case "M":
+ case "L":
+ case "T":
+ case "C":
+ case "S":
+ case "Q":
+ g = e.x, x = e.y; break;
+ case "H":
+ g = e.x; break;
+ case "V":
+ x = e.y } h(g, x, e.pathSegType) } }; for (i._svgPathToAbsolute(e), a = e.getTotalLength(), c = [], n = 0; n < e.pathSegList.numberOfItems; n += 1) c.push(e.pathSegList.getItem(n)); for (u = c.concat(); m < a;) { if ((l = c[e.getPathSegAtLength(m)]) != d) { for (; u.length && u[0] != l;) b(u.shift());
+ d = l } switch (l.pathSegTypeAsLetter.toUpperCase()) {
+ case "C":
+ case "T":
+ case "S":
+ case "Q":
+ case "A":
+ s = e.getPointAtLength(m), h(s.x, s.y, 0) } m += t } for (n = 0, r = u.length; n < r; ++n) b(u[n]); return y }, i._svgPathToAbsolute = function(e) { for (var t, n, i, o, r, a, s = e.pathSegList, l = 0, c = 0, u = s.numberOfItems, d = 0; d < u; ++d) { var p = s.getItem(d),
+ f = p.pathSegTypeAsLetter; if (/[MLHVCSQTA]/.test(f)) "x" in p && (l = p.x), "y" in p && (c = p.y);
+ else switch ("x1" in p && (i = l + p.x1), "x2" in p && (r = l + p.x2), "y1" in p && (o = c + p.y1), "y2" in p && (a = c + p.y2), "x" in p && (l += p.x), "y" in p && (c += p.y), f) {
+ case "m":
+ s.replaceItem(e.createSVGPathSegMovetoAbs(l, c), d); break;
+ case "l":
+ s.replaceItem(e.createSVGPathSegLinetoAbs(l, c), d); break;
+ case "h":
+ s.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l), d); break;
+ case "v":
+ s.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c), d); break;
+ case "c":
+ s.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l, c, i, o, r, a), d); break;
+ case "s":
+ s.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l, c, r, a), d); break;
+ case "q":
+ s.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l, c, i, o), d); break;
+ case "t":
+ s.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l, c), d); break;
+ case "a":
+ s.replaceItem(e.createSVGPathSegArcAbs(l, c, p.r1, p.r2, p.angle, p.largeArcFlag, p.sweepFlag), d); break;
+ case "z":
+ case "Z":
+ l = t, c = n }
+ "M" != f && "m" != f || (t = l, n = c) } } }, function(e, t, n) { var i = {};
+ e.exports = i; var o = n(5);
+ n(0);
+ i.create = o.create, i.add = o.add, i.remove = o.remove, i.clear = o.clear, i.addComposite = o.addComposite, i.addBody = o.addBody, i.addConstraint = o.addConstraint }]) }));
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/n-gon-master/style.css b/WebGames-master/WebGames-master/n-gon-master/style.css
new file mode 100644
index 00000000..9b15685e
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/style.css
@@ -0,0 +1,1745 @@
+:root {
+ --build-bg-color: #aeb6c2;
+ --card-color: #fafcfd;
+ --hover-card-color: #e5e5ed;
+}
+
+body {
+ font-family: "Helvetica", "Arial", sans-serif;
+ margin: 0;
+ overflow: hidden;
+ cursor: auto;
+ /* filter: grayscale(1); */
+ /* transition: background-color 0.2s ease-in-out; */
+}
+
+canvas {
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 0;
+ user-select: none;
+}
+
+select {
+ font-size: 0.8em;
+ border: 1px #333 solid;
+ border-radius: 6px;
+}
+
+select option {
+ background-color: #fff;
+}
+
+input {
+ padding: 0px 4px;
+ font-size: 0.8em;
+ border: 1px #333 solid;
+ border-radius: 4px;
+}
+
+a {
+ text-decoration: none;
+ color: #08c;
+}
+
+em {
+ opacity: 0.7;
+}
+
+#splash {
+ user-select: none;
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ z-index: 2;
+ transition: opacity 5s ease-in;
+}
+
+*:focus {
+ outline: none;
+}
+
+table {
+ border-collapse: collapse;
+ width: 360px;
+}
+
+tr {
+ padding: 10px;
+ text-align: left;
+}
+
+td {
+ padding-left: 10px;
+}
+
+.key-input-train {
+ padding: 0px 5px;
+ border: 2px solid #444;
+ color: #444;
+ border-radius: 4px;
+ background-color: #d0d0d0;
+ text-align: center;
+ font-weight: 400;
+}
+
+.key-input {
+ padding: 3px 8px;
+ border: 2px solid #333;
+ background-color: #fff;
+ text-align: center;
+}
+
+.pause-table {
+ width: auto;
+}
+
+.key-input-pause {
+ width: 15px;
+ padding: 0px 2px;
+ border: 2px solid #333;
+ background-color: #fff;
+ text-align: center;
+}
+
+.key-used {
+ color: #777;
+ font-size: 80%;
+}
+
+summary {
+ font-size: 1.2em;
+}
+
+.SVG-button {
+ border: 1.5px #333 solid;
+ border-radius: 8px;
+ background-color: #fff;
+}
+
+.SVG-button:hover {
+ background-color: #eee;
+}
+
+.SVG-button-splash {
+ border: 2px #333 solid;
+ border-radius: 8px;
+ background-color: #fff;
+ transition: opacity 5s ease-in;
+}
+
+.SVG-button-splash:hover {
+ background-color: #eee;
+}
+
+#start-button {
+ position: absolute;
+ bottom: 108px;
+ right: 4px;
+ z-index: 12;
+ /* top-left | top-right | bottom-right | bottom-left */
+ /* border-radius: 8px 8px 0 0; */
+}
+
+#training-button {
+ position: absolute;
+ bottom: 56px;
+ right: 4px;
+ z-index: 12;
+ /* border-radius: 8px 0px 0 0; */
+}
+
+#experiment-button {
+ position: absolute;
+ bottom: 4px;
+ right: 4px;
+ z-index: 12;
+ /* border-radius: 8px 0 8px 8px; */
+}
+
+
+
+
+
+#construct {
+ display: none;
+ position: absolute;
+ bottom: 0%;
+ right: 0%;
+ z-index: 1;
+ width: 250px;
+ height: 200px;
+ background-color: #fff;
+ color: #000;
+ font-size: 0.9em;
+ white-space: pre;
+ padding: 3px;
+ border: 1px #333 solid;
+}
+
+#flex-center {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 100%;
+}
+
+.choose-grid {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ padding: 10px 1px;
+ margin: 0px;
+ border: 0px;
+ z-index: 12;
+ max-height: 99vh;
+ font-size: 1.3em;
+ display: grid;
+ grid-template-columns: repeat(3, 384px);
+ align-items: stretch;
+ visibility: hidden;
+ opacity: 0;
+ transition: opacity 0.25s linear;
+ overflow: auto;
+ -ms-overflow-style: none;
+ scrollbar-width: none;
+}
+
+.choose-grid-no-images {
+ border-radius: 8px;
+ border: 10px solid #444;
+ gap: 10px;
+ background-color: #444;
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ margin: 0px;
+ z-index: 12;
+ max-height: 99vh;
+ font-size: 1.3em;
+ display: grid;
+ grid-template-columns: 384px;
+ align-items: stretch;
+ visibility: hidden;
+ opacity: 0;
+ transition: opacity 0.25s linear;
+ overflow: auto;
+ -ms-overflow-style: none;
+ scrollbar-width: none;
+ /* box-shadow: 7px 7px 6px rgba(0, 0, 0, 0.13); */
+}
+
+
+#choose-grid::-webkit-scrollbar {
+ display: none;
+}
+
+.choose-grid-module {
+ line-height: 160%;
+ background-color: var(--card-color);
+ font-size: 0.75em;
+}
+
+.choose-grid-module:hover {
+ background-color: var(--hover-card-color);
+}
+
+.choose-grid-module:hover .card-text {
+ background-color: var(--hover-card-color);
+}
+
+.research-select {
+ float: right;
+ margin-right: 10px;
+}
+
+.pause-grid {
+ padding: 2px;
+ margin: 0px;
+ display: none;
+ grid-template-columns: 384px;
+ grid-auto-rows: minmax(auto, auto);
+ align-content: start;
+ align-items: start;
+ z-index: 2;
+ font-size: 1.3em;
+}
+
+#pause-grid-right {
+ position: absolute;
+ top: -2px;
+ right: -4px;
+ overflow: auto;
+ max-height: 100vh;
+ -ms-overflow-style: none;
+ scrollbar-width: none;
+ padding: 1px;
+}
+
+#pause-grid-right::-webkit-scrollbar {
+ display: none;
+}
+
+#pause-grid-left {
+ position: absolute;
+ top: -2px;
+ left: -4px;
+ overflow: auto;
+ max-height: 100vh;
+ -ms-overflow-style: none;
+ scrollbar-width: none;
+}
+
+#pause-grid-left::-webkit-scrollbar {
+ display: none;
+}
+
+.pause-grid-module {
+ line-height: 160%;
+ background-color: var(--card-color);
+ font-size: 0.75em;
+}
+
+.sort {
+ padding: 0.1em 0.3em;
+ border: 1px solid #444;
+ /* min-height: 88px; */
+ line-height: 100%;
+ background-color: var(--card-color);
+}
+
+.sort-button {
+ border: 1px #333 solid;
+ border-radius: 0.4em;
+ background-color: #fff;
+ font-size: 0.5em;
+ /* padding: 0.3em; */
+
+}
+
+.sort-button:hover {
+ background-color: #eee;
+}
+
+.pause-eject .card-text {
+ animation: techColorCycle 1s linear infinite alternate;
+}
+
+#experiment-grid {
+ display: flex;
+ justify-content: center;
+ padding: 0px;
+ margin: 0px;
+ border: 0px;
+ background-color: var(--build-bg-color);
+ display: none;
+ grid-template-columns: repeat(auto-fit, 384px);
+ grid-auto-flow: row;
+ /* grid-auto-rows: minmax(auto, auto); */
+ position: relative;
+ /* bottom: 0px; */
+ z-index: 10;
+ font-size: 1.3em;
+ -ms-overflow-style: none;
+ /* IE and Edge */
+ scrollbar-width: none;
+ /* Firefox */
+}
+
+#experiment-grid::-webkit-scrollbar {
+ display: none;
+}
+
+.experiment-grid-module {
+ line-height: 160%;
+ background-color: var(--card-color);
+ font-size: 0.75em;
+}
+
+.experiment-grid-hide {
+ display: none;
+}
+
+.grid-title {
+ padding-bottom: 6px;
+ padding-top: 4px;
+ font-size: 1.4em;
+ font-weight: 600;
+}
+
+.experiment-grid-module:hover:not(.build-tech-selected, .build-field-selected, .build-gun-selected) {
+ background-color: var(--card-color);
+}
+
+.experiment-start-box {
+ background-color: var(--card-color);
+ position: sticky;
+ top: 0;
+ z-index: 10;
+ align-self: start;
+ width: 276px;
+ line-height: 200%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ border: 2px #333 solid;
+ border-top: 0px;
+ border-radius: 10px;
+ border-top-left-radius: 0px;
+ /* border-bottom-left-radius: 0px; */
+ border-top-right-radius: 0px;
+ padding: 0.2em 0px;
+ /* height: 210px; */
+ box-shadow: 8px 8px 6px rgba(0, 0, 50, 0.15);
+ /* opacity: 0.1; */
+}
+
+.card-background {
+ height: 340px;
+ background-size: contain;
+ background-repeat: no-repeat;
+ display: flex;
+ justify-content: flex-end;
+ flex-direction: column;
+}
+
+.card-text {
+ background-color: var(--card-color);
+ padding: 0.5em 1em;
+ border: 1px solid #444;
+ margin-top: -1px;
+ margin-right: -1px;
+ font-size: 0.92em;
+ min-height: 88px;
+ /* border-radius: 5px; */
+}
+
+.cancel-card {
+ text-align: center;
+ font-size: 1.1em;
+ font-weight: 100;
+ justify-self: end;
+ border: 1px solid #444;
+ margin-top: -1px;
+ margin-right: -1px;
+ padding: 1px;
+ line-height: 160%;
+ background-color: var(--card-color);
+}
+
+.cancel-card:hover {
+ background-color: var(--hover-card-color);
+}
+
+.research-card {
+ font-size: 1.1em;
+ font-weight: 100;
+ border: 1px solid #444;
+ margin-top: -1px;
+ margin-right: -1px;
+ padding: 1px 0px 1px 10px;
+ line-height: 160%;
+ background-color: var(--card-color);
+}
+
+.research-card:hover {
+ background-color: var(--hover-card-color);
+}
+
+.research-cancel {
+ display: flex;
+ gap: 10px;
+ line-height: 160%;
+ /* background-color: var(--card-color); */
+ font-size: 1em;
+ position: sticky;
+ top: 0px;
+ z-index: 10;
+}
+
+.sticky {
+ position: sticky;
+ top: 0px;
+ z-index: 10;
+}
+
+/* keeps 5 columns at 1440px */
+@media (min-width: 1710px) and (max-width: 1950px) {
+
+ .experiment-grid-module,
+ .choose-grid-module,
+ .pause-grid-module,
+ .research-cancel {
+ line-height: 143%;
+ font-size: 0.68em;
+ }
+
+ .research-cancel {
+ font-size: 0.9em;
+ }
+
+ #experiment-grid,
+ .choose-grid,
+ .pause-grid {
+ grid-template-columns: repeat(auto-fit, 340px);
+ }
+
+ .card-background {
+ height: 290px;
+ }
+
+ .card-text {
+ min-height: 75px;
+ }
+}
+
+/* (min-width: 30em) and (max-width: 80em) */
+@media (max-width: 1709px) {
+
+ .experiment-grid-module,
+ .choose-grid-module,
+ .pause-grid-module {
+ line-height: 139%;
+ font-size: 0.58em;
+ }
+
+ .research-cancel {
+ font-size: 0.8em;
+ }
+
+ #experiment-grid,
+ .choose-grid,
+ .pause-grid {
+ grid-template-columns: repeat(auto-fit, 285px);
+ }
+
+ .card-background {
+ height: 240px;
+ }
+
+ .card-text {
+ min-height: 64px;
+ }
+}
+
+/* .card-text */
+.choose-grid-no-images .card-text,
+.choose-grid-no-images .research-card,
+.choose-grid-no-images .cancel-card {
+ border-radius: 5px;
+}
+
+.experiment-grid-module:hover .card-text {
+ background-color: var(--hover-card-color);
+}
+
+.build-tech-selected .card-text {
+ background-color: hsl(253, 100%, 84%);
+}
+
+.build-tech-selected.experiment-grid-module:hover .card-text {
+ background-color: hsl(253, 100%, 81%);
+}
+
+.build-gun-selected .card-text {
+ background-color: hsl(218, 100%, 81%);
+}
+
+.build-gun-selected.experiment-grid-module:hover .card-text {
+ background-color: hsl(218, 100%, 76%);
+}
+
+.build-field-selected .card-text {
+ background-color: hsl(193, 100%, 75%);
+}
+
+.build-field-selected.experiment-grid-module:hover .card-text {
+ background-color: hsl(193, 100%, 68%);
+}
+
+.experiment-grid-disabled {
+ /* background-color: var(--build-bg-color); */
+ /* color: #000; */
+ opacity: 0.35;
+}
+
+.experiment-grid-disabled[data-descr] {
+ position: relative;
+}
+
+.experiment-grid-disabled[data-descr]:hover::after {
+ content: '\a \00a0 \00a0 \00a0 REQUIRES:\a \00a0 \00a0 \00a0 ' attr(data-descr);
+ white-space: pre-wrap;
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background-color: var(--build-bg-color);
+ z-index: 1;
+ opacity: 1;
+ transition: opacity 0.5s ease;
+}
+
+#info {
+ position: absolute;
+ bottom: 3px;
+ left: 3px;
+ z-index: 10;
+ font-size: 1.5em;
+ transition: opacity 5s ease-in;
+ width: 100%;
+
+ /* border: 1.5px #333 solid; */
+ /* border-radius: 8px; */
+ /* background-color: #fff; */
+}
+
+.details-div {
+ padding: 10px;
+ border-radius: 8px;
+ border: 2px #333 solid;
+ background-color: var(--card-color);
+}
+
+
+#dmg {
+ position: absolute;
+ z-index: 2;
+ width: 100%;
+ height: 100%;
+ display: none;
+ /* background-color also set in mass-energy tech */
+ background-color: #f67;
+ opacity: 0;
+ transition: opacity 1s;
+}
+
+#damage-bar {
+ position: absolute;
+ /* top: 1px;
+ left: 15px;
+ height: 7px;
+ width: 0px;
+ transition: width 0.3s linear; */
+ top: 16px;
+ right: 4px;
+ height: 0px;
+ width: 7px;
+ transition: height 0.25s linear;
+ opacity: 1;
+ z-index: 2;
+ pointer-events: none;
+ background-color: rgb(255, 55, 95);
+ /* border-bottom: 1.5px solid #701; */
+ /* border-right: 1.5px solid #701; */
+ display: none;
+}
+
+#defense-bar {
+ position: absolute;
+ top: 8px;
+ left: 15px;
+ height: 7px;
+ width: 0px;
+ transition: width 0.25s linear;
+ opacity: 1;
+ z-index: 2;
+ pointer-events: none;
+ background-color: #fff;
+ border-right: 1.5px solid #777;
+ display: none;
+}
+
+#health {
+ position: absolute;
+ top: 15px;
+ left: 15px;
+ height: 20px;
+ width: 0px;
+ transition: width 1s ease-out;
+ z-index: 2;
+ pointer-events: none;
+ background-color: rgb(9, 245, 166);
+ border-right: 2px solid rgb(51, 162, 125);
+ display: none;
+}
+
+#health-bg {
+ position: absolute;
+ top: 15px;
+ left: 15px;
+ height: 20px;
+ width: 0px;
+ transition: width 1s ease-out;
+ background-color: #032;
+ opacity: 0.1;
+ z-index: 1;
+ pointer-events: none;
+ display: none;
+}
+
+/* background on title page */
+#fade-out {
+ position: absolute;
+ z-index: 2;
+ width: 100%;
+ height: 100%;
+ background-color: #e2e9ec;
+ opacity: 1;
+ transition: opacity 3s;
+ pointer-events: none;
+}
+
+#guns {
+ position: absolute;
+ top: 82px;
+ left: 15px;
+ z-index: 2;
+ font-size: 23px;
+ color: #222;
+ background-color: rgba(255, 255, 255, 0.2);
+ line-height: 120%;
+ user-select: none;
+ pointer-events: none;
+ padding: 0px 5px 0px 5px;
+ border-radius: 5px;
+}
+
+#field {
+ position: absolute;
+ top: 45px;
+ left: 15px;
+ z-index: 2;
+ font-size: 23px;
+ color: #000;
+ text-align: right;
+ opacity: 0.7;
+ background-color: rgba(190, 210, 245, 0.25);
+ user-select: none;
+ pointer-events: none;
+ padding: 0px 5px 0px 5px;
+ border-radius: 5px;
+}
+
+#right-HUD {
+ position: absolute;
+ top: 15px;
+ right: 15px;
+ z-index: 2;
+ font-size: 20px;
+ text-align: right;
+ line-height: 120%;
+ user-select: none;
+ pointer-events: none;
+ /*border: 2px solid rgba(0, 0, 0, 0.4);*/
+ color: #222;
+ padding: 0px 5px 0px 5px;
+ border-radius: 5px;
+ opacity: 0.35;
+ background-color: rgba(255, 255, 255, 0.4);
+}
+
+#right-HUD-constraint {
+ position: absolute;
+ top: 12px;
+ right: 15px;
+ z-index: 2;
+ font-size: 20px;
+ text-align: right;
+ line-height: 120%;
+ user-select: none;
+ pointer-events: none;
+ padding: 5px 10px 5px 10px;
+ border-radius: 8px;
+ color: #624;
+ opacity: 0.35;
+ background-color: rgba(255, 215, 241, 0.4);
+ /* color: rgb(141, 23, 88);
+ opacity: 0.35;
+ background-color: rgba(141, 23, 88, 0.1); */
+ /* font-weight: 400; */
+ transition: all 0.5s linear;
+}
+
+#text-log {
+ z-index: 2;
+ position: absolute;
+ bottom: 10px;
+ left: 10px;
+ padding: 10px;
+ border-radius: 4px;
+ line-height: 140%;
+ font-size: 1.15em;
+ color: #555;
+ background-color: rgba(255, 255, 255, 0.5);
+ pointer-events: none;
+ user-select: none;
+}
+
+.constraint {
+ color: rgb(141, 23, 88);
+ /* font-weight: 100; */
+ /* text-decoration: underline; */
+}
+
+.color-text {
+ color: #000;
+}
+
+.color-var {
+ color: hsl(253, 100%, 58%);
+}
+
+.color-symbol {
+ color: hsl(290, 100%, 40%);
+}
+
+.color-gun {
+ color: hsl(218, 100%, 58%);
+}
+
+.highlight {
+ border-radius: 6px;
+ background-color: #ff0;
+ padding: 3px;
+}
+
+.color-f {
+ color: #0ad;
+ letter-spacing: 1px;
+}
+
+.color-s {
+ color: #04f;
+ letter-spacing: 1px;
+}
+
+.color-d {
+ color: #f03;
+ letter-spacing: 1px;
+}
+
+.color-p {
+ color: #067;
+ letter-spacing: 1px;
+}
+
+.color-h {
+ color: #0b7;
+ letter-spacing: 1px;
+}
+
+.color-e {
+ color: #d60;
+ letter-spacing: 1px;
+}
+
+.color-m {
+ color: hsl(253, 100%, 50%);
+ letter-spacing: 1px;
+}
+
+.color-g {
+ color: hsl(218, 80%, 40%);
+ letter-spacing: 1px;
+}
+
+.color-ammo {
+ color: #356;
+}
+
+.color-choice {
+ display: inline-block;
+}
+
+.color-choice span {
+ display: inline-block;
+ animation: bounce 3s infinite;
+ transform-origin: bottom;
+ color: #555;
+}
+
+.color-choice span:nth-child(1) {
+ animation-delay: 0s;
+}
+
+.color-choice span:nth-child(2) {
+ animation-delay: 1s;
+}
+
+.color-choice span:nth-child(3) {
+ animation-delay: 2s;
+}
+
+@keyframes bounce {
+ 0% {
+ transform: translateY(0);
+ }
+
+ 15% {
+ transform: translateY(-2px);
+ color: #aaa;
+ }
+
+ 30% {
+ transform: translateY(0);
+ }
+
+ 100% {
+ transform: translateY(0);
+ }
+}
+
+.color-invulnerable {
+ color: #fff;
+ text-shadow: 0px 0px 7px #000;
+}
+
+.color-dark-matter {
+ color: #246;
+ text-shadow: 0px 0px 7px #246;
+}
+
+.color-tokamak {
+ color: #5c3ab8;
+ font-weight: 100;
+ text-shadow: 0px -5px 9px rgb(255, 0, 204);
+}
+
+
+
+.color-dup {
+ font-variant: small-caps;
+ letter-spacing: 1px;
+ text-shadow: 1.5px -1.5px hsla(243, 100%, 38%, 0.2);
+}
+
+.color-remove {
+ text-decoration: line-through;
+ /* letter-spacing: 2px; */
+ border-radius: 3px;
+ padding: 0px 3px;
+ background-color: hsl(255, 40%, 71%);
+ color: #fff;
+}
+
+.color-cloaked {
+ letter-spacing: 2px;
+ animation: cloak 6s linear infinite alternate;
+ color: rgba(0, 0, 0, 0);
+}
+
+@keyframes cloak {
+ 0% {
+ text-shadow: 0px 0px 0px #000;
+ opacity: 1;
+ }
+
+ 50% {
+ text-shadow: 0px 0px 0px #000;
+ opacity: 1;
+ }
+
+ 100% {
+ text-shadow: 0px 0px 15px #000;
+ opacity: 0;
+ }
+}
+
+.color-laser {
+ color: #f02;
+ font-weight: 100;
+ letter-spacing: -0.8px;
+}
+
+.color-plasma {
+ color: #c0e;
+ letter-spacing: 1px;
+ background-color: rgba(132, 0, 255, 0.06);
+ padding: 2px;
+ border-radius: 9px;
+ letter-spacing: 1px;
+}
+
+.color-worm {
+ color: #fff;
+ text-shadow: 1px 0px 2px #234;
+}
+
+.color-print {
+ color: #567;
+ font-family: 'Courier New', Courier, monospace;
+}
+
+.color-defense {
+ background-color: hsla(227, 9%, 71%, 0.279);
+ padding: 2px;
+ border-radius: 4px;
+ letter-spacing: 1px;
+ font-weight: 100;
+}
+
+.color-bot {
+ font-variant: small-caps;
+ background-color: rgba(75, 125, 150, 0.06);
+ border: 0.1em solid #146;
+ color: #146;
+ padding: 0em 0.3em 0.08em 0.3em;
+ font-weight: 400;
+}
+
+.no-box {
+ border: none;
+ background-color: transparent;
+ padding: 0;
+}
+
+.color-block {
+ background-color: rgba(0, 0, 0, 0.1);
+ border: 0.1em solid #333;
+ padding: 0.5px;
+ font-weight: 100;
+}
+
+.color-cancel {
+ background-color: var(--card-color);
+ border: 0.15em #444 solid;
+ padding: 0.2em;
+ border-radius: 0.2em;
+ font-weight: 800;
+ font-size: 1em;
+}
+
+.color-junk {
+ letter-spacing: 1px;
+ font-family: Lucida Console, Courier, monospace;
+}
+
+.color-r {
+ color: #f7b;
+ letter-spacing: 1px;
+}
+
+.color-flop {
+ text-decoration: underline;
+ font-weight: 100;
+ letter-spacing: -1px;
+}
+
+.color-alt {
+ text-decoration: underline;
+ font-weight: 100;
+ letter-spacing: -1px;
+}
+
+.faded {
+ opacity: 0.7;
+ font-size: 90%;
+}
+
+.circle-grid {
+ width: 1.32em;
+ height: 1.32em;
+ border-radius: 50%;
+ display: inline-block;
+ margin-bottom: -0.3em;
+}
+
+.circle-grid-instant {
+ width: 1.1em;
+ height: 1.1em;
+ border-radius: 50%;
+ border: 0.15em solid hsl(255, 100%, 71%);
+ display: inline-block;
+ margin-bottom: -0.35em;
+}
+
+.circle-grid-skin {
+ width: 1.25em;
+ height: 1.25em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #fff;
+ opacity: 0.8;
+ border: 0.08em solid #222;
+ position: absolute;
+ top: -0.05em;
+ left: 0em;
+}
+
+.circle-grid-skin-eye {
+ width: 0.18em;
+ height: 0.18em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #fff;
+ border: 0.08em solid #222;
+ position: absolute;
+ top: 0.45em;
+ left: 0.9em;
+}
+
+.junk {
+ background-color: hsl(254, 44%, 75%);
+ border-radius: 25%;
+}
+
+.research-circle {
+ width: 0.9em;
+ height: 0.9em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #f7b;
+ border: 0.065em #fff solid;
+ opacity: 0.85;
+ margin-bottom: -0.1em;
+}
+
+.ammo-circle {
+ width: 0.75em;
+ height: 0.75em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #467;
+ border: 0.05em #fff solid;
+ opacity: 0.95;
+ margin-bottom: -1.5px;
+}
+
+.heal-circle {
+ width: 0.95em;
+ height: 0.95em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #0d9;
+ border: 0.05em #fff solid;
+ opacity: 0.85;
+ margin-bottom: -2px;
+}
+
+.heal-circle-energy {
+ width: 0.95em;
+ height: 0.95em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #ff0;
+ border: 0.05em #000 solid;
+ opacity: 0.85;
+ margin-bottom: -2px;
+}
+
+.coupling-circle {
+ width: 0.7em;
+ height: 0.7em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #0ae;
+ border: 0.05em #fff solid;
+ margin-bottom: -0.5px;
+}
+
+.boost-circle {
+ width: 0.7em;
+ height: 0.7em;
+ border-radius: 50%;
+ display: inline-block;
+ background-color: #f03;
+ border: 0.05em #fff solid;
+ opacity: 0.9;
+ margin-bottom: -0.5px;
+}
+
+@keyframes pulse {
+ 0% {
+ border-radius: 0%;
+ }
+
+ 100% {
+ border-radius: 50%;
+ }
+}
+
+.field {
+ background-color: #0cf;
+}
+
+.tech {
+ background-color: hsl(255, 100%, 71%);
+}
+
+.gun {
+ background-color: rgb(0, 80, 218);
+}
+
+.heal {
+ background-color: #0d9;
+}
+
+.research {
+ background-color: #f7b;
+}
+
+.color-speed {
+ display: inline-block;
+ transform: skew(-27deg);
+ /* font-weight: 400; */
+ color: #038;
+}
+
+.color-randomize {
+ display: inline-block;
+ animation: randomize 4s linear infinite alternate;
+ transform-origin: bottom;
+ color: #555;
+}
+
+@keyframes randomize {
+
+ 0%,
+ 100% {
+ font-family: Arial;
+ }
+
+ 20% {
+ font-family: Times New Roman;
+ }
+
+ 40% {
+ font-family: Verdana;
+ }
+
+ 60% {
+ font-family: Georgia;
+ }
+
+ 80% {
+ font-family: Courier New;
+ }
+}
+
+.alt {
+ animation: alt 8s linear infinite alternate;
+ font-weight: 400;
+ letter-spacing: 1px;
+}
+
+@keyframes alt {
+ 0% {
+ text-shadow: 3px 0px 0px;
+ }
+
+ 100% {
+ text-shadow: -3px 0px 0px;
+ }
+
+}
+
+.flicker {
+ animation: flicker 4s linear infinite;
+}
+
+@keyframes flicker {
+ 0% {
+ opacity: 1;
+ }
+
+ 80% {
+ opacity: 1;
+ }
+
+ 90% {
+ opacity: 0;
+ }
+
+ 100% {
+ opacity: 1;
+ }
+}
+
+.color-coupling {
+ text-shadow: 0px 0px 1.5px #0cf;
+ letter-spacing: 1px;
+ font-weight: 100;
+}
+
+.box {
+ padding: 3px 8px 3px 8px;
+ border: 2px solid #444;
+ border-radius: 4px;
+ background-color: rgba(255, 255, 255, 0.5);
+}
+
+.wrapper {
+ display: grid;
+ grid-template-columns: 360px 10px;
+ align-self: center;
+ justify-content: center;
+}
+
+.grid-box {
+ align-self: center;
+ justify-self: center;
+}
+
+.right {
+ text-align: right;
+}
+
+.lore {
+ animation: bgColor 3.5s linear infinite;
+}
+
+.lore-text {
+ animation: textColor 3s linear infinite;
+}
+
+.entanglement {
+ font-size: 1.1em;
+ font-weight: 100;
+ text-align: center;
+ letter-spacing: 10px;
+ border: none;
+ background-color: var(--card-color);
+}
+
+.flipX {
+ animation: 14s anim-flipX linear infinite;
+}
+
+@keyframes anim-flipX {
+ 0% {
+ transform: rotateX(0.5turn);
+ }
+
+ 50% {
+ transform: rotateX(1turn);
+ }
+
+ 100% {
+ transform: rotateX(0.5turn);
+ }
+}
+
+@keyframes fieldColorCycle {
+ 0% {
+ background-color: rgb(255, 255, 255)
+ }
+
+ 100% {
+ background-color: rgb(0, 204, 255)
+ }
+}
+
+@keyframes techColorCycle {
+ 0% {
+ background-color: hsl(253, 100%, 100%)
+ }
+
+ 100% {
+ background-color: hsl(253, 100%, 90%)
+ }
+}
+
+@keyframes bgColor {
+ 0% {
+ background-color: rgb(63, 218, 216)
+ }
+
+ 10% {
+ background-color: rgb(47, 201, 226)
+ }
+
+ 20% {
+ background-color: rgb(28, 127, 238)
+ }
+
+ 30% {
+ background-color: rgb(95, 21, 242)
+ }
+
+ 40% {
+ background-color: rgb(186, 12, 248)
+ }
+
+ 50% {
+ background-color: rgb(251, 7, 217)
+ }
+
+ 60% {
+ background-color: rgba(255, 0, 0)
+ }
+
+ 70% {
+ background-color: rgb(255, 0, 0)
+ }
+
+ 80% {
+ background-color: rgb(255, 154, 0)
+ }
+
+ 90% {
+ background-color: rgb(208, 222, 33)
+ }
+
+ 100% {
+ background-color: rgb(79, 220, 74)
+ }
+}
+
+@keyframes textColor {
+ 0% {
+ color: rgb(63, 218, 216)
+ }
+
+ 10% {
+ color: rgb(47, 201, 226)
+ }
+
+ 20% {
+ color: rgb(28, 127, 238)
+ }
+
+ 30% {
+ color: rgb(95, 21, 242)
+ }
+
+ 40% {
+ color: rgb(186, 12, 248)
+ }
+
+ 50% {
+ color: rgb(251, 7, 217)
+ }
+
+ 60% {
+ color: rgba(255, 0, 0)
+ }
+
+ 70% {
+ color: rgb(255, 0, 0)
+ }
+
+ 80% {
+ color: rgb(255, 154, 0)
+ }
+
+ 90% {
+ color: rgb(208, 222, 33)
+ }
+
+ 100% {
+ color: rgb(79, 220, 74)
+ }
+}
+
+.link {
+ color: #000;
+}
+
+.link:hover {
+ text-decoration: underline;
+}
+
+/*
+.fade-ins {
+ animation: 1.5s linear 1s fadeins;
+}
+
+@keyframes fadeins {
+ 0% {
+ opacity: 0;
+ }
+
+ 100% {
+ opacity: 1;
+ }
+} */
+.blurry-text {
+ color: transparent;
+ text-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
+}
+
+.unblur {
+ color: transparent;
+ text-shadow: 0 0 7px rgba(0, 0, 0, 0.5);
+ animation: 2.5s ease 0.5s normal forwards 1 unblur;
+}
+
+@keyframes unblur {
+ 0% {
+ color: transparent;
+ text-shadow: 0 0 7px rgba(0, 0, 0, 0.5);
+ }
+
+ 100% {
+ /* font-weight: 800; */
+ color: #000;
+ text-shadow: 0 0 0px rgba(0, 0, 0, 0.5);
+ }
+}
+
+.fade-in {
+ opacity: 0;
+ animation: 2s ease 1.5s normal forwards 1 fadein;
+}
+
+.fade-in-fast {
+ opacity: 0;
+ animation: 1.5s ease 1s normal forwards 1 fadein;
+}
+
+.fade-in-faster {
+ opacity: 0;
+ animation: 2s ease 0.5s normal forwards 1 fadein;
+}
+
+@keyframes fadein {
+ 0% {
+ opacity: 0;
+ }
+
+ 100% {
+ opacity: 1;
+ }
+}
+
+@keyframes dash {
+ to {
+ stroke-dashoffset: 0;
+ }
+}
+
+.draw-lines {
+ stroke-dasharray: 20;
+ stroke-dashoffset: 20;
+ animation: dash 2.4s ease-in forwards;
+}
+
+.draw-lines-dash {
+ stroke-dasharray: 4;
+ stroke-dashoffset: 4;
+ animation: dash 2.4s ease-in forwards;
+}
+
+.draw-lines-o {
+ stroke-dasharray: 11;
+ stroke-dashoffset: 11;
+ animation: dash 2.4s ease-in forwards;
+}
+
+.draw-lines-g {
+ stroke-dasharray: 17;
+ stroke-dashoffset: 17;
+ animation: dash 2.4s ease-in forwards;
+}
+
+.draw-lines-box-1 {
+ stroke-dasharray: 1000;
+ stroke-dashoffset: 1000;
+ animation: dash 5s ease-in forwards;
+ animation-delay: 0s;
+}
+
+.draw-lines-box-2 {
+ stroke-dasharray: 1000;
+ stroke-dashoffset: 1000;
+ animation: dash 2.6s ease-in forwards;
+ animation-delay: 1s;
+}
+
+.draw-lines-box-3 {
+ stroke-dasharray: 1000;
+ stroke-dashoffset: 1000;
+ animation: dash 1.15s ease-in forwards;
+ animation-delay: 1.55s;
+}
+
+.draw-lines3 {
+ stroke-dasharray: 3000;
+ stroke-dashoffset: 3000;
+ animation: dash 3.1s ease-in forwards;
+}
+
+.draw-lines4 {
+ stroke-dasharray: 500;
+ stroke-dashoffset: 500;
+ animation: dash 3.5s ease-in forwards;
+}
+
+
+
+.grid-container {
+ display: grid;
+ grid-template-columns: 0fr 5fr 0fr;
+ line-height: 150%;
+ background-color: #fff;
+ padding: 15px 0 14px 0;
+ border-radius: 5px;
+}
+
+.far-right-column {
+ display: grid;
+ grid-template-rows: repeat(7, 1fr);
+ font-size: 2rem;
+ font-family: monospace;
+ align-self: center;
+ justify-self: center;
+ width: 22px;
+ /* padding: 0rem; */
+}
+
+.far-right-column>div {
+ padding-top: 50px;
+}
+
+#difficulty-slider {
+ margin-top: 2.3rem;
+ /* height: 26.3rem; */
+ height: 31.4rem;
+ width: 2rem;
+ writing-mode: vertical-lr;
+ direction: ltr;
+}
+
+.left-column {
+ grid-row: 1 / span 7
+}
+
+.right-column {
+ display: grid;
+ grid-template-rows: repeat(7, 1fr);
+ /* to adjust the width of this column edit the "gridTemplateColumns" in the difficulty power up js code*/
+}
+
+.row {
+ transition: opacity 0.4s ease-out;
+ /* border: 2px #444 solid; */
+ /* margin-top: -2px; */
+ font-size: 1.2rem;
+ padding: 10px;
+}
+
+.pause-difficulty-row {
+ line-height: 130%;
+ font-size: 1em;
+ padding: 7px 0px 7px 0px;
+ /* top | right | bottom | left */
+ margin: -5px 0;
+}
+
+#constraint-1 {
+ background-color: hsl(240, 18%, 95%);
+ border-radius: 7px 7px 0 0;
+}
+
+#constraint-2 {
+ background-color: hsl(240, 18%, 93%);
+}
+
+#constraint-3 {
+ background-color: hsl(240, 18%, 89%);
+}
+
+#constraint-4 {
+ background-color: hsl(240, 18%, 85%);
+}
+
+#constraint-5 {
+ background-color: hsl(240, 18%, 81%);
+}
+
+#constraint-6 {
+ background-color: hsl(240, 18%, 77%);
+}
+
+#constraint-7 {
+ background-color: hsl(240, 18%, 73%);
+ border-radius: 0 0 7px 7px;
+}
+
+#constraint-1:hover {
+ background-color: hsl(240, 18%, 93%);
+ border: 1px #444 solid;
+ padding: 9px;
+}
+
+#constraint-2:hover {
+ background-color: hsl(240, 18%, 91%);
+ border: 1px #444 solid;
+ padding: 9px;
+}
+
+#constraint-3:hover {
+ background-color: hsl(240, 18%, 87%);
+ border: 1px #444 solid;
+ padding: 9px;
+}
+
+#constraint-4:hover {
+ background-color: hsl(240, 18%, 83%);
+ border: 1px #444 solid;
+ padding: 9px;
+}
+
+#constraint-5:hover {
+ background-color: hsl(240, 18%, 79%);
+ border: 1px #444 solid;
+ padding: 9px;
+}
+
+#constraint-6:hover {
+ background-color: hsl(240, 18%, 75%);
+ border: 1px #444 solid;
+ padding: 9px;
+}
+
+#constraint-7:hover {
+ background-color: hsl(240, 18%, 71%);
+ border: 1px #444 solid;
+ padding: 9px;
+}
+
+#choose-difficulty {
+ text-align: center;
+ font-size: 1.1em;
+ padding: 5px;
+ margin-top: 10px;
+ color: #333;
+ border-radius: 5px;
+}
+
+.pause-details {
+ background-color: #e2e9ec;
+ border: 1px solid #333;
+ border-radius: 5px;
+ padding: 7px;
+ margin-bottom: 10px;
+ /* box-shadow: 4px 4px 4px hsla(240, 0%, 17%, 0.14); */
+}
+
+.tooltip {}
+
+.tooltip .tooltiptext {
+ visibility: hidden;
+ background-color: #fff;
+ border-radius: 0.3em;
+ padding: 0.2em 0.3em;
+ border: solid #000 1px;
+
+ position: relative;
+ z-index: 1;
+ bottom: 100%;
+ left: 0%;
+ margin-left: -50%;
+}
+
+.tooltip:hover .tooltiptext {
+ visibility: visible;
+}
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/n-gon-master/todo.txt b/WebGames-master/WebGames-master/n-gon-master/todo.txt
new file mode 100644
index 00000000..7d47bf94
--- /dev/null
+++ b/WebGames-master/WebGames-master/n-gon-master/todo.txt
@@ -0,0 +1,1278 @@
+******************************************************** NEXT PATCH **************************************************
+
+new level corridor
+ new level element fizzler - it removes blocks
+interferometer has wider platforms, a few helpful blocks, and fewer mobs
+level constraints are announced in console
+
+foam gun no longer pushes the player back when firing
+wave gun buffs
+ 1.2x base damage
+ 1.1x base ammo
+ 0.1->0.13x speed in map
+ 0.25->0.30x speed in blocks
+ tech: phase velocity 1.4->1.5x damage
+pigeonhole principle gives 1.3->1.4 damage per gun
+ you can no longer switch guns, your gun cycles each level
+quenching 0.4->0.5x overheal converts into max health
+tungsten carbide no longer has reduced coyote cycles
+control theory 1.5->2x damage at max health
+stability 0.3->0.2 damage taken at max health
+overcharge +88->100 max energy, 4->5% JUNK
+zoospore vector 10->13% chance for spores on mob death
+replication 15->10% JUNK
+interest 6->5% of your power ups spawn each level
+
+updated "about" details menu
+ moved classic n-gon to here from settings
+ added links to community content in "about"
+ Are there more links I should add?
+ added an n-gon SVG head image
+
+bugs
+ fixed outline on splash screen doesn't sync right on safari browser
+ fixed possible lock out on training levels: "hold", "throw", "throwAt"
+ from losing block behind a door
+ shortcut sort buttons in experiment mode properly order tech without clicking sort
+ fixed/increased the horizontal velocity contribution for some guns
+ this makes bullets shot on moving platforms more realistic
+ nail gun, super balls, foam, harpoon
+
+******************************************************** BUGS ********************************************************
+
+figure out why seeded random isn't making runs the same:
+ shuffle is being used for a wide variety of things that don't need a seeded random
+ make two shuffle functions?
+ check which of these is working
+ level order
+ is flipped
+ constraint order
+ mob type order
+ boss order
+ gun, field, tech options
+ make field options offered precalculated so it doesn't depend on player choices?
+ generate all constraints at the start of the game
+ doesn't seem to be determined by the seed...
+ display future constraints in pause menu?
+
+player can become crouched while not touching the ground if they exit the ground while crouched
+
+*********************************************************** TODO *****************************************************
+
+tech: demineralization - 0.2x damage taken, but it slowly reduces effect
+ increase to full:
+ at start of level?
+ when you get the tech
+ decrease:
+ over time
+ at start of new level
+
+!!conformal - similar rules for small and big scales linked to holographic principle
+!!holonomy - parallel transport of a vector leads to movement (applies to curved space)
+ when far away from your wormhole regenerate 1% of your max energy per second
+ when far away from your wormhole reduce damage taken
+ heal last hit damage after enter wormhole
+!!quasar - plasma torch from both ends
+ only after wormhole eats a block fire?
+ or just increase plasma length after eating block?
+
+make a text orb for JUNK text to make JUNK more clear
+
+procedural animation
+ https://www.youtube.com/watch?v=qlfh_rv6khY
+
+tech: ice-VII - 1.5x duration for ice-IX
+tech: - freezing grenades/explosions
+tech: - when you get a bot, get a second bot
+tech: - after killing a Boss
+ heal to full
+ gain 3x damage for the rest of the level
+
+new level - rework testChamber
+
+Boss (or mob) that quickly moves towards player, but then moves perpendicularly to player, like dodging
+ could respond to when player presses fire key or to when it takes damage
+
+new snakeBoss type that eats mobs
+ each time it eats:
+ heal?
+ get shield if full?
+ make boss longer (if snake)
+ get shield
+ get orbitals
+ spawn spawns (little red square mobs)
+ when boss dies
+ spawn eaten mobs?
+ spawn generic mobs?
+ nothing
+ make snake new colors, width
+
+Boss mob - takes a snapshot of the positions of all mobs, player, blocks, power ups. Then 3 seconds later it teleports everything back to those spots.
+ after snap shot is stored draw outline of body positions for a second to show the change
+ immune after snapshot? or immune after teleport?
+Boss mob - records the position of mobs every few cycles
+ makes a ghost copy of the mob that is delayed by a few seconds
+ ghost can damage player, but doesn't have a matter.js object
+ gives mobs short snake tails, like snakeBoss
+ brings 1 mob back to life every few seconds
+
+tech: atomic pile - lose 1 health if you are above the maximum energy
+ generate energy for each nearby mob?
+ do damage?
+ plasma torch tech?
+
+make player mass an adjustable var in the skin
+ does this mess with jump height or air control?
+increase mass and movement speed at the same time
+ increase jump differently because it scales extra with mass
+ m.defaultMass = 4.5
+ m.definePlayerMass()
+ possible player.mass bad interactions
+ grapple
+
+tech - after a power up is duplicated
+ update text to random effect after choosing tech, or after each trigger, or on first display of tech
+ pick 1 effect at random
+ become immune to damage taken for 5 seconds
+ summon JUNK bots for 10 seconds
+ 2x current energy
+ gain 1.01x damage permanently
+ cool name:
+
+after picking up heals gain ____
+ 0.1x damage taken for 12s
+after picking up ammo gain ____
+ 4x fire rate for 12s
+after picking up research gain ____
+ +10 choices for 12s
+
+tech: Energy generation increases with you velocity
+ Newtons' 3rd law?
+
+tech - getting caught in an explosion gives you _____
+ damage for 10 seconds?
+ heals
+
+explosions have a chance to spawn spores
+ infinite feedback loop with spores that explode?
+
+tech - getting a new gun also gives you 2 random tech for that gun
+ or a field?
+ can these guntech tech be converted into a player choice?
+
+how to reduce the number of clicks and keypresses
+ auto fire mode
+ player shoots at whatever is nearby
+ should player have to look towards mobs?
+ increase ammo?
+
+animate egg laying mobs
+ just draw a circle when it happens?
+
+improve new player experience
+ training is too long to be a tutorial
+ before nail gun level offer player option to continue or switch to normal game
+
++40% foam size
++40% foam damage
+-40% foam ammo gain
+When foam is in an explosion it also explodes with size proportional to the size of the foam bubble
+Requires foam, explosion source, not aerogel
+
+Cosmological natural selection: do something with black holes
+ spawn black hole mobs
+ after bosses die?
+ after any mob dies
+ at the start of new levels
+ make new black hole bullet mobs
+
+write code the checks version and compares it to the version from patch notes
+ and link to main page if they don't match
+ (this is because there are several outdated versions hosted on sites with ads)
+
+foam tech: increase size of foam and increase duration, but drop speed down, so they come to a stop and just hang
+ allow them to harm player?
+ this is probably just too annoying
+Foam slow down mobs twice as much and slowly pulls them towards the ground
+ +30% foam damage
+ Half foam velocity
+ Foam is now effected by gravity
+ Requires a source of foam and not aerogel
+ https://en.m.wikipedia.org/wiki/Tungsten_hexafluoride
+
+if needles touch map and mob at the same time pin mob to map
+ this might be better as a railgun tech, or a railgun rework
+ name rebar
+
+make grappling hook of different shapes
+ shapes
+ longer
+ circular with spikes
+ indicate tech upgrades?
+ swarf, reel, tokamak
+ do this in draw or in verticies?
+ draw can have different colors
+
+player got stuck inside block that wasn't pick up able
+
+tech - killing a mob heals for the last damage you took
+ disable cloaking heal? maybe you don't need to disable, just don't heal twice
+ heal for 50%?
+ heal from mob damage or from kills?
+
+on sucker mob death trigger radiation damage AoE and a graphic (Hawking radiation)
+
+tech prismatic laser - cycles between different laser colors every 1-2 seconds
+
+
+When you destroy an enemy’s shield it causes a large explosion. Requires not bubble fusion
+
+sword slash for plasma torch (giving up on this for now, had trouble making graphics look good)
+ activates when mouse is close to player
+ gradual activation
+ sharp cut off
+ use length of torch as cut off length
+ make it look like hollow knight slash
+ what about upgrades to extruder,plasma ball
+ give them their own version of a slash?
+ make a tech that buffs the slash, but it disables extruder,plasma ball
+
+
+
+more (all) bosses need to be made of parts
+ good examples: spiderBoss, dragonFlyBoss, beetleBoss
+ methods:
+ spawn adds in phases, like beetle and tether
+ constraints, like spider
+ be nice if each constrained part does something different
+ constrained mobs that regen after phases
+ flock, like cellBoss, blockBoss
+ Bosses that could be converted to more parts
+ "orbitalBoss", "shooterBoss", "bomberBoss", "launcherBoss", "laserTargetingBoss", "streamBoss", "pulsarBoss", "grenadierBoss", "blinkBoss", "laserBombingBoss", "blockBoss", "revolutionBoss", "slashBoss", "timeSkipBoss", "sneakBoss"
+ "sneakBoss" could get sneaker adds after each hide phase
+ "laserTargetingBoss" could have close range stabbers constrained, a few long range shooters, and a few laser shooters
+
+defense power up - a short term defense boost, like the ones for damage.
+ Or maybe it would last until you take one hit.
+ Or last until you lost a total of 20 health.
+
+use cross product rotation for other mobs?
+ snipers, shooters?
+ //gently rotate towards the player with a torque, use cross product to decided clockwise or counterclockwise
+ const laserStartVector = Vector.sub(this.position, this.vertices[this.swordVertex])
+ const playerVector = Vector.sub(this.position, m.pos)
+ const cross = Matter.Vector.cross(laserStartVector, playerVector)
+ this.torque = 0.00002 * this.inertia * (cross > 0 ? 1 : -1)
+
+super-bot: fires super balls
+
+tech: after a needle hits a mobs
+ the needle splits into 3 needles?
+ reset your fire CD?
+ fire again for zero ammo
+ 2x damage for each consecutive mob hit?
+
+mob non-combat behaviors, like Rain World
+ gathering
+ blocks
+ eating blocks to heal?
+ power ups
+ eating power ups and ejecting them on death
+ flocking
+ grouping near mobs
+ keeping distance from mobs
+ sharing velocity with other mobs: boids
+ wander
+ random walk with a bias towards the player
+ play
+ fight other mobs
+
+consider increasing the base player horizontal movement
+ maybe only increase ground movement, air control seems fine
+ would this unbalance any maps?
+
+tech stubs should be a tech unlocked by skins
+ nitinol, tungsten?
+ maybe give another benefit?
+ defense?
+ make a shared variable for skin defense, since you can only have one skin
+
+make a lemming that walks until it hits a wall and then turns around robotically
+ body or mob?
+ can't be killed?
+
+mobs attack mines
+ mines periodically set all mobs to have player location to be the mine
+ is this going to work with all mob vision types?
+
+tech circular polarization - wave gun bullets move in a circle
+
+Tech: relativity
+ Simulation speed scales with movement speed. When still, time moves at 0.4 speed, at full walking speed it’s 1. (So if you’re falling or something and you move faster the simulation will be faster than usual)
+ Also a damage and/or defense boost to make it worth using
+
+wormhole tech - teleport away mobs with mass below 3 when they get too near the player
+ short CD, small energy cost, only mobs below a mass
+
+tech: Bose Einstein condensate - freezes enemies in pilot wave, and drains some energy?
+
+mob status effect - vulnerability
+ mobs take 4x damage for __ time
+ afterwards mobs go back to normal damage taken
+ graphical effect while they take extra damage
+ needs to come from a "rare"ish effect
+ merge with the decloaking damage effect
+ decloaking gives all mobs (nearby??) a 3x damage taken status?
+ this can be merged with the stun crit damage tech
+ also the increased damage every hit tech?
+ bad idea because the graphical effect will be too annoying
+
+tech: sporangium that grow little trees
+ the trees have an area of effect damage for about 6-10 seconds
+ maybe something similar to radioactive drones, but maybe a few smaller shapes
+
+hookBoss fires a hook that pulls player towards it
+ hook does a bit of damage
+ player targeted unless cloaking
+ also add effect to finalBoss
+
+mob status effect - emit - mobs fire lasers for a few seconds
+ tech: phosphorescence - mobs emit after being hit with laser beams
+
+Tech: "Solid rocket motor": Missiles would start at 300% speed and 200% missile damage upon explosion, but the speed and damage would decrease to 40% speed and damage as time goes on
+tech: every time shotgun fires it's a different shotgun mode: nails, ice, needles, worms, fleas, rivets, ... but you get more ammo
+
+for tech power ups no tech options are displayed until you research once
+ or display only JUNK until you research once
+ increase the number of options after each research
+
+When receiving damage, in addition to becoming invulnerable to attacks, also become intangible for the set period of time
+
+tech increase max energy and energy to 5000, but you can no longer regen energy through any process
+
+it would be nice if there was incentive to go slow when choosing tech so n-gon is more relaxing
+ add some css based visual effects for opening up a tech,gun,field
+
+make a new coupling effect for perfect diamagnetism
+
+make a faster smaller version of cell boss that also has map collisions
+
+laserMines need a copy of laser-bot method
+ this is a very rare bug, so not a priority
+
+JUNK tech description that changes similar to cards in inscription
+ that changes based on mouse position
+ can you tell if mouse is over card?
+
+PWA?
+ https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps
+ https://codeburst.io/how-to-easily-turn-your-static-website-to-a-progressive-web-app-pwa-b0af08da9693
+ https://github.com/landgreen/n-gon/pull/32/files
+
+Tech:when relay switch/flip flop is on, turn ammo powerups into boosts, when relay swicth/flip flop is off, ammo powerups remain ammo powerups
+ or toggle other power ups
+ health/ammo
+
+complete blowSuckBoss... or don't
+
+tech: laser reflections increase damage
+
+JUNK tech different effects based on night or day
+ use system time
+
+Boss that shoots out a ring of bullets, then after a few seconds it gravitates the bullets back
+
+tech give laser mines more lasers (3->4? 5?)
+
+rewindBoss: after hitting 1/5 damage thresholds the boss rewinds back in time to where it was a few seconds ago
+ track it's data like player history
+
+make orbitals increase orbital rotation speed after Orbital boss takes damage
+
+worms can target player, buff their damage
+ can't target player in first few seconds?
+
+plasma field tech - similar to regression, but for plasma ticks
+
+greatly increase walking speed
+ not mid air control?
+ for time dilation field
+ make jumping normal
+
+junk tech: charged shot
+immediately fire all of your ammo
+
+after taking damage explode while invulnerable
+ scale explosion radius with damage
+
+tech: get sent to a new tab that closes in 3 minutes
+ in the new tab you play reactor
+ if you die in reactor you die in game, if you win you get 2-3 tech in the original game?
+ give player equipment like many-worlds
+ count guns, field, tech and give random stuff on new tab
+ i-frame instead of tab?
+
+tech: missiles explode a 2nd time after 1/2 a second (with a slightly different position determined by original velocity)
+
+seed isn't working right from shared URL
+
+mob mechanics
+ bullets hit player and stay attached for 4-5 seconds, slowing player
+ hopperBullets?
+ black hole sucker effect on tail
+ vines
+ attached to map and grows, a series of spheres connected by vines
+ if node dies it's removed from tree
+ vine do
+ keeps track of connection tree
+ nested object with nesting to show connection
+ spawns new nodes
+ draws connections as quad lines
+
+standing wave no longer pushes mobs away, but it can do damage to mobs caught in area effect
+ Standing wave harmonics no longer deflects, but instead discharges excess energy as lightning toward nearby enemies
+negative mass field does damage to mobs inside field
+ combine with standing wave effect? pilot wave?
+
+store value of last hit health lost
+ tech: killing the mob that caused the last hit spawns a heal power up equal to 1/2 of last hit
+ time limit for effect?
+ need to also store who hit player
+
+add small SVG pics to in-game console
+ when?
+ one for each field?
+ use stuff on physics notes:
+simulation.inGameConsole(`
+
+`);
+
+path-finding
+ build a path-finding map on level load
+ how to convert vertices into block grid?
+ check points for map collisions and build grid
+ is there a path-finding algorithm for vertices, instead of block grid
+ use for:
+ mobs,
+ drones?
+ bots that can go far from player and return
+
+make plasma ball power up and block pick up still work when you have no no energy
+ make a unique CD var for plasma ball?
+
+tech: entropic gravity - gain defense for each research
+ requires wormhole or pilot wave or negative mass field?
+
+mitosis: after needle,bullets or rivets hit a surface split off into two smaller less damaging versions that have their velocity reset -firerate
+
+after killing a mob go invulnerable for 1 second
+ critical hit with laser, harpoon, nails, needle, rivet
+
+spawn 2 bots after exiting 1 level
+ or spawn 3 after 2 levels?
+ (randomize 2-5 bots)
+ replace all bot tech with this?
+
+cloaking field
+ for 6 seconds after de-cloaking tell all active mobs that the player is in the wrong position?
+ how to code?
+ just delay setting the m.isCloak for a couple seconds
+ and also set all active bots to remember player in the de-cloaked stop
+
+scrap bots can't move?
+ only works for nail, foam, laser
+ might be tricky code?
+ make a new bot type called scrap bot?
+
+JUNK tech: Pacifism
+ You cannot attack mobs, mobs cannot attack you
+ over write the mob.damage and player.damage methods
+
+mob mechanic: beacon
+ periodically add locations to an array
+ teleport back to a location in the array
+ at random
+ if velocity not facing player?
+
+super balls do more damage after bouncing?
+ how to check for bounce?
+ maybe just increases damage after hitting a mob
+
+super short range foam that acts like flame thrower
+ high fire rate
+ short life spawn
+ start large?
+ extra ammo?
+ or only 1/2 of ammo is used?
+
+laser tech where bots move around and follow you while firing lasers in the direction you are looking
+ they fire when you fire?
+ they aim at player history aim location, with 1s delay
+ bots position spread out perpendicular to the direction you are looking
+ can they get stuck?
+ maybe absolution position, no collide
+ do they need to be physics objects then?
+ make a special bot type for this
+ beam is similar to diffuse beam
+
+
+
+
+double research
+
+map ban option in settings
+ dropdown list with checkboxes by each map
+
+bullets that can target the player
+ occurs if no mobs targets around
+ worms? drones? missiles? spores?
+ all of the above?
+
+Currently, the mob just deals higher damage on impact, which is annoying although not hard to compete with nor unique
+By "redesign" I mean replacing instances of the regular mob, since the same code is used for the tiny red projectiles (I think) just add a new mob and remove the old one from the rotation
+The new mob should be as such, a "real" exploding mob:
+Deals regular damage on impact, but breaks apart on touch into several red dots (like the ones thrown out by the going through walls boss) and a chance for also throwing a bomb or two (increases with difficulty)
+If the mob is close to the player or heading into the player fast it will shatter as well (and the projectiles will inherit its speed)
+By a formula such as
+ShouldShatter(distToPlayer, speed) = distToPlayer * speed > threshold
+Optionally (and a part I can do as I'm good at it and it doesn't revolve around a lot of functional code which you don't like other people doing):
+Color changing based on the mob explosion status
+Regular state: red
+About to explode: animation to dark red
+Exploding: several shockwaves from the explosion points and tiny trails given to the shrapnel for a second or two until they deaccelerate
+
+pause time like invariant for other things...
+ throwing blocks
+ charging railgun
+ charging anything?
+
+guntech fire a bullet that fires nail fragments after 1s in the same direction as the original bullet
+ like overwatch roadhog
+
+bring back:
+ the old phase decoherence field
+ make cloak only active on input.field down
+ could be a tech
+ would need some other buff
+ how to make it good enough
+ combine with not killing tech?
+ stun mobs that touch you while phased
+ firing doesn't exit you from cloak
+ but it does drain some energy
+ tech pilot wave: Bose Einstein condensate - freeze mobs in superposition with pilot wave
+
+tech: plasma drip
+
+plasma ball
+ graphics should look more like a real plasma ball
+ gently scale damage with circleRadius
+ balance corona discharge
+ delay on returning to player is annoying
+ scale float effect with ball size
+ tech upgrades
+ greatly improve floating effects while holding
+ black hole: gives the plasma ball gravity
+ stun on expansion
+ plasma orb increases in size and power as it eats enemies
+ while attached?
+
+flashlight effect
+ make level.do() graphic that only shows direction player is facing
+ pattern it after cloaking field, or timeSkipBoss
+ will it work with cloaking field at the same time
+
+double jump?
+
+tech: coyote time
+ you can still jump for 2 seconds after falling off a ledge
+ make it a JUNK tech? so you can keep the name
+ some other benefit
+ reduce your gravity also?
+ increase jump?
+
+tech smoke grenades - mobs inside a cloud can't see player
+ draw on the region so it's hard for player to see as well
+ you'd have to make something similar to MACHO that exists after an explosion goes off
+ maybe just keep it simple:
+ stun mobs for a long time, and draw a 99& alpha grey circle for the same time
+ don't worry about mobs seeing you inside the circle, the circle is kinda small so it doesn't matter
+
+
+tech mines: mines fire _____ instead of nails
+ needles
+ super balls?
+ foam?
+
+tech: frozen mobs die at 10% life
+
+tech: harpoons stick into enemies
+ detonate after a short delay
+ attaches mob to wall if possible
+ firing while harpoon is stuck into an enemy rips it out of them, inflicting damage and stun and pulling them towards you
+
+
+
+enemies stuck with foam receive upward force over time
+ only form aerogel tech?
+
+Tech: superglue
+Requires: foam + another gun or plasma torch or molecular assembler
+ Foam bubbles decay 50% slower
+ Enemies stuck with foam cannot move
+ Foam does 0 damage
+ Enemies stuck with foam take 25% more damage
+ should foam bots gets this also or is that too strong
+
+const ctx = canvas.getContext('2d', {‘willReadFrequently': true});
+
+//deal with game crashes?
+canvas.addEventListener("contextlost", onContextLost);
+canvas.addEventListener("contextrestored", redraw);
+ctx.reset();
+
+a mine tech that makes mines you can stand on
+ works similar to the field block throwing system
+ but you don't need to find a block to throw
+ blocks explode after mobs touch them
+ or 3 seconds after you touch them
+ benefits from all block tech
+
+go non-collide with mobs when immune to damage?
+
+mobs that are invulnerable from the front
+
+vertical reversed version of reservoir level, start at top and press buttons to lower slime
+ mechanic: push a very large block into slime in order to stand on it and avoid slime
+
+add anticipation to more mob attacks
+ stabber
+ striker
+
+can mob bullets damage other mob?
+ maybe if they switch collisions and classType === "body" or obj.classType === "bullet"
+
+figure out how to get friction effects on map/body to apply to player
+also horizontal moving platform?
+
+growBoss and cellBoss are too similar
+
+variant of Occam's razor - remove 50% of your tech for each removed get:
+ 2 bots?
+ 50 energy max
+
+tech immune to harm after mob kill
+ require no other mob kill tech?
+ cloaking field tech?
+
+final boss invulnerability
+ until mobs are cleared?
+ in between phases
+ for all of one phase
+
+JUNK tech - do something fun to the mob display health method
+
+new platform element, spring
+ toggle to on when player touches platform
+ platform extends in any direction
+
+boss that gives nearby mobs invulnerability
+ invulnerability needs to toggle off and on
+ boss is only mildly aggressive
+ repulsed by player up to a point
+ attracted to mobs
+
+training
+ save training level progress as local variable
+ reset progress to zero if you clear all training levels
+ maybe only save progress if you made if past the trainingHeal level
+ make the training button more obvious if the account has only played 1-2 times
+ larger?
+ position?
+ animated text?
+ uses the lore voice/text code?
+ replace all mob clear triggers with button triggers?
+ tutorial rooms:
+ look around with your mouse?
+ easier deflecting level, with 1-2 attacking mobs
+ gun rooms: (different mobs type in each room)
+ different mobs in each room
+ how to introduce mob shields?
+ "hopper" "slasher" "shooter "grenadier" "striker" "laser" "stabber" "springer" "pulsar" "launcher" "launcherOne" "exploder" "sneaker" "sucker" "sniper" "spinner" "grower" "beamer" "focuser" "spawner" "ghoster"
+ spores - use 1 ammo to take out several mobs at once, you have to block with your shield until the mobs die
+ drones - use mouse to bring drones around a couple corners
+ foam - slow boss mob, and run away
+ laser - reflect off walls to hit mobs
+ field rooms:
+ standing wave - bullets come from every direction
+ perfect diamagnetism - drop field to rapid stream of bullets and fire gun at them
+ negative mass - fly over a bunch of ground based mobs , hoppers
+ molecular assembler - guide drones around the corner
+ plasma torch - nothing fancy, just kill mobs
+ time dilation - get past some mobs
+ cloaking - sneak past mobs to collect some heals
+ pilot wave - toss blocks at mobs
+ worm hole - teleport past lasers
+ puzzle/platforming rooms:
+ use the double constrained platforms
+ stealth room
+ probably should make 2+
+ combat rooms:
+ boss gauntlet, spawn with nothing but a few power ups and fight 10 bosses
+ use no gun, just bots to kil stuff
+
+balance time dilation with bose einstein (you can freeze everything and take no damage)
+ code is still there, need to balance
+ balance with energy drain?
+
+make a line of constrained mobs move like a snake
+ apply forces with directions determined by time and position on the snake
+
+tech: basic research - heal power ups spawn as research power ups instead, and using research heals you (needs to be pretty low, like 3% health)
+tech: maintenance - heals no longer spawn, but using research heals you 100%
+
+foam tech - make it move slower, last much longer, and push away other foam bullets
+ not sure about bouncing off walls, but that might be fun too
+
+tech extend fracture analysis to give bonus damage to frozen also, but reduce the 400%->300%?
+
+pulsar mobs retarget too easily
+also they drift around too much
+
+convert blocked mobs into bullets
+ only for the very small bullets that move fast after being blocked
+ delete bulletmob and spawn a nail-like bullet with the same properties as the bulletmob
+
+electric motors: increases movement speed and jump height, but jumping and moving costs energy
+ overwrite the key event listeners?
+ JUNK tech?
+
+mob that fires bullets in 4,5,6,7 different directions at once, no aiming
+ grow a bit before it fires to indicate state
+
+quasarBoss: inverted pulsar boss that hits everything except where its aiming
+
+intro map: diegeticly draw a mouse with field highlighted
+ also indicate space?
+ dynamically adjust drawing after picking up a gun
+
+give history boss legs?
+
+field tech - disable blocking, but does high damage to mobs inside field
+ and maybe slows mobs it damages
+
+mob/boss that fires a laser at player, but give player time to avoid
+ laser isn't always on
+ they target where player was 1 second ago
+ they turn to face player?
+
+Plasma Burner: upgrade for plasma torch, basically just a jet engine. does high damage, but short range, mostly for player movement.
+ maybe reduce gravity to really low then apply a vector away from mouse direction
+
+auto-gon - auto battler with n-gon mob AI and tech
+ you build a group of mobs and bosses from n-gon
+ they fight other mobs and bosses
+ similar research and tech system to n-gon
+ some mobs can fire player weapons
+
+Pilot wave tech
+ Energy use is increased, but you can now shape blocks using pressure
+ Grouping blocks will merge them into a massive ball
+ Size, density is determined by total mass
+
+aoe effect pushes mobs away, then rapidly pulls them in
+ for mines?
+
+mob: spawning seekers on death
+
+drones can combine with other drones to get bigger?
+drones that grab powers ups can grab more then one and get even bigger each time
+
+it would be helpful if there was a mechanism to recover mobs that fly off the map
+ add a ceiling system and a left/right walls system similar to the floor checks but only for mobs
+make non moving bosses not move after getting hit
+ shooter, shielding,
+
+scrolling console history in pause menu?
+pause should at least show the last in game console message
+
+in testing mode console log the body you click on
+
+tech: Standing Wave: Shockwave. Use FIELD button to shrink your shield and charge up, release to unleash a Shockwave.
+
+tech: quantized shields - harmonic standing wave field can only lose 33 energy per hit
+ draw 1,2,3 levels of the field based on energy?
+ the blocked value only scales up to 2x or 4x (33 energy) blocked
+ doesn't stack with spherical tech
+
+make a tech that improves all charge guns
+ for: pulse, foam, railgun
+ effect:
+ faster charge rate?
+ fire speed already does that...
+ harm reduction while charging
+ less ammo/energy used while charging?
+
+tech plasma : plasma length increases then decreases as you hold down the field button (like stabbing with a spear)
+ grows to 1.5 longer after 0.3 seconds, then returns to normal length over 1 second, until field is pressed again
+ extra energy is drained when field is longer
+
+energy conservation 6% damage recovered as energy
+ there is space for a negative effect in the text...
+
+tech: use the ability for power ups to have custom code
+ (note: this code is half way done, it just needs to be completed)
+ attracted to player
+ attracted to other power ups
+ explode if they touch?
+
+apply the new gun.do functions to other guns
+ railgun
+ crouching missile?
+ works similar to foam
+ performance issues?
+
+look into improving mouse lag with pointer lock?
+https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API
+https://www.vsynctester.com/game.html
+https://news.ycombinator.com/item?id=26530272
+
+tech: time dilation - when you exit time dilation rewind to the state you entered
+ position, velocity, and health
+ no energy cost
+
+be able to open up custom mode in the normal game
+ might need to be rebuilt from scratch
+ while in through testing mode?
+ have a way to make limited changes as allowed by tech you pick up in game
+ disable the in custom setting flag
+
+make different move methods
+ tech crouch charge jump
+ tech double jump
+
+tech when mobs are at full health you do 40% to them
+
+tech- move super fast, go intangible, drain energy very fast
+ this is like a dodge roll
+ tech for standing wave?, cloaking?
+
+tech pilot wave: mini black hole - pull mobs and blocks in with more force
+ also from farther away
+ also do damage?
+tech pilot wave: antigravity - blocks have no gravity for a few seconds after exiting the field
+ maybe they bounce too?
+ maybe they explode?
+
+new power up - increase damage and fire speed, for 15 seconds
+ named boost?
+ enabled by a tech
+ power up color: ?
+ how to indicate effect duration
+ or just give the effect after picking up a reroll
+
+tech- do 50% more damage in close, but 50% less at a distance
+ code it like techisFarAwayDmg
+ have these tech disable each other
+
+new status effect: weakness, mobs do 75% les damage
+ graphic indication?
+
+new status effect: fear - push mob away from player for a time
+
+new status effect - apply status effect to mobs that makes blocks attracted to them
+ only lasts a few cycles
+ or zero cycles and it doesn't need to be a status
+
+have some mobs spawn in later in the level (in hard and why modes)
+ where
+ at defined points in array levelSpawns = [{x:0,y:0},{x:0,y:0}]
+ store the locations of mobs when the level starts to use as respawn points
+ remove the locations that are close to player
+ when?
+ after some mobs are dead
+ after the boss is killed
+
+look for tech that could update description text with count and tech is information
+ can only use variables that change in effect() and remove()
+ this.description = `8% chance to duplicate spawned power ups chance to duplicate = ${techduplicateChance}`
+
+use mac automator to speed up your n-gon -> git sync
+
+movement fluidity
+ let legs jump on mobs, but player will still take damage
+ like: ori and the blind forest, celeste
+ many of the movement abilities in these games require levels to be built around the ability
+ general feeling of responsiveness and control
+ coyote time: can still jump a few cycles after leaving ground
+ tech double jump
+ tech air dash
+ tech wall jump
+ wall grab?
+ maybe remove falling damage and block damage?
+
+have a mob apply a positive status effect on other mobs,
+ heal?
+ make it yellow
+ damage bonus, but how?
+ possible balance issues
+
+css transition for pause menu
+
+animate new level spawn by having the map aspects randomly fly into place
+
+n-gon outreach ideas
+ blips - errant signal on youtube
+ reddit - r/IndieGaming
+ hacker news - show hacker news post
+ twitch - lets play
+
+******************************************************** LEVELS ********************************************************
+
+map: observatory
+ button controls rotation of telescope
+ laser beam shoots out of telescope
+ button opens the dome
+
+level with mobs that follow a genetic algorithm
+ mobs have genes
+ the last mob that did damage saves it's genes to local storage
+ new mobs have the saved genes, but with some random mutations
+ mutations need to be balanced to prevent a gene from moving towards infinity
+ total genome must equal 1 (100%)
+ binary genes have a flat cost
+ example: phasing through walls might cost 0.2
+ spectrum genes have a rate
+ example: acceleration cost 0.01 per 0.001
+ possible genes
+ genes should only effect it's ability to touch the player
+ so not damage?
+ genome: spectrum
+ acceleration
+ top speed / air friction
+ damageReduction
+ duration?
+ health decreases naturally?
+ or they just go away like bullets?
+ spawn rate
+ look frequency / memory?
+ genome: binary
+ go through walls
+ blink/teleport (like striker)
+ grow when near target
+ split into two
+ shielded
+ occurs in a specialized level
+ named: gene lab, gene factory, genetic lab, genome facility
+ in the level sequence after lab and before gauntlet?
+ level ends after a period of time
+ exit is hidden until time is up and it appears
+ the level tests player durability/evasion
+ this is a nice contrast to the final level that tests damage output, and the gauntlet which tests AoE damage
+
+rename intro level to something lore related
+
+buttons can now on/off boosts
+
+repeat map in vertical when you fall teleport to above the mab, as if the map repeats
+ camera looks strange when you teleport player with a high velocity
+
+map element - player rotates a rotor that makes a platform go up or down
+
+level element: a zone with wind, anti-gravity, extra gravity
+ control with button
+
+******************************************************** MOBS ********************************************************
+
+mob that charges up and then fires many bullets at once in a connect
+
+mob that draws a lin from it to the player, and past. then it charges across that line
+
+mob that spawns eggs after they die
+ eggs don't attack but grow back into a mob after about 10s
+
+mob mechanics
+ use the force at a location effect, like the plasma field
+ Matter.Body.applyForce(who, path[1], force)
+
+mob - after taking damage
+ release seekers
+ teleports
+
+hop boss:
+ AoE damage when landing
+ pull in player? and blocks?
+ extra gravity on falling?
+ immune to damage while falling?
+
+mob: molecule shapes - 2 separate mobs joined by a bond
+ use constraints: just spawn 2x or 3x groupings
+ low friction so they can spin around
+ spin when attacking player?
+ increase constraint length when attacking
+
+Mob: "Tentacle": Sits on wall. Is a black blob. When you get near it, reaches out and grabs you, similar to wires. Does not deal damage.
+ maybe it could be immune to damage? but it is spawned by an actual mob
+
+level Boss: fractal Sierpiński triangle
+ https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle
+ spawns a 1/2 size version of the boss, this version can also spawn a smaller version, but it is capped at some size level
+ they spawn once at the start of the level
+ if a version dies, one can be replaced every ten seconds by the largest version
+
+mob: wall mounted guns / lasers
+ not part of randomized mob pool, customized to each level
+
+level boss: fires a line intersection in a random direction every few seconds.
+ the last two intersections have a destructive laser between them.
+
+******************************************************** SOUND ********************************************************
+
+add sounds
+ https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode
+ https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Advanced_techniques
+ style
+ interesting chords, like music, mixolyd
+ can fade into the background
+ chords gradual rise and fall in volume
+ shouldn't be traditional effects
+ adjust volume with distance
+ mute option to settings
+ end all sounds with each new level
+ write some functions to produce sounds
+ will this effect performance?
+ https://padenot.github.io/web-audio-perf/
+ "Web Audio API implementation use two threads", so it probably isn't much of an issue
+ when to make sounds?
+ if near some strange thing in the level
+ after grabbing a power up, in the selection menu
+ from mobs, damage,inside field
+ when activating fields: time, negative mass,
+
+ //setup audio context
+ function tone(frequency) {
+ const audioCtx = new(window.AudioContext || window.webkitAudioContext)();
+ const oscillator = audioCtx.createOscillator();
+ const gainNode = audioCtx.createGain();
+ gainNode.gain.value = 0.25; //controls volume
+ oscillator.connect(gainNode);
+ gainNode.connect(audioCtx.destination);
+ oscillator.type = "sine"; // 'sine' 'square', 'sawtooth', 'triangle' and 'custom'
+ oscillator.frequency.value = frequency; // value in hertz
+ oscillator.start();
+ return { oscillator: oscillator, audioCtx: audioCtx }
+ }
+ // https://www.fresnostate.edu/folklore/Olson/JUSTINT.HTM
+ // mixolyd. C D E F+ G A+ B
+ // key=G 264 297 330 356.40 396* 445.50 495
+ // const t264 = tone(264)
+ // t264.oscillator.stop(t264.audioCtx.currentTime + 2) //in seconds, not milliseconds for some reason
+ // tone(297)
+ // tone(330)
+ // tone(356.40)
+ // tone(396)
+ // tone(445.50)
+ // tone(495)
+
+******************************************************** IMAGES ********************************************************
+
+process: discord midjourney prompts -> "pixelmator pro" adjust color, repair, scale to 384x256, export PNG -> webP? -> place in /img folder
+make n-gon a progressive web app to manage image downloads, cache
+wave function collapse opens the pause menu after it triggers alternate reality
+ this is actually good, maybe reuse this code to get pause menu to open at any time
+if pause is pressed while selecting power ups, display pause menu on top of selection menu
+***styles***
+ try --- Pastel drawing, Psychedelic art, Arabesque (cool patterns), knolling (everything spread out and placed on a flat mat)
+ try taking screen shots of fields graphics and feeding them into midJourney V4
+ technology stuff --- Dan Matutina (cute complex technology),
+ Katsuhiro Otomo (intricate space technology), Tsutomu Nihei (black and white detailed future tech)
+ infographics of all know multiverses. 1980s Japanese graphic design, dimensional astrolabe,
+ Japanese poster graphics, Ralph McQuarrie (looks like star wars), Simon Stålenhag (retro-futuristic), Yoshiyuki Tomino (detailed anime future technology)
+ isometric: low-poly, box cutout, made in blender, Materials: matte clay
+ subtractive sculpture
+ kinetic sculpture
+ quantum stuff -- Hypertorus, Glowing Opal Pearlescent, Physics, Hydro-Dipping Hydrodipped, Vija Celmins, Matt Molloy (photo of golden waves in the sky)
+***maybe redo***
+ laser
+ supercritical fission
+***past style themes***
+ base prompt for player on 5.2: clean white robot spherical turret on bird legs test chamber
+ standing wave - a 3-D cyan transparent nested concentric aligned centered sphere with rings
+ by Philippe Starck
+ perfect diamagnetism - physics magnetic field chalk diagram
+ time dilation - graphic of a hyperbolic equation Luminogram
+ negative mass - Blacklight painting by Moebius
+ plasma torch - by Dan Mumford
+
+ metamaterial cloaking - Scientific photography by Miki Asai, by Bruce Munro
+ molecular assembler - by Laurie Greasley 16-bit Isometric
+ wormhole - by Tim White
+ pilot wave - none
+
+ nail gun - Screenprint
+ shotgun - blueprint by Dan McPharlin
+ grenades, missiles, explosions - vibrant fireball explosion sonic shockwave ring art by Victo Ngai --ar 3:2 --v 5 --s 750
+ spores - turquoise black spores on a white background full color scientific anatomy by Ernst Haeckel
+ drones - insect quadcopter tilt-shift photography
+ super balls - By Akari Toriyama
+ wave - sound wave oscilloscope by Paul Catherall, concentric circles by Paul Catherall
+ Barbara Takenaga's painting depicting a clean sound wave on aoscilloscope device --ar 3:2 --v 5
+ foam - black blobs Ink doodle
+ harpoon - iron harpoon on a rope weapon art white background by Eiichiro Oda --no fish --ar 3:2 --v 5 --s 750
+ mine - by Dan McPharlin
+ laser - complex optical scientific equipment
+ knolling photography
+
+ guns, ammo - isometric clean pixel art image cutaway of , style of tekkonkinkreet
+ defensive - Paper cutout
+ bots - hovering drone by Laurie Greasley 16-bit Isometric
+ generic energy tech - by Laurie Greasley
+ duplication, cancel - by Kazumasa Nagai
+ anti-shear topology, fracture analysis, shear stress - Chemigram
+ ON/OFF - ASCII art
+ block throwing - Bauhaus style
+ tech that adds JUNK - by Choi Jeong-hwa
+ ice IX - microscope images of ice crystals
+ tech that spawns health - glowing green balls by Enki Bilal
+ invulnerable - by Nick Veasey (photos that look like x-rays)
+ alternate reality - Fractal art
+ tech choice - mandala tile Mosaic
+ time, CPT, pause - by Lee Bontecou
+ boost, coupling power ups tech - cyan electron orbiting a black nucleus electric field as bas-relief //(by Kazumasa Nagai)
+ radioactive - volumetric atomic nucleus diagram by Paul Catherall
+
+******************************************************** LORE ********************************************************
+
+look up sci-fi science ideas here https://projectrho.com/public_html/rocket/
+
+possible names for tech
+ sidereal - with respect to the stars (an extra rotation for time keeping)
+ entropic gravity - gravity is emergent in a holographic way
+ (maybe a field tech for negative mass)
+ hypergolic - A hypergolic propellant combination used in a rocket engine is one whose components spontaneously ignite when they come into contact with each other.
+ swarm intelligence - for a drone tech
+ metaheuristic - is a higher-level procedure or heuristic designed to find, generate, or select a heuristic (partial search algorithm) that may provide a sufficiently good solution to an optimization problem, especially with incomplete or imperfect information or limited computation capacity
+ stochastic optimization
+ electrostatic discharge
+ Gödel's incompleteness
+ quantum zeno effect (perturbation of a system prevents some systems from evolving because it scrambles coherence) (apply to lasers, fields)
+ counterfactual - something false
+ regression to the mean
+ phlogiston theory is a superseded scientific theory that postulated the existence of a fire-like element called phlogiston
+ Laplace's demon was a notable published articulation of causal determinism on a scientific basis by Pierre-Simon Laplace in 1814.[1] According to determinism, if someone (the demon) knows the precise location and momentum of every atom in the universe, their past and future values for any given time are entailed; they can be calculated from the laws of classical mechanics.
+ evolutionary cosmology
+ eternal inflation
+ hypergraph
+ SQUID (for superconducting quantum interference device) is a very sensitive magnetometer used to measure extremely subtle magnetic fields, based on superconducting loops containing Josephson junctions.
+ Josephson junction - superconducting junction used in SQUIDS and quantum computers
+ nuclear pasta - hard matter in neutron star
+ nonlocal, nonlocality: maybe use for pilot wave
+ fine-tuned universe
+ nonperturbative
+ D-branes
+ instanton or pseudoparticle
+ soliton (wave packet)
+ hall effect thrusters
+ spaghettification
+ particle accelerator
+ superluminal signalling
+ NP-complete
+ lenticular lens: is an array of lenses, designed so that when viewed from slightly different angles, different parts of the image underneath are shown.
+ p-hacking JUNK tech
+ https://en.wikipedia.org/wiki/High-entropy_alloys high yield strength and low ductility, high temp resistance
+ https://en.wikipedia.org/wiki/Refractory_metals hard, high temp resistance
+ https://en.wikipedia.org/wiki/Upper-atmospheric_lightning#Elves
+ prion quine - self replicating protein
+ Unitarity - https://en.wikipedia.org/wiki/Unitarity_(physics) - all probabilities add up to 1, calculations work the same forward and backwards in time
+ this is violated by expansion of the universe
+ https://en.wikipedia.org/wiki/Cosmic_censorship_hypothesis - black holes can't leak
+ Alcubierre warp drive (FTL with negative mass)
+ Spherules - A spherule is a small sphere or spherical body. It can also refer to a thick-walled spherical structure that contains endospores and occurs in the parasitic form of fungi
+ negative entropy
+ memetics
+ magnetorquers - produce spin by pushing on earth's magnetic field
+ Josephson junction - superconducting junction
+ Pyroelectricity - voltage from temp changes - upgrade from piezoelectricity
+ Unruh effect - accelerating makes heat/thermal particles
+ configuration space - holds the position of everything (related to fermions/bosons and particle interactions)
+ stress–energy tensor
+ radioisotope thermoelectric generator -
+ retrovirus: these things make JUNK DNA so link it somehow to that tech?
+ Upon infection with a retrovirus, a cell converts the retroviral RNA into DNA and sometimes the DNA will be passed on to progeny as JUNK DNA
+ amalgam, amalgamation - the action, process, or result of combining or uniting.
+ thermoplastic - the stuff in 3-D printers, use for molecular assembler tech
+ ergosphere - region of a spinning black hole that might allow FTL or alternate realities.
+ equivalence principle - gravity and acceleration are the same
+ Casimir effect - attractive force between two close conductive plates
+ difference engine - early calculator/computer
+ cyanoacrylate - superglue use for a slowing effect?
+ superposition - something with waves overlapping
+ math terms - integral, derivative, Laplace transform, inflection point
+ quasicrystals - something with low friction, maybe defense?
+ Coalescence - things merging together like clouds. maybe mergin power ups?
+ trihydrogen cation - common molecule in space, dark matter tech?
+ superradiance - laser tech
+ cryocoolers - freezing effects
+ metaphysics - maybe this changes something deep and universal about physics? not sure
+ cork - used as a heat shield for rockets
+ P = NP - something with speeding up calculation times
+ transistivity - something where a>b and b>c -> a>c
+ lenticular - looks different from different angles (lasers?, cloaking?)
+ every few seconds pick a random skin tech?
+ De Sitter space - simple model of universe related to general relativity (mass-energy?)
+ active optics - something with lasers? maybe something with diffuse beam getting smaller
+ Quintessence - related to dark energy
+ biofilm - something defensive? related to spores?
+
+******************************************************* DESIGN ******************************************************
+
+priorities
+ synergies between tech
+ difficult to achieve synergies that feel so powerful they are game breaking / changing
+ randomized content that adds repeatability
+ bosses, mobs, levels, tech
+ graphical indicators of tech effects and quantity
+ subtle lore woven into unexpected places
+
+add more randomize sub level map content
+ left/right sides of lock
+ small lab rooms
+
+list of powerful synergies
+ CPT + high energy regen
+ research + bot fabrication + ersatz bots + various bot upgrades
+ harpoon + high fire rate + alternator + time dilation
+ duplication 100%
+ interest + coupling, research + (peer review? or Bayesian statistics)
+ electronegativity and high energy?
+ electronegativity + anyon + duplication + Maxwells demon + interest + pair production
+ chain reaction + invulnerable + Abelian group + parasitism = clear all mobs on level
+
+
+************************************************* COMMUNITY LINKS *************************************************
+
+load old commits
+ www.cornbread2100.com/n-gon-loader
+
+n-gon fork
+ kgurchiek.github.io/n-gon-portal-gun
+ 3xiondev.github.io/n-gon-upgraded
+ coaldeficit.github.io/c-gon
+ n-gon-enhanced.vercel.app
+
+bookmarlet
+ github.com/Whyisthisnotavalable/n-scythe
+ github.com/kgurchiek/n-gon-mobile
+ github.com/kgurchiek/n-gon-controller
+
+text
+ ngon.fandom.com/wiki/N-gon
+ github.com/3xionDev/n-docs
\ No newline at end of file
diff --git a/WebGames-master/WebGames-master/script.js b/WebGames-master/WebGames-master/script.js
index 356b4586..9504338a 100644
--- a/WebGames-master/WebGames-master/script.js
+++ b/WebGames-master/WebGames-master/script.js
@@ -423,6 +423,11 @@ const mainContentData = [
image: "/WebGames-master/WebGames-master/games2/assets/vex7.jpeg",
link: "/WebGames-master/WebGames-master/games2/game/vex7/index.html",
},
+ {
+ name: "n-gon",
+ image: "/WebGames-master/WebGames-master/assets/n-gon.png",
+ link: "/WebGames-master/WebGames-master/n-gon-master/index.html",
+ },
];
mainContentData.forEach(item => {