├── .settings
├── Copying
├── README.md
├── brick.ogg
├── coin.ogg
├── die.ogg
├── flagpole.ogg
├── gameover.ogg
├── init.ogg
├── jump.ogg
├── mario.sh
├── stomp.ogg
├── timewarning.ogg
├── up.ogg
├── world1-1.ogg
└── worldcleared.ogg
/.settings:
--------------------------------------------------------------------------------
1 | _topScore=22730
2 | _sound=on
3 | _color=off
4 |
--------------------------------------------------------------------------------
/Copying:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | mario-shellscript
2 | =================
3 |
4 | Game do Mario Bros em Shell Script
5 |
--------------------------------------------------------------------------------
/brick.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/brick.ogg
--------------------------------------------------------------------------------
/coin.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/coin.ogg
--------------------------------------------------------------------------------
/die.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/die.ogg
--------------------------------------------------------------------------------
/flagpole.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/flagpole.ogg
--------------------------------------------------------------------------------
/gameover.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/gameover.ogg
--------------------------------------------------------------------------------
/init.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/init.ogg
--------------------------------------------------------------------------------
/jump.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/jump.ogg
--------------------------------------------------------------------------------
/mario.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -i
2 |
3 | ##################################################################################
4 | # #
5 | # Copyright (C) 2012 Doriedson Alves Galdino de Oliveira #
6 | # Thiago Andre Silva #
7 | # Vitor Augusto Andrioli #
8 | # #
9 | # This program is free software: you can redistribute it and/or modify #
10 | # it under the terms of the GNU General Public License as published by #
11 | # the Free Software Foundation, either version 3 of the License, or #
12 | # (at your option) any later version. #
13 | # #
14 | # This program is distributed in the hope that it will be useful, #
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17 | # GNU General Public License for more details. #
18 | # #
19 | # You should have received a copy of the GNU General Public License #
20 | # along with this program. If not, see . #
21 | # #
22 | ##################################################################################
23 |
24 | # Autores:
25 | # Doriedson RA 1430431213050
26 | # Thiago Andre RA 1430431213077
27 | # Vitor Augusto RA 1430431213047
28 | # Data: 24/04/2012
29 |
30 | # DESCRICAO:
31 | # Jogo do Mario Bros estilo nintendo 8 bits.
32 |
33 | # CHANGELOG:
34 |
35 | # 2012/05/09 (Doriedson, Vitor, Thiago)
36 | # Eliminada a funcao LoadGame que carregava o mapa da primeira fase em caracters e criada a LoadFase1 para gerar a primeira fase
37 | # a partir de mapa de caracters menores.
38 | # Criada funcao MontaCanvas para pegar o tamanho da tela em um mapa de caracters e jogar no buffer
39 |
40 | # 2012/05/15 (Doriedson, Vitor, Thiago)
41 | # Adicionada Funcao Splash para mostrar as vidas do personagem e definir abertura de tela
42 | # Adicionada Funcao ColisaoBuraco para relizar colisão com os buracos do cenario
43 | # Adicionada Funcao Dead para relizar animação da morte do personagem
44 | # Adicionada Funcao Play para centralizar as rotinas de execução de audio
45 |
46 | # 2012/05/22 (Doriedson, Vitor, Thiago)
47 | # Adicionada Funcao ColisaoBloco
48 | # Adicionada Funcao ColisaoCoin
49 |
50 | # 2012/05/29 (Doriedson, Vitor, Thiago)
51 | # Adicionado Inimigo na fase
52 | # Adicionada Funcao ResizeScreen para ajustar o jogo no terminal caso o terminal seja redimensionado
53 | # Alteradas algumas variaveis, inclusive a do jogador, para vetor, para melhorar o calculo de colisao e possivel adicao de cor nos itens da tela como o personagem e as moedas.
54 |
55 | # 2012/06/05 (Doriedson, Vitor, Thiago)
56 | # Corrigido bug na funcao LoadFase1 (toda vez que o personagem morre a funcao eh chamada e os vetores fasel[37] [38] e [39] eram incrementados,
57 | # nunca sendo zerados)
58 | # Removido tput clear na funcao resizeScreen para evitar scrolling no terminal e adicionado string com espaços
59 | # Adicionada tela de gameover
60 | # Adicionada funcao para incrementar score e salvar topscore
61 | # Criada funcao MontaMenu, quando mudava o tamanho do terminal não redesenhava e estourava o grafico
62 | # Alterada funcao FPS para controle de uma unica unidade do tempo
63 | # Ajustado movimento do personagem para ficar com mais suavidade
64 | # Retirado desenho das moedas no buffer da fase e criada funcao DrawCoin para desenhar no buffer da tela e realizar animacao
65 | # Criada variavel _edgeScreen para permitir renderizar desenhos que ficam com parte visivel na camera e parte nao visivel
66 | # Corrigido problema de colisao com o inimigo que era avaliado soh o primeiro pois saia da funcao com return e nao avaliava os outros
67 | # Usado -i na frente do /bash/bin inicialamente para importar variaveis como LINES e COLUMNS para nao realizar processos com tput ...
68 | # ...mas foi verificado que é mais lento do que o comando tput entao permanene pelo motivo de suprir a mensagem de retorno de erro ...
69 | # ...quando a musica de background é morta pelo kill.
70 |
71 | # [ FUNCOES ] --------------------------------------------------------------------------------------------------------
72 |
73 | _version="1.0" #20120618
74 |
75 | # Funcao para pegar tamanho do terminal
76 | function TerminalSize {
77 |
78 | # Cria variavel com altura do terminal em linhas
79 | local _tmph=`tput lines`
80 |
81 | # Cria variavel com largura do terminal em colunas
82 | local _tmpw=`tput cols`
83 |
84 | # Verifica se houve mudança no tamando do terminal
85 | if [ $_tmph -ne $_height ] || [ $_tmpw -ne $_width ]; then
86 |
87 | _height=$_tmph
88 | _width=$_tmpw
89 |
90 | ResizeScreen
91 |
92 | fi
93 |
94 | }
95 |
96 | # Funcao para redimensionamento do terminal
97 | function ResizeScreen {
98 |
99 | # Inicializa variavel para definir o meio da tela em largura para economizar recalculo no jogo
100 | _widthMid=$((_width / 2))
101 |
102 | # Cria variavel para determinar onde começara o desenho da tela subtraindo a altura de desenho do jogo (36 linhas)
103 | _initY=$((_height - _heightScreen))
104 |
105 | #Cria variaveis para verificar se o terminal eh maior que 80 colunas e centraliza a tela do menu no meio com espaços em volta
106 | _spaceIni=""
107 | _spaceFim=""
108 |
109 | if [ $_width -gt 80 ]; then
110 |
111 | _i=$(( (( _width - 80 )) / 2 ))
112 | _f=$(( (( _width - 80 )) - _i ))
113 | _spaceIni=`printf "%${_i}s"`
114 | _spaceFim=`printf "%${_f}s"`
115 | fi
116 |
117 | ((_s= _width*_height))
118 |
119 | _clearScreen=`printf "%${_s}s"`
120 |
121 | # Cria uma variavel com espaços da largura da tela
122 | _spaceScreen=`printf "%${_width}s"`
123 |
124 | # limpa o topo da tela onde não será usado na screen do jogo
125 | # _screen=""
126 | # for (( _k=0; _k<(_height-_heightScreen); _k++ )); do
127 | _screen+="$_spaceScreen"
128 | # done
129 |
130 | tput reset
131 | tput civis
132 |
133 | # Configura a cor do fundo da tela
134 | #tput setab 7
135 |
136 | # Configura a cor da fonte
137 | #tput setaf 0
138 |
139 | ClearScreen
140 |
141 | _scoreX=$((((_width-80))/2)) # Guarda a Posição do Score na tela de acordo o tamanho do terminal aberto
142 |
143 | }
144 |
145 | # Função para limpar a tela
146 | function ClearScreen {
147 |
148 | tput cup 0 0
149 |
150 | if [ $_color = "on" ]; then
151 | echo -ne "${_cor[1]}$_clearScreen"
152 | else
153 | echo -ne "\E[00;30;47m$_clearScreen"
154 | fi
155 |
156 | tput cup $_initY 0 # Seta o ponteiro para a linha em que o jogo será desenhado (renderizado)
157 |
158 | }
159 |
160 | # Função para montar a primeira fase do jogo
161 | function LoadFase1 {
162 |
163 | _sizeFase=3000 # Tamanho da fase (largura)
164 | _btela=`printf "%${_sizeFase}s"` # Variavel com caracter espaço do tamanho da fase para montar o buffer da tela
165 |
166 | _tamQuad=100
167 |
168 | _flagDraw[4]="█ ███"
169 |
170 | _flagX=2883
171 | _flagY=6
172 |
173 | # Vetor de localização dos inimigos definindo sua area de movimento
174 | _enemyX=(0 200 350 500 650 900 1490 1750 2030 2450 2780)
175 | _enemyPathIni=(0 150 320 460 610 880 1480 1710 2000 2330 2700)
176 | _enemyPathFim=(0 250 420 560 710 980 1580 1810 2100 2480 2800)
177 |
178 | # Posicao das moedas no cenario
179 | _coin=(0 80 190 210 330 350 370 390 410 430 660 800 830 860 890 1010 1080 1150 1240 1260 1280 1370 1390 1410 1480 1500 1520 1540 1590 1650 1720 1810 1830 1850 1870 1890 2260 2290 2320 2350 2410 2540 2570 2600 2630)
180 |
181 | # Posicao dos blocos no cenario
182 | _bloco=(0 105 135 165 495 525 555 630 690 975 1035 1110 1305 1320 1335 1560 1620 1680 1785 1920 2010 2040 2070 2100 2130 2160 2385 2670 2760 2790)
183 |
184 | # Posicao das nuvens no cenario
185 | _nuvem=(0 30 220 290 450 580 750 930 1180 1430 1740 1950 2180 2450 2720 2830 2965)
186 |
187 | # Posição dos buracos na fase
188 | _buraco=(0 280 580 850 1420 1830 2300 2500)
189 |
190 | # Vetor para guardar a posição das monts na tela
191 | _mont=(0 35 150 210 390 520 740 810 960 1050 1180 1250 1360 1570 1780 1900 2060 2120 2350 2420 2580 2790)
192 |
193 | _nuvem[0]=${#_nuvem[*]} # Define a quantidade de nuvens no cenario
194 | _nuvemY=(0) # Posicao em Y da nuvem no cenario
195 | _nuvemHeight=$_nuvem[0] # Altura da nuvem no cenario
196 |
197 | for (( _k=1; _k<_nuvem[0]; _k++ )); do
198 | _nuvemY[$_k]=2
199 | done
200 |
201 | _enemyX[0]=${#_enemyX[*]} # Define a constante da quantidade de (indices no vetor dos) inimigos
202 | _enemyWidth=16 # Largura do inimigo
203 | _enemyHeight=(0) # Altura do inimigo eh definido no indice[0] do sprite atual
204 | _enemyY=(0) # Posição do inimigo no eixo de y definido pelo piso e altura
205 | _enemyVelocX=(1) # Velocidade do inimigo
206 | _enemySprite=(0) # Define qual sprite do inimigo sera desenhado
207 | _enemyDead=(0) # vetor para definir inimigos vivos
208 | _aniEnemy=(0) # Define sprite de animacao do inimigo
209 |
210 | # Preenche o vetor com a posicao do quadrante dos inimigos
211 | for ((_k=1; _k<_enemyX[0]; _k++)); do
212 |
213 | _enemyVelocX[$_k]=${_enemyVelocX[0]}
214 | _enemySprite[$_k]=${_enemySprite[0]}
215 | _aniEnemy[$_k]=0
216 | _enemyDead[$_k]=0
217 |
218 | done
219 |
220 | _coin[0]=${#_coin[*]} # Define a constante da quantidade de moedas
221 | _coinWidth=10 # Largura da moeda
222 | _coinHeight=5 # Altura da moeda
223 | _coinY=(9) #posicao da moeda em y
224 | _coinQ=(0) #vetor para definir o quadrante das moedas
225 | _coinSprite=(0) #define sprite de animacao das moedas
226 |
227 | #Cria um vetor para o quadrante para checar as colisoes com as moedas
228 | for ((_k=1; _k<_coin[0]; _k++)); do
229 |
230 | _tmp=$((_coin[_k] / _coinWidth))
231 | _coinY[$_k]=${_coinY[0]}
232 | _coinQ[$_tmp]=$_k
233 | _coinSprite[$_k]=${_coinSprite[0]}
234 |
235 | done
236 |
237 |
238 | _blocoWidth=15 #largura do bloco
239 | _blocoY=8 #posicao do bloco em y
240 | _blocoHeight=7 #altura do bloco
241 | _blocoQ=(0) #vetor para definir o quadrante
242 | _bloco[0]=${#_bloco[*]}
243 |
244 | for ((_k=1; _k<_bloco[0]; _k++)); do
245 |
246 | _tmp=$((_bloco[_k] / _blocoWidth))
247 | _blocoQ[$_tmp]=$_k
248 |
249 | done
250 |
251 | _montWidth=30 #largura da montanha
252 | _mont[0]=${#_mont[*]}
253 |
254 | _buraco[0]=${#_buraco[*]}
255 | _buracoWidth=25
256 |
257 | #buffer da tela
258 | for (( _k=0; _k<=36; _k++ )); do
259 | _fasel[$_k]="$_btela"
260 | done
261 |
262 | #monta o piso da fase no buffer
263 | _tmp=$((_sizeFase / 10))
264 |
265 | _fasel[37]=""
266 | _fasel[38]=""
267 | _fasel[39]=""
268 |
269 | #Coloca o piso na fase
270 | for (( _k=0; _k<_tmp; _k++ )); do
271 |
272 | _fasel[37]+="${_piso1}"
273 | _fasel[38]+="${_piso2}"
274 | _fasel[39]+="${_piso1}"
275 |
276 | done
277 |
278 | #desenha as nuvens no cenario
279 | for (( _k=1; _k<_nuvem[0]; _k++ )); do
280 |
281 | _tmpPos=${_nuvem[$_k]}
282 |
283 | _ind=${_nuvemY[$_k]}
284 |
285 | for (( _l=_ind; _l<_ind + _nuvemDraw[0]; _l++ )); do
286 |
287 | _tmp0=$(( _l - _ind + 1))
288 | _tmp1=${#_nuvemDraw[$_tmp0]}
289 |
290 | _f=$(( _tmpPos + _tmp1 ))
291 |
292 | _fasel[$_l]="${_fasel[$_l]:0:$_tmpPos}${_nuvemDraw[$_tmp0]}${_fasel[$_l]:$_f}"
293 | done
294 | done
295 |
296 | #desenha os buracos na fase
297 | # for (( _k=1; _k<_buraco[0]; _k++ )); do
298 | #
299 | # _tmpPos=${_buraco[$_k]}
300 | #
301 | # _f=$(( _tmpPos + 24 ))
302 | #
303 | # _fasel[37]="${_fasel[37]:0:$_tmpPos}${_buracoDraw}${_fasel[37]:$_f}"
304 | # _fasel[38]="${_fasel[38]:0:$_tmpPos}${_buracoDraw}${_fasel[38]:$_f}"
305 | # _fasel[39]="${_fasel[39]:0:$_tmpPos}${_buracoDraw}${_fasel[39]:$_f}"
306 | # done
307 |
308 | #desenha as montanhas no buffer da fase
309 | for (( _k=1; _k<_mont[0]; _k++ )); do
310 |
311 | _montX=${_mont[$_k]}
312 | _tmp2=$(( _montX + _montWidth ))
313 | for (( _l=1; _l<=7; _l++ )); do
314 | _tmp=$((_l + 29 ))
315 | _fasel[$_tmp]="${_fasel[$_tmp]:0:$_montX}${_montDraw[$_l]}${_fasel[$_tmp]:$_tmp2}"
316 | done
317 | done
318 |
319 | #desenha os blocos na fase
320 | for (( _k=1; _k<_bloco[0]; _k++ )); do
321 |
322 | _blocoX=${_bloco[$_k]}
323 | _tmp2=$(( _blocoX + _blocoWidth ))
324 |
325 | _fasel[$((_blocoY))]="${_fasel[$((_blocoY))]:0:$_blocoX}${_blocoDraw[0]}${_fasel[$((_blocoY))]:$_tmp2}"
326 | _fasel[$((_blocoY+1))]="${_fasel[$((_blocoY+1))]:0:$_blocoX}${_blocoDraw[1]}${_fasel[$((_blocoY+1))]:$_tmp2}"
327 | _fasel[$((_blocoY+2))]="${_fasel[$((_blocoY+2))]:0:$_blocoX}${_blocoDraw[1]}${_fasel[$((_blocoY+2))]:$_tmp2}"
328 | _fasel[$((_blocoY+3))]="${_fasel[$((_blocoY+3))]:0:$_blocoX}${_blocoDraw[1]}${_fasel[$((_blocoY+3))]:$_tmp2}"
329 | _fasel[$((_blocoY+4))]="${_fasel[$((_blocoY+4))]:0:$_blocoX}${_blocoDraw[1]}${_fasel[$((_blocoY+4))]:$_tmp2}"
330 | _fasel[$((_blocoY+5))]="${_fasel[$((_blocoY+5))]:0:$_blocoX}${_blocoDraw[1]}${_fasel[$((_blocoY+5))]:$_tmp2}"
331 | _fasel[$((_blocoY+6))]="${_fasel[$((_blocoY+6))]:0:$_blocoX}${_blocoDraw[0]}${_fasel[$((_blocoY+6))]:$_tmp2}"
332 | done
333 |
334 | #desenha moedas na fase
335 | # for (( _k=1; _k<_coin[0]; _k++ )); do
336 |
337 | # _coinX=${_coin[$_k]}
338 | # _tmp2=$(( _coinX + _coinWidth ))
339 | # for (( _l=1; _l<=5; _l++ )); do
340 | # _tmp=$((_l+8))
341 | # _fasel[$_tmp]="${_fasel[$_tmp]:0:$_coinX}${_coinDraw[$_l]}${_fasel[$_tmp]:$_tmp2}"
342 | # done
343 | # done
344 |
345 | #desenha o castelo na fase
346 | for (( _k=1; _k<=_castle[0]; _k++ )); do
347 |
348 | ((_tmp = _k + 5))
349 | _tmpL=${#_castle[$_k]}
350 | _tmpI=$((_sizeFase-120))
351 | _tmpF=$((_tmpI + _tmpL))
352 |
353 | _fasel[$_tmp]="${_fasel[$_tmp]:0:$_tmpI}${_castle[$_k]}${_fasel[$_tmp]:$_tmpF}"
354 | done
355 |
356 | }
357 |
358 | # funcao para desenhar os buracos na fase
359 | function DrawBuraco {
360 |
361 | _ubound=${_buraco[0]}
362 |
363 | for (( _k=1; _k < _ubound; _k++ )); do #laco para verificar cada inimigo
364 |
365 | #verifica se o buraco esta visivel na camera
366 | if [ $((_buraco[_k] + _buracoWidth)) -ge $_cameraX ] && [ ${_buraco[$_k]} -le $((_cameraX + _width)) ]; then
367 |
368 | _buracoX=$(( _buraco[_k] + _edgeWidth - _cameraX ))
369 | _buracoL=$(( _buracoX + _buracoWidth ))
370 |
371 | _tmp=${_canvasC[0]}
372 |
373 | for (( _l=37; _l<40; _l++ )); do
374 | _canvas[$_l]="${_canvas[$_l]:0:$((_buracoX-2))}${_buracoDraw}${_canvas[$_l]:$((_buracoL+2))}"
375 |
376 | if [ $_color = "on" ]; then
377 | _tmp=${_canvasC[0]}
378 | ((_tmp++))
379 | _canvasC[$_tmp]=${_cor[2]}
380 | if [ $((_buracoX - _edgeWidth)) -lt 0 ]; then
381 | _canvasP[$_tmp]=$((_width * _l))
382 | else
383 | _canvasP[$_tmp]=$(( (_width * _l) + _buracoX - _edgeWidth ))
384 | fi
385 | ((_tmp++))
386 | _canvasC[$_tmp]=${_cor[3]}
387 | if [ $((_buracoL - _edgeWidth)) -gt $_width ]; then
388 | _canvasP[$_tmp]=$(( _width * (_l+1) ))
389 | else
390 | _canvasP[$_tmp]=$(( (_width * _l) + _buracoL - _edgeWidth ))
391 | fi
392 |
393 | _canvasC[0]=$_tmp
394 |
395 | fi
396 |
397 | done
398 |
399 |
400 | fi
401 | done
402 |
403 | }
404 |
405 | # Funcao para montar o buffer de fundo da tela a partir da cordenada do jogador
406 | function MontaCanvas {
407 |
408 | #Limpa o buffer para posicionar a camera na tela da primeira fase
409 | #_canvas=""
410 |
411 | #verifica se a posicao do jogador é menor do que o meio do terminal
412 | if [ $_jogX -lt $_widthMid ]; then
413 |
414 | _cameraX=0 #zera a posicao da camera
415 |
416 | else
417 | if [ $_jogX -ge $((_sizeFase - _widthMid)) ]; then #se posicao do jogador passou do meio do terminal
418 |
419 | _cameraX=$((_sizeFase - _width)) #fixa a camera no final da fase
420 |
421 | else
422 |
423 | _cameraX=$((_jogX - _widthMid)) #fixa o jogador no meio da camera
424 | fi
425 | fi
426 |
427 | #gera o buffer da tela de acordo com a posicao da camera
428 | for (( _k=0; _k<_heightScreen; _k++ )); do
429 |
430 | _f=$(( _cameraX + _width -1))
431 |
432 | _canvas[$_k]="${_edgeScreen}${_fasel[$_k]:$_cameraX:$_width}${_edgeScreen}"
433 |
434 | done
435 |
436 |
437 | }
438 |
439 | #Sair do jogo para o terminal
440 | function Sair {
441 |
442 | #Restaura configurações do terminal
443 | stty $_terminal
444 |
445 | #Retorna o ponteiro que pisca na tela
446 | tput cnorm
447 |
448 | #Volta as cores ao normal
449 | tput sgr0
450 |
451 | #Limpa a tela
452 | tput reset
453 |
454 | #Restaura o terminal ao seu padrao
455 | #stty sane
456 |
457 | # Verifica se ocorreu algum erro e imprime na tela do terminal
458 | if [ "$_erro" != "" ]; then
459 | echo -e $_erro
460 | fi
461 |
462 | # termina o programa
463 | exit
464 | }
465 |
466 | #inicializa as variaveis para comecar o jogo
467 | function InitGame {
468 |
469 | _score=0 #zera o score atual
470 |
471 | # _coins=0 #Zera as moedas pega em jogo anterior
472 |
473 | _jogLife=3 #variavel com valor inicial de vidas para o jogo
474 |
475 | Splash #Função para exibir as vidas do jogador
476 |
477 | }
478 |
479 | # funcao para somar score e salvar top score
480 | function Score {
481 |
482 | ((_score+=$1))
483 |
484 | if [ $_score -ge $_topScore ]; then
485 | _topScore=$_score
486 | SaveSettings
487 | fi
488 |
489 | }
490 |
491 | #função para salvar configurações quando ocorrer mudanças
492 | function SaveSettings {
493 |
494 | echo "_topScore=$_topScore">.settings
495 | echo "_sound=$_sound">>.settings
496 | echo "_color=$_color">>.settings
497 |
498 | }
499 | #Função para exibir as vidas do jogador
500 | function Splash {
501 |
502 | #Seta o nome da tela atual(estado do jogo)
503 | _screenGame="SPLASH"
504 |
505 | LoadColors
506 |
507 | #Registra Coordenadas iniciais do jogador
508 | _jogX=0
509 | _jogY=0
510 | _velocY=0
511 | _velocX=0
512 |
513 | _jogDead=false #Controla se o jogador morreu
514 |
515 | # guarda qual sprite do personagem sera exibido
516 | _jogAni=0 #controla a animacao de sprite para dar sensacao mais real do andar
517 | _jogSprite=0
518 |
519 | #lado do jogador (Sprite) d=direito e=esquerdo
520 | _jogSide="D"
521 |
522 | #Preenche o buffer com a tela do Splash
523 | for (( _y=0; _y<12; _y++ )); do
524 |
525 | _canvas[$_y]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
526 |
527 | done
528 |
529 | _canvas[12]="${_edgeScreen}${_spaceIni} █████ ${_spaceFim}${_edgeScreen}"
530 | _canvas[13]="${_edgeScreen}${_spaceIni} █░░░░M███ ${_spaceFim}${_edgeScreen}"
531 | _canvas[14]="${_edgeScreen}${_spaceIni} █░░░░░░░░░█ ${_spaceFim}${_edgeScreen}"
532 | _canvas[15]="${_edgeScreen}${_spaceIni} ███ █ ███ ${_spaceFim}${_edgeScreen}"
533 | _canvas[16]="${_edgeScreen}${_spaceIni} █ ██ █ █ X 0${_jogLife} ${_spaceFim}${_edgeScreen}"
534 | _canvas[17]="${_edgeScreen}${_spaceIni} █ ██ █ █ ${_spaceFim}${_edgeScreen}"
535 | _canvas[18]="${_edgeScreen}${_spaceIni} ██ █████ ${_spaceFim}${_edgeScreen}"
536 | _canvas[19]="${_edgeScreen}${_spaceIni} ██ █ ${_spaceFim}${_edgeScreen}"
537 | _canvas[20]="${_edgeScreen}${_spaceIni} █████ ${_spaceFim}${_edgeScreen}"
538 |
539 | for (( _y=21; _y<_heightScreen; _y++ )); do
540 |
541 | _canvas[$_y]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
542 |
543 | done
544 |
545 | Render #chama função Render
546 |
547 | LoadFase1 #Carrega a tela da primeira fase para o buffer
548 |
549 | sleep 1 #adormece o script por 1 segundos
550 |
551 | #Toca som de fundo tema
552 | Play "background"
553 |
554 | #Seta o nome da tela atual(posicao no jogo)
555 | _screenGame="GAME"
556 |
557 | _timeIni=$SECONDS #set variavel com tempo de segundo do sistema para controlar tempo no jogo
558 | }
559 |
560 | # função para desenha gameover na tela
561 | function GameOver {
562 |
563 | # seta que o jogo na tela de game over
564 | _screenGame="GAMEOVER"
565 |
566 | LoadColors
567 |
568 | #Preenche o buffer com a tela do Splash
569 | for (( _y=0; _y<13; _y++ )); do
570 |
571 | _canvas[$_y]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
572 |
573 | done
574 |
575 | #desenho do gameover
576 |
577 | _canvas[13]="${_edgeScreen}$_spaceIni ████ ████ ██ ██ ██████ ████ ██ ██ ██████ █████ ██ $_spaceFim${_edgeScreen}"
578 | _canvas[14]="${_edgeScreen}$_spaceIni ██ ██ ██ ███ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ $_spaceFim${_edgeScreen}"
579 | _canvas[15]="${_edgeScreen}$_spaceIni ██ ███ ██████ ██ █ ██ ████ ██ ██ ██ ██ ████ █████ ██ $_spaceFim${_edgeScreen}"
580 | _canvas[16]="${_edgeScreen}$_spaceIni ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ $_spaceFim${_edgeScreen}"
581 | _canvas[17]="${_edgeScreen}$_spaceIni ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ██ ██ ██ $_spaceFim${_edgeScreen}"
582 |
583 |
584 | for (( _y=18; _y<_heightScreen; _y++ )); do
585 |
586 | _canvas[$_y]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
587 |
588 | done
589 |
590 | Render #chama função Render
591 |
592 | sleep 4 #adormece o script por segundos
593 |
594 | LoadMenu
595 | }
596 |
597 | # função para desenhar a tela de GameWin
598 | function GameWin {
599 |
600 | # seta que o jogo na tela de game over
601 | _screenGame="GAMEWIN"
602 |
603 | LoadColors
604 |
605 | #Preenche o buffer com a tela do Splash
606 | for (( _y=0; _y<10; _y++ )); do
607 |
608 | _canvas[$_y]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
609 |
610 | done
611 |
612 | #desenho do fim do jogo WIN
613 |
614 | _canvas[10]="${_edgeScreen}${_spaceIni} █████ ████ █████ ████ █████ ██████ ██ ██ ████ ██ ${_spaceFim}${_edgeScreen}"
615 | _canvas[11]="${_edgeScreen}${_spaceIni} ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ${_spaceFim}${_edgeScreen}"
616 | _canvas[12]="${_edgeScreen}${_spaceIni} █████ ██████ █████ ██████ █████ ████ ██ ███ ████ ██ ${_spaceFim}${_edgeScreen}"
617 | _canvas[13]="${_edgeScreen}${_spaceIni} ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ${_spaceFim}${_edgeScreen}"
618 | _canvas[14]="${_edgeScreen}${_spaceIni} ██ ██ ██ ██ ██ ██ ██ █████ ██████ ██ ██ ████ ██ ${_spaceFim}${_edgeScreen}"
619 | _canvas[15]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
620 | _canvas[16]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
621 | _canvas[17]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
622 | _canvas[18]="${_edgeScreen}${_spaceIni} TRABALHO EM SHELL SCRIPT ${_spaceFim}${_edgeScreen}"
623 | _canvas[19]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
624 | _canvas[20]="${_edgeScreen}${_spaceIni} FATEC CARAPICUIBA ${_spaceFim}${_edgeScreen}"
625 | _canvas[21]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
626 | _canvas[22]="${_edgeScreen}${_spaceIni} DISCIPLINA LSO (LABORATORIO DE SISTEMAS OPERACIONAIS) ${_spaceFim}${_edgeScreen}"
627 | _canvas[23]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
628 | _canvas[24]="${_edgeScreen}${_spaceIni} PROF. RUBENS ${_spaceFim}${_edgeScreen}"
629 | _canvas[25]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
630 | _canvas[26]="${_edgeScreen}${_spaceIni} ALUNO DORIEDSON ALVES GALDINO DE OLIVEIRA ${_spaceFim}${_edgeScreen}"
631 | _canvas[27]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
632 | _canvas[28]="${_edgeScreen}${_spaceIni} ALUNO VITOR AUGUSTO ANDRIOLI ${_spaceFim}${_edgeScreen}"
633 | _canvas[29]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
634 | _canvas[30]="${_edgeScreen}${_spaceIni} ALUNO THIAGO ANDRE SILVA ${_spaceFim}${_edgeScreen}"
635 | _canvas[31]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
636 |
637 |
638 | for (( _y=32; _y<_heightScreen; _y++ )); do
639 |
640 | _canvas[$_y]="${_edgeScreen}${_spaceScreen}${_edgeScreen}"
641 |
642 | done
643 |
644 | Render #chama função Render
645 |
646 | sleep 4 #adormece o script por segundos
647 |
648 | read -n1
649 |
650 | LoadMenu
651 | }
652 |
653 | #Carrega a tela do menu para o buffer
654 | function LoadMenu {
655 |
656 | if [ $_musicId ]; then
657 | Stop $_musicId #Mata o processo da musica de fundo
658 | fi
659 |
660 | #Seta o nome da tela atual(posicao no jogo)
661 | _screenGame="MENU"
662 |
663 | }
664 |
665 | #monta tela do menu no canvas
666 | function MontaMenu {
667 |
668 | #Limpa o buffer para preencher com a tela do menu
669 | #_canvas=""
670 |
671 | #Preenche o buffer com a tela menu
672 | for (( _y=0; _y<26; _y++ )); do
673 |
674 | _canvas[$_y]="${_edgeScreen}${_spaceIni}${_menu[$_y]}${_spaceFim}${_edgeScreen}"
675 |
676 | done
677 |
678 | _tmpi=$((36+12-${#_topScore}))
679 | _canvas[26]="${_edgeScreen}${_spaceIni}${_menu[26]:0:$_tmpi}${_topScore}${_menu[26]:60}${_spaceFim}${_edgeScreen}"
680 |
681 | for (( _y=27; _y<_heightScreen; _y++ )); do
682 |
683 | _canvas[$_y]="${_edgeScreen}${_spaceIni}${_menu[$_y]}${_spaceFim}${_edgeScreen}"
684 |
685 | done
686 |
687 | }
688 |
689 | function LoadColors {
690 |
691 | if [ $_color = "off" ]; then
692 | return
693 | fi
694 |
695 | # vetor para guardar as cores do cenario
696 | _canvasC=(0) #guarda a cor
697 | _canvasP=(0) #guarda a posicao da cor
698 |
699 | _tmp=0
700 |
701 | ((_tmp++))
702 | _canvasC[$_tmp]=${_cor[1]}
703 | _canvasP[$_tmp]=0
704 |
705 | ((_tmp++))
706 | _canvasC[$_tmp]=${_cor[2]}
707 | _canvasP[$_tmp]=$((_width * 2))
708 |
709 | case $_screenGame in
710 |
711 | "MENU")
712 | _tmp2=${#_spaceIni}
713 | for ((_k=5; _k<18; _k++)); do
714 | ((_tmp++))
715 | _canvasC[$_tmp]=${_cor[0]}
716 | _canvasP[$_tmp]=$(((_width * _k) + _tmp2 + 15))
717 | ((_tmp++))
718 | _canvasC[$_tmp]=${_cor[2]}
719 | _canvasP[$_tmp]=$(((_width * _k) + _tmp2 + 65))
720 | done
721 |
722 | ((_tmp++))
723 | _canvasC[$_tmp]=${_cor[3]}
724 | _canvasP[$_tmp]=$((_width * 37))
725 | ;;
726 |
727 | "GAME"|"DEAD"|"WIN"|"WINPOINT")
728 | ((_tmp++))
729 | _canvasC[$_tmp]=${_cor[3]}
730 | _canvasP[$_tmp]=$((_width * 37))
731 | ;;
732 |
733 | esac
734 |
735 | _canvasC[0]=$_tmp
736 |
737 | }
738 |
739 | #Desenha o Jogador no buffer da tela
740 | function DrawJogador {
741 |
742 | #Calcula a posição inicial do desenho do jogador no buffer da tela
743 | _tmpJogX=$((_jogX - (_cameraX - _edgeWidth)))
744 | _tmpIni=1
745 |
746 | if [ $((_jogY + _jogHeight -1)) -gt 39 ]; then
747 | _tmpJogHeight=$(( 40 - _jogY ))
748 | elif [ $_jogY -lt 0 ]; then
749 | _tmpJogHeight=$(( _jogHeight + _jogY ))
750 | _tmpIni=$((-_jogY +1))
751 | else
752 | _tmpJogHeight=$_jogHeight
753 | fi
754 |
755 | #Laço para desenhar o jogador
756 | for (( _l=_tmpIni; _l<=_tmpJogHeight; _l++ )); do
757 |
758 | #Pega pŕoxima variável(linha) do desenho do jogador
759 | _tmp="_mario${_jogSide}${_jogSprite}[$_l]"
760 |
761 | #Lê o valor da variável como nome de outro variavel
762 | _tmp="${!_tmp}"
763 |
764 | #Calcula o tamanho restante da buffer da tela para recorte
765 | _tmpf=$((_tmpJogX+${#_tmp}))
766 |
767 | #Desenha a linha do personagem no buffer da tela
768 | #_screen="${_screen:0:$_posIniJog}${_tmp}${_screen:$_resto}"
769 | _tmpJogY=$(( _jogY+_l-1))
770 | _canvas[$_tmpJogY]="${_canvas[$_tmpJogY]:0:$_tmpJogX}${_tmp}${_canvas[$_tmpJogY]:$_tmpf}"
771 |
772 | done
773 | }
774 |
775 | #função para desenhar o score no topo do buffer da tela
776 | function DrawScore {
777 |
778 | # Gera novo buffer para tela
779 | #_screen="$_canvas"
780 |
781 | #posicao das linhas temporariamente
782 | _tmp=0
783 |
784 | #posiciona e imprime o title score
785 | #_screen="${_screen:0:$_tmp}${_spaceIni}${_scoreTitle0}${_spaceFim}${_screen:$((_tmp + _width))}"
786 | _canvas[0]="${_edgeScreen}${_spaceIni}${_scoreTitle0}${_spaceFim}${_edgeScreen}"
787 |
788 | _tmpScore=${#_score}
789 | _tmpScorei=$((11 - _tmpScore))
790 |
791 | _tmpCoin=${#_coins}
792 | _tmpCoini=$((21 - _tmpCoin))
793 |
794 | _tmpTime=${#_time}
795 | _tmpTimei=$(( 37 - _tmpTime ))
796 |
797 | ((_tmp+=_width))
798 | _canvas[1]="${_edgeScreen}${_spaceIni}${_scoreTitle1:0:$_tmpScorei}${_score}${_scoreTitle1:11:${_tmpCoini}}${_coins}${_scoreTitle1:32:$_tmpTimei}${_time}${_scoreTitle1:69}${_spaceFim}${_edgeScreen}"
799 |
800 | # gera o texto que exibe o fps e posiciona na tela
801 | _texto="[s]sound:$_sound [c]color:$_color LPS:$_lps"
802 |
803 | # _i=$((39 * _width))
804 | _l=${#_texto}
805 |
806 | # posiciona e imprime o texto fps na _screen
807 | _pos=$((39))
808 | _canvas[$_pos]="${_edgeScreen}${_texto}${_canvas[$_pos]:$((_l + _edgeWidth))}${_edgeScreen}"
809 |
810 | }
811 |
812 | #Desenha o buffer no terminal
813 | function Render {
814 |
815 | # se jogo esta em andamento chama função para montar o buffer da tela de acordo a posição da camera na fase
816 | case $_screenGame in
817 |
818 | "GAME"|"DEAD"|"WIN"|"WINPOINT")
819 | MontaCanvas;;
820 |
821 | "MENU")
822 | MontaMenu;;
823 |
824 | esac
825 |
826 |
827 | case $_screenGame in
828 |
829 | "SPLASH"|"GAMEOVER"|"GAMEWIN")
830 | DrawScore #desenha o score no topo da tela
831 | ;;
832 |
833 | "MENU")
834 | DrawScore #desenha o score no topo da tela
835 | _temp=0 #variavel nao utilizada para nao deixar o case vazio
836 | ;;
837 |
838 | "GAME"|"DEAD"|"WIN"|"WINPOINT")
839 | DrawBuraco #desenha buracos na fase
840 | DrawScore #desenha o score no topo da tela
841 | DrawCoin #desenha as moedas se existir
842 | DrawEnemy #desenha o inimigo se existir
843 | DrawFlag #desenha a bandeira do mastro
844 | DrawJogador #Desenha o jogador
845 | ;;
846 |
847 | esac
848 |
849 | _screen=""
850 |
851 | for (( _k=0; _k<_heightScreen; _k++ )); do
852 | _canvas[$_k]="${_canvas[$_k]:$_edgeWidth:$_width}"
853 | _screen+="${_canvas[$_k]}"
854 | done
855 |
856 | if [ $_color = "on" ]; then
857 |
858 | #echo "${_canvasC[*]}"
859 |
860 | BubbleSort
861 |
862 | # QuickSort 1 ${_canvasC[0]}
863 |
864 |
865 | # _tmpSize=$(( _width * _height / 10 ))
866 |
867 | # for (( _k=_tmpSize; _k>0; _k-- )); do
868 | # if [ ! -z ${_canvasP[$_k]} ]; then
869 | #_screen="${_screen:0:${_canvasP[$_k]}}${_canvasC[$_k]}${_screen:${_canvasP[$_k]}}"
870 | # fi
871 | # done
872 |
873 | for (( _k=_canvasC[0]; _k>0; _k-- )); do
874 | _screen="${_screen:0:${_canvasP[$_k]}}${_canvasC[$_k]}${_screen:${_canvasP[$_k]}}"
875 | done
876 | fi
877 |
878 | #Desenha a cena atual do jogo no terminal
879 | echo -ne "$_screen"
880 |
881 | tput cup $_initY 0 #Posiciona o ponteiro na tela para desenhar o buffer
882 |
883 | }
884 |
885 | function QuickSort {
886 |
887 | local _ini=$1
888 | local _fim=$2
889 | local _pivo=${_canvasP[$(( (_ini + _fim ) / 2 ))]}
890 |
891 | while [ $_ini -lt $_fim ]; do
892 |
893 | while [ ${_canvasP[$_ini]} -lt $_pivo ]; do
894 | ((_ini++))
895 | done
896 |
897 | while [ ${_canvasP[$_fim]} -gt $_pivo ]; do
898 | ((_fim--))
899 | done
900 |
901 | if [ $_ini -le $_fim ]; then
902 | local _aux=${_canvasP[$_ini]}
903 | _canvasP[$_ini]=${_canvasP[$_fim]}
904 | _canvasP[$_fim]=$_aux
905 |
906 | local _aux=${_canvasC[$_ini]}
907 | _canvasC[$_ini]=${_canvasC[$_fim]}
908 | _canvasC[$_fim]=$_aux
909 |
910 | ((_ini++))
911 | ((_fim--))
912 | fi
913 |
914 | if [ $_fim -gt $1 ]; then
915 | QuickSort $1 $_fim
916 | fi
917 |
918 | if [ $_ini -lt $2 ]; then
919 | QuickSort $_ini $2
920 | fi
921 | done
922 |
923 | }
924 |
925 | #ordena o vetor de cores da menor posicao para maior
926 | function BubbleSort {
927 |
928 | for (( _k=(_canvasC[0]); _k>1; _k-- )); do
929 |
930 | for (( _l=1; _l<_k; _l++ )); do
931 |
932 | (( _tmp= _l + 1 ))
933 |
934 |
935 | if [ $((_canvasP[$_l])) -gt $((_canvasP[$_tmp])) ]; then
936 |
937 | _tmpV=${_canvasP[$_tmp]}
938 | _canvasP[$_tmp]=${_canvasP[$_l]}
939 | _canvasP[$_l]=$_tmpV
940 |
941 | _tmpC=${_canvasC[$_tmp]}
942 | _canvasC[$_tmp]=${_canvasC[$_l]}
943 | _canvasC[$_l]=$_tmpC
944 |
945 | fi
946 |
947 | done
948 |
949 | done
950 |
951 | }
952 |
953 | # funcao para desenhar as moedas
954 | function DrawCoin {
955 |
956 | ((_tmp1=_cameraX / _coinWidth))
957 | ((_tmp2=(_cameraX + _width) / _coinWidth))
958 |
959 | for (( _k=_tmp1; _k<=_tmp2; _k++)); do
960 |
961 | _tmpCoin=${_coinQ[$_k]} #pega a posicao do indice do vetor das moedas se existir
962 |
963 |
964 | if [ $_k -eq 0 ] || [ -z $_tmpCoin ]; then #verifica se o indíce do quadrante não é zero e se existe moeda no quadrante
965 | continue
966 | else
967 |
968 | _coinX=${_coin[$_tmpCoin]} #pega a posicao x da moeda
969 |
970 | if [ $_coinX -gt 0 ]; then #se existir moeda desenha ela
971 |
972 | ((_coinX-=(_cameraX-_edgeWidth)))
973 |
974 | ((_coinSprite[_tmpCoin]++))
975 |
976 | if [ ${_coinSprite[$_tmpCoin]} -eq 6 ]; then
977 | _coinSprite[$_tmpCoin]=0
978 | fi
979 |
980 | ((_tmpSp=_coinSprite[_tmpCoin]/2))
981 |
982 | #Laço para desenhar a moeda
983 | for (( _l=1; _l<=_coinHeight; _l++ )); do
984 |
985 | #Pega pŕoxima variável(linha) do desenho do jogador
986 | _tmpS="_coinDraw${_tmpSp}[$_l]"
987 |
988 | #Lê o valor da variável como nome de outro variavel
989 | _tmpS="${!_tmpS}"
990 |
991 | #Calcula o tamanho restante da buffer da tela para recorte
992 | _tmpf=$((_coinX + _coinWidth))
993 |
994 | #Desenha a linha da coin no buffer da tela
995 | _tmpCoinY=$(( _coinY[_tmpCoin] + _l -1))
996 |
997 | _canvas[$_tmpCoinY]="${_canvas[$_tmpCoinY]:0:$_coinX}${_tmpS}${_canvas[$_tmpCoinY]:$_tmpf}"
998 |
999 | if [ $_color = "on" ]; then
1000 |
1001 | _tmp=${_canvasC[0]}
1002 | ((_tmp++))
1003 | _canvasC[$_tmp]=${_cor[4]}
1004 |
1005 | if [ $((_coinX - _edgeWidth)) -lt 0 ]; then
1006 | _canvasP[$_tmp]=$((_width * _tmpCoinY))
1007 | else
1008 | _canvasP[$_tmp]=$(( (_width * _tmpCoinY) + _coinX - _edgeWidth ))
1009 | fi
1010 |
1011 | ((_tmp++))
1012 | _canvasC[$_tmp]=${_cor[2]}
1013 | if [ $((_tmpf - _edgeWidth)) -gt $_width ]; then
1014 | _canvasP[$_tmp]=$(( _width * (_tmpCoinY+1) ))
1015 | else
1016 | _canvasP[$_tmp]=$(( (_width * _tmpCoinY) + _tmpf - _edgeWidth ))
1017 | fi
1018 |
1019 | _canvasC[0]=$_tmp
1020 |
1021 | fi
1022 |
1023 | done
1024 |
1025 | fi
1026 | fi
1027 |
1028 | done
1029 |
1030 | }
1031 |
1032 | # funcao para desenhar a bandeira no mastro
1033 | function DrawFlag {
1034 |
1035 | if [ $_flagX -lt $(( _cameraX + _width )) ]; then
1036 |
1037 | for (( _k=1; _k<=_flagDraw[0]; _k++ )); do
1038 |
1039 | #Calcula o tamanho restante da buffer da tela para recorte
1040 | _tmpL=${#_flagDraw[$_k]}
1041 | _tmpY=$(( _flagY + _k -1 ))
1042 | _tmpX=$(( _flagX - _cameraX + _edgeWidth ))
1043 | _tmpF=$(( _tmpX + _tmpL ))
1044 |
1045 |
1046 | #Desenha a linha do inimigo no buffer da tela
1047 | _canvas[$_tmpY]="${_canvas[$_tmpY]:0:$_tmpX}${_flagDraw[$_k]}${_canvas[$_tmpY]:$_tmpF}"
1048 |
1049 | done
1050 |
1051 |
1052 |
1053 | fi
1054 |
1055 | }
1056 |
1057 | #função para desenhar o inimigo se existir
1058 | function DrawEnemy {
1059 |
1060 | _ubound=${_enemyX[0]}
1061 |
1062 | for (( _k=1; _k < _ubound; _k++ )); do #laco para verificar cada inimigo
1063 |
1064 | #verifica se o path do inimigo esta visivel na camera
1065 | if [ $((_enemyX[_k] + _enemyWidth)) -ge $_cameraX ] && [ ${_enemyX[$_k]} -le $((_cameraX + _width)) ] && [ ${_enemySprite[$_k]} -le 6 ]; then
1066 |
1067 | _tmpY="_gompa${_enemySprite[$_k]}[0]" #Pega o sprite do inimigo
1068 | _tmpY="${!_tmpY}"
1069 |
1070 | #Calcula a posição inicial do desenho do inimigo no buffer da tela
1071 | _tmpEnemyY=$((_enemyY[_k])) #$((37 - _tmpY))
1072 | _tmpEnemyX=$(( _enemyX[_k] - (_cameraX - _edgeWidth)))
1073 |
1074 | #Laço para desenhar o inimigo
1075 | for (( _l=1; _l<=_tmpY; _l++ )); do
1076 |
1077 | _tmpE="_gompa${_enemySprite[$_k]}[$_l]" #Pega o sprite do inimigo
1078 | _tmpE="${!_tmpE}"
1079 |
1080 | #Calcula o tamanho restante da buffer da tela para recorte
1081 | _tmpL=${#_tmpE}
1082 | _tmpf=$(( _tmpEnemyX + _tmpL ))
1083 |
1084 | #Desenha a linha do inimigo no buffer da tela
1085 | _canvas[$_tmpEnemyY]="${_canvas[$_tmpEnemyY]:0:$_tmpEnemyX}${_tmpE}${_canvas[$_tmpEnemyY]:$_tmpf}"
1086 |
1087 | #Muda a posição inicial de plotagem para a próxima linha do inimigo
1088 | ((_tmpEnemyY++))
1089 | done
1090 | fi
1091 | done
1092 |
1093 | }
1094 |
1095 | #Função para ouvir o teclado
1096 | function ListenKey {
1097 | stty -icanon min 0
1098 | # ouve as teclas pressionadas pelo teclado
1099 | _key=$(dd bs=3 count=1 2>/dev/null)
1100 |
1101 | #read -n1 -t 0.001 _key
1102 |
1103 | # eliminar os caracters especias de quando as setas direcionais forem pressionadas
1104 | # while [ "$_key" = "^" ] || [ "$_key" = "[" ]; do
1105 |
1106 | # read -n1 -t 0.001 _key
1107 | # done
1108 |
1109 | #Verifica as teclas pressionadas
1110 | case $_key in
1111 |
1112 | $KEY_ENTER) #tecla ENTER
1113 | case $_screenGame in
1114 |
1115 | "MENU")
1116 | InitGame;; #Inicia o jogo
1117 |
1118 | esac
1119 | ;;
1120 |
1121 |
1122 | $KEY_ESC) #tecla ESC
1123 | case $_screenGame in
1124 |
1125 | "MENU")
1126 | Sair ;; #Termina o programa
1127 |
1128 | "GAME")
1129 | LoadMenu;; #Carrega a tela de menu
1130 |
1131 | esac
1132 | ;;
1133 |
1134 | $KEY_UP) #Seta para cima
1135 | case $_screenGame in
1136 |
1137 | "GAME")
1138 | #_clearBuffer=true
1139 | #Verifica se velocidade de y é = 0 e se o personagem esta no piso entao libera para pulo
1140 | if [ $_velocY -eq 0 ] && [ $((_jogY+_jogHeight)) -eq $((_piso)) ]; then
1141 | Play "jump" #Toca audio do pulo
1142 | #_jogSprite=2 #Sprite do jogador pulando
1143 | ((_velocY=-6)) #Define velocidade do pulo
1144 | fi
1145 | ;;
1146 | esac
1147 | ;;
1148 |
1149 | $KEY_RIGHT) # Pressionado a seta para direita
1150 | case $_screenGame in
1151 |
1152 | "GAME")
1153 | #_clearBuffer=true
1154 | #_jogSide=d #lado do jogador a desenhar
1155 | ((_velocX=4)) #Velocidade do jogador em X
1156 | ;;
1157 | esac
1158 | ;;
1159 |
1160 | $KEY_LEFT) # Pressionado a seta para esquerda
1161 | case $_screenGame in
1162 |
1163 | "GAME")
1164 | #_clearBuffer=true
1165 | #_jogSide=e #lado do jogador a desenhar
1166 | ((_velocX=-4)) #velocidade do jogador em X
1167 | ;;
1168 | esac
1169 | ;;
1170 |
1171 | "s")
1172 | if [ $_sound = "off" ] ; then
1173 | _sound="on"
1174 |
1175 | if [ $_screenGame = "GAME" ]; then
1176 | Play "background"
1177 | fi
1178 | else
1179 | _sound="off"
1180 |
1181 | if [ $_musicId ]; then
1182 | Stop $_musicId #para o processo da musica de fundo
1183 | fi
1184 | fi
1185 | SaveSettings
1186 | ;;
1187 |
1188 | "c")
1189 | if [ $_color = "on" ]; then
1190 | _color="off"
1191 | else
1192 | _color="on"
1193 | fi
1194 | SaveSettings
1195 | ClearScreen
1196 | ;;
1197 |
1198 | esac
1199 |
1200 |
1201 | #Se for capturado alguma tecla antes entao limpa o buffer para caso de segurar a tecla pressionada
1202 | #if [ $_clearBuffer = true ] ; then
1203 | # read -n100 -t0.001 _discard
1204 | # _clearBuffer=false
1205 | #fi
1206 | }
1207 |
1208 | #Função para verificar quantos loops por segundo o jogo está conseguindo rodar
1209 | function FPS {
1210 | # incrementa 1 na variável quadros
1211 | ((_quadros++))
1212 |
1213 | # Guarda o nanosegundo atual do relógio do sistema
1214 | _tempo2N=$((10#`date +%N`))
1215 |
1216 | # verifica se passou 1 segundo desde o início da contagem e coloca os quadros contados na
1217 | # variável _fps para exibição posteriormente
1218 | # if [ $((SECONDS - _tempoS)) -gt 0 ] ; then
1219 |
1220 |
1221 | #Guarda o segundo atual desde quando o terminal foi aberto
1222 | # _tempoS=$SECONDS
1223 |
1224 |
1225 | # fi
1226 |
1227 | #Calcula a diferenca entre agora e a ultima leitura em nanosegundo
1228 | _tmp=$((_tempo2N-_tempoN))
1229 |
1230 | #corrige a diferenca pra positivo se for negativo a cada segundo que se passa
1231 | if [ $_tmp -lt 0 ]; then
1232 | ((_tmp+=1000000000))
1233 |
1234 |
1235 | if [ $_quadroRender -gt 5 ]; then
1236 | #Atualiza a taxa de quadros por segundo
1237 | _lps=$_quadros
1238 | _fps=$_quadroRender
1239 |
1240 | #Zera o contador de quadros para comecar novamente
1241 | _quadros=0
1242 |
1243 | _quadroRender=0
1244 |
1245 |
1246 | fi
1247 |
1248 | fi
1249 |
1250 | #a cada 1 decimo de segundo libera para cálculo de movimento do personagem e cenario
1251 | if [ $_tmp -ge 100000000 ]; then
1252 | ((_quadroRender++))
1253 |
1254 | _tempoN=$_tempo2N
1255 | _next=true
1256 |
1257 | TerminalSize
1258 |
1259 | case $_screenGame in
1260 |
1261 | "GAME") #opção para reduzir um segundo no relógio de tempo do jogo
1262 |
1263 | _time=$(( _timeGame - (( SECONDS - _timeIni )) ))
1264 |
1265 | if [ $_time -eq 30 ]; then
1266 | if [ $_quadroRender -eq 5 ]; then
1267 | Play "timewarning"
1268 | fi
1269 |
1270 | elif [ $_time -eq 27 ]; then
1271 | if [ $_quadroRender -eq 5 ]; then
1272 | Play "background"
1273 | fi
1274 |
1275 | elif [ $_time -eq 0 ]; then # se tempo acabou o personagem morre
1276 |
1277 | Dead "time"
1278 | _velocY=-5
1279 | _jogSprite=0
1280 | _jogSide="F"
1281 |
1282 | fi
1283 | ;;
1284 | esac
1285 |
1286 | fi
1287 | }
1288 |
1289 |
1290 | #Funcao para calcular o movimento do jogador
1291 | function Jogador {
1292 |
1293 | case $_screenGame in
1294 |
1295 | "WINPOINT")
1296 | if [ $_time -gt 0 ]; then
1297 | Score 10
1298 | ((_time--))
1299 | Play "point"
1300 | else
1301 | GameWin
1302 | fi
1303 | ;;
1304 |
1305 | "WIN")
1306 |
1307 | # Controla o movimento na vertical(pulo) e faz colisao com o piso do cenario
1308 | if [ $_velocY -ne 0 ] || [ $((_jogY - 1 + _jogHeight)) -ne $((_piso - 1)) ]; then
1309 |
1310 | _jogSprite="2"
1311 | ((_velocY+=_gravidade)) #incremento de velocidade pela gravidade
1312 | ((_jogY+=_velocY)) #incremento de posição vertical do personagem pela velocidade
1313 | ((_flagY=_jogY))
1314 | #verifica se o personagem atravessou o piso
1315 | if [ $((_jogY - 1 + _jogHeight)) -ge $((_piso)) ]; then
1316 | _jogAni=0
1317 | _jogSprite="0"
1318 | ((_jogY=_piso - _jogHeight)) #nao houve colisao entao posiciona o personagem no piso
1319 | _velocY=0 #zera a velocidade de y
1320 | Play "worldcleared"
1321 | fi
1322 | elif [ $_jogX -lt 2927 ]; then
1323 | ((_jogX++))
1324 | #Animacao do Personagem
1325 | ((_jogAni++))
1326 |
1327 | if [ $_jogAni -eq 2 ]; then
1328 | _jogSprite=0
1329 | _jogAni=0
1330 | else
1331 | _jogSprite=1
1332 | fi
1333 | else
1334 | _jogX=3001
1335 | _screenGame="WINPOINT"
1336 | fi
1337 | ;;
1338 |
1339 | "GAME"|"DEAD") # se jogo em fase ou personagem morto processa movimento do personagem
1340 | if [ $_jogDead = true ]; then
1341 | ((_velocY+=_gravidade))
1342 | ((_jogY+=_velocY))
1343 | if [ $_jogY -gt 50 ]; then
1344 | if [ $_jogLife -eq 0 ]; then # se acabou as vidas do personagem termina jogo e volta para o menu principal
1345 | sleep 1
1346 | GameOver
1347 | else # se não mostra vidas restante do jogador
1348 | sleep 2
1349 | Splash
1350 | fi
1351 | fi
1352 |
1353 | return
1354 | fi
1355 |
1356 | # Controla o movimento na horizontal do personagem e faz colisao com os limites do cenario
1357 | if [ $_velocX -ne 0 ]; then
1358 |
1359 | if [ $_velocX -gt 0 ]; then
1360 | ((_jogX+=4)) # =_velocX)) #Movimenta o Personagem
1361 | else
1362 | ((_jogX-=4))
1363 | fi
1364 | if [ $_velocX -lt 0 ]; then
1365 |
1366 | _jogSide="E"
1367 |
1368 | #Colisao com o comeco e o fim da fase
1369 | if [ $_jogX -lt 0 ]; then
1370 | _jogX=0
1371 | fi
1372 |
1373 | #se personagem toca o piso a velocidade do persogem em x sofre alteração
1374 | if [ $_velocY -eq 0 ]; then
1375 | ((_velocX++))
1376 | fi
1377 |
1378 | else
1379 | #determina o sprite da posicao que o personagem anda
1380 | _jogSide="D"
1381 |
1382 | #colisao com o fim do cenario
1383 | if [ $_jogX -gt $((_sizeFase - _jogWidth)) ]; then
1384 | _jogX=$((_sizeFase - _jogWidth))
1385 | fi
1386 |
1387 | #se personagem toca o piso a velocidade do persogem em x sofre alteração
1388 | if [ $_velocY -eq 0 ]; then
1389 | ((_velocX--))
1390 | fi
1391 |
1392 |
1393 | fi
1394 |
1395 | #Animacao do Personagem
1396 | ((_jogAni++))
1397 |
1398 | if [ $_jogAni -eq 2 ]; then
1399 | _jogSprite=0
1400 | _jogAni=0
1401 | else
1402 | _jogSprite=1
1403 | fi
1404 | else
1405 | _jogAni=0
1406 | _jogSprite=0
1407 | fi
1408 |
1409 | # Controla o movimento na vertical(pulo) e faz colisao com o piso do cenario
1410 | if [ $_velocY -ne 0 ] || [ $((_jogY - 1 + _jogHeight)) -ne $((_piso - 1)) ]; then
1411 |
1412 | _jogSprite="2"
1413 | ((_velocY+=_gravidade)) #incremento de velocidade pela gravidade
1414 | ((_jogY+=_velocY)) #incremento de posição vertical do personagem pela velocidade
1415 |
1416 | #verifica se o personagem atravessou o piso
1417 | if [ $((_jogY - 1 + _jogHeight)) -ge $((_piso)) ]; then
1418 | _jogAni=0
1419 | _jogSprite="0"
1420 |
1421 | ColisaoBuraco # Verifica se houve colisao com buraco
1422 | if [ $? -eq 0 ]; then
1423 | ((_jogY=_piso - _jogHeight)) #nao houve colisao entao posiciona o personagem no piso
1424 | _velocY=0 #zera a velocidade de y
1425 | fi
1426 |
1427 | fi
1428 | else
1429 | ColisaoBuraco # Verifica se houve colisao com buraco
1430 |
1431 | fi
1432 |
1433 | ;;
1434 |
1435 | esac
1436 |
1437 | if [ $_screenGame = "GAME" ]; then
1438 |
1439 | #verifica qual sentido o personagem está andando para dar prioridade a colisao do bloco da esquerda ou direita quando colidir com dois
1440 | if [ $_jogSide = "D" ]; then
1441 | _tmp2=$(( _jogX / _blocoWidth ))
1442 | _tmp1=$(( ((_jogX+15)) / _blocoWidth ))
1443 | else
1444 | _tmp1=$(( _jogX / _blocoWidth ))
1445 | _tmp2=$(( ((_jogX+15)) / _blocoWidth ))
1446 | fi
1447 |
1448 | ColisaoBloco $_tmp1 #verifica se houve colisao com o primeiro quadrante
1449 | if [ $? -eq 0 ]; then #se nao houve
1450 | ColisaoBloco $_tmp2 #verifica se houve colisao com o segundo quadrante
1451 | fi
1452 |
1453 | #verifica colisao com as moedas, como a largura do personagem equivale a 3 moedas por isso 3 testes
1454 | ColisaoCoin $(( _jogX / _coinWidth ))
1455 | ColisaoCoin $(( ((_jogX + 8)) / _coinWidth ))
1456 | ColisaoCoin $(( ((_jogX + 15)) / _coinWidth ))
1457 |
1458 | ColisaoEnemy
1459 | ColisaoMastro
1460 |
1461 | fi
1462 |
1463 |
1464 | }
1465 |
1466 | function ColisaoMastro {
1467 |
1468 | if [ $((_jogX + _jogWidth)) -gt 2880 ]; then
1469 |
1470 | _screenGame="WIN"
1471 | Play "flagpole"
1472 | _flagY=$_jogY
1473 | _velocY=0
1474 | _tmp=$(( ((21 - $_jogY) * 330) + 50 ))
1475 |
1476 | _tmpL=${#_tmp}
1477 | ((_tmpL+=2))
1478 |
1479 | _flagDraw[4]="${_flagDraw[4]:0:2}$_tmp${_flagDraw[4]:$_tmpL}"
1480 |
1481 | Score $_tmp
1482 | _jogX=$(( 2883 - _jogWidth))
1483 | fi
1484 |
1485 | }
1486 |
1487 | #funcao colisao inimigo
1488 | function ColisaoEnemy {
1489 |
1490 | #_firstQ=$(( _cameraX / _tamQuad )) #pega o primeiro quadrante
1491 | _ubound=${_enemyX[0]}
1492 |
1493 | for (( _k=1; _k<_ubound; _k++ )); do #laco para verificar cada inimigo
1494 |
1495 | #verifica se o path do inimigo esta visivel na camera
1496 | if [ ${_enemyPathIni[$_k]} -lt $((_cameraX + _width)) ] && [ ${_enemyPathFim[$_k]} -gt $_cameraX ] && [ ${_enemySprite[$_k]} -lt 3 ]; then
1497 | if [ $_jogX -gt $((_enemyX[_k] + _enemyWidth -1)) ]; then #personagem esta do lado direito do inimigo
1498 | _tmp=0
1499 |
1500 | elif [ $_jogY -gt $((_enemyY[_k] + _enemyHeight[_k] -1)) ]; then #personagem esta do lado de baixo do inimigo
1501 | _tmp=0
1502 |
1503 | elif [ $((_jogX + _jogWidth -1)) -lt ${_enemyX[$_k]} ]; then #personagem esta do lado esquerdo do inimigo
1504 | _tmp=0
1505 |
1506 | elif [ $((_jogY + _jogHeight -1)) -lt ${_enemyY[$_k]} ]; then #personagem esta do lado de cima do inimigo
1507 | _tmp=0
1508 |
1509 | #A partir daqui houve colisao
1510 | #Próximo if verifica se a colisão foi lateral entao o personagem morre
1511 | elif [ $((_jogY + _jogHeight -1 - _velocY)) -lt ${_enemyY[$_k]} ]; then
1512 | Play "enemy"
1513 | Score 100
1514 | _jogY=$((_enemyY[_k] - _jogHeight))
1515 | _velocY=-3
1516 | _enemySprite[$_k]=2
1517 | _enemyDead[$_k]=1
1518 | return 1 #retorna que houve colisao
1519 | else
1520 | Dead "enemy"
1521 | _velocY=-5
1522 | _jogSprite=0
1523 | if [ $_jogSide = "D" ]; then
1524 | ((_jogX=_enemyX[_k] - _jogWidth))
1525 | else
1526 | ((_jogX=_enemyX[_k] + _enemyWidth))
1527 | fi
1528 | _jogSide="F"
1529 | return 1 #retorna que houve colisao
1530 | fi
1531 |
1532 |
1533 | fi
1534 | done
1535 |
1536 | }
1537 |
1538 | #funcao para colisao com moedas
1539 | function ColisaoCoin {
1540 |
1541 | _tmpQ=$1 #recebe o quadrante para teste
1542 |
1543 | _tmp=${_coinQ[$_tmpQ]} #pega a posicao do indice do vetor das moedas se existir
1544 |
1545 | if [ $_tmpQ -eq 0 ] || [ -z $_tmp ]; then #verifica se o indíce do quadrante não é zero e se existe moeda no quadrante
1546 | return
1547 | fi
1548 |
1549 | _coinX=${_coin[$_tmp]} #pega a posicao x da moeda
1550 |
1551 | if [ $_coinX -gt 0 ]; then #se existir moeda checar colisao
1552 |
1553 | if [ $_jogX -gt $((_coinX + _coinWidth)) ]; then #personagem esta do lado direito da moeda
1554 | return 0 #retorna que nao houve colisao
1555 | fi
1556 |
1557 | if [ $((_jogY)) -gt $((_coinY[_tmp] + _coinHeight)) ]; then #personagem esta do lado de baixo da moeda
1558 | return 0 #retorna que nao houve colisao
1559 | fi
1560 |
1561 | if [ $((_jogX + 15)) -lt $_coinX ]; then #personagem esta do lado esquerdo da moeda
1562 | return 0 #retorna que nao houve colisao
1563 | fi
1564 |
1565 | if [ $((_jogY+_jogHeight)) -lt ${_coinY[$_tmp]} ]; then #personagem esta do lado de cima da moeda
1566 | return 0 #retorna que nao houve colisao
1567 | fi
1568 |
1569 | Play "coin" #toca o som da moeda
1570 | _coin[$_tmp]=0 #tira a moeda do vetor
1571 | GetCoin #chama funcao para fazer contagem de ponto da moeda
1572 |
1573 | _tmp2=$(( _coinX + _coinWidth )) #pega a posicao do final da moeda
1574 |
1575 | # for (( _k=9; _k<=13; _k++ )); do #limpa o desenho da moeda no buffer da fase
1576 |
1577 | # _fasel[$_k]="${_fasel[$_k]:0:$_coinX}${_coinClear}${_fasel[$_k]:$_tmp2}"
1578 |
1579 | # done
1580 |
1581 | return 1 #retorna que houve colisao
1582 | fi
1583 |
1584 | }
1585 |
1586 | #funcao para contagem de pontos da moeda
1587 | function GetCoin {
1588 |
1589 | ((_coins++)) #incrementa ponto da moeda
1590 | Score 200 #incrementa ponto do score
1591 |
1592 | if [ $_coins -gt 99 ]; then #verifica se moedas chegou a 100 para converter em vida
1593 |
1594 | ((_coins-=100)) #subtrai 100 moedas do contador
1595 | Play "up" #toca som de ganho de vida
1596 | ((_jogLife++)) #incrementa 1 na variavel vida
1597 | fi
1598 |
1599 | }
1600 |
1601 | #funcao para colisao do bloco
1602 | function ColisaoBloco {
1603 |
1604 | _tmpQ=$1 #recebe a posicao do quadrante
1605 |
1606 | _tmp=${_blocoQ[$_tmpQ]} #recebe a posicao do indice do bloco se existir
1607 |
1608 | if [ $_tmpQ -eq 0 ] || [ -z $_tmp ]; then #verifica se o indíce do quadrante não é zero e se existe bloco no quadrante
1609 | return 0 #retorna que nao houve colisao
1610 | fi
1611 |
1612 | _blocoX=${_bloco[$_tmp]} #pega a posicao x do bloco
1613 |
1614 | if [ $_blocoX -gt 0 ]; then #se existir bloco checar colisao
1615 |
1616 | if [ $_jogX -gt $((_blocoX -1 + _blocoWidth)) ]; then #personagem esta do lado direito do bloco
1617 | return 0 #retorna que nao houve colisao
1618 | fi
1619 |
1620 | if [ $((_jogY)) -gt $((_blocoY -1 + _blocoHeight)) ]; then #personagem esta do lado de baixo do bloco
1621 | return 0 #retorna que nao houve colisao
1622 | fi
1623 |
1624 | if [ $((_jogX -1 + _jogWidth)) -lt $_blocoX ]; then #personagem esta do lado esquerdo do bloco
1625 | return 0 #retorna que nao houve colisao
1626 | fi
1627 |
1628 | if [ $((_jogY -1 + _jogHeight)) -lt $_blocoY ]; then #personagem esta do lado de cima do bloco
1629 | return 0 #retorna que nao houve colisao
1630 | fi
1631 |
1632 | #A partir daqui houve colisao
1633 | #Próximo if verifica se a colisão foi lateral para não quebrar o bloco
1634 | if [ $((_jogY - _velocY)) -lt $((_blocoY -1 + _blocoHeight)) ]; then
1635 |
1636 | if [ $_jogSide = "D" ]; then # se não houve colisao posiciona o jogador ao lado do bloco
1637 | _jogX=$((_blocoX - 16))
1638 | else
1639 | _jogX=$((_blocoX + _blocoWidth))
1640 | fi
1641 | _velocX=0
1642 | return 1
1643 |
1644 | fi
1645 |
1646 | Play "bloco" #som do bloco quebrando
1647 | Score 50 #incrementa score
1648 | _bloco[$_tmp]=0 #Limpa o bloco do vetor
1649 | _jogY=$((_blocoY + _blocoHeight)) #posiciona o jogador abaixo do bloco
1650 | _velocY=$((- _velocY)) #incrementa a velocidade de y
1651 |
1652 |
1653 | _tmp2=$(( _blocoX + _blocoWidth )) #variavel para definir final do desenho do bloco (limpar)
1654 |
1655 | for (( _k=_blocoY; _k<_blocoY+_blocoHeight; _k++ )); do #limpa o desenho do bloco do buffer da fase
1656 | _fasel[$_k]="${_fasel[$_k]:0:$_blocoX}${_blocoClear}${_fasel[$_k]:$_tmp2}"
1657 | done
1658 |
1659 | return 1 #retorna que houve colisao
1660 | fi
1661 |
1662 | }
1663 |
1664 | #Funcao para detectar colisao do personagem com buracos na fase
1665 | function ColisaoBuraco {
1666 |
1667 | for (( _k=1; _k<_buraco[0]; _k++ )); do
1668 |
1669 | _buracoX=${_buraco[$_k]}
1670 |
1671 | if [ $((_jogX + (_jogWidth/2))) -gt $((_buracoX+2)) ] && [ $((_jogX + (_jogWidth/2))) -lt $((_buracoX + 2 + _buracoWidth )) ]; then #se houve colisão então mata personagem
1672 |
1673 | _jogX=$((_buracoX + 2 +(_buracoWidth/2) - (_jogWidth/2) ))
1674 | Dead "buraco"
1675 |
1676 | return 1 #houve colisao
1677 | fi
1678 |
1679 | done
1680 | return 0 #nao houve colisao
1681 | }
1682 |
1683 | #Função para matar o personagem definindo trilha sonora e tipo de animação do personagem
1684 | function Dead {
1685 |
1686 | #Define que o jogo está na passagem de morte do personagem
1687 | _screenGame="DEAD"
1688 |
1689 | ((_jogLife--)) #Subtrai um vida do personagem
1690 |
1691 | if [ $_jogLife = 0 ]; then #se zerou as vidas do jogador toca audio fim de jogo
1692 | Play "gameover"
1693 | else #se não toca audio de perda de vida
1694 | Play "die"
1695 | fi
1696 |
1697 | _jogDead=true #define variavel verdadeira para rotina de animação da morte do personagem
1698 |
1699 | ((_velocY+=_gravidade)) #Atualaiza velocidade de queda do personagem
1700 | }
1701 |
1702 | #Função para parar a musica
1703 | function Stop {
1704 |
1705 | kill -9 $1 1 2>/dev/null
1706 |
1707 | }
1708 |
1709 |
1710 | #Função para tocar os audios
1711 | function Play {
1712 |
1713 | if [ $_sound = "off" ]; then
1714 | return
1715 | fi
1716 |
1717 | case $1 in #Seleciona qual audio deve ser tocado
1718 |
1719 | "worldcleared")
1720 | canberra-gtk-play --file="worldcleared.ogg" 1 2>/dev/null&
1721 | ;;
1722 |
1723 | "flagpole")
1724 | if [ $_musicId ]; then
1725 | Stop $_musicId #Mata o processo da musica de fundo
1726 | fi
1727 | canberra-gtk-play --file="flagpole.ogg" 1 2>/dev/null&
1728 | ;;
1729 |
1730 | "timewarning")
1731 | if [ $_musicId ]; then
1732 | Stop $_musicId #Mata o processo da musica de fundo
1733 | fi
1734 | canberra-gtk-play --file="timewarning.ogg" 1 2>/dev/null&
1735 | ;;
1736 |
1737 | "gameover")
1738 | if [ $_musicId ]; then
1739 | Stop $_musicId #Mata o processo da musica de fundo
1740 | fi
1741 | canberra-gtk-play --file="gameover.ogg" 1 2>/dev/null&
1742 | ;;
1743 |
1744 | "die")
1745 | if [ $_musicId ]; then
1746 | Stop $_musicId #Mata o processo da musica de fundo
1747 | fi
1748 | canberra-gtk-play --file="die.ogg" 1 2>/dev/null&
1749 | ;;
1750 |
1751 | "background")
1752 | if [ $_musicId ]; then
1753 | Stop $_musicId #Mata o processo da musica de fundo
1754 | fi
1755 |
1756 | canberra-gtk-play -l 99 -V 0 --file="world1-1.ogg" 1 2>/dev/null & _musicId="$!"
1757 | #Guarda o id do processo da musica para parar quando for preciso
1758 | ;;
1759 |
1760 | "jump")
1761 | canberra-gtk-play --file="jump.ogg" 1 2>/dev/null&;;
1762 |
1763 | "bloco")
1764 | canberra-gtk-play --file="brick.ogg" 1 2>/dev/null&;;
1765 |
1766 | "point")
1767 | canberra-gtk-play --file="coin.ogg" 1 2>/dev/null&;;
1768 |
1769 | "coin")
1770 | canberra-gtk-play --file="coin.ogg" 1 2>/dev/null&;;
1771 |
1772 | "up")
1773 | canberra-gtk-play --file="up.ogg" 1 2>/dev/null&;;
1774 |
1775 | "enemy")
1776 | canberra-gtk-play --file="stomp.ogg" 1 2>/dev/null&;;
1777 | esac
1778 |
1779 | }
1780 |
1781 | function MoveEnemy {
1782 |
1783 | case $_screenGame in
1784 |
1785 | "GAME") # se jogo em fase processa movimento do inimigo
1786 |
1787 | #_firstQ=$(( _cameraX / _tamQuad )) #pega o primeiro quadrante
1788 | _ubound=${_enemyX[0]}
1789 |
1790 | for (( _k=1; _k<_ubound; _k++ )); do #laco para verificar cada inimigo
1791 |
1792 | #verifica se o path do inimigo esta visivel na camera
1793 | if [ ${_enemyPathIni[$_k]} -lt $((_cameraX + _width)) ] && [ ${_enemyPathFim[$_k]} -gt $_cameraX ] && [ ${_enemySprite[$_k]} -lt 6 ]; then
1794 |
1795 | #((_aniEnemy[_k]++))
1796 |
1797 | #Animacao do inimigo
1798 | case ${_enemySprite[$_k]} in
1799 | 0)
1800 | ChangeSpriteEnemy $_k
1801 | _enemySprite[$_k]=1
1802 | _aniEnemy=1
1803 |
1804 | ;;
1805 | 1)
1806 | ChangeSpriteEnemy $_k
1807 | ((_enemySprite[_k]+=_aniEnemy))
1808 | ;;
1809 | 2)
1810 | if [ ${_enemyDead[$_k]} -eq 1 ]; then
1811 | _enemySprite[$_k]=3
1812 | else
1813 | ChangeSpriteEnemy $_k
1814 | _enemySprite[$_k]=1
1815 | _aniEnemy=-1
1816 | fi
1817 | ;;
1818 | 3)
1819 | _enemySprite[$_k]=4;;
1820 | 4)
1821 | _enemySprite[$_k]=5;;
1822 | 5)
1823 | _enemySprite[$_k]=6;;
1824 | esac
1825 |
1826 | fi
1827 |
1828 |
1829 | _enemyHeight[$_k]="_gompa${_enemySprite[$_k]}[0]"
1830 | _enemyHeight[$_k]=${!_enemyHeight[$_k]}
1831 | _enemyY[$_k]=$((_piso - _enemyHeight[$_k]))
1832 |
1833 | done
1834 |
1835 | esac
1836 | }
1837 |
1838 | function ChangeSpriteEnemy {
1839 |
1840 | _k=$1
1841 |
1842 | # if [ ${_aniEnemy[$_k]} -eq 2 ]; then
1843 | ((_enemyX[_k]+=_enemyVelocX[_k])) #Movimenta o inimigo
1844 |
1845 | if [ $(( _enemyX[_k] + enemyWidth )) -gt $(( _enemyPathFim[_k] )) ] || [ ${_enemyX[$_k]} -lt ${_enemyPathIni[$_k]} ]; then
1846 | (( _enemyVelocX[_k]=-_enemyVelocX[_k] ))
1847 | fi
1848 |
1849 |
1850 | _aniEnemy[$_k]=0
1851 | # fi
1852 |
1853 |
1854 | }
1855 |
1856 | # [ INICIO SCRIPT ] ----------------------------------------------------------------------------------------------------------
1857 |
1858 | # Carrega as configurações salva
1859 | . .settings
1860 |
1861 | # Mapa do score no topo da tela
1862 | _scoreTitle0=" MARIO WORLD TIME "
1863 | _scoreTitle1=" 000000 @x00 1-1 000 "
1864 |
1865 |
1866 | # Mapa de caracters do jogador mario e das montanhas de fundo
1867 |
1868 | _montDraw[0]=7
1869 | _montDraw[1]=" ████████ "
1870 | _montDraw[2]=" ████ ████ "
1871 | _montDraw[3]=" ██ ██ "
1872 | _montDraw[4]=" ██ ██ ░░░░ ██ "
1873 | _montDraw[5]=" ██ ██ ░░ ██ "
1874 | _montDraw[6]=" ██ ░░ ██ "
1875 | _montDraw[7]="██ ░░ ██"
1876 |
1877 | # Mapa de caracters do Menu do jogo
1878 | _menu[0]=" "
1879 | _menu[1]=" "
1880 | _menu[2]=" "
1881 | _menu[3]=" "
1882 | _menu[4]=" "
1883 | _menu[5]=" @ @ "
1884 | _menu[6]=" ██ ██ ████ █████ ██████ ████ "
1885 | _menu[7]=" ███ ███ ██ ██ ██ ██ ██ ██ ██ "
1886 | _menu[8]=" ██ █ ██ ██████ █████ ██ ██ ██ "
1887 | _menu[9]=" ██ ██ ██ ██ ██ ██ ██ ██ ██ "
1888 | _menu[10]=" ██ ██ ██ ██ ██ ██ ██████ ████ "
1889 | _menu[11]=" "
1890 | _menu[12]=" █████ █████ ████ ████ "
1891 | _menu[13]=" ██ ██ ██ ██ ██ ██ ██ "
1892 | _menu[14]=" █████ █████ ██ ██ ████ "
1893 | _menu[15]=" ██ ██ ██ ██ ██ ██ ██ ██ "
1894 | _menu[16]=" █████ ██ ██ ████ ████ ██ "
1895 | _menu[17]=" @ @ "
1896 | _menu[18]=" 2012 FATEC CARAPICUIBA "
1897 | _menu[19]=" "
1898 | _menu[20]=" "
1899 | _menu[21]=" "
1900 | _menu[22]=" "
1901 | _menu[23]=" P R E S S E N T E R T O S T A R T "
1902 | _menu[24]=" "
1903 | _menu[25]=" "
1904 | _menu[26]=" TOP - 0000000000 "
1905 | _menu[27]=" "
1906 | _menu[28]=" "
1907 | _menu[29]=" "
1908 | _menu[30]=" ████████ "
1909 | _menu[31]=" ████ ████ █ █ █ "
1910 | _menu[32]=" ██ ██ █ █ █ █ █ █ "
1911 | _menu[33]=" ██ ██ ░░░░ ██ █ █ █ █ █ █ "
1912 | _menu[34]=" ██ ██ ░░ ██ █ █ █ █ "
1913 | _menu[35]=" ██ ░░ ██ █ █ "
1914 | _menu[36]="██ ░░ ██ █ █ "
1915 | _menu[37]="░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░"
1916 | _menu[38]="█░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░█"
1917 | _menu[39]="░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░░░░░██░░░░"
1918 |
1919 | _flagDraw[0]=7
1920 | _flagDraw[1]="████"
1921 | _flagDraw[2]="█ ████"
1922 | _flagDraw[3]="█ ███"
1923 | _flagDraw[4]="█ ███"
1924 | _flagDraw[5]="█ ███"
1925 | _flagDraw[6]="█ ████"
1926 | _flagDraw[7]="████"
1927 |
1928 | _castle[0]=31
1929 | _castle[1]=" @@@"
1930 | _castle[2]=" @@@@@ ___ ___ ___ __ ___ ___ ___"
1931 | _castle[3]=" @@@ |░░░| |░░░| |░░░| |░░| |░░░| |░░░| |░░░|"
1932 | _castle[4]=" | | |░░░| |░░░| |░░░| |░░| |░░░| |░░░| |░░░|"
1933 | _castle[5]=" | | |░░|░░░░|░░░░|░░░░|░░░░|░░░|░░░░|░░░░|░░░░|░░░░|░░░|"
1934 | _castle[6]=" | | |░░░░|░░░░|░░░░|░░░░|░░░░|░░░|░░░░|░░░░|░░░░|░░░░|░|"
1935 | _castle[7]=" | | |░░|░░░░|██████░░░|░░░░|░░░|░░░░|░░░░██████░░░░|░░░|"
1936 | _castle[8]=" | | |░░░░|░░░██████|░░░░|░░░░|░░░|░░░░|░░██████░|░░░░|░|"
1937 | _castle[9]=" | | |░░|░░░░|██████░░░|░░░░|░░░|░░░░|░░░░██████░░░░|░░░|"
1938 | _castle[10]=" | | |░░░░|░░░██████|░░░░|░░░░|░░░|░░░░|░░██████░|░░░░|░|"
1939 | _castle[11]=" | | |░░|░░░░|██████░░░|░░░░|░░░|░░░░|░░░░██████░░░░|░░░|"
1940 | _castle[12]=" | | __ ___|░░░░___░██████|░░░░░___░░░░___░░░░░_██████░___░░░░|___ __"
1941 | _castle[13]=" | | |░░| |░░░|░░░|░░░|███|░░░|░░░|░░░|░░|░░░|░░░|░░░|███|░░░|░░░|░░░| |░░|"
1942 | _castle[14]=" | | |░░| |░░░|░░░|░░░|░░░|░░░|░░░|░░░|░░|░░░|░░░|░░░|░░░|░░░|░░░|░░░| |░░|"
1943 | _castle[15]=" | | |░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░|"
1944 | _castle[16]=" | | |░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1945 | _castle[17]=" | | |░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░████████░░|░░░░|░░░░|░░░░|░░░░░░|░░░░|░░|"
1946 | _castle[18]=" | | |░|░░░░|░░░░|░░░░|░░░░|░░░░|░░░████████████░░░|░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1947 | _castle[19]=" | | |░░░|░░░░|░░░░|░░░░|░░░░|░░░░|██████████████░░░░|░░░░|░░░░|░░░░░░|░░░░|░░|"
1948 | _castle[20]=" | | |░|░░░░|░░░░|░░░░|░░░░|░░░░|░████████████████░|░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1949 | _castle[21]=" | | |░░░|░░░░|░░░░|░░░░|░░░░|░░░██████████████████░░|░░░░|░░░░|░░░░|░░░░|░░░░|"
1950 | _castle[22]=" | | |░|░░░░|░░░░|░░░░|░░░░|░░░░████████████████████░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1951 | _castle[23]=" | | |░░░|░░░░|░░░░|░░░░|░░░░|░░████████████████████░|░░░░|░░░░|░░░░|░░░░|░░░░|"
1952 | _castle[24]=" | | |░|░░░░|░░░░|░░░░|░░░░|░░░░████████████████████░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1953 | _castle[25]=" | | |░░░|░░░░|░░░░|░░░░|░░░░|░░████████████████████░|░░░░|░░░░|░░░░|░░░░|░░░░|"
1954 | _castle[26]=" | | |░|░░░░|░░░░|░░░░|░░░░|░░░░████████████████████░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1955 | _castle[27]=" | | |░░░|░░░░|░░░░|░░░░|░░░░|░░████████████████████░|░░░░|░░░░|░░░░|░░░░|░░░░|"
1956 | _castle[28]=" | | |░|░░░░|░░░░|░░░░|░░░░|░░░░████████████████████░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1957 | _castle[29]=" _| |_ |░░░|░░░░|░░░░|░░░░|░░░░|░░████████████████████░|░░░░|░░░░|░░░░|░░░░|░░░░|"
1958 | _castle[30]="|░░░░░| |░|░░░░|░░░░|░░░░|░░░░|░░░░████████████████████░░░░|░░░░|░░░░|░░░░|░░░░|░|"
1959 | _castle[31]="|░░░░░| |░░░|░░░░|░░░░|░░░░|░░░░|░░████████████████████░|░░░░|░░░░|░░░░|░░░░|░░░░|"
1960 |
1961 | _marioD0[0]=16
1962 | _marioD0[1]=""
1963 | _marioD0[2]=" █████"
1964 | _marioD0[3]=' █░░░░M███'
1965 | _marioD0[4]=' █░░░░░░░░░█'
1966 | _marioD0[5]=' ███ █ ███'
1967 | _marioD0[6]='█ ██ █ █'
1968 | _marioD0[7]='█ ██ █ █'
1969 | _marioD0[8]=' ██ █████'
1970 | _marioD0[9]=' ██ █'
1971 | _marioD0[10]=' █░░██░░█'
1972 | _marioD0[11]='█░░░░██░░█'
1973 | _marioD0[12]='█░░░░█████'
1974 | _marioD0[13]=' █ ██ ██'
1975 | _marioD0[14]=' █ ░░░███'
1976 | _marioD0[15]=' █░░░░░█'
1977 | _marioD0[16]=' █████'
1978 |
1979 | _marioE0[0]=16
1980 | _marioE0[1]=""
1981 | _marioE0[2]=' █████'
1982 | _marioE0[3]=' ███M░░░░█'
1983 | _marioE0[4]='█░░░░░░░░░█'
1984 | _marioE0[5]=' ███ █ ███'
1985 | _marioE0[6]='█ █ ██ █'
1986 | _marioE0[7]='█ █ ██ █'
1987 | _marioE0[8]=' █████ ██'
1988 | _marioE0[9]=' █ ██'
1989 | _marioE0[10]=' █░░██░░█'
1990 | _marioE0[11]=' █░░██░░░░█'
1991 | _marioE0[12]=' █████░░░░█'
1992 | _marioE0[13]=' ██ ██ █'
1993 | _marioE0[14]=' ███░░░ █'
1994 | _marioE0[15]=' █░░░░░█'
1995 | _marioE0[16]=' █████'
1996 |
1997 | _marioD1[0]=16
1998 | _marioD1[1]=' █████'
1999 | _marioD1[2]=' █░░░░M███'
2000 | _marioD1[3]=' █░░░░░░░░░█'
2001 | _marioD1[4]=' ███ █ ███'
2002 | _marioD1[5]=' █ ██ █ █'
2003 | _marioD1[6]=' █ ██ █ █'
2004 | _marioD1[7]=' ██ █████'
2005 | _marioD1[8]=' ███ █'
2006 | _marioD1[9]=' ██░░░██░░███'
2007 | _marioD1[10]='█ ░░░░██░░█░█'
2008 | _marioD1[11]='█ ░░██████░ █'
2009 | _marioD1[12]=' █ ████ ██ █ █'
2010 | _marioD1[13]=' █████████░░█'
2011 | _marioD1[14]=' █░░██████░░░█'
2012 | _marioD1[15]=' █░░░█ █░░░█'
2013 | _marioD1[16]=' ███ ███'
2014 |
2015 | _marioE1[0]=16
2016 | _marioE1[1]=' █████'
2017 | _marioE1[2]=' ███M░░░░█'
2018 | _marioE1[3]=' █░░░░░░░░░█'
2019 | _marioE1[4]=' ███ █ ███'
2020 | _marioE1[5]=' █ █ ██ █'
2021 | _marioE1[6]=' █ █ ██ █'
2022 | _marioE1[7]=' █████ ██'
2023 | _marioE1[8]=' █ ███'
2024 | _marioE1[9]=' ███░░██░░░██'
2025 | _marioE1[10]=' █░█░░██░░░░ █'
2026 | _marioE1[11]='█ ░██████░░ █'
2027 | _marioE1[12]='█ █ ██ ████ █'
2028 | _marioE1[13]=' █░░█████████'
2029 | _marioE1[14]=' █░░░██████░░█'
2030 | _marioE1[15]=' █░░░█ █░░░█'
2031 | _marioE1[16]=' ███ ███'
2032 |
2033 | _marioF0[0]=16
2034 | _marioF0[1]=' ███████'
2035 | _marioF0[2]=' ██░░░M░░░██'
2036 | _marioF0[3]=' █░░░░███░░░░█'
2037 | _marioF0[4]=' ███████████'
2038 | _marioF0[5]=' █ █ █ █'
2039 | _marioF0[6]='██ ░░░ ██'
2040 | _marioF0[7]=' █ █████████ █'
2041 | _marioF0[8]='█ █ █░█ ██'
2042 | _marioF0[9]='█ ██ █░█ ██ █'
2043 | _marioF0[10]=' █ █░█████░░ █ █'
2044 | _marioF0[11]=' █░░░░░░░░█████'
2045 | _marioF0[12]=' ████░░░░░█░░░█'
2046 | _marioF0[13]='█░░░░█░░░█░░░░█'
2047 | _marioF0[14]=' █░░░░█████░░░█'
2048 | _marioF0[15]=' █░░░█ ███'
2049 | _marioF0[16]=' ███'
2050 |
2051 | _marioD2[0]=16
2052 | _marioD2[1]=' █████ ███'
2053 | _marioD2[2]=' █░░░░M██ █'
2054 | _marioD2[3]=' █░░░░░░░░█ █'
2055 | _marioD2[4]=' ███ █ ███░█'
2056 | _marioD2[5]=' █ ██ █ ░█'
2057 | _marioD2[6]=' █ ██ █ ░█'
2058 | _marioD2[7]=' ██ ██████'
2059 | _marioD2[8]=' ██ ░█'
2060 | _marioD2[9]=' █░░░█░░░█░█'
2061 | _marioD2[10]=' ███░░░█░░░████'
2062 | _marioD2[11]='█ █░░█ ██ █░░█'
2063 | _marioD2[12]='█ █░██████░░░█'
2064 | _marioD2[13]=' █░█████████░░█'
2065 | _marioD2[14]='█░░░████████░░█'
2066 | _marioD2[15]='█░░██████ ██'
2067 | _marioD2[16]=' ██ ███'
2068 |
2069 | _marioE2[0]=16
2070 | _marioE2[1]=' ███ █████'
2071 | _marioE2[2]='█ ██M░░░░█'
2072 | _marioE2[3]='█ █░░░░░░░░█'
2073 | _marioE2[4]=' █░███ █ ███'
2074 | _marioE2[5]=' █░ █ ██ █'
2075 | _marioE2[6]=' █░ █ ██ █'
2076 | _marioE2[7]=' ██████ ██'
2077 | _marioE2[8]=' █░ ██'
2078 | _marioE2[9]=' █░█░░░█░░░█'
2079 | _marioE2[10]=' ████░░░█░░░███'
2080 | _marioE2[11]='█░░█ ██ █░░█ █'
2081 | _marioE2[12]='█░░░██████░█ █'
2082 | _marioE2[13]=' █░░█████████░█'
2083 | _marioE2[14]=' █░░████████░░░█'
2084 | _marioE2[15]=' ██ ██████░░█'
2085 | _marioE2[16]=' ███ ██'
2086 |
2087 |
2088 |
2089 | _marioD00=13
2090 | _marioD01=" █████"
2091 | _marioD02=' █░░░░M███'
2092 | _marioD03=' █░░░░░░░░░█'
2093 | _marioD04=' ███ █ ███'
2094 | _marioD05=' █ ██ █ █'
2095 | _marioD06=' █ ██ █ █'
2096 | _marioD07=' ██ █████'
2097 | _marioD08=' ██ █'
2098 | _marioD09=' █ ██ ██'
2099 | _marioD010=' █ ░░░███'
2100 | _marioD011=' █░░░░░█'
2101 | _marioD012=' █████'
2102 |
2103 | _marioE00=13
2104 | _marioE01=' █████'
2105 | _marioE02=' ███M░░░░█'
2106 | _marioE03=' █░░░░░░░░░█'
2107 | _marioE04=' ███ █ ███'
2108 | _marioE05=' █ █ ██ █'
2109 | _marioE06=' █ █ ██ █'
2110 | _marioE07=' █████ ██'
2111 | _marioE08=' █ ██'
2112 | _marioE09=' ██ ██ █'
2113 | _marioE010=' ███░░░ █'
2114 | _marioE011=' █░░░░░█'
2115 | _marioE012=' █████'
2116 |
2117 | _marioD10=13
2118 | _marioD11=' █████'
2119 | _marioD12=' █░░░░M███'
2120 | _marioD13=' █░░░░░░░░░█'
2121 | _marioD14=' ███ █ ███'
2122 | _marioD15=' █ ██ █ █'
2123 | _marioD16=' █ ██ █ █'
2124 | _marioD17=' ██ █████'
2125 | _marioD18=' ███ █'
2126 | _marioD19=' █ ████ ██ █'
2127 | _marioD110=' █████████░░█'
2128 | _marioD111=' █░░██████░░░█'
2129 | _marioD112=' █░░░█ █░░░█'
2130 | _marioD113=' ███ ███'
2131 |
2132 | _marioE10=13
2133 | _marioE11=' █████'
2134 | _marioE12=' ███M░░░░█'
2135 | _marioE13=' █░░░░░░░░░█'
2136 | _marioE14=' ███ █ ███'
2137 | _marioE15=' █ █ ██ █'
2138 | _marioE16=' █ █ ██ █'
2139 | _marioE17=' █████ ██'
2140 | _marioE18=' █ ███'
2141 | _marioE19=' █ ██ ████ █'
2142 | _marioE110=' █░░█████████'
2143 | _marioE111=' █░░░██████░░█'
2144 | _marioE112=' █░░░█ █░░░█'
2145 | _marioE113=' ███ ███'
2146 |
2147 | _marioD20=13
2148 | _marioD21=' █████ ███'
2149 | _marioD22=' █░░░░M██ █'
2150 | _marioD23=' █░░░░░░░░█ █'
2151 | _marioD24=' ███ █ ███░█'
2152 | _marioD25=' █ ██ █ ░█'
2153 | _marioD26=' █ ██ █ ░█'
2154 | _marioD27=' ██ ██████'
2155 | _marioD28=' ██ ░█'
2156 | _marioD29=' ██████░░░█'
2157 | _marioD210=' █████████░░█'
2158 | _marioD211=' █░░███████░░█'
2159 | _marioD212='█░░██████ ██'
2160 | _marioD213=' ██ ███'
2161 |
2162 | _marioE20=13
2163 | _marioE21=' ███ █████'
2164 | _marioE22='█ ██M░░░░█'
2165 | _marioE23='█ █░░░░░░░░█'
2166 | _marioE24=' █░███ █ ███'
2167 | _marioE25=' █░ █ ██ █'
2168 | _marioE26=' █░ █ ██ █'
2169 | _marioE27=' ██████ ██'
2170 | _marioE28=' █░ ██'
2171 | _marioE29=' █░░░██████'
2172 | _marioE210=' █░░█████████'
2173 | _marioE211=' █░░███████░░█'
2174 | _marioE212=' ██ █████░░█'
2175 | _marioE213=' ███ ██'
2176 |
2177 | _gompa0[0]=10
2178 | _gompa0[1]=" ████"
2179 | _gompa0[2]=" ██████████"
2180 | _gompa0[3]=" ███ >████< █"
2181 | _gompa0[4]=" ████ █ ██ █ ██"
2182 | _gompa0[5]="█████ ██ ███"
2183 | _gompa0[6]=" ██████████████"
2184 | _gompa0[7]=" █████░░░░███"
2185 | _gompa0[8]=" ███░░░░░░ "
2186 | _gompa0[9]=" ████░░░░██"
2187 | _gompa0[10]=" ████░░██"
2188 |
2189 | _gompa1[0]=10
2190 | _gompa1[1]=" ████"
2191 | _gompa1[2]=" ██████████"
2192 | _gompa1[3]=" ██ >████< ██"
2193 | _gompa1[4]=" ███ █ ██ █ ███"
2194 | _gompa1[5]="████ ██ ████"
2195 | _gompa1[6]=" ██████████████"
2196 | _gompa1[7]=" ████░░░░████"
2197 | _gompa1[8]=" ░░░░░░"
2198 | _gompa1[9]=" ██░░░░░░██"
2199 | _gompa1[10]=" ██░░░░██"
2200 |
2201 | _gompa2[0]=10
2202 | _gompa2[1]=" ████"
2203 | _gompa2[2]=" ██████████"
2204 | _gompa2[3]=" █ >████< ███"
2205 | _gompa2[4]=" ██ █ ██ █ ████"
2206 | _gompa2[5]="███ ██ █████"
2207 | _gompa2[6]=" ██████████████"
2208 | _gompa2[7]=" ███░░░░████"
2209 | _gompa2[8]=" ░░░░░░███"
2210 | _gompa2[9]=" ██░░░░████"
2211 | _gompa2[10]=" ██░░████"
2212 |
2213 | _gompa3[0]=8
2214 | _gompa3[1]=" ████████"
2215 | _gompa3[2]=" ███ >████< ███"
2216 | _gompa3[3]="████ █ ██ █ ████"
2217 | _gompa3[4]="████ ██ ████"
2218 | _gompa3[5]=" █████░░░░█████"
2219 | _gompa3[6]=" ░░░░░░"
2220 | _gompa3[7]=" ███░░░░███"
2221 | _gompa3[8]=" ███░░███"
2222 |
2223 | _gompa3[0]=5
2224 | _gompa3[1]=" ████████████"
2225 | _gompa3[2]=" ████ >████< ████"
2226 | _gompa3[3]="█████ █ ██ █ █████"
2227 | _gompa3[4]=" ███░░░░░░███"
2228 | _gompa3[5]=" ███░░░░███"
2229 |
2230 | _gompa4[0]=3
2231 | _gompa4[1]=" ████████████"
2232 | _gompa4[2]="█████ █ ██ █ █████"
2233 | _gompa4[3]=" ███░░░░███"
2234 |
2235 | _nuvemDraw[0]=13
2236 | _nuvemDraw[1]=" ███████"
2237 | _nuvemDraw[2]=" ██ ██"
2238 | _nuvemDraw[3]=" ██ ██"
2239 | _nuvemDraw[4]=" █ █ █ ░ █"
2240 | _nuvemDraw[5]=" ████ █ █ ░ ████"
2241 | _nuvemDraw[6]=" ███ ░ ███"
2242 | _nuvemDraw[7]=" ██ ░ █"
2243 | _nuvemDraw[8]=" █ ░ █"
2244 | _nuvemDraw[9]=" ██ ░░░░ ░ ░░ ███"
2245 | _nuvemDraw[10]=" ███ ░░░░ ░ ░░░░░ █"
2246 | _nuvemDraw[11]=" ████ ░░░░░░ ██ ██"
2247 | _nuvemDraw[12]=" ██ ██ ██████"
2248 | _nuvemDraw[13]=" ██████"
2249 |
2250 |
2251 | _coinDraw0[0]=5
2252 | _coinDraw0[1]=" @@ "
2253 | _coinDraw0[2]=" @@ @@ "
2254 | _coinDraw0[3]=" @ @@ @ "
2255 | _coinDraw0[4]=" @@ @@ "
2256 | _coinDraw0[5]=" @@ "
2257 |
2258 | _coinDrawC[1]=${_cor[4]}
2259 | _coinDrawC[2]=${_cor[4]}
2260 | _coinDrawC[3]=${_cor[4]}
2261 | _coinDrawC[4]=${_cor[4]}
2262 | _coinDrawC[5]=${_cor[4]}
2263 |
2264 | _coinDraw1[0]=5
2265 | _coinDraw1[1]=" @@ "
2266 | _coinDraw1[2]=" @ @ "
2267 | _coinDraw1[3]=" @ @@ @ "
2268 | _coinDraw1[4]=" @ @ "
2269 | _coinDraw1[5]=" @@ "
2270 |
2271 | _coinDraw2[0]=5
2272 | _coinDraw2[1]=" @@ "
2273 | _coinDraw2[2]=" @@ "
2274 | _coinDraw2[3]=" @@ "
2275 | _coinDraw2[4]=" @@ "
2276 | _coinDraw2[5]=" @@ "
2277 |
2278 | # Cria o mapa de caracters para o piso
2279 | _piso1='░░░░██░░░░'
2280 | _piso2='█░░░░░░░░█'
2281 |
2282 | _buracoDraw="██ ██" # Variavel para desenhar o buraco na fase
2283 |
2284 | # Buffer de desenho do Bloco
2285 | _blocoDraw[0]="███████████████"
2286 | _blocoDraw[1]="█░░░░░░░░░░░░░█"
2287 | _blocoClear=" "
2288 |
2289 | #Inicializa as variaveis existentes no programa
2290 | #Salva as configurações atuais do terminal
2291 | _terminal=$(stty -g)
2292 |
2293 | # -echo Desliga o que eh digitado na tela
2294 | # -icanon desliga o modo canonico
2295 | # min 0 minimo de caracters a esperar para fazer leitura
2296 | #-icrnl converte o caracter new line[enter] para carrier return para ser detectado em _ListenKey
2297 | stty -echo -icanon -icrnl min 0 #time 0
2298 |
2299 | # Desliga o cursor piscante na tela
2300 | tput civis
2301 |
2302 | # Define constantes para as Teclas de controle seremm detectadas no _ListenKey
2303 | KEY_ENTER=$(printf '\x0d')
2304 | KEY_BACKSPACE=$(printf '\x08')
2305 | KEY_ESC=$(printf '\x1b')
2306 | KEY_UP=$(echo -ne '\e[A')
2307 | KEY_LEFT=$(echo -ne '\e[D')
2308 | KEY_RIGHT=$(echo -ne '\e[C')
2309 | KEY_DOWN=$(echo -ne '\e[B')
2310 |
2311 | if [ $TERM = "linux" ]; then
2312 | _cor[0]="\E[00;37;41m" # logo
2313 | _cor[1]="\E[00;37;46m" # Title
2314 | _cor[2]="\E[00;30;46m" # ceu
2315 | _cor[3]="\E[00;31;42m" # piso
2316 | _cor[4]="\E[00;33;46m" # amarelo para coin
2317 | _cor[5]="\E[00;36;46m" # invisible
2318 | else
2319 | _cor[0]="\E[01;37;41m" # logo
2320 | _cor[1]="\E[01;37;46m" # Title
2321 | _cor[2]="\E[02;30;46m" # ceu
2322 | _cor[3]="\E[02;31;42m" # piso
2323 | _cor[4]="\E[01;33;46m" # amarelo para coin
2324 | _cor[5]="\E[00;36;46m" # invisible
2325 | fi
2326 |
2327 | #definicao minima de Largura e Altura da tela do jogo em linhas por colunas
2328 | _heightScreen=40
2329 | _widthScreen=80
2330 |
2331 | # Inicializa variaveis de controle de tempo
2332 | #_tempoS=$SECONDS #((10#`date +%S`)) Define o tempo inicial com os segundos desde quando o terminal foi aberto
2333 | _tempoN=0
2334 | _tempo2N=0
2335 |
2336 | #Controla quantos eventos por segundo devem ocorrer
2337 | _next=false
2338 |
2339 | # inicializa variavel para posicao da camera no cenario
2340 | _cameraX=0
2341 |
2342 | # inicializa variavel para definir a largura da fase em caracters
2343 | _sizeFase=0
2344 |
2345 | #Cores possíveis no terminal
2346 | # 0 preto
2347 | # 1 vermelho
2348 | # 2 verde
2349 | # 3 amarelo
2350 | # 4 azul escuro
2351 | # 5 cinza
2352 | # 6 azul claro
2353 | # 7 branco
2354 |
2355 | _edgeWidth=30
2356 | _edgeScreen=`printf "%${_edgeWidth}s"` # Variavel para permitir renderizar desenhos que ficam com parte visivel na camera e parte nao visivel
2357 |
2358 | _width=0
2359 | _height=0
2360 |
2361 | TerminalSize
2362 |
2363 | _score=0 #Variavel para guardar o score atual do jogo
2364 | _coins=0 #Variavel para as moedas capturadas no jogo
2365 | _world="1-1" #Nivel atual do jogo
2366 | _timeGame=300 #Define quanto tempo terá a fase
2367 | _timeIni=0 #Guarda o tempo em segundos do inicio do jogo
2368 | _time=0 #Tempo atual do jogo em segundos
2369 |
2370 | #Carrega a tela do menu no buffer
2371 | LoadMenu
2372 |
2373 | _jogAni=0 #Controla a animacao de sprite para dar sensacao mais real do andar
2374 | # guarda qual sprite do personagem sera exibido
2375 | _jogSprite=0
2376 |
2377 | #qual lado do jogador (d=direito e=esquerdo) será exibido
2378 | _jogSide="D"
2379 |
2380 | _jogHeight=16
2381 | _jogWidth=16
2382 |
2383 | # Coordenadas iniciais do jogador x,y e velocidade em x e y
2384 | _jogX=0
2385 | _jogY=0
2386 | _velocY=0
2387 | _velocX=0
2388 |
2389 | # define se o jogado morreu
2390 | _jogDead=false
2391 |
2392 | #Variavel que guarda as vidas do personagem
2393 | _jogLife=0
2394 |
2395 | #Define a tela atual do Jogo se esta: no menu, no jogo ou em pausa no jogo
2396 | _screenGame="MENU"
2397 |
2398 | # Fisica do Jogo
2399 | _gravidade=1
2400 |
2401 | # Coordenada da posicao do piso no cenario para colisao do personagem
2402 | _piso=37
2403 |
2404 | # Variaveis de controle de calculo e exibicao de quadros por segundo do jogo (velocidade do jogo)
2405 | _quadroRender=0
2406 | _quadros=0
2407 | _lps=0 #loops por segundo
2408 | _fps=0 #frames por segundo
2409 |
2410 | #Variavel para controle de limpeza do buffer do teclado: ver Function ListenKey
2411 | _clearBuffer=false
2412 |
2413 |
2414 | # Verifica se há linhas suficientes para desenha o jogo no terminal
2415 | # caso contrário gera um erro, termina o programa e exibe mensagem para o usuario
2416 | if [ $_height -lt $_heightScreen ] || [ $_width -lt $_widthScreen ]; then
2417 | _erro="Terminal deve ter no mínimo $_heightScreen linhas x $_widthScreen colunas!\nEncontrado $_height linhas x $_width colunas."
2418 | Sair
2419 | fi
2420 |
2421 | ClearScreen
2422 |
2423 | tput cup $(( _initY + 12 )) 0
2424 |
2425 | echo "$_spaceIni Copyright (C) 2012 Doriedson Alves Galdino de Oliveira "
2426 | echo "$_spaceIni Thiago Andre Silva "
2427 | echo "$_spaceIni Vitor Augusto Andrioli "
2428 | echo " "
2429 | echo "$_spaceIni This program is free software: you can redistribute it and/or modify "
2430 | echo "$_spaceIni it under the terms of the GNU General Public License as published by "
2431 | echo "$_spaceIni the Free Software Foundation, either version 3 of the License, or "
2432 | echo "$_spaceIni (at your option) any later version. "
2433 | echo "$_spaceIni "
2434 | echo "$_spaceIni This program is distributed in the hope that it will be useful, "
2435 | echo "$_spaceIni but WITHOUT ANY WARRANTY; without even the implied warranty of "
2436 | echo "$_spaceIni MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
2437 | echo "$_spaceIni GNU General Public License for more details. "
2438 | echo " "
2439 | echo "$_spaceIni You should have received a copy of the GNU General Public License "
2440 | echo "$_spaceIni along with this program. If not, see . "
2441 |
2442 | read -n1
2443 |
2444 | ClearScreen
2445 |
2446 | # guarda o nanosegundo atual do relógio do sistema, aqui foi usado 10# para conversão de base
2447 | # pois quando o segundo chega a 08 dá erro com cálculos por que o bash entende que o número
2448 | # é octadecimal e como o sistema octadecimal vai até o 7, entao gera um erro, por isso precisamos
2449 | # forçar o entendimento para a base decimal com 10#
2450 | _tempoN=$((10#`date +%N`))
2451 |
2452 |
2453 | # [ TIME LINE ] --------------------------------------------------------------------------------------------------------------------
2454 |
2455 | # loop do jogo (Time Line)
2456 | while true; do
2457 |
2458 | FPS #Atualiza a taxa de quadros por segundo
2459 |
2460 | ListenKey #Houve o Teclado
2461 |
2462 | if [ $_next = true ]; then
2463 | LoadColors #Carrega as cores de fundo
2464 |
2465 | MoveEnemy #Calcula movimento do inimigo
2466 |
2467 | Jogador #Calcula Coordenadas do Jogador
2468 |
2469 | Render #Renderiza o jogo no terminal
2470 | fi
2471 |
2472 | _next=false #Controle para quando poderá calcular o próximo quadro do jogo
2473 |
2474 | done
2475 |
2476 |
--------------------------------------------------------------------------------
/stomp.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/stomp.ogg
--------------------------------------------------------------------------------
/timewarning.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/timewarning.ogg
--------------------------------------------------------------------------------
/up.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/up.ogg
--------------------------------------------------------------------------------
/world1-1.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/world1-1.ogg
--------------------------------------------------------------------------------
/worldcleared.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Doriedson/mario-shellscript/2b7fdc00d7a6031d71c26393284850d296b684b3/worldcleared.ogg
--------------------------------------------------------------------------------