Compare commits
414 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52e3004465 | ||
|
|
5557b10cfa | ||
|
|
fdb2f50a20 | ||
|
|
0d46333c4e | ||
|
|
c3b0331d8a | ||
|
|
0e24c8eb2e | ||
|
|
be77353917 | ||
|
|
d3c71ddb20 | ||
|
|
c49e134e13 | ||
|
|
81249b3f4a | ||
|
|
51a7d389af | ||
|
|
5f0e0ce205 | ||
|
|
6f44371df1 | ||
|
|
15bcb941de | ||
|
|
5d9542113a | ||
|
|
0fb1b4e09c | ||
|
|
1e02914267 | ||
|
|
6db1062768 | ||
|
|
adf6d7e08d | ||
|
|
c492e5fd73 | ||
|
|
7ed5b1c116 | ||
|
|
53d3f9cdde | ||
|
|
edccce8563 | ||
|
|
a87fded4cf | ||
|
|
fdae025495 | ||
|
|
fa6061c623 | ||
|
|
8ab921d5b4 | ||
|
|
723331f814 | ||
|
|
71630e80e4 | ||
|
|
5646c6a7a8 | ||
|
|
582229e17c | ||
|
|
7e2a55aa07 | ||
|
|
b05fb07d77 | ||
|
|
7e60538469 | ||
|
|
9f59648c26 | ||
|
|
13b2787173 | ||
|
|
6c635fe75a | ||
|
|
6d5ded3c7d | ||
|
|
cbb68060c6 | ||
|
|
0fba875c72 | ||
|
|
98899881e7 | ||
|
|
8fd41702c6 | ||
|
|
34d174e315 | ||
|
|
3265d3fcd4 | ||
|
|
7d42ae3c9a | ||
|
|
e6fcf24f89 | ||
|
|
16d8ba09fb | ||
|
|
7223aec001 | ||
|
|
0ec2fff5bf | ||
|
|
78bbd99f0d | ||
|
|
b4c73f4888 | ||
|
|
677dc46eeb | ||
|
|
fbb7cb442c | ||
|
|
909331ac51 | ||
|
|
785e3213d5 | ||
|
|
fad6cc2e1b | ||
|
|
9a0c857131 | ||
|
|
bac1e69164 | ||
|
|
8e9c180278 | ||
|
|
3859c66f0e | ||
|
|
9a5176e430 | ||
|
|
95cfb076d1 | ||
|
|
9043224bb2 | ||
|
|
01db4a6f99 | ||
|
|
035e905a3e | ||
|
|
b2ed2d6f6d | ||
|
|
fbef18f58b | ||
|
|
4f866f2a9a | ||
|
|
af93126e05 | ||
|
|
5bda007763 | ||
|
|
f70868ce22 | ||
|
|
6e44341d67 | ||
|
|
3788da41cd | ||
|
|
57c1cb9ffa | ||
|
|
85b8f10778 | ||
|
|
0a35055aa0 | ||
|
|
3ef6a15741 | ||
|
|
d190e73ad3 | ||
|
|
79d30931c3 | ||
|
|
56f103953d | ||
|
|
be7be4c1cc | ||
|
|
5553ecfd88 | ||
|
|
ab9ffb7558 | ||
|
|
c181965682 | ||
|
|
31d1c0c112 | ||
|
|
82913393a8 | ||
|
|
523c7d34c0 | ||
|
|
71eea49eba | ||
|
|
98e9176b73 | ||
|
|
b8a8670301 | ||
|
|
a69b2f7e21 | ||
|
|
722bd11689 | ||
|
|
4d01a2678f | ||
|
|
8fc246a051 | ||
|
|
f954d78903 | ||
|
|
196df0c78b | ||
|
|
ddf6d60ed4 | ||
|
|
c423f3bfc6 | ||
|
|
2a962929f3 | ||
|
|
b74261ca04 | ||
|
|
7176ff19dc | ||
|
|
62db0c91de | ||
|
|
b36d6f0db2 | ||
|
|
81ea8edf47 | ||
|
|
567931097e | ||
|
|
4a4b46cbe1 | ||
|
|
cdbdbac1e7 | ||
|
|
5eed925b7b | ||
|
|
c76c4e8a5c | ||
|
|
a2557fce51 | ||
|
|
40ce32c5da | ||
|
|
7af99c55ef | ||
|
|
232eb35acf | ||
|
|
757cc4261c | ||
|
|
851862f8db | ||
|
|
5689210c46 | ||
|
|
4d31672264 | ||
|
|
7e9d31bb04 | ||
|
|
1b61bc4bb0 | ||
|
|
84b7f9ea36 | ||
|
|
d880218056 | ||
|
|
3706e3e998 | ||
|
|
e2abd0e7fb | ||
|
|
647002a75c | ||
|
|
9484fbbace | ||
|
|
1c169add0d | ||
|
|
7e43dbf64b | ||
|
|
ce4600350e | ||
|
|
db8ac0422d | ||
|
|
fc7ff91882 | ||
|
|
0dfb54ff7f | ||
|
|
65b34f8192 | ||
|
|
ad2cdfebd4 | ||
|
|
1113bafac4 | ||
|
|
0938a48563 | ||
|
|
68aefef5b9 | ||
|
|
e85494a57a | ||
|
|
e9f0f75c5b | ||
|
|
9c8dc6383e | ||
|
|
f7e3ceb31e | ||
|
|
c3f09a45dc | ||
|
|
fbc7341439 | ||
|
|
179f94528b | ||
|
|
beaefdc0c0 | ||
|
|
ea37c101e0 | ||
|
|
a5d736f624 | ||
|
|
0a84347d11 | ||
|
|
b032b75c07 | ||
|
|
c27056da58 | ||
|
|
302e8727e1 | ||
|
|
18c76b6dae | ||
|
|
5867e5e931 | ||
|
|
f4d146d0ec | ||
|
|
548c4d5b26 | ||
|
|
6860a1e814 | ||
|
|
3a38ab4635 | ||
|
|
0e83ebc6af | ||
|
|
b47178faac | ||
|
|
7cd99ae192 | ||
|
|
81a16597b9 | ||
|
|
79edc17b70 | ||
|
|
1eb4eccd55 | ||
|
|
2aff1c69a3 | ||
|
|
65c8d77cf4 | ||
|
|
502d410777 | ||
|
|
0d02b2f90d | ||
|
|
167e1d391b | ||
|
|
f6ac674864 | ||
|
|
83af3223df | ||
|
|
518eb6df52 | ||
|
|
199e4bed4c | ||
|
|
63d1cd9a60 | ||
|
|
4bbf04129a | ||
|
|
d4496aada8 | ||
|
|
71d29dcf3b | ||
|
|
956875c306 | ||
|
|
e375d5aa49 | ||
|
|
8a4a0262e9 | ||
|
|
2b16927567 | ||
|
|
92c39e7f1c | ||
|
|
185d0f4b05 | ||
|
|
82c9367044 | ||
|
|
4045f997c2 | ||
|
|
934b02bd84 | ||
|
|
4e27134403 | ||
|
|
76ec36d805 | ||
|
|
285139fc4e | ||
|
|
a62a4c8534 | ||
|
|
3696e43696 | ||
|
|
778baf07cc | ||
|
|
106e03c3b8 | ||
|
|
c34e3f33c6 | ||
|
|
b4ab5b4e14 | ||
|
|
b4252c05bf | ||
|
|
cbb297750f | ||
|
|
6cbfa30e8b | ||
|
|
58c33d04db | ||
|
|
e306a408dc | ||
|
|
8ef5764b0d | ||
|
|
b81ab55554 | ||
|
|
6947ff4529 | ||
|
|
20d2e6ed2f | ||
|
|
a3a6e72099 | ||
|
|
faee000550 | ||
|
|
1cf4fff74a | ||
|
|
6df3667072 | ||
|
|
d059806f20 | ||
|
|
e03d6abbc8 | ||
|
|
648befbf58 | ||
|
|
78dffe0d04 | ||
|
|
fa3c247bd5 | ||
|
|
73d96b7306 | ||
|
|
ffd600917d | ||
|
|
da6fffbc81 | ||
|
|
5e8f722c91 | ||
|
|
7e9078be51 | ||
|
|
26d2f226a8 | ||
|
|
b89af52a73 | ||
|
|
ac939fc8f8 | ||
|
|
a00465dee8 | ||
|
|
ecd12d2163 | ||
|
|
a0ad65d7df | ||
|
|
8fcf95c120 | ||
|
|
a78c51da26 | ||
|
|
b91b30a854 | ||
|
|
fb9d637fb7 | ||
|
|
a467f5078b | ||
|
|
6c521556a0 | ||
|
|
b22177e926 | ||
|
|
19dd819072 | ||
|
|
c22732e4cc | ||
|
|
24bd3745e3 | ||
|
|
afc51649fe | ||
|
|
d9202081aa | ||
|
|
40b8c76856 | ||
|
|
cfeb6d6b75 | ||
|
|
a667e74db5 | ||
|
|
682b933dac | ||
|
|
ee5862a782 | ||
|
|
bf898dc717 | ||
|
|
55934859e3 | ||
|
|
8a6a3a8eef | ||
|
|
6bdf4cd06e | ||
|
|
2c2c89e040 | ||
|
|
490f178f62 | ||
|
|
f2c66d1904 | ||
|
|
c1461de661 | ||
|
|
905717d462 | ||
|
|
470464518b | ||
|
|
b04aa38abb | ||
|
|
3b06e40e72 | ||
|
|
1d5184e235 | ||
|
|
85ca2fb2a1 | ||
|
|
d3cc6be62c | ||
|
|
4eb852ac78 | ||
|
|
139cb6b05e | ||
|
|
35f9517ea8 | ||
|
|
095beddcb9 | ||
|
|
1b2ce74a39 | ||
|
|
fa0fce0eb6 | ||
|
|
1a9aea09ef | ||
|
|
0cfbbec3f9 | ||
|
|
f47f25180c | ||
|
|
c71e401b08 | ||
|
|
364e8cbfb8 | ||
|
|
93509019a9 | ||
|
|
6ca863ffb0 | ||
|
|
a425dccaa5 | ||
|
|
2eb14690fc | ||
|
|
da12c09942 | ||
|
|
dd2ba9a5ba | ||
|
|
ea65d7f896 | ||
|
|
3d16659046 | ||
|
|
8d726b52a9 | ||
|
|
6cf53c39bf | ||
|
|
cd586acd33 | ||
|
|
3d4947bcb5 | ||
|
|
044afe7976 | ||
|
|
9dbd05a8a8 | ||
|
|
5efee6741f | ||
|
|
3d7c24ef1b | ||
|
|
de27fa1d5a | ||
|
|
02c6a268c3 | ||
|
|
ae57eb2080 | ||
|
|
4af38765af | ||
|
|
f3f0ac4827 | ||
|
|
5f1776bdf4 | ||
|
|
c9193d1035 | ||
|
|
948db2893b | ||
|
|
92e24ceb99 | ||
|
|
e591ceece9 | ||
|
|
7ef60c2874 | ||
|
|
471243f38e | ||
|
|
bde67b4c5e | ||
|
|
666d1cbf99 | ||
|
|
2831e16798 | ||
|
|
521fc2d755 | ||
|
|
d103e7aec2 | ||
|
|
7349ccc6a0 | ||
|
|
cd32f64f80 | ||
|
|
983c1361dd | ||
|
|
3657f91c0c | ||
|
|
7edfc9b29e | ||
|
|
e77b85fba3 | ||
|
|
0f848370fe | ||
|
|
4618c9b04e | ||
|
|
5c40412e34 | ||
|
|
48d2ec90fc | ||
|
|
06af3f0c2c | ||
|
|
2c244014df | ||
|
|
5766a55115 | ||
|
|
ce2bd76d80 | ||
|
|
b0c27f044e | ||
|
|
0d3be3e10f | ||
|
|
6ddead591a | ||
|
|
560ea5a6ce | ||
|
|
60457b4d99 | ||
|
|
86be54ae49 | ||
|
|
6eec19b9af | ||
|
|
935e9bbc44 | ||
|
|
59d443e889 | ||
|
|
31b962adba | ||
|
|
aeba3a05aa | ||
|
|
9737f8eaa7 | ||
|
|
a0a5b0e7b0 | ||
|
|
8902903099 | ||
|
|
353dc4d2d6 | ||
|
|
a8d797cd46 | ||
|
|
3d158cc902 | ||
|
|
9f8a625c8e | ||
|
|
3eda0c7fe1 | ||
|
|
81fef6072b | ||
|
|
8fea00cfac | ||
|
|
960ade79ca | ||
|
|
6ac2aeea60 | ||
|
|
e5ceb2d8a5 | ||
|
|
713dfd064d | ||
|
|
188cfda940 | ||
|
|
3eb81eb6a2 | ||
|
|
be59edcb97 | ||
|
|
bf4425babb | ||
|
|
85e7aeec99 | ||
|
|
8793b7117f | ||
|
|
7d7c08ad54 | ||
|
|
d4c040b527 | ||
|
|
5c532525cc | ||
|
|
1b1244d113 | ||
|
|
27af28d02c | ||
|
|
0fbb2b99b0 | ||
|
|
861638b9d0 | ||
|
|
e6c19ff4a9 | ||
|
|
2ff9d17f46 | ||
|
|
5566c748c2 | ||
|
|
730b2f30a0 | ||
|
|
cb52878006 | ||
|
|
ab0816a44e | ||
|
|
f2918178d7 | ||
|
|
b9ad7a4ac3 | ||
|
|
981359289c | ||
|
|
37e7ec0985 | ||
|
|
0e2c5ad182 | ||
|
|
3e3a9e7b6e | ||
|
|
27e4e36e03 | ||
|
|
bbe50fc9da | ||
|
|
410d783126 | ||
|
|
f47d0909cc | ||
|
|
907b8a2f42 | ||
|
|
1923153f46 | ||
|
|
5875f2a320 | ||
|
|
895749024a | ||
|
|
2e40f67b1b | ||
|
|
f1de905f87 | ||
|
|
b0d4a7cb8a | ||
|
|
fed698d0d2 | ||
|
|
db01a216fd | ||
|
|
b46a823342 | ||
|
|
2190128fd3 | ||
|
|
9e096b1c89 | ||
|
|
14580c55ac | ||
|
|
076b0453c6 | ||
|
|
6b983c0542 | ||
|
|
07d6c311d7 | ||
|
|
58c337c33c | ||
|
|
aeb2d7b8d5 | ||
|
|
b0fdd8cf76 | ||
|
|
fbde23fbb0 | ||
|
|
3f507c0363 | ||
|
|
a2979d237b | ||
|
|
9d67db049a | ||
|
|
851f486a48 | ||
|
|
be43d1644b | ||
|
|
75505ca79f | ||
|
|
7c8b9962ca | ||
|
|
149cfcb995 | ||
|
|
7611baf52e | ||
|
|
efd3a46331 | ||
|
|
4c0cb41a0e | ||
|
|
f6594e9923 | ||
|
|
4a832ad714 | ||
|
|
0200ba6c95 | ||
|
|
d047c2de5b | ||
|
|
f30f16b8ce | ||
|
|
52f5b2e5d2 | ||
|
|
0fc59325ab | ||
|
|
eba852bbde | ||
|
|
f82dd94089 | ||
|
|
3e9e2079a7 | ||
|
|
585455e67c | ||
|
|
b7e0a470c7 | ||
|
|
87cfcb7a4f | ||
|
|
31cc886d07 | ||
|
|
9a2889b35b | ||
|
|
44daa8ac89 | ||
|
|
e44e3521b6 |
25
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,24 +1,7 @@
|
||||
<!--
|
||||
Only submit a pull request if all of the following conditions are met:
|
||||
Please target the `master` branch in priority.
|
||||
PRs can target `3.x` if the same change was done in `master`, or is not relevant there.
|
||||
|
||||
* It must work with the latest stable Godot version. Do not submit a
|
||||
pull request if it only works with alpha/beta builds.
|
||||
|
||||
* It must follow all of the Godot style guides, including the GDScript
|
||||
style guide and the C# style guide.
|
||||
|
||||
* The demo should not be overcomplicated. Simplicity is usually preferred.
|
||||
|
||||
* If you are submitting a new demo, please ensure that it includes a
|
||||
README file similar to the other demos.
|
||||
|
||||
* If you are submitting a copy of a demo translated to C# etc:
|
||||
|
||||
* Please ensure that there is a good reason to have this demo translated.
|
||||
We don't want to have multiple copies of every single project.
|
||||
|
||||
* Please ensure that the code mirrors the original closely.
|
||||
|
||||
* In the project.godot file and in the README, include "with C#" etc in
|
||||
the title, and also include a link to the original in the README.
|
||||
Relevant fixes are cherry-picked for stable branches as needed by maintainers.
|
||||
You can mention in the description if the change is compatible with `3.x`.
|
||||
-->
|
||||
|
||||
32
.github/dist/export_presets.cfg
vendored
@@ -1,23 +1,41 @@
|
||||
[preset.0]
|
||||
|
||||
name="HTML5"
|
||||
platform="HTML5"
|
||||
name="Web"
|
||||
platform="Web"
|
||||
runnable=true
|
||||
advanced_options=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path=""
|
||||
script_export_mode=1
|
||||
script_encryption_key=""
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_export_mode=2
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
variant/export_type=0
|
||||
variant/extensions_support=false
|
||||
variant/thread_support=true
|
||||
vram_texture_compression/for_desktop=true
|
||||
vram_texture_compression/for_mobile=false
|
||||
vram_texture_compression/for_mobile=true
|
||||
html/export_icon=true
|
||||
html/custom_html_shell=""
|
||||
html/head_include=""
|
||||
html/full_window_size=true
|
||||
html/canvas_resize_policy=2
|
||||
html/focus_canvas_on_start=true
|
||||
html/experimental_virtual_keyboard=true
|
||||
progressive_web_app/enabled=true
|
||||
progressive_web_app/ensure_cross_origin_isolation_headers=true
|
||||
progressive_web_app/offline_page=""
|
||||
progressive_web_app/display=0
|
||||
progressive_web_app/orientation=1
|
||||
progressive_web_app/icon_144x144=""
|
||||
progressive_web_app/icon_180x180=""
|
||||
progressive_web_app/icon_512x512=""
|
||||
progressive_web_app/background_color=Color(0, 0, 0, 1)
|
||||
|
||||
45
.github/dist/footer.html
vendored
@@ -1,19 +1,38 @@
|
||||
<!-- The list of demos will be inserted above by the CI process. -->
|
||||
</ul>
|
||||
<h2>Unavailable demos</h2>
|
||||
<ul>
|
||||
<li><code>2d/hdr/</code>: Not supported on HTML5 yet.
|
||||
<li><code>3d/voxel/</code>: Not supported on HTML5 yet.
|
||||
<li><code>audio/device_changer/</code>: Not supported on HTML5 due to browser limitations.
|
||||
<li><code>loading/background_load/</code>: Not supported on HTML5 yet.
|
||||
<li><code>loading/multiple_threads_loading/</code>: Not supported on HTML5 yet.
|
||||
<li><code>loading/threads/</code>: Not supported on HTML5 yet.
|
||||
<li><code>misc/matrix_transform/</code>: Results are only visible in the editor.
|
||||
<li><code>mobile/android_iap/</code>: Only relevant on native Android.
|
||||
<li><code>mobile/sensors/</code>: Not supported on HTML5 yet.
|
||||
<li><code>mono/*/</code>: Not available yet (requires Mono-enabled HTML5 build).</li>
|
||||
<li><code>networking/*/</code>: Doesn't make sense to be hosted on a static host, as the server must be hosted on the same origin due to the browser's same-origin policy.</li>
|
||||
<li><code>plugins/*/</code>: Only effective within the editor.</li>
|
||||
<ul class="unsupported-demos">
|
||||
<li><code>2d/glow</code>: Not supported on the Compatibility rendering method (which the web platform always uses).</li>
|
||||
<li><code>2d/navigation_mesh_chunks</code>: Relies on debug-only drawing functionality which is not available in projects exported in release mode.</li>
|
||||
<li><code>2d/physics_tests</code>: Relies on debug-only drawing functionality which is not available in projects exported in release mode.</li>
|
||||
<li><code>3d/labels_and_texts</code>: Does not export in headless mode due to an engine bug (font importing infinite loop).</li>
|
||||
<li><code>3d/decals</code>: Not supported on the Compatibility rendering method (which the web platform always uses).</li>
|
||||
<li><code>3d/ik</code>: Demo is not fully ported to Godot 4 yet (even though the feature works on the web).</li>
|
||||
<li><code>3d/navigation_mesh_chunks</code>: Relies on debug-only drawing functionality which is not available in projects exported in release mode.</li>
|
||||
<li><code>3d/occlusion_culling_mesh_lod</code>: Occlusion culling is disabled by default in web builds to decrease binary size.</li>
|
||||
<li><code>3d/particles</code>: Demo mostly showcases features that are not available in Compatibility (which the web platform always uses).</li>
|
||||
<li><code>3d/physical_light_camera_units</code>: Demo is not tuned for the Compatibility rendering method (which the web platform always uses).</li>
|
||||
<li><code>3d/physics_tests</code>: Relies on debug-only drawing functionality which is not available in projects exported in release mode.</li>
|
||||
<li><code>3d/variable_rate_shading</code>: Not supported on the Compatibility rendering method (which the web platform always uses)</li>
|
||||
<li><code>3d/volumetric_fog</code>: Not supported on the Compatibility rendering method (which the web platform always uses)</li>
|
||||
<li><code>3d/voxel</code>: Freezes after a few seconds of gameplay due to web platform-specific threading issues.</li>
|
||||
<li><code>audio/bpm_sync</code>: Not functional on the web platform due to differences in the audio playback implementation.</li>
|
||||
<li><code>audio/device_changer</code>: Not relevant for the web platform, as the web browser always chooses the audio output device.</li>
|
||||
<li><code>audio/midi_piano</code>: Not functional on the web platform due to differences in the audio playback implementation.</li>
|
||||
<li><code>audio/spectrum</code>: Not functional on the web platform due to differences in the audio playback implementation.</li>
|
||||
<li><code>compute/*</code>: Not supported on the Compatibility rendering method (which the web platform always uses).</li>
|
||||
<li><code>gui/msdf_font</code>: Does not export in headless mode due to an engine bug (font importing crashes).</li>
|
||||
<li><code>gui/translation</code>: Does not export in headless mode due to an engine bug (font importing crashes).</li>
|
||||
<li><code>loading/runtime_save_load</code>: Native filesystem access is not available on the web platform.</li>
|
||||
<li><code>misc/compute_shader_heightmap</code>: Not supported on the Compatibility rendering method (which the web platform always uses).</li>
|
||||
<li><code>misc/large_world_coordinates</code>: Not supported on the Compatibility rendering method (which the web platform always uses).</li>
|
||||
<li><code>misc/matrix_transform</code>: Results are only visible in the editor.</li>
|
||||
<li><code>mobile/android_iap</code>: Only relevant on native Android.</li>
|
||||
<li><code>mobile/sensors</code>: Not supported on the web platform.</li>
|
||||
<li><code>mono/*</code>: Not available yet (requires Mono-enabled HTML5 build).</li>
|
||||
<li><code>networking/*</code>: Doesn't make sense to be hosted on a static host, as the server must be hosted on the same origin due to the browser's same-origin policy.</li>
|
||||
<li><code>plugins/*</code>: Only effective within the editor.</li>
|
||||
<li><code>xr/*</code>: Not functional on the web platform, as these demos are not designed for WebXR.</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
22
.github/dist/header.html
vendored
@@ -4,13 +4,15 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Godot demos exported to HTML5</title>
|
||||
<title>Official Godot demos exported to Web</title>
|
||||
<style>
|
||||
:root {
|
||||
--background-color: #fff;
|
||||
--text-color: #222;
|
||||
--link-color: hsl(220, 100%, 45%);
|
||||
--link-visited-color: hsl(270, 100%, 55%);
|
||||
--link-underline-color: hsla(220, 100%, 45%, 0.3);
|
||||
--link-underline-visited-color: hsla(270, 100%, 45%, 0.3);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@@ -18,7 +20,9 @@
|
||||
--background-color: #222;
|
||||
--text-color: #eee;
|
||||
--link-color: hsl(200, 100%, 70%);
|
||||
--link-visited-color: hsl(250, 100%, 80%);
|
||||
--link-underline-color: hsla(200, 100%, 70%, 0.3);
|
||||
--link-underline-visited-color: hsla(250, 100%, 70%, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +56,11 @@
|
||||
text-decoration-thickness: 0.125rem;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: var(--link-visited-color);
|
||||
text-decoration-color: var(--link-visited-color);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
filter: brightness(117.5%);
|
||||
}
|
||||
@@ -88,6 +97,9 @@
|
||||
margin: 20px 10px;
|
||||
}
|
||||
|
||||
.unsupported-demos li {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@@ -96,12 +108,12 @@
|
||||
<p>
|
||||
This page lists
|
||||
<a href="https://github.com/godotengine/godot-demo-projects">official Godot demo projects</a>
|
||||
exported to HTML5 for testing purposes. These projects are deployed automatically
|
||||
exported to the web for testing purposes. These projects are deployed automatically
|
||||
on every commit on the <code>master</code> branch of the repository.
|
||||
</p>
|
||||
<p>
|
||||
The HTML5 exports on this page are provided for demonstration purposes only.
|
||||
Some of these demos may not function or render correctly on HTML5,
|
||||
The web exports on this page are provided for demonstration purposes only.
|
||||
Some of these demos may not function or render correctly on the web platform,
|
||||
especially on mobile devices.
|
||||
For best performance, it's recommended to
|
||||
<a href="https://godotengine.org/download">download</a> a native editor
|
||||
@@ -110,7 +122,7 @@
|
||||
<p>
|
||||
See the
|
||||
<a href="https://docs.godotengine.org/en/stable/getting_started/workflow/export/exporting_for_web.html">Exporting for the Web</a>
|
||||
documentation for information on exporting your own projects to HTML5.
|
||||
documentation for information on exporting your own projects to the web.
|
||||
</p>
|
||||
|
||||
<h2>List of demos</h2>
|
||||
|
||||
4
.gitignore
vendored
@@ -20,3 +20,7 @@ mono_crash.*.json
|
||||
.directory
|
||||
.DS_Store
|
||||
*~
|
||||
*.blend1
|
||||
|
||||
# Jetbrains IDE files
|
||||
.idea/
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
These demos are all 2D, but otherwise do not have a common theme.
|
||||
|
||||
Languages: Most have GDScript, some have
|
||||
[GDSL](https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/shading_language.html)
|
||||
[Godot shader language](https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/shading_language.html)
|
||||
|
||||
Renderers: 6 of them are GLES 3, but most are GLES 2
|
||||
Renderers: Glow for 2D and Physics Platformer use Forward+, 2D Particles uses Mobile, and the rest use Compatibility
|
||||
|
||||
@@ -9,9 +9,9 @@ in the documentation for more information.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
Renderer: Compatibility
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/887
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2711
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/bullet.png-ff1424653e10246c11e3724e402c519e.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bcoiuym4nw1ua"
|
||||
path="res://.godot/imported/bullet.png-ff1424653e10246c11e3724e402c519e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://bullet.png"
|
||||
dest_files=[ "res://.import/bullet.png-ff1424653e10246c11e3724e402c519e.stex" ]
|
||||
dest_files=["res://.godot/imported/bullet.png-ff1424653e10246c11e3724e402c519e.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -8,86 +8,81 @@ const BULLET_COUNT = 500
|
||||
const SPEED_MIN = 20
|
||||
const SPEED_MAX = 80
|
||||
|
||||
const bullet_image = preload("res://bullet.png")
|
||||
const bullet_image := preload("res://bullet.png")
|
||||
|
||||
var bullets = []
|
||||
var shape
|
||||
var bullets := []
|
||||
var shape := RID()
|
||||
|
||||
|
||||
class Bullet:
|
||||
var position = Vector2()
|
||||
var speed = 1.0
|
||||
var position := Vector2()
|
||||
var speed := 1.0
|
||||
# The body is stored as a RID, which is an "opaque" way to access resources.
|
||||
# With large amounts of objects (thousands or more), it can be significantly
|
||||
# faster to use RIDs compared to a high-level approach.
|
||||
var body = RID()
|
||||
var body := RID()
|
||||
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
||||
shape = Physics2DServer.circle_shape_create()
|
||||
func _ready() -> void:
|
||||
shape = PhysicsServer2D.circle_shape_create()
|
||||
# Set the collision shape's radius for each bullet in pixels.
|
||||
Physics2DServer.shape_set_data(shape, 8)
|
||||
PhysicsServer2D.shape_set_data(shape, 8)
|
||||
|
||||
for _i in BULLET_COUNT:
|
||||
var bullet = Bullet.new()
|
||||
# Give each bullet its own speed.
|
||||
bullet.speed = rand_range(SPEED_MIN, SPEED_MAX)
|
||||
bullet.body = Physics2DServer.body_create()
|
||||
var bullet := Bullet.new()
|
||||
# Give each bullet its own random speed.
|
||||
bullet.speed = randf_range(SPEED_MIN, SPEED_MAX)
|
||||
bullet.body = PhysicsServer2D.body_create()
|
||||
|
||||
Physics2DServer.body_set_space(bullet.body, get_world_2d().get_space())
|
||||
Physics2DServer.body_add_shape(bullet.body, shape)
|
||||
PhysicsServer2D.body_set_space(bullet.body, get_world_2d().get_space())
|
||||
PhysicsServer2D.body_add_shape(bullet.body, shape)
|
||||
# Don't make bullets check collision with other bullets to improve performance.
|
||||
# Their collision mask is still configured to the default value, which allows
|
||||
# bullets to detect collisions with the player.
|
||||
Physics2DServer.body_set_collision_layer(bullet.body, 0)
|
||||
PhysicsServer2D.body_set_collision_mask(bullet.body, 0)
|
||||
|
||||
# Place bullets randomly on the viewport and move bullets outside the
|
||||
# play area so that they fade in nicely.
|
||||
bullet.position = Vector2(
|
||||
rand_range(0, get_viewport_rect().size.x) + get_viewport_rect().size.x,
|
||||
rand_range(0, get_viewport_rect().size.y)
|
||||
randf_range(0, get_viewport_rect().size.x) + get_viewport_rect().size.x,
|
||||
randf_range(0, get_viewport_rect().size.y)
|
||||
)
|
||||
var transform2d = Transform2D()
|
||||
var transform2d := Transform2D()
|
||||
transform2d.origin = bullet.position
|
||||
Physics2DServer.body_set_state(bullet.body, Physics2DServer.BODY_STATE_TRANSFORM, transform2d)
|
||||
PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
|
||||
|
||||
bullets.push_back(bullet)
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
func _process(_delta: float) -> void:
|
||||
# Order the CanvasItem to update every frame.
|
||||
update()
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
var transform2d = Transform2D()
|
||||
var offset = get_viewport_rect().size.x + 16
|
||||
for bullet in bullets:
|
||||
func _physics_process(delta: float) -> void:
|
||||
var transform2d := Transform2D()
|
||||
var offset := get_viewport_rect().size.x + 16
|
||||
for bullet: Bullet in bullets:
|
||||
bullet.position.x -= bullet.speed * delta
|
||||
|
||||
if bullet.position.x < -16:
|
||||
# The bullet has left the screen; move it back to the right.
|
||||
# Move the bullet back to the right when it left the screen.
|
||||
bullet.position.x = offset
|
||||
|
||||
transform2d.origin = bullet.position
|
||||
|
||||
Physics2DServer.body_set_state(bullet.body, Physics2DServer.BODY_STATE_TRANSFORM, transform2d)
|
||||
PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
|
||||
|
||||
|
||||
# Instead of drawing each bullet individually in a script attached to each bullet,
|
||||
# we are drawing *all* the bullets at once here.
|
||||
func _draw():
|
||||
var offset = -bullet_image.get_size() * 0.5
|
||||
for bullet in bullets:
|
||||
func _draw() -> void:
|
||||
var offset := -bullet_image.get_size() * 0.5
|
||||
for bullet: Bullet in bullets:
|
||||
draw_texture(bullet_image, bullet.position + offset)
|
||||
|
||||
|
||||
# Perform cleanup operations (required to exit without error messages in the console).
|
||||
func _exit_tree():
|
||||
for bullet in bullets:
|
||||
Physics2DServer.free_rid(bullet.body)
|
||||
func _exit_tree() -> void:
|
||||
for bullet: Bullet in bullets:
|
||||
PhysicsServer2D.free_rid(bullet.body)
|
||||
|
||||
Physics2DServer.free_rid(shape)
|
||||
PhysicsServer2D.free_rid(shape)
|
||||
bullets.clear()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/face_happy.png-38d387d31ec13459f749c93ce3d75d80.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d3u7k0742d5ug"
|
||||
path="res://.godot/imported/face_happy.png-38d387d31ec13459f749c93ce3d75d80.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://face_happy.png"
|
||||
dest_files=[ "res://.import/face_happy.png-38d387d31ec13459f749c93ce3d75d80.stex" ]
|
||||
dest_files=["res://.godot/imported/face_happy.png-38d387d31ec13459f749c93ce3d75d80.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/face_sad.png-0ac7165eab24f595aba17a746a66c550.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://8j32onnr4qo3"
|
||||
path="res://.godot/imported/face_sad.png-0ac7165eab24f595aba17a746a66c550.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://face_sad.png"
|
||||
dest_files=[ "res://.import/face_sad.png-0ac7165eab24f595aba17a746a66c550.stex" ]
|
||||
dest_files=["res://.godot/imported/face_sad.png-0ac7165eab24f595aba17a746a66c550.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB |
@@ -1,34 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
BIN
2d/bullet_shower/icon.webp
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
34
2d/bullet_shower/icon.webp.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://brwp8bimc75uu"
|
||||
path="res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.webp"
|
||||
dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -4,30 +4,34 @@ extends Node2D
|
||||
# efficient than using instancing and nodes, but requires more programming and
|
||||
# is less visual. Bullets are managed together in the `bullets.gd` script.
|
||||
|
||||
# The number of bullets currently touched by the player.
|
||||
var touching = 0
|
||||
## The number of bullets currently touched by the player.
|
||||
var touching := 0
|
||||
|
||||
onready var sprite = $AnimatedSprite
|
||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
# The player follows the mouse cursor automatically, so there's no point
|
||||
# in displaying the mouse cursor.
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
||||
|
||||
|
||||
func _input(event):
|
||||
func _input(event: InputEvent) -> void:
|
||||
# Getting the movement of the mouse so the sprite can follow its position.
|
||||
if event is InputEventMouseMotion:
|
||||
position = event.position - Vector2(0, 16)
|
||||
|
||||
|
||||
func _on_body_shape_entered(_body_id, _body, _body_shape, _local_shape):
|
||||
func _on_body_shape_entered(_body_id: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int) -> void:
|
||||
# Player got touched by a bullet so sprite changes to sad face.
|
||||
touching += 1
|
||||
if touching >= 1:
|
||||
sprite.frame = 1
|
||||
|
||||
|
||||
func _on_body_shape_exited(_body_id, _body, _body_shape, _local_shape):
|
||||
func _on_body_shape_exited(_body_id: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int) -> void:
|
||||
touching -= 1
|
||||
# When non of the bullets are touching the player,
|
||||
# sprite changes to happy face.
|
||||
if touching == 0:
|
||||
sprite.frame = 0
|
||||
|
||||
@@ -6,36 +6,31 @@
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Bullet Shower"
|
||||
config/description="Demonstrates how to manage large amounts of objects efficiently using low-level Servers."
|
||||
config/tags=PackedStringArray("2d", "demo", "official", "performance")
|
||||
run/main_scene="res://shower.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/features=PackedStringArray("4.2")
|
||||
config/icon="res://icon.webp"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/untyped_declaration=1
|
||||
|
||||
[display]
|
||||
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
[physics]
|
||||
[layer_names]
|
||||
|
||||
2d/cell_size=64
|
||||
common/enable_pause_aware_picking=true
|
||||
2d_physics/layer_1="Player"
|
||||
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
quality/intended_usage/framebuffer_allocation=0
|
||||
quality/intended_usage/framebuffer_allocation.mobile=0
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 0.133333, 0.133333, 0.2, 1 )
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
|
||||
@@ -1,34 +1,40 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://c78by7hc4fmwx"]
|
||||
|
||||
[ext_resource path="res://bullets.gd" type="Script" id=2]
|
||||
[ext_resource path="res://face_happy.png" type="Texture" id=3]
|
||||
[ext_resource path="res://face_sad.png" type="Texture" id=4]
|
||||
[ext_resource path="res://player.gd" type="Script" id=5]
|
||||
[ext_resource type="Script" path="res://bullets.gd" id="2"]
|
||||
[ext_resource type="Texture2D" uid="uid://d3u7k0742d5ug" path="res://face_happy.png" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://8j32onnr4qo3" path="res://face_sad.png" id="4"]
|
||||
[ext_resource type="Script" path="res://player.gd" id="5"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 3 ), ExtResource( 4 ) ],
|
||||
[sub_resource type="SpriteFrames" id="1"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("3")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"name": &"default",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
}]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
[sub_resource type="CircleShape2D" id="2"]
|
||||
radius = 27.0
|
||||
|
||||
[node name="Shower" type="Node2D"]
|
||||
|
||||
[node name="Bullets" type="Node2D" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Player" type="Area2D" parent="."]
|
||||
script = ExtResource( 5 )
|
||||
script = ExtResource("5")
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="Player"]
|
||||
frames = SubResource( 1 )
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Player"]
|
||||
sprite_frames = SubResource("1")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
|
||||
shape = SubResource( 2 )
|
||||
shape = SubResource("2")
|
||||
|
||||
[connection signal="body_shape_entered" from="Player" to="Player" method="_on_body_shape_entered"]
|
||||
[connection signal="body_shape_exited" from="Player" to="Player" method="_on_body_shape_exited"]
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://HUD.gd" type="Script" id=1]
|
||||
[ext_resource path="res://fonts/Xolonium-Regular.ttf" type="DynamicFontData" id=2]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 64
|
||||
font_data = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
size = 64
|
||||
font_data = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="InputEventAction" id=3]
|
||||
action = "ui_select"
|
||||
|
||||
[sub_resource type="ShortCut" id=4]
|
||||
shortcut = SubResource( 3 )
|
||||
|
||||
[node name="HUD" type="CanvasLayer"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
margin_bottom = 78.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "0"
|
||||
align = 1
|
||||
|
||||
[node name="MessageLabel" type="Label" parent="."]
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
margin_top = -79.5
|
||||
margin_bottom = 79.5
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Dodge the
|
||||
Creeps"
|
||||
align = 1
|
||||
|
||||
[node name="StartButton" type="Button" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -90.0
|
||||
margin_top = -200.0
|
||||
margin_right = 90.0
|
||||
margin_bottom = -100.0
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
shortcut = SubResource( 4 )
|
||||
text = "Start"
|
||||
|
||||
[node name="MessageTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="pressed" from="StartButton" to="." method="_on_StartButton_pressed"]
|
||||
[connection signal="timeout" from="MessageTimer" to="." method="_on_MessageTimer_timeout"]
|
||||
@@ -1,55 +0,0 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://Main.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Mob.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://HUD.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://art/House In a Forest Loop.ogg" type="AudioStream" id=5]
|
||||
[ext_resource path="res://art/gameover.wav" type="AudioStream" id=6]
|
||||
|
||||
[sub_resource type="Curve2D" id=1]
|
||||
_data = {
|
||||
"points": PoolVector2Array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 0, 0, 0, 0, 0, 480, 720, 0, 0, 0, 0, 0, 720, 0, 0, 0, 0, 0, 0 )
|
||||
}
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
mob_scene = ExtResource( 2 )
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color( 0.219608, 0.372549, 0.380392, 1 )
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 3 )]
|
||||
|
||||
[node name="MobTimer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
|
||||
[node name="ScoreTimer" type="Timer" parent="."]
|
||||
|
||||
[node name="StartTimer" type="Timer" parent="."]
|
||||
wait_time = 2.0
|
||||
one_shot = true
|
||||
|
||||
[node name="StartPosition" type="Position2D" parent="."]
|
||||
position = Vector2( 240, 450 )
|
||||
|
||||
[node name="MobPath" type="Path2D" parent="."]
|
||||
curve = SubResource( 1 )
|
||||
|
||||
[node name="MobSpawnLocation" type="PathFollow2D" parent="MobPath"]
|
||||
|
||||
[node name="HUD" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
[node name="Music" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 5 )
|
||||
|
||||
[node name="DeathSound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 6 )
|
||||
|
||||
[connection signal="hit" from="Player" to="." method="game_over"]
|
||||
[connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]
|
||||
[connection signal="timeout" from="ScoreTimer" to="." method="_on_ScoreTimer_timeout"]
|
||||
[connection signal="timeout" from="StartTimer" to="." method="_on_StartTimer_timeout"]
|
||||
[connection signal="start_game" from="HUD" to="." method="new_game"]
|
||||
@@ -1,10 +0,0 @@
|
||||
extends RigidBody2D
|
||||
|
||||
func _ready():
|
||||
$AnimatedSprite.playing = true
|
||||
var mob_types = $AnimatedSprite.frames.get_animation_names()
|
||||
$AnimatedSprite.animation = mob_types[randi() % mob_types.size()]
|
||||
|
||||
|
||||
func _on_VisibilityNotifier2D_screen_exited():
|
||||
queue_free()
|
||||
@@ -1,54 +0,0 @@
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://Mob.gd" type="Script" id=1]
|
||||
[ext_resource path="res://art/enemyFlyingAlt_1.png" type="Texture" id=2]
|
||||
[ext_resource path="res://art/enemyFlyingAlt_2.png" type="Texture" id=3]
|
||||
[ext_resource path="res://art/enemyWalking_1.png" type="Texture" id=4]
|
||||
[ext_resource path="res://art/enemyWalking_2.png" type="Texture" id=5]
|
||||
[ext_resource path="res://art/enemySwimming_1.png" type="Texture" id=6]
|
||||
[ext_resource path="res://art/enemySwimming_2.png" type="Texture" id=7]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 2 ), ExtResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "fly",
|
||||
"speed": 3.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 6 ), ExtResource( 7 ) ],
|
||||
"loop": true,
|
||||
"name": "swim",
|
||||
"speed": 4.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 4 ), ExtResource( 5 ) ],
|
||||
"loop": true,
|
||||
"name": "walk",
|
||||
"speed": 4.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 35.2706
|
||||
height = 23.3281
|
||||
|
||||
[node name="Mob" type="RigidBody2D" groups=[
|
||||
"mobs",
|
||||
]]
|
||||
collision_mask = 0
|
||||
gravity_scale = 0.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
scale = Vector2( 0.75, 0.75 )
|
||||
frames = SubResource( 1 )
|
||||
animation = "walk"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
|
||||
|
||||
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
||||
@@ -1,53 +0,0 @@
|
||||
extends Area2D
|
||||
|
||||
signal hit
|
||||
|
||||
export var speed = 400 # How fast the player will move (pixels/sec).
|
||||
var screen_size # Size of the game window.
|
||||
|
||||
func _ready():
|
||||
screen_size = get_viewport_rect().size
|
||||
hide()
|
||||
|
||||
|
||||
func _process(delta):
|
||||
var velocity = Vector2.ZERO # The player's movement vector.
|
||||
if Input.is_action_pressed("move_right"):
|
||||
velocity.x += 1
|
||||
if Input.is_action_pressed("move_left"):
|
||||
velocity.x -= 1
|
||||
if Input.is_action_pressed("move_down"):
|
||||
velocity.y += 1
|
||||
if Input.is_action_pressed("move_up"):
|
||||
velocity.y -= 1
|
||||
|
||||
if velocity.length() > 0:
|
||||
velocity = velocity.normalized() * speed
|
||||
$AnimatedSprite.play()
|
||||
else:
|
||||
$AnimatedSprite.stop()
|
||||
|
||||
position += velocity * delta
|
||||
position.x = clamp(position.x, 0, screen_size.x)
|
||||
position.y = clamp(position.y, 0, screen_size.y)
|
||||
|
||||
if velocity.x != 0:
|
||||
$AnimatedSprite.animation = "right"
|
||||
$AnimatedSprite.flip_v = false
|
||||
$AnimatedSprite.flip_h = velocity.x < 0
|
||||
elif velocity.y != 0:
|
||||
$AnimatedSprite.animation = "up"
|
||||
$AnimatedSprite.flip_v = velocity.y > 0
|
||||
|
||||
|
||||
func start(pos):
|
||||
position = pos
|
||||
show()
|
||||
$CollisionShape2D.disabled = false
|
||||
|
||||
|
||||
func _on_Player_body_entered(_body):
|
||||
hide() # Player disappears after being hit.
|
||||
emit_signal("hit")
|
||||
# Must be deferred as we can't change physics properties on a physics callback.
|
||||
$CollisionShape2D.set_deferred("disabled", true)
|
||||
@@ -1,71 +0,0 @@
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://art/playerGrey_walk1.png" type="Texture" id=2]
|
||||
[ext_resource path="res://art/playerGrey_walk2.png" type="Texture" id=3]
|
||||
[ext_resource path="res://art/playerGrey_up1.png" type="Texture" id=4]
|
||||
[ext_resource path="res://art/playerGrey_up2.png" type="Texture" id=5]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 2 ), ExtResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 4 ), ExtResource( 5 ) ],
|
||||
"loop": true,
|
||||
"name": "up",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 26.1701
|
||||
height = 14.822
|
||||
|
||||
[sub_resource type="Gradient" id=3]
|
||||
colors = PoolColorArray( 1, 1, 1, 0.501961, 1, 1, 1, 0 )
|
||||
|
||||
[sub_resource type="GradientTexture" id=4]
|
||||
gradient = SubResource( 3 )
|
||||
|
||||
[sub_resource type="Curve" id=5]
|
||||
_data = [ Vector2( 0.00501098, 0.5 ), 0.0, 0.0, 0, 0, Vector2( 0.994989, 0.324 ), 0.0, 0.0, 0, 0 ]
|
||||
|
||||
[sub_resource type="CurveTexture" id=6]
|
||||
curve = SubResource( 5 )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=7]
|
||||
flag_disable_z = true
|
||||
gravity = Vector3( 0, 0, 0 )
|
||||
initial_velocity = 1.0
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
scale = 0.75
|
||||
scale_curve = SubResource( 6 )
|
||||
color_ramp = SubResource( 4 )
|
||||
|
||||
[node name="Player" type="Area2D"]
|
||||
z_index = 10
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
frames = SubResource( 1 )
|
||||
animation = "right"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Trail" type="Particles2D" parent="."]
|
||||
z_index = -1
|
||||
amount = 10
|
||||
speed_scale = 2.0
|
||||
local_coords = false
|
||||
process_material = SubResource( 7 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]
|
||||
@@ -4,19 +4,17 @@ This is a simple game where your character must move
|
||||
and avoid the enemies for as long as possible.
|
||||
|
||||
This is a finished version of the game featured in the
|
||||
["Your first game"](https://docs.godotengine.org/en/latest/getting_started/step_by_step/your_first_game.html)
|
||||
["Your first 2D game"](https://docs.godotengine.org/en/latest/getting_started/first_2d_game/index.html)
|
||||
tutorial in the documentation. For more details,
|
||||
consider following the tutorial in the documentation.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 3 (particles are not available in GLES 2)
|
||||
Renderer: Compatibility
|
||||
|
||||
Note: There is a C# version available [here](https://github.com/godotengine/godot-demo-projects/tree/master/mono/dodge_the_creeps).
|
||||
|
||||
Note: There is a GDNative C++ version available [here](https://github.com/godotengine/gdnative-demos/tree/master/cpp/dodge_the_creeps).
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/515
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2712
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="ogg_vorbis"
|
||||
type="AudioStreamOGGVorbis"
|
||||
path="res://.import/House In a Forest Loop.ogg-1a6a72ae843ad792b7039931227e8d50.oggstr"
|
||||
importer="oggvorbisstr"
|
||||
type="AudioStreamOggVorbis"
|
||||
uid="uid://q2pf4fr8d0ks"
|
||||
path="res://.godot/imported/House In a Forest Loop.ogg-1a6a72ae843ad792b7039931227e8d50.oggvorbisstr"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/House In a Forest Loop.ogg"
|
||||
dest_files=[ "res://.import/House In a Forest Loop.ogg-1a6a72ae843ad792b7039931227e8d50.oggstr" ]
|
||||
dest_files=["res://.godot/imported/House In a Forest Loop.ogg-1a6a72ae843ad792b7039931227e8d50.oggvorbisstr"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=true
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/enemyFlyingAlt_1.png-559f599b16c69b112c1b53f6332e9489.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://yqglrrsx7j1f"
|
||||
path="res://.godot/imported/enemyFlyingAlt_1.png-559f599b16c69b112c1b53f6332e9489.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/enemyFlyingAlt_1.png"
|
||||
dest_files=[ "res://.import/enemyFlyingAlt_1.png-559f599b16c69b112c1b53f6332e9489.stex" ]
|
||||
dest_files=["res://.godot/imported/enemyFlyingAlt_1.png-559f599b16c69b112c1b53f6332e9489.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/enemyFlyingAlt_2.png-31dc7310eda6e1b721224f3cd932c076.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bpot8awhdn6ph"
|
||||
path="res://.godot/imported/enemyFlyingAlt_2.png-31dc7310eda6e1b721224f3cd932c076.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/enemyFlyingAlt_2.png"
|
||||
dest_files=[ "res://.import/enemyFlyingAlt_2.png-31dc7310eda6e1b721224f3cd932c076.stex" ]
|
||||
dest_files=["res://.godot/imported/enemyFlyingAlt_2.png-31dc7310eda6e1b721224f3cd932c076.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/enemySwimming_1.png-dd0e11759dc3d624c8a704f6e98a3d80.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://5lvm88ij4jqn"
|
||||
path="res://.godot/imported/enemySwimming_1.png-dd0e11759dc3d624c8a704f6e98a3d80.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/enemySwimming_1.png"
|
||||
dest_files=[ "res://.import/enemySwimming_1.png-dd0e11759dc3d624c8a704f6e98a3d80.stex" ]
|
||||
dest_files=["res://.godot/imported/enemySwimming_1.png-dd0e11759dc3d624c8a704f6e98a3d80.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/enemySwimming_2.png-4c0cbc0732264c4ea3290340bd4a0a62.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bng45cvsgufqc"
|
||||
path="res://.godot/imported/enemySwimming_2.png-4c0cbc0732264c4ea3290340bd4a0a62.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/enemySwimming_2.png"
|
||||
dest_files=[ "res://.import/enemySwimming_2.png-4c0cbc0732264c4ea3290340bd4a0a62.stex" ]
|
||||
dest_files=["res://.godot/imported/enemySwimming_2.png-4c0cbc0732264c4ea3290340bd4a0a62.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/enemyWalking_1.png-5af6eedbe61b701677d490ffdc1e6471.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bu4221t7qpa7d"
|
||||
path="res://.godot/imported/enemyWalking_1.png-5af6eedbe61b701677d490ffdc1e6471.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/enemyWalking_1.png"
|
||||
dest_files=[ "res://.import/enemyWalking_1.png-5af6eedbe61b701677d490ffdc1e6471.stex" ]
|
||||
dest_files=["res://.godot/imported/enemyWalking_1.png-5af6eedbe61b701677d490ffdc1e6471.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/enemyWalking_2.png-67c480ed60c35e95f5acb0436246b935.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://booij5t7h4efb"
|
||||
path="res://.godot/imported/enemyWalking_2.png-67c480ed60c35e95f5acb0436246b935.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/enemyWalking_2.png"
|
||||
dest_files=[ "res://.import/enemyWalking_2.png-67c480ed60c35e95f5acb0436246b935.stex" ]
|
||||
dest_files=["res://.godot/imported/enemyWalking_2.png-67c480ed60c35e95f5acb0436246b935.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamSample"
|
||||
path="res://.import/gameover.wav-98c95c744b35280048c2bd093cf8a356.sample"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://dw26fpygeag8o"
|
||||
path="res://.godot/imported/gameover.wav-98c95c744b35280048c2bd093cf8a356.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/gameover.wav"
|
||||
dest_files=[ "res://.import/gameover.wav-98c95c744b35280048c2bd093cf8a356.sample" ]
|
||||
dest_files=["res://.godot/imported/gameover.wav-98c95c744b35280048c2bd093cf8a356.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -17,5 +18,7 @@ force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=true
|
||||
edit/normalize=true
|
||||
edit/loop=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/playerGrey_up1.png-6bd114d0a6beac91f48e3a7314d44564.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b4yyoafu8bi0q"
|
||||
path="res://.godot/imported/playerGrey_up1.png-6bd114d0a6beac91f48e3a7314d44564.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/playerGrey_up1.png"
|
||||
dest_files=[ "res://.import/playerGrey_up1.png-6bd114d0a6beac91f48e3a7314d44564.stex" ]
|
||||
dest_files=["res://.godot/imported/playerGrey_up1.png-6bd114d0a6beac91f48e3a7314d44564.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/playerGrey_up2.png-d6aba85f5f2675ebc7045efa7552ee79.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bko65a0nd66st"
|
||||
path="res://.godot/imported/playerGrey_up2.png-d6aba85f5f2675ebc7045efa7552ee79.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/playerGrey_up2.png"
|
||||
dest_files=[ "res://.import/playerGrey_up2.png-d6aba85f5f2675ebc7045efa7552ee79.stex" ]
|
||||
dest_files=["res://.godot/imported/playerGrey_up2.png-d6aba85f5f2675ebc7045efa7552ee79.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/playerGrey_walk1.png-c4773fe7a7bf85d7ab732eb4458c2742.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ftkxr8r4qghp"
|
||||
path="res://.godot/imported/playerGrey_walk1.png-c4773fe7a7bf85d7ab732eb4458c2742.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/playerGrey_walk1.png"
|
||||
dest_files=[ "res://.import/playerGrey_walk1.png-c4773fe7a7bf85d7ab732eb4458c2742.stex" ]
|
||||
dest_files=["res://.godot/imported/playerGrey_walk1.png-c4773fe7a7bf85d7ab732eb4458c2742.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/playerGrey_walk2.png-34d2d916366100182d08037c51884043.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://couyhcegeihme"
|
||||
path="res://.godot/imported/playerGrey_walk2.png-34d2d916366100182d08037c51884043.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://art/playerGrey_walk2.png"
|
||||
dest_files=[ "res://.import/playerGrey_walk2.png-34d2d916366100182d08037c51884043.stex" ]
|
||||
dest_files=["res://.godot/imported/playerGrey_walk2.png-34d2d916366100182d08037c51884043.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
33
2d/dodge_the_creeps/fonts/Xolonium-Regular.ttf.import
Normal file
@@ -0,0 +1,33 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://cit6gwe5px1q8"
|
||||
path="res://.godot/imported/Xolonium-Regular.ttf-bc2981e3069cff4c34dd7c8e2bb73fba.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://fonts/Xolonium-Regular.ttf"
|
||||
dest_files=["res://.godot/imported/Xolonium-Regular.ttf-bc2981e3069cff4c34dd7c8e2bb73fba.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
@@ -10,10 +10,10 @@ func show_message(text):
|
||||
|
||||
func show_game_over():
|
||||
show_message("Game Over")
|
||||
yield($MessageTimer, "timeout")
|
||||
await $MessageTimer.timeout
|
||||
$MessageLabel.text = "Dodge the\nCreeps"
|
||||
$MessageLabel.show()
|
||||
yield(get_tree().create_timer(1), "timeout")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$StartButton.show()
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func update_score(score):
|
||||
|
||||
func _on_StartButton_pressed():
|
||||
$StartButton.hide()
|
||||
emit_signal("start_game")
|
||||
start_game.emit()
|
||||
|
||||
|
||||
func _on_MessageTimer_timeout():
|
||||
61
2d/dodge_the_creeps/hud.tscn
Normal file
@@ -0,0 +1,61 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://ccqoreueuxdb7"]
|
||||
|
||||
[ext_resource type="Script" path="res://hud.gd" id="1"]
|
||||
[ext_resource type="FontFile" uid="uid://cit6gwe5px1q8" path="res://fonts/Xolonium-Regular.ttf" id="2_2jm3i"]
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_fopy7"]
|
||||
action = &"start_game"
|
||||
|
||||
[sub_resource type="Shortcut" id="4"]
|
||||
events = [SubResource("InputEventAction_fopy7")]
|
||||
|
||||
[node name="HUD" type="CanvasLayer"]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="."]
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 78.0
|
||||
grow_horizontal = 2
|
||||
theme_override_fonts/font = ExtResource("2_2jm3i")
|
||||
theme_override_font_sizes/font_size = 60
|
||||
text = "0"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="MessageLabel" type="Label" parent="."]
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -79.5
|
||||
offset_bottom = 79.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_fonts/font = ExtResource("2_2jm3i")
|
||||
theme_override_font_sizes/font_size = 60
|
||||
text = "Dodge the
|
||||
Creeps"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="StartButton" type="Button" parent="."]
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -90.0
|
||||
offset_top = -200.0
|
||||
offset_right = 90.0
|
||||
offset_bottom = -100.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
theme_override_fonts/font = ExtResource("2_2jm3i")
|
||||
theme_override_font_sizes/font_size = 60
|
||||
shortcut = SubResource("4")
|
||||
text = "Start"
|
||||
|
||||
[node name="MessageTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="pressed" from="StartButton" to="." method="_on_StartButton_pressed"]
|
||||
[connection signal="timeout" from="MessageTimer" to="." method="_on_MessageTimer_timeout"]
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,34 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
BIN
2d/dodge_the_creeps/icon.webp
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
34
2d/dodge_the_creeps/icon.webp.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://brwp8bimc75uu"
|
||||
path="res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.webp"
|
||||
dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -1,12 +1,8 @@
|
||||
extends Node
|
||||
|
||||
export(PackedScene) var mob_scene
|
||||
@export var mob_scene: PackedScene
|
||||
var score
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
||||
|
||||
func game_over():
|
||||
$ScoreTimer.stop()
|
||||
$MobTimer.stop()
|
||||
@@ -16,7 +12,7 @@ func game_over():
|
||||
|
||||
|
||||
func new_game():
|
||||
get_tree().call_group("mobs", "queue_free")
|
||||
get_tree().call_group(&"mobs", &"queue_free")
|
||||
score = 0
|
||||
$Player.start($StartPosition.position)
|
||||
$StartTimer.start()
|
||||
@@ -26,28 +22,29 @@ func new_game():
|
||||
|
||||
|
||||
func _on_MobTimer_timeout():
|
||||
# Create a new instance of the Mob scene.
|
||||
var mob = mob_scene.instantiate()
|
||||
|
||||
# Choose a random location on Path2D.
|
||||
var mob_spawn_location = get_node("MobPath/MobSpawnLocation")
|
||||
mob_spawn_location.offset = randi()
|
||||
|
||||
# Create a Mob instance and add it to the scene.
|
||||
var mob = mob_scene.instance()
|
||||
add_child(mob)
|
||||
|
||||
# Set the mob's direction perpendicular to the path direction.
|
||||
var direction = mob_spawn_location.rotation + PI / 2
|
||||
var mob_spawn_location = get_node(^"MobPath/MobSpawnLocation")
|
||||
mob_spawn_location.progress = randi()
|
||||
|
||||
# Set the mob's position to a random location.
|
||||
mob.position = mob_spawn_location.position
|
||||
|
||||
# Set the mob's direction perpendicular to the path direction.
|
||||
var direction = mob_spawn_location.rotation + PI / 2
|
||||
|
||||
# Add some randomness to the direction.
|
||||
direction += rand_range(-PI / 4, PI / 4)
|
||||
direction += randf_range(-PI / 4, PI / 4)
|
||||
mob.rotation = direction
|
||||
|
||||
# Choose the velocity for the mob.
|
||||
var velocity = Vector2(rand_range(150.0, 250.0), 0.0)
|
||||
var velocity = Vector2(randf_range(150.0, 250.0), 0.0)
|
||||
mob.linear_velocity = velocity.rotated(direction)
|
||||
|
||||
# Spawn the mob by adding it to the Main scene.
|
||||
add_child(mob)
|
||||
|
||||
func _on_ScoreTimer_timeout():
|
||||
score += 1
|
||||
59
2d/dodge_the_creeps/main.tscn
Normal file
@@ -0,0 +1,59 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://cyfwty2q3rdse"]
|
||||
|
||||
[ext_resource type="Script" path="res://main.gd" id="1_0r6n5"]
|
||||
[ext_resource type="PackedScene" uid="uid://rkdnhqgf2hpj" path="res://mob.tscn" id="2_50pww"]
|
||||
[ext_resource type="PackedScene" uid="uid://4vwrqjegqwpj" path="res://player.tscn" id="3_veqnc"]
|
||||
[ext_resource type="PackedScene" uid="uid://ccqoreueuxdb7" path="res://hud.tscn" id="4_0qnje"]
|
||||
[ext_resource type="AudioStream" uid="uid://q2pf4fr8d0ks" path="res://art/House In a Forest Loop.ogg" id="5_55d8h"]
|
||||
[ext_resource type="AudioStream" uid="uid://dw26fpygeag8o" path="res://art/gameover.wav" id="6_hp1r0"]
|
||||
|
||||
[sub_resource type="Curve2D" id="1"]
|
||||
_data = {
|
||||
"points": PackedVector2Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 0, 0, 0, 0, 0, 480, 720, 0, 0, 0, 0, 0, 720, 0, 0, 0, 0, 0, 0)
|
||||
}
|
||||
point_count = 5
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource("1_0r6n5")
|
||||
mob_scene = ExtResource("2_50pww")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.219608, 0.372549, 0.380392, 1)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("3_veqnc")]
|
||||
|
||||
[node name="MobTimer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
|
||||
[node name="ScoreTimer" type="Timer" parent="."]
|
||||
|
||||
[node name="StartTimer" type="Timer" parent="."]
|
||||
wait_time = 2.0
|
||||
one_shot = true
|
||||
|
||||
[node name="StartPosition" type="Marker2D" parent="."]
|
||||
position = Vector2(240, 450)
|
||||
|
||||
[node name="MobPath" type="Path2D" parent="."]
|
||||
curve = SubResource("1")
|
||||
|
||||
[node name="MobSpawnLocation" type="PathFollow2D" parent="MobPath"]
|
||||
|
||||
[node name="HUD" parent="." instance=ExtResource("4_0qnje")]
|
||||
|
||||
[node name="Music" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("5_55d8h")
|
||||
|
||||
[node name="DeathSound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("6_hp1r0")
|
||||
|
||||
[connection signal="hit" from="Player" to="." method="game_over"]
|
||||
[connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]
|
||||
[connection signal="timeout" from="ScoreTimer" to="." method="_on_ScoreTimer_timeout"]
|
||||
[connection signal="timeout" from="StartTimer" to="." method="_on_StartTimer_timeout"]
|
||||
[connection signal="start_game" from="HUD" to="." method="new_game"]
|
||||
10
2d/dodge_the_creeps/mob.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
extends RigidBody2D
|
||||
|
||||
func _ready():
|
||||
var mob_types = Array($AnimatedSprite2D.sprite_frames.get_animation_names())
|
||||
$AnimatedSprite2D.animation = mob_types.pick_random()
|
||||
$AnimatedSprite2D.play()
|
||||
|
||||
|
||||
func _on_VisibilityNotifier2D_screen_exited():
|
||||
queue_free()
|
||||
49
2d/dodge_the_creeps/mob.tscn
Normal file
@@ -0,0 +1,49 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://rkdnhqgf2hpj"]
|
||||
|
||||
[ext_resource type="Script" path="res://mob.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://yqglrrsx7j1f" path="res://art/enemyFlyingAlt_1.png" id="2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpot8awhdn6ph" path="res://art/enemyFlyingAlt_2.png" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://bu4221t7qpa7d" path="res://art/enemyWalking_1.png" id="4"]
|
||||
[ext_resource type="Texture2D" uid="uid://booij5t7h4efb" path="res://art/enemyWalking_2.png" id="5"]
|
||||
[ext_resource type="Texture2D" uid="uid://5lvm88ij4jqn" path="res://art/enemySwimming_1.png" id="6"]
|
||||
[ext_resource type="Texture2D" uid="uid://bng45cvsgufqc" path="res://art/enemySwimming_2.png" id="7"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="1"]
|
||||
animations = [{
|
||||
"frames": [ExtResource( "6" ), ExtResource( "7" )],
|
||||
"loop": true,
|
||||
"name": &"swim",
|
||||
"speed": 4.0
|
||||
}, {
|
||||
"frames": [ExtResource( "2" ), ExtResource( "3" )],
|
||||
"loop": true,
|
||||
"name": &"fly",
|
||||
"speed": 3.0
|
||||
}, {
|
||||
"frames": [ExtResource( "4" ), ExtResource( "5" )],
|
||||
"loop": true,
|
||||
"name": &"walk",
|
||||
"speed": 4.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="2"]
|
||||
radius = 37.0
|
||||
height = 100.0
|
||||
|
||||
[node name="Mob" type="RigidDynamicBody2D" groups=["mobs"]]
|
||||
collision_mask = 0
|
||||
gravity_scale = 0.0
|
||||
script = ExtResource( "1" )
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
scale = Vector2(0.75, 0.75)
|
||||
frames = SubResource( "1" )
|
||||
animation = &"walk"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
rotation = 1.5708
|
||||
shape = SubResource( "2" )
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||
|
||||
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
||||
54
2d/dodge_the_creeps/player.gd
Normal file
@@ -0,0 +1,54 @@
|
||||
extends Area2D
|
||||
|
||||
signal hit
|
||||
|
||||
@export var speed = 400 # How fast the player will move (pixels/sec).
|
||||
var screen_size # Size of the game window.
|
||||
|
||||
func _ready():
|
||||
screen_size = get_viewport_rect().size
|
||||
hide()
|
||||
|
||||
|
||||
func _process(delta):
|
||||
var velocity = Vector2.ZERO # The player's movement vector.
|
||||
if Input.is_action_pressed(&"move_right"):
|
||||
velocity.x += 1
|
||||
if Input.is_action_pressed(&"move_left"):
|
||||
velocity.x -= 1
|
||||
if Input.is_action_pressed(&"move_down"):
|
||||
velocity.y += 1
|
||||
if Input.is_action_pressed(&"move_up"):
|
||||
velocity.y -= 1
|
||||
|
||||
if velocity.length() > 0:
|
||||
velocity = velocity.normalized() * speed
|
||||
$AnimatedSprite2D.play()
|
||||
else:
|
||||
$AnimatedSprite2D.stop()
|
||||
|
||||
position += velocity * delta
|
||||
position = position.clamp(Vector2.ZERO, screen_size)
|
||||
|
||||
if velocity.x != 0:
|
||||
$AnimatedSprite2D.animation = &"right"
|
||||
$AnimatedSprite2D.flip_v = false
|
||||
$Trail.rotation = 0
|
||||
$AnimatedSprite2D.flip_h = velocity.x < 0
|
||||
elif velocity.y != 0:
|
||||
$AnimatedSprite2D.animation = &"up"
|
||||
rotation = PI if velocity.y > 0 else 0
|
||||
|
||||
|
||||
func start(pos):
|
||||
position = pos
|
||||
rotation = 0
|
||||
show()
|
||||
$CollisionShape2D.disabled = false
|
||||
|
||||
|
||||
func _on_body_entered(_body):
|
||||
hide() # Player disappears after being hit.
|
||||
hit.emit()
|
||||
# Must be deferred as we can't change physics properties on a physics callback.
|
||||
$CollisionShape2D.set_deferred(&"disabled", true)
|
||||
75
2d/dodge_the_creeps/player.tscn
Normal file
@@ -0,0 +1,75 @@
|
||||
[gd_scene load_steps=13 format=3 uid="uid://4vwrqjegqwpj"]
|
||||
|
||||
[ext_resource type="Script" path="res://player.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://ftkxr8r4qghp" path="res://art/playerGrey_walk1.png" id="2"]
|
||||
[ext_resource type="Texture2D" uid="uid://couyhcegeihme" path="res://art/playerGrey_walk2.png" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://b4yyoafu8bi0q" path="res://art/playerGrey_up1.png" id="4"]
|
||||
[ext_resource type="Texture2D" uid="uid://bko65a0nd66st" path="res://art/playerGrey_up2.png" id="5"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="1"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("3")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": ExtResource("5")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"up",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="2"]
|
||||
radius = 27.0
|
||||
height = 68.0
|
||||
|
||||
[sub_resource type="Gradient" id="3"]
|
||||
colors = PackedColorArray(1, 1, 1, 0.501961, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="4"]
|
||||
gradient = SubResource("3")
|
||||
|
||||
[sub_resource type="Curve" id="5"]
|
||||
_data = [Vector2(0.00501098, 0.5), 0.0, 0.0, 0, 0, Vector2(0.994989, 0.324), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="6"]
|
||||
curve = SubResource("5")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="7"]
|
||||
gravity = Vector3(0, 0, 0)
|
||||
scale_curve = SubResource("6")
|
||||
color_ramp = SubResource("4")
|
||||
|
||||
[node name="Player" type="Area2D"]
|
||||
z_index = 10
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
scale = Vector2(0.5, 0.5)
|
||||
sprite_frames = SubResource("1")
|
||||
animation = &"right"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("2")
|
||||
|
||||
[node name="Trail" type="GPUParticles2D" parent="."]
|
||||
z_index = -1
|
||||
amount = 10
|
||||
process_material = SubResource("7")
|
||||
texture = ExtResource("2")
|
||||
speed_scale = 2.0
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
@@ -6,7 +6,7 @@
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
@@ -14,50 +14,64 @@ config/name="Dodge the Creeps"
|
||||
config/description="This is a simple game where your character must move
|
||||
and avoid the enemies for as long as possible.
|
||||
|
||||
This is a finished version of the game featured in the 'Your first game'
|
||||
This is a finished version of the game featured in the 'Your first 2D game'
|
||||
tutorial in the documentation. For more details, consider
|
||||
following the tutorial in the documentation."
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/tags=PackedStringArray("2d", "demo", "official")
|
||||
run/main_scene="res://main.tscn"
|
||||
config/features=PackedStringArray("4.2")
|
||||
config/icon="res://icon.webp"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/width=480
|
||||
window/size/height=720
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="keep"
|
||||
window/size/viewport_width=480
|
||||
window/size/viewport_height=720
|
||||
window/size/window_width_override=480
|
||||
window/size/window_height_override=720
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
[input]
|
||||
|
||||
move_left={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
move_up={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
move_down={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
start_game={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
|
||||
15
2d/dynamic_tilemap_layers/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Dynamic TileMap Layers
|
||||
|
||||
Example of how to make a fake wall using TileMap's
|
||||
`_tile_data_runtime_update()` method. It shows how
|
||||
to disable collisions per layer.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: Compatibility
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2713
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
BIN
2d/dynamic_tilemap_layers/icon.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
34
2d/dynamic_tilemap_layers/icon.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bpov140lx7at3"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
2d/dynamic_tilemap_layers/level/obstacle.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
34
2d/dynamic_tilemap_layers/level/obstacle.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cs8h2qyuakmko"
|
||||
path="res://.godot/imported/obstacle.png-06287f6b2d26dd03335fd87ab78c2cc2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://level/obstacle.png"
|
||||
dest_files=["res://.godot/imported/obstacle.png-06287f6b2d26dd03335fd87ab78c2cc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
51
2d/dynamic_tilemap_layers/level/tile_map.gd
Normal file
@@ -0,0 +1,51 @@
|
||||
extends TileMapLayer
|
||||
|
||||
# You can have multiple layers if you make this an array.
|
||||
var player_in_secret := false
|
||||
var layer_alpha := 1.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if player_in_secret:
|
||||
if layer_alpha > 0.3:
|
||||
# Animate the layer transparency.
|
||||
layer_alpha = move_toward(layer_alpha, 0.3, delta)
|
||||
self_modulate = Color(1, 1, 1, layer_alpha)
|
||||
else:
|
||||
set_process(false)
|
||||
else:
|
||||
if layer_alpha < 1.0:
|
||||
layer_alpha = move_toward(layer_alpha, 1.0, delta)
|
||||
self_modulate = Color(1, 1, 1, layer_alpha)
|
||||
else:
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _use_tile_data_runtime_update(_coords: Vector2i) -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func _tile_data_runtime_update(_coords: Vector2i, tile_data: TileData) -> void:
|
||||
# Remove collision for secret layer.
|
||||
tile_data.set_collision_polygons_count(0, 0)
|
||||
|
||||
|
||||
func _on_secret_detector_body_entered(body: Node2D) -> void:
|
||||
if body is not CharacterBody2D:
|
||||
# Detect the player only.
|
||||
return
|
||||
|
||||
player_in_secret = true
|
||||
set_process(true)
|
||||
|
||||
|
||||
func _on_secret_detector_body_exited(body: Node2D) -> void:
|
||||
if body is not CharacterBody2D:
|
||||
return
|
||||
|
||||
player_in_secret = false
|
||||
set_process(true)
|
||||
32
2d/dynamic_tilemap_layers/player/player.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
const WALK_FORCE = 600
|
||||
const WALK_MAX_SPEED = 200
|
||||
const STOP_FORCE = 1300
|
||||
const JUMP_SPEED = 200
|
||||
|
||||
@onready var gravity: float = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Horizontal movement code. First, get the player's input.
|
||||
var walk := WALK_FORCE * (Input.get_axis(&"move_left", &"move_right"))
|
||||
# Slow down the player if they're not trying to move.
|
||||
if abs(walk) < WALK_FORCE * 0.2:
|
||||
# The velocity, slowed down a bit, and then reassigned.
|
||||
velocity.x = move_toward(velocity.x, 0, STOP_FORCE * delta)
|
||||
else:
|
||||
velocity.x += walk * delta
|
||||
# Clamp to the maximum horizontal movement speed.
|
||||
velocity.x = clamp(velocity.x, -WALK_MAX_SPEED, WALK_MAX_SPEED)
|
||||
|
||||
# Vertical movement code. Apply gravity.
|
||||
velocity.y += gravity * delta
|
||||
|
||||
# Move based on the velocity and snap to the ground.
|
||||
# TODO: This information should be set to the CharacterBody properties instead of arguments: snap, Vector2.DOWN, Vector2.UP
|
||||
# TODO: Rename velocity to linear_velocity in the rest of the script.
|
||||
move_and_slide()
|
||||
|
||||
# Check for jumping. is_on_floor() must be called after movement code.
|
||||
if is_on_floor() and Input.is_action_just_pressed(&"jump"):
|
||||
velocity.y = -JUMP_SPEED
|
||||
BIN
2d/dynamic_tilemap_layers/player/player.png
Normal file
|
After Width: | Height: | Size: 502 B |
34
2d/dynamic_tilemap_layers/player/player.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dfb8rr2fakwgp"
|
||||
path="res://.godot/imported/player.png-1ad27fc2a62fa126eae918723933dd6f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://player/player.png"
|
||||
dest_files=["res://.godot/imported/player.png-1ad27fc2a62fa126eae918723933dd6f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
17
2d/dynamic_tilemap_layers/player/player.tscn
Normal file
@@ -0,0 +1,17 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://1o70ce0fv10w"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/player.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://dfb8rr2fakwgp" path="res://player/player.png" id="2"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="1"]
|
||||
size = Vector2(14, 14)
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(-0.315559, 0.157784)
|
||||
shape = SubResource("1")
|
||||
71
2d/dynamic_tilemap_layers/project.godot
Normal file
@@ -0,0 +1,71 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Dynamic TileMap Layers"
|
||||
config/description="Example of how to make a kinematic character controller in 2D using
|
||||
CharacterBody2D. The character moves around, is affected by moving
|
||||
platforms, can jump through one-way collision platforms, etc."
|
||||
config/tags=PackedStringArray("2d", "demo", "official", "tilemap")
|
||||
run/main_scene="res://world.tscn"
|
||||
config/features=PackedStringArray("4.3")
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/untyped_declaration=1
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=530
|
||||
window/size/viewport_height=495
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
[input]
|
||||
|
||||
jump={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
common/physics_ticks_per_second=120
|
||||
2d/default_gravity=500
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
environment/defaults/default_clear_color=Color(0.156863, 0.133333, 0.25098, 1)
|
||||
BIN
2d/dynamic_tilemap_layers/screenshots/fake_wall.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
48
2d/dynamic_tilemap_layers/world.tscn
Normal file
@@ -0,0 +1,48 @@
|
||||
[gd_scene load_steps=8 format=4 uid="uid://de7qapkqfycxl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cs8h2qyuakmko" path="res://level/obstacle.png" id="2"]
|
||||
[ext_resource type="Script" path="res://level/tile_map.gd" id="2_q8fhk"]
|
||||
[ext_resource type="PackedScene" uid="uid://1o70ce0fv10w" path="res://player/player.tscn" id="3"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_on5ov"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_vnjib"]
|
||||
texture = ExtResource("2")
|
||||
0:0/0 = 0
|
||||
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_xqlka"]
|
||||
physics_layer_0/collision_layer = 1
|
||||
physics_layer_0/physics_material = SubResource("PhysicsMaterial_on5ov")
|
||||
sources/0 = SubResource("TileSetAtlasSource_vnjib")
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a2gec"]
|
||||
size = Vector2(112, 48)
|
||||
|
||||
[node name="World" type="Node2D"]
|
||||
|
||||
[node name="Ground" type="TileMapLayer" parent="."]
|
||||
use_parent_material = true
|
||||
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAsAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA8AAAAAAAAAAAAAABAAAAAAAAAAAAAAABEAAAAAAAAAAAAAABIAAAAAAAAAAAAAABMAAAAAAAAAAAAAABQAAAAAAAAAAAAAABUAAAAAAAAAAAAAABYAAAAAAAAAAAAAABcAAAAAAAAAAAAAABgAAAAAAAAAAAAAABkAAAAAAAAAAAAAABoAAAAAAAAAAAAAABsAAAAAAAAAAAAAABwAAAAAAAAAAAAAAB0AAAAAAAAAAAAAAB4AAAAAAAAAAAABAAAAAAAAAAAAAAABAAEAAAAAAAAAAAABAAIAAAAAAAAAAAABAAMAAAAAAAAAAAABAAQAAAAAAAAAAAABAAUAAAAAAAAAAAABAAYAAAAAAAAAAAABAAcAAAAAAAAAAAABAAgAAAAAAAAAAAABAAkAAAAAAAAAAAABAAoAAAAAAAAAAAABAAsAAAAAAAAAAAABAAwAAAAAAAAAAAABAA0AAAAAAAAAAAABAA4AAAAAAAAAAAABAA8AAAAAAAAAAAABABAAAAAAAAAAAAABABEAAAAAAAAAAAABABIAAAAAAAAAAAABABMAAAAAAAAAAAABABQAAAAAAAAAAAABABUAAAAAAAAAAAABABYAAAAAAAAAAAABABcAAAAAAAAAAAABABgAAAAAAAAAAAABABkAAAAAAAAAAAABABoAAAAAAAAAAAABABsAAAAAAAAAAAABABwAAAAAAAAAAAABAB0AAAAAAAAAAAABAB4AAAAAAAAAAAACAAAAAAAAAAAAAAACAAEAAAAAAAAAAAACAB0AAAAAAAAAAAACAB4AAAAAAAAAAAADAAAAAAAAAAAAAAADAAEAAAAAAAAAAAADAB0AAAAAAAAAAAADAB4AAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAEAAAAAAAAAAAAEAB0AAAAAAAAAAAAEAB4AAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAEAAAAAAAAAAAAFAB0AAAAAAAAAAAAFAB4AAAAAAAAAAAAGAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAGAB0AAAAAAAAAAAAGAB4AAAAAAAAAAAAHAAAAAAAAAAAAAAAHAAEAAAAAAAAAAAAHAB0AAAAAAAAAAAAHAB4AAAAAAAAAAAAIAAAAAAAAAAAAAAAIAAEAAAAAAAAAAAAIAB0AAAAAAAAAAAAIAB4AAAAAAAAAAAAJAAAAAAAAAAAAAAAJAAEAAAAAAAAAAAAJAB0AAAAAAAAAAAAJAB4AAAAAAAAAAAAKAAAAAAAAAAAAAAAKAAEAAAAAAAAAAAAKAB0AAAAAAAAAAAAKAB4AAAAAAAAAAAALAAAAAAAAAAAAAAALAAEAAAAAAAAAAAALAB0AAAAAAAAAAAALAB4AAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAEAAAAAAAAAAAAMAB0AAAAAAAAAAAAMAB4AAAAAAAAAAAANAAAAAAAAAAAAAAANAAEAAAAAAAAAAAANAB0AAAAAAAAAAAANAB4AAAAAAAAAAAAOAAAAAAAAAAAAAAAOAAEAAAAAAAAAAAAOAB0AAAAAAAAAAAAOAB4AAAAAAAAAAAAPAAAAAAAAAAAAAAAPAAEAAAAAAAAAAAAPAB0AAAAAAAAAAAAPAB4AAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAEAAAAAAAAAAAAQAB0AAAAAAAAAAAAQAB4AAAAAAAAAAAARAAAAAAAAAAAAAAARAAEAAAAAAAAAAAARAB0AAAAAAAAAAAARAB4AAAAAAAAAAAASAAAAAAAAAAAAAAASAAEAAAAAAAAAAAASAB0AAAAAAAAAAAASAB4AAAAAAAAAAAATAAAAAAAAAAAAAAATAAEAAAAAAAAAAAATAB0AAAAAAAAAAAATAB4AAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAEAAAAAAAAAAAAUAB0AAAAAAAAAAAAUAB4AAAAAAAAAAAAVAAAAAAAAAAAAAAAVAAEAAAAAAAAAAAAVAB0AAAAAAAAAAAAVAB4AAAAAAAAAAAAWAAAAAAAAAAAAAAAWAAEAAAAAAAAAAAAWAB0AAAAAAAAAAAAWAB4AAAAAAAAAAAAXAAAAAAAAAAAAAAAXAAEAAAAAAAAAAAAXAB0AAAAAAAAAAAAXAB4AAAAAAAAAAAAYAAAAAAAAAAAAAAAYAAEAAAAAAAAAAAAYAB0AAAAAAAAAAAAYAB4AAAAAAAAAAAAZAAAAAAAAAAAAAAAZAAEAAAAAAAAAAAAZAB0AAAAAAAAAAAAZAB4AAAAAAAAAAAAaAAAAAAAAAAAAAAAaAAEAAAAAAAAAAAAaAB0AAAAAAAAAAAAaAB4AAAAAAAAAAAAbAAAAAAAAAAAAAAAbAAEAAAAAAAAAAAAbAB0AAAAAAAAAAAAbAB4AAAAAAAAAAAAcAAAAAAAAAAAAAAAcAAEAAAAAAAAAAAAcAB0AAAAAAAAAAAAcAB4AAAAAAAAAAAAdAAAAAAAAAAAAAAAdAAEAAAAAAAAAAAAdAB0AAAAAAAAAAAAdAB4AAAAAAAAAAAAeAAAAAAAAAAAAAAAeAAEAAAAAAAAAAAAeAB0AAAAAAAAAAAAeAB4AAAAAAAAAAAAfAAAAAAAAAAAAAAAfAAEAAAAAAAAAAAAfAAIAAAAAAAAAAAAfAAMAAAAAAAAAAAAfAAQAAAAAAAAAAAAfAAUAAAAAAAAAAAAfAAYAAAAAAAAAAAAfAAcAAAAAAAAAAAAfAAgAAAAAAAAAAAAfAAkAAAAAAAAAAAAfAAoAAAAAAAAAAAAfAAsAAAAAAAAAAAAfAAwAAAAAAAAAAAAfAA0AAAAAAAAAAAAfAA4AAAAAAAAAAAAfAA8AAAAAAAAAAAAfABAAAAAAAAAAAAAfABEAAAAAAAAAAAAfABIAAAAAAAAAAAAfABMAAAAAAAAAAAAfABQAAAAAAAAAAAAfABUAAAAAAAAAAAAfABYAAAAAAAAAAAAfABcAAAAAAAAAAAAfABgAAAAAAAAAAAAfABkAAAAAAAAAAAAfABoAAAAAAAAAAAAfABsAAAAAAAAAAAAfABwAAAAAAAAAAAAfAB0AAAAAAAAAAAAfAB4AAAAAAAAAAAAgAAAAAAAAAAAAAAAgAAEAAAAAAAAAAAAgAAIAAAAAAAAAAAAgAAMAAAAAAAAAAAAgAAQAAAAAAAAAAAAgAAUAAAAAAAAAAAAgAAYAAAAAAAAAAAAgAAcAAAAAAAAAAAAgAAgAAAAAAAAAAAAgAAkAAAAAAAAAAAAgAAoAAAAAAAAAAAAgAAsAAAAAAAAAAAAgAAwAAAAAAAAAAAAgAA0AAAAAAAAAAAAgAA4AAAAAAAAAAAAgAA8AAAAAAAAAAAAgABAAAAAAAAAAAAAgABEAAAAAAAAAAAAgABIAAAAAAAAAAAAgABMAAAAAAAAAAAAgABQAAAAAAAAAAAAgABUAAAAAAAAAAAAgABYAAAAAAAAAAAAgABcAAAAAAAAAAAAgABgAAAAAAAAAAAAgABkAAAAAAAAAAAAgABoAAAAAAAAAAAAgABsAAAAAAAAAAAAgABwAAAAAAAAAAAAgAB0AAAAAAAAAAAAgAB4AAAAAAAAAAAAOABgAAAAAAAAAAAAPABgAAAAAAAAAAAAQABgAAAAAAAAAAAARABgAAAAAAAAAAAASABgAAAAAAAAAAAATABgAAAAAAAAAAAAUABgAAAAAAAAAAAAUABcAAAAAAAAAAAAUABYAAAAAAAAAAAATABYAAAAAAAAAAAASABYAAAAAAAAAAAARABYAAAAAAAAAAAAQABYAAAAAAAAAAAAPABYAAAAAAAAAAAAOABYAAAAAAAAAAAAOABcAAAAAAAAAAAAPABcAAAAAAAAAAAAQABcAAAAAAAAAAAARABcAAAAAAAAAAAASABcAAAAAAAAAAAATABcAAAAAAAAAAAAOABkAAAAAAAAAAAAPABkAAAAAAAAAAAAQABkAAAAAAAAAAAARABkAAAAAAAAAAAASABkAAAAAAAAAAAATABkAAAAAAAAAAAAUABkAAAAAAAAAAAA=")
|
||||
tile_set = SubResource("TileSet_xqlka")
|
||||
|
||||
[node name="Secret" type="TileMapLayer" parent="."]
|
||||
use_parent_material = true
|
||||
tile_map_data = PackedByteArray("AAAOABoAAAAAAAAAAAAOABsAAAAAAAAAAAAOABwAAAAAAAAAAAAPABoAAAAAAAAAAAAPABsAAAAAAAAAAAAPABwAAAAAAAAAAAAQABoAAAAAAAAAAAAQABsAAAAAAAAAAAAQABwAAAAAAAAAAAARABoAAAAAAAAAAAARABsAAAAAAAAAAAARABwAAAAAAAAAAAASABoAAAAAAAAAAAASABsAAAAAAAAAAAASABwAAAAAAAAAAAATABoAAAAAAAAAAAATABsAAAAAAAAAAAATABwAAAAAAAAAAAAUABoAAAAAAAAAAAAUABsAAAAAAAAAAAAUABwAAAAAAAAAAAA=")
|
||||
tile_set = SubResource("TileSet_xqlka")
|
||||
script = ExtResource("2_q8fhk")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
offset = Vector2(265, 247)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("3")]
|
||||
position = Vector2(120, 456)
|
||||
|
||||
[node name="SecretDetector" type="Area2D" parent="."]
|
||||
position = Vector2(280, 440)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="SecretDetector"]
|
||||
shape = SubResource("RectangleShape2D_a2gec")
|
||||
|
||||
[connection signal="body_entered" from="SecretDetector" to="Secret" method="_on_secret_detector_body_entered"]
|
||||
[connection signal="body_exited" from="SecretDetector" to="Secret" method="_on_secret_detector_body_exited"]
|
||||
@@ -1,60 +1,87 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://dmn8nkpogiwsf"]
|
||||
|
||||
[ext_resource path="res://player/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://fonts/source_code_pro_explanations.tres" type="DynamicFont" id=2]
|
||||
[ext_resource path="res://debug/StatesStackDiplayer.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://debug/ControlsPanel.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://fonts/source_code_pro_explanations_bold.tres" type="DynamicFont" id=5]
|
||||
[ext_resource type="PackedScene" uid="uid://bpdyvy2681m3i" path="res://player/Player.tscn" id="1"]
|
||||
[ext_resource type="FontFile" uid="uid://b5bspum6ffekd" path="res://fonts/SourceCodePro-Bold.ttf" id="2_r1c5f"]
|
||||
[ext_resource type="PackedScene" uid="uid://cvi13chv8g4hj" path="res://debug/StatesStackDiplayer.tscn" id="3"]
|
||||
[ext_resource type="PackedScene" uid="uid://bq6rrfy53rfvo" path="res://debug/ControlsPanel.tscn" id="4"]
|
||||
|
||||
[sub_resource type="Animation" id="1"]
|
||||
|
||||
[sub_resource type="Animation" id="2"]
|
||||
length = 0.6
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BodyPivot/Body:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.4),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="3"]
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qbwwp"]
|
||||
_data = {
|
||||
"idle": SubResource("1"),
|
||||
"stagger": SubResource("2"),
|
||||
"walk": SubResource("3")
|
||||
}
|
||||
|
||||
[node name="Demo" type="Node"]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 640, 400 )
|
||||
[node name="Player" parent="." instance=ExtResource("1")]
|
||||
position = Vector2(640, 400)
|
||||
|
||||
[node name="StateMachine" parent="Player" index="0"]
|
||||
start_state = NodePath("Idle")
|
||||
|
||||
[node name="AnimationPlayer" parent="Player" index="1"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_qbwwp")
|
||||
}
|
||||
|
||||
[node name="StateNameDisplayer" parent="Player" index="5"]
|
||||
theme_override_fonts/font = ExtResource("2_r1c5f")
|
||||
|
||||
[node name="Explanations" type="RichTextLabel" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = -370.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -730.0
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
offset_left = 10.0
|
||||
offset_top = -370.0
|
||||
offset_right = -10.0
|
||||
offset_bottom = -730.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_vertical = 4
|
||||
custom_fonts/bold_font = ExtResource( 5 )
|
||||
custom_fonts/normal_font = ExtResource( 2 )
|
||||
mouse_filter = 2
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "This example shows how to apply the State programming pattern in GDScript, including Hierarchical States, and a pushdown automaton.
|
||||
|
||||
States are common in games. You can use the pattern to:
|
||||
|
||||
1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage
|
||||
2. Respect the Single Responsibility Principle. Each State object represents [b]one[/b] action
|
||||
3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
|
||||
|
||||
You can read more about States in the excellent [url=http://gameprogrammingpatterns.com/state.html]Game Programming Patterns ebook[/url]."
|
||||
text = "This example shows how to apply the State programming pattern in GDScript, including Hierarchical States, and a pushdown automaton.
|
||||
|
||||
States are common in games. You can use the pattern to:
|
||||
|
||||
1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage
|
||||
2. Respect the Single Responsibility Principle. Each State object represents one action
|
||||
1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage.
|
||||
2. Respect the Single Responsibility Principle. Each State object represents one action.
|
||||
3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
|
||||
|
||||
You can read more about States in the excellent Game Programming Patterns ebook."
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="StatesStackDiplayer" parent="Control" instance=ExtResource( 3 )]
|
||||
[node name="StatesStackDiplayer" parent="Control" instance=ExtResource("3")]
|
||||
layout_mode = 0
|
||||
|
||||
[node name="ControlsPanel" parent="Control" instance=ExtResource( 4 )]
|
||||
[node name="ControlsPanel" parent="Control" instance=ExtResource("4")]
|
||||
layout_mode = 1
|
||||
|
||||
[editable path="Player"]
|
||||
|
||||
@@ -6,9 +6,9 @@ pushdown automaton.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
Renderer: Compatibility
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/516
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2714
|
||||
|
||||
## Why use a state machine
|
||||
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/source_code_pro_explanations.tres" type="DynamicFont" id=1]
|
||||
[gd_scene format=3 uid="uid://bq6rrfy53rfvo"]
|
||||
|
||||
[node name="ControlsPanel" type="Panel"]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -220.0
|
||||
margin_bottom = 170.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
offset_left = -150.0
|
||||
offset_bottom = 171.0
|
||||
grow_horizontal = 0
|
||||
|
||||
[node name="Keys" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -10.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Shoot:
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -56.5
|
||||
offset_top = -65.0
|
||||
offset_right = 56.5
|
||||
offset_bottom = 65.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Actions" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Move:
|
||||
Shoot:
|
||||
Attack:
|
||||
Stagger:
|
||||
Jump:
|
||||
Sprint:"
|
||||
|
||||
[node name="Keys2" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -10.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "R
|
||||
[node name="Keys" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "WASD
|
||||
R
|
||||
F
|
||||
X
|
||||
Space
|
||||
Shift"
|
||||
align = 2
|
||||
|
||||
@@ -1,30 +1,16 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/source_code_pro_explanations_bold.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://fonts/source_code_pro_explanations.tres" type="DynamicFont" id=2]
|
||||
[gd_scene format=3 uid="uid://bywptem1jb35a"]
|
||||
|
||||
[node name="Explanations" type="RichTextLabel"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = -370.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -730.0
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
offset_left = 10.0
|
||||
offset_top = -370.0
|
||||
offset_right = -10.0
|
||||
offset_bottom = -730.0
|
||||
size_flags_vertical = 4
|
||||
custom_fonts/bold_font = ExtResource( 1 )
|
||||
custom_fonts/normal_font = ExtResource( 2 )
|
||||
mouse_filter = 2
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "This example shows how to apply the State programming pattern in GDscript, including Hierarchical States, and a pushdown automaton.
|
||||
|
||||
States are common in games. You can use the pattern to:
|
||||
|
||||
1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage
|
||||
2. Respect the Single Responsibility Principle. Each State object represents [b]one[/b] action
|
||||
3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
|
||||
|
||||
You can read more about States in the excellent [url=http://gameprogrammingpatterns.com/state.html]Game Programming Patterns ebook[/url]."
|
||||
text = "This example shows how to apply the State programming pattern in GDscript, including Hierarchical States, and a pushdown automaton.
|
||||
|
||||
States are common in games. You can use the pattern to:
|
||||
@@ -34,6 +20,3 @@ States are common in games. You can use the pattern to:
|
||||
3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
|
||||
|
||||
You can read more about States in the excellent Game Programming Patterns ebook."
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
@@ -1,48 +1,41 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cvi13chv8g4hj"]
|
||||
|
||||
[ext_resource path="res://debug/states_stack_displayer.gd" type="Script" id=1]
|
||||
[ext_resource path="res://fonts/SourceCodePro-Bold.ttf" type="DynamicFontData" id=2]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 20
|
||||
use_filter = true
|
||||
font_data = ExtResource( 2 )
|
||||
[ext_resource type="Script" path="res://debug/states_stack_displayer.gd" id="1"]
|
||||
[ext_resource type="FontFile" uid="uid://b5bspum6ffekd" path="res://fonts/SourceCodePro-Bold.ttf" id="2_58if7"]
|
||||
|
||||
[node name="StatesStackDiplayer" type="Panel"]
|
||||
margin_right = 210.0
|
||||
margin_bottom = 170.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
offset_right = 210.0
|
||||
offset_bottom = 170.0
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Title" type="Label" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -105.0
|
||||
margin_right = 105.0
|
||||
margin_bottom = 40.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Pushown"
|
||||
align = 1
|
||||
valign = 1
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Title" type="Label" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("2_58if7")
|
||||
text = "StateStack"
|
||||
uppercase = true
|
||||
|
||||
[node name="States" type="Label" parent="."]
|
||||
margin_left = 20.0
|
||||
margin_top = 50.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 170.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Jump
|
||||
Test"
|
||||
align = 1
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Numbers" type="Label" parent="."]
|
||||
margin_left = 20.0
|
||||
margin_top = 50.0
|
||||
margin_right = 190.0
|
||||
margin_bottom = 170.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
[node name="Numbers" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("2_58if7")
|
||||
text = "1.
|
||||
2."
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="States" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("2_58if7")
|
||||
text = "Jump
|
||||
Test"
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
extends Panel
|
||||
|
||||
onready var fsm_node = get_node("../../Player/StateMachine")
|
||||
@onready var fsm_node: Node = get_node(^"../../Player/StateMachine")
|
||||
|
||||
func _process(_delta):
|
||||
var states_names = ""
|
||||
var numbers = ""
|
||||
var index = 0
|
||||
for state in fsm_node.states_stack:
|
||||
states_names += String(state.get_name()) + "\n"
|
||||
func _process(_delta: float) -> void:
|
||||
var states_names := ""
|
||||
var numbers := ""
|
||||
var index := 0
|
||||
|
||||
for state: Node in fsm_node.states_stack:
|
||||
states_names += String(state.name) + "\n"
|
||||
numbers += str(index) + "\n"
|
||||
index += 1
|
||||
$States.text = states_names
|
||||
$Numbers.text = numbers
|
||||
|
||||
%States.text = states_names
|
||||
%Numbers.text = numbers
|
||||
|
||||
33
2d/finite_state_machine/fonts/SourceCodePro-Bold.ttf.import
Normal file
@@ -0,0 +1,33 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://b5bspum6ffekd"
|
||||
path="res://.godot/imported/SourceCodePro-Bold.ttf-bf03bd9c90603419d32725fc00754bf7.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://fonts/SourceCodePro-Bold.ttf"
|
||||
dest_files=["res://.godot/imported/SourceCodePro-Bold.ttf-bf03bd9c90603419d32725fc00754bf7.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
@@ -1,12 +0,0 @@
|
||||
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/SourceCodePro-Bold.ttf" type="DynamicFontData" id=1]
|
||||
|
||||
[resource]
|
||||
|
||||
size = 20
|
||||
use_mipmaps = false
|
||||
use_filter = true
|
||||
font_data = ExtResource( 1 )
|
||||
_sections_unfolded = [ "Font", "Settings" ]
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/SourceCodePro-Black.ttf" type="DynamicFontData" id=1]
|
||||
|
||||
[resource]
|
||||
|
||||
size = 24
|
||||
use_mipmaps = false
|
||||
use_filter = true
|
||||
font_data = ExtResource( 1 )
|
||||
_sections_unfolded = [ "Font", "Settings" ]
|
||||
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
@@ -1,34 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
BIN
2d/finite_state_machine/icon.webp
Normal file
|
After Width: | Height: | Size: 12 KiB |
34
2d/finite_state_machine/icon.webp.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://brwp8bimc75uu"
|
||||
path="res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.webp"
|
||||
dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -1,122 +1,118 @@
|
||||
[gd_scene load_steps=20 format=2]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://bpdyvy2681m3i"]
|
||||
|
||||
[ext_resource path="res://player/player_controller.gd" type="Script" id=1]
|
||||
[ext_resource path="res://player/player_state_machine.gd" type="Script" id=2]
|
||||
[ext_resource path="res://player/states/motion/on_ground/idle.gd" type="Script" id=3]
|
||||
[ext_resource path="res://player/states/motion/on_ground/move.gd" type="Script" id=4]
|
||||
[ext_resource path="res://player/states/motion/in_air/jump.gd" type="Script" id=5]
|
||||
[ext_resource path="res://player/states/combat/stagger.gd" type="Script" id=6]
|
||||
[ext_resource path="res://player/states/combat/attack.gd" type="Script" id=7]
|
||||
[ext_resource path="res://player/states/die.gd" type="Script" id=8]
|
||||
[ext_resource path="res://player/shadow.png" type="Texture" id=9]
|
||||
[ext_resource path="res://player/body.png" type="Texture" id=10]
|
||||
[ext_resource path="res://player/bullet/bullet_spawner.gd" type="Script" id=11]
|
||||
[ext_resource path="res://player/weapon/weapon_pivot.gd" type="Script" id=12]
|
||||
[ext_resource path="res://player/weapon/Sword.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://fonts/SourceCodePro-Bold.ttf" type="DynamicFontData" id=14]
|
||||
[ext_resource path="res://player/states/debug/state_name_displayer.gd" type="Script" id=15]
|
||||
[ext_resource type="Script" path="res://player/player_controller.gd" id="1"]
|
||||
[ext_resource type="Script" path="res://player/player_state_machine.gd" id="2"]
|
||||
[ext_resource type="Script" path="res://player/states/motion/on_ground/idle.gd" id="3"]
|
||||
[ext_resource type="Script" path="res://player/states/motion/on_ground/move.gd" id="4"]
|
||||
[ext_resource type="Script" path="res://player/states/motion/in_air/jump.gd" id="5"]
|
||||
[ext_resource type="Script" path="res://player/states/combat/stagger.gd" id="6"]
|
||||
[ext_resource type="Script" path="res://player/states/combat/attack.gd" id="7"]
|
||||
[ext_resource type="Script" path="res://player/states/die.gd" id="8"]
|
||||
[ext_resource type="Texture2D" uid="uid://eds33w28pilu" path="res://player/shadow.png" id="9"]
|
||||
[ext_resource type="Texture2D" uid="uid://ds53oxkqrcumd" path="res://player/body.png" id="10"]
|
||||
[ext_resource type="Script" path="res://player/bullet/bullet_spawner.gd" id="11"]
|
||||
[ext_resource type="Script" path="res://player/weapon/weapon_pivot.gd" id="12"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdacdp11r3jua" path="res://player/weapon/Sword.tscn" id="13"]
|
||||
[ext_resource type="Script" path="res://player/states/debug/state_name_displayer.gd" id="15"]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
[sub_resource type="Animation" id="1"]
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
[sub_resource type="Animation" id="2"]
|
||||
length = 0.6
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BodyPivot/Body:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.4 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.4),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ) ]
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
[sub_resource type="Animation" id="3"]
|
||||
|
||||
[sub_resource type="DynamicFont" id=4]
|
||||
size = 20
|
||||
use_filter = true
|
||||
font_data = ExtResource( 14 )
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ ]
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vi1hn"]
|
||||
_data = {
|
||||
"idle": SubResource("1"),
|
||||
"stagger": SubResource("2"),
|
||||
"walk": SubResource("3")
|
||||
}
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="StateMachine" type="Node" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Idle" type="Node" parent="StateMachine"]
|
||||
script = ExtResource( 3 )
|
||||
script = ExtResource("3")
|
||||
|
||||
[node name="Move" type="Node" parent="StateMachine"]
|
||||
script = ExtResource( 4 )
|
||||
script = ExtResource("4")
|
||||
|
||||
[node name="Jump" type="Node" parent="StateMachine"]
|
||||
script = ExtResource( 5 )
|
||||
script = ExtResource("5")
|
||||
|
||||
[node name="Stagger" type="Node" parent="StateMachine"]
|
||||
script = ExtResource( 6 )
|
||||
script = ExtResource("6")
|
||||
|
||||
[node name="Attack" type="Node" parent="StateMachine"]
|
||||
script = ExtResource( 7 )
|
||||
script = ExtResource("7")
|
||||
|
||||
[node name="Die" type="Node" parent="StateMachine"]
|
||||
script = ExtResource( 8 )
|
||||
script = ExtResource("8")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/idle = SubResource( 1 )
|
||||
anims/stagger = SubResource( 2 )
|
||||
anims/walk = SubResource( 3 )
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_vi1hn")
|
||||
}
|
||||
|
||||
[node name="Shadow" type="Sprite" parent="."]
|
||||
self_modulate = Color( 1, 1, 1, 0.361098 )
|
||||
position = Vector2( 0, -4 )
|
||||
texture = ExtResource( 9 )
|
||||
[node name="Shadow" type="Sprite2D" parent="."]
|
||||
self_modulate = Color(1, 1, 1, 0.361098)
|
||||
position = Vector2(0, -4)
|
||||
texture = ExtResource("9")
|
||||
|
||||
[node name="BodyPivot" type="Position2D" parent="."]
|
||||
[node name="BodyPivot" type="Marker2D" parent="."]
|
||||
|
||||
[node name="Body" type="Sprite" parent="BodyPivot"]
|
||||
position = Vector2( 0, -58 )
|
||||
texture = ExtResource( 10 )
|
||||
[node name="Body" type="Sprite2D" parent="BodyPivot"]
|
||||
position = Vector2(0, -58)
|
||||
texture = ExtResource("10")
|
||||
|
||||
[node name="BulletSpawn" type="Node2D" parent="BodyPivot"]
|
||||
position = Vector2( 0, -58 )
|
||||
script = ExtResource( 11 )
|
||||
position = Vector2(0, -58)
|
||||
script = ExtResource("11")
|
||||
|
||||
[node name="CooldownTimer" type="Timer" parent="BodyPivot/BulletSpawn"]
|
||||
wait_time = 0.2
|
||||
one_shot = true
|
||||
|
||||
[node name="WeaponPivot" type="Position2D" parent="BodyPivot"]
|
||||
position = Vector2( 0, -58 )
|
||||
script = ExtResource( 12 )
|
||||
[node name="WeaponPivot" type="Marker2D" parent="BodyPivot"]
|
||||
position = Vector2(0, -58)
|
||||
script = ExtResource("12")
|
||||
|
||||
[node name="Offset" type="Position2D" parent="BodyPivot/WeaponPivot"]
|
||||
position = Vector2( 110, 0 )
|
||||
[node name="Offset" type="Marker2D" parent="BodyPivot/WeaponPivot"]
|
||||
position = Vector2(110, 0)
|
||||
|
||||
[node name="Sword" parent="BodyPivot/WeaponPivot/Offset" instance=ExtResource( 13 )]
|
||||
[node name="Sword" parent="BodyPivot/WeaponPivot/Offset" instance=ExtResource("13")]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
polygon = PoolVector2Array( -20, 0, -20, -20, 20, -20, 20, 0 )
|
||||
polygon = PackedVector2Array(-20, 0, -20, -20, 20, -20, 20, 0)
|
||||
|
||||
[node name="StateNameDisplayer" type="Label" parent="."]
|
||||
margin_left = -109.0
|
||||
margin_top = -172.0
|
||||
margin_right = 110.0
|
||||
margin_bottom = -138.0
|
||||
custom_fonts/font = SubResource( 4 )
|
||||
offset_left = -109.0
|
||||
offset_top = -180.0
|
||||
offset_right = 110.0
|
||||
offset_bottom = -143.0
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_constants/outline_size = 8
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "Idle"
|
||||
align = 1
|
||||
valign = 1
|
||||
horizontal_alignment = 1
|
||||
uppercase = true
|
||||
script = ExtResource( 15 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
script = ExtResource("15")
|
||||
|
||||
[connection signal="state_changed" from="StateMachine" to="BodyPivot/WeaponPivot/Offset/Sword" method="_on_StateMachine_state_changed"]
|
||||
[connection signal="state_changed" from="StateMachine" to="StateNameDisplayer" method="_on_StateMachine_state_changed"]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/body.png-313f6363670a5852a7b7126ab476d8b1.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ds53oxkqrcumd"
|
||||
path="res://.godot/imported/body.png-313f6363670a5852a7b7126ab476d8b1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://player/body.png"
|
||||
dest_files=[ "res://.import/body.png-313f6363670a5852a7b7126ab476d8b1.stex" ]
|
||||
dest_files=["res://.godot/imported/body.png-313f6363670a5852a7b7126ab476d8b1.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://b6uru8lfx45ma"]
|
||||
|
||||
[ext_resource path="res://player/bullet/bullet.gd" type="Script" id=1]
|
||||
[ext_resource type="Script" path="res://player/bullet/bullet.gd" id="1"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
[sub_resource type="CircleShape2D" id="1"]
|
||||
radius = 12.0
|
||||
|
||||
[node name="Bullet" type="KinematicBody2D"]
|
||||
[node name="Bullet" type="CharacterBody2D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
shape = SubResource("1")
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
extends KinematicBody2D
|
||||
extends CharacterBody2D
|
||||
|
||||
var direction = Vector2()
|
||||
export(float) var speed = 1000.0
|
||||
var direction := Vector2()
|
||||
@export var speed := 1000.0
|
||||
|
||||
onready var root = get_tree().root
|
||||
@onready var root := get_tree().root
|
||||
|
||||
func _ready():
|
||||
set_as_toplevel(true)
|
||||
func _ready() -> void:
|
||||
set_as_top_level(true)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not root.get_visible_rect().has_point(position):
|
||||
queue_free()
|
||||
|
||||
var motion = direction * speed * delta
|
||||
var collision_info = move_and_collide(motion)
|
||||
var motion := direction * speed * delta
|
||||
var collision_info := move_and_collide(motion)
|
||||
if collision_info:
|
||||
queue_free()
|
||||
|
||||
|
||||
func _draw():
|
||||
draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.white)
|
||||
func _draw() -> void:
|
||||
draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.WHITE)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
extends Node2D
|
||||
|
||||
var bullet = preload("Bullet.tscn")
|
||||
var bullet := preload("Bullet.tscn")
|
||||
|
||||
func _unhandled_input(event):
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("fire"):
|
||||
fire()
|
||||
|
||||
|
||||
func fire():
|
||||
func fire() -> void:
|
||||
if not $CooldownTimer.is_stopped():
|
||||
return
|
||||
|
||||
$CooldownTimer.start()
|
||||
var new_bullet = bullet.instance()
|
||||
var new_bullet := bullet.instantiate()
|
||||
add_child(new_bullet)
|
||||
new_bullet.position = global_position
|
||||
new_bullet.direction = owner.look_direction
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
extends KinematicBody2D
|
||||
# The Player is a KinematicBody2D, in other words a physics-driven object.
|
||||
extends CharacterBody2D
|
||||
# The Player is a CharacterBody2D, in other words a physics-driven object.
|
||||
# It can move, collide with the world, etc...
|
||||
# The player has a state machine, but the body and the state machine are separate.
|
||||
|
||||
signal direction_changed(new_direction)
|
||||
signal direction_changed(new_direction: Vector2)
|
||||
|
||||
var look_direction = Vector2.RIGHT setget set_look_direction
|
||||
var look_direction := Vector2.RIGHT:
|
||||
set(value):
|
||||
look_direction = value
|
||||
set_look_direction(value)
|
||||
|
||||
func take_damage(attacker, amount, effect = null):
|
||||
if is_a_parent_of(attacker):
|
||||
func take_damage(attacker: Node, amount: float, effect: Node = null) -> void:
|
||||
if is_ancestor_of(attacker):
|
||||
return
|
||||
|
||||
$States/Stagger.knockback_direction = (attacker.global_position - global_position).normalized()
|
||||
$Health.take_damage(amount, effect)
|
||||
|
||||
|
||||
func set_dead(value):
|
||||
func set_dead(value: bool) -> void:
|
||||
set_process_input(not value)
|
||||
set_physics_process(not value)
|
||||
$CollisionPolygon2D.disabled = value
|
||||
|
||||
|
||||
func set_look_direction(value):
|
||||
look_direction = value
|
||||
emit_signal("direction_changed", value)
|
||||
func set_look_direction(value: Vector2) -> void:
|
||||
direction_changed.emit(value)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
extends "res://state_machine/state_machine.gd"
|
||||
|
||||
onready var idle = $Idle
|
||||
onready var move = $Move
|
||||
onready var jump = $Jump
|
||||
onready var stagger = $Stagger
|
||||
onready var attack = $Attack
|
||||
@onready var idle: Node = $Idle
|
||||
@onready var move: Node = $Move
|
||||
@onready var jump: Node = $Jump
|
||||
@onready var stagger: Node = $Stagger
|
||||
@onready var attack: Node = $Attack
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
states_map = {
|
||||
"idle": idle,
|
||||
"move": move,
|
||||
@@ -16,7 +16,7 @@ func _ready():
|
||||
}
|
||||
|
||||
|
||||
func _change_state(state_name):
|
||||
func _change_state(state_name: String) -> void:
|
||||
# The base state_machine interface this node extends does most of the work.
|
||||
if not _active:
|
||||
return
|
||||
@@ -24,10 +24,11 @@ func _change_state(state_name):
|
||||
states_stack.push_front(states_map[state_name])
|
||||
if state_name == "jump" and current_state == move:
|
||||
jump.initialize(move.speed, move.velocity)
|
||||
._change_state(state_name)
|
||||
|
||||
super._change_state(state_name)
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
# Here we only handle input that can interrupt states, attacking in this case,
|
||||
# otherwise we let the state node handle it.
|
||||
if event.is_action_pressed("attack"):
|
||||
@@ -35,4 +36,5 @@ func _unhandled_input(event):
|
||||
return
|
||||
_change_state("attack")
|
||||
return
|
||||
|
||||
current_state.handle_input(event)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/shadow.png-493c4635eca1ce8bdece629560617dc7.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://eds33w28pilu"
|
||||
path="res://.godot/imported/shadow.png-493c4635eca1ce8bdece629560617dc7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://player/shadow.png"
|
||||
dest_files=[ "res://.import/shadow.png-493c4635eca1ce8bdece629560617dc7.stex" ]
|
||||
dest_files=["res://.godot/imported/shadow.png-493c4635eca1ce8bdece629560617dc7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extends "res://state_machine/state.gd"
|
||||
|
||||
func enter():
|
||||
owner.get_node("AnimationPlayer").play("idle")
|
||||
func enter() -> void:
|
||||
owner.get_node(^"AnimationPlayer").play("idle")
|
||||
|
||||
|
||||
func _on_Sword_attack_finished():
|
||||
emit_signal("finished", "previous")
|
||||
func _on_Sword_attack_finished() -> void:
|
||||
finished.emit("previous")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
extends "res://state_machine/state.gd"
|
||||
# The stagger state end with the stagger animation from the AnimationPlayer.
|
||||
# The animation only affects the Body Sprite's modulate property so it
|
||||
# The animation only affects the Body Sprite2D's modulate property so it
|
||||
# could stack with other animations if we had two AnimationPlayer nodes.
|
||||
|
||||
func enter():
|
||||
owner.get_node("AnimationPlayer").play("stagger")
|
||||
func enter() -> void:
|
||||
owner.get_node(^"AnimationPlayer").play("stagger")
|
||||
|
||||
|
||||
func _on_animation_finished(anim_name):
|
||||
func _on_animation_finished(anim_name: String) -> void:
|
||||
assert(anim_name == "stagger")
|
||||
emit_signal("finished", "previous")
|
||||
finished.emit("previous")
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
extends Label
|
||||
|
||||
var start_position = Vector2()
|
||||
var start_position := Vector2()
|
||||
|
||||
func _ready():
|
||||
start_position = rect_position
|
||||
func _ready() -> void:
|
||||
start_position = position
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
rect_position = $"../BodyPivot".position + start_position
|
||||
func _physics_process(_delta: float) -> void:
|
||||
position = $"../BodyPivot".position + start_position
|
||||
|
||||
|
||||
func _on_StateMachine_state_changed(current_state):
|
||||
text = String(current_state.get_name())
|
||||
func _on_StateMachine_state_changed(current_state: Node) -> void:
|
||||
text = String(current_state.name)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
extends "res://state_machine/state.gd"
|
||||
|
||||
# Initialize the state. E.g. change the animation.
|
||||
func enter():
|
||||
func enter() -> void:
|
||||
owner.set_dead(true)
|
||||
owner.get_node("AnimationPlayer").play("die")
|
||||
owner.get_node(^"AnimationPlayer").play("die")
|
||||
|
||||
|
||||
func _on_animation_finished(_anim_name):
|
||||
emit_signal("finished", "dead")
|
||||
func _on_animation_finished(_anim_name: String) -> void:
|
||||
finished.emit("dead")
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
extends "../motion.gd"
|
||||
|
||||
export(float) var base_max_horizontal_speed = 400.0
|
||||
@export var base_max_horizontal_speed := 400.0
|
||||
|
||||
export(float) var air_acceleration = 1000.0
|
||||
export(float) var air_deceleration = 2000.0
|
||||
export(float) var air_steering_power = 50.0
|
||||
@export var air_acceleration := 1000.0
|
||||
@export var air_deceleration := 2000.0
|
||||
@export var air_steering_power := 50.0
|
||||
|
||||
export(float) var gravity = 1600.0
|
||||
@export var gravity := 1600.0
|
||||
|
||||
var enter_velocity = Vector2()
|
||||
var enter_velocity := Vector2()
|
||||
|
||||
var max_horizontal_speed = 0.0
|
||||
var horizontal_speed = 0.0
|
||||
var horizontal_velocity = Vector2()
|
||||
var max_horizontal_speed := 0.0
|
||||
var horizontal_speed := 0.0
|
||||
var horizontal_velocity := Vector2()
|
||||
|
||||
var vertical_speed = 0.0
|
||||
var height = 0.0
|
||||
var vertical_speed := 0.0
|
||||
var height := 0.0
|
||||
|
||||
func initialize(speed, velocity):
|
||||
func initialize(speed: float, velocity: Vector2) -> void:
|
||||
horizontal_speed = speed
|
||||
if speed > 0.0:
|
||||
max_horizontal_speed = speed
|
||||
@@ -26,8 +26,8 @@ func initialize(speed, velocity):
|
||||
enter_velocity = velocity
|
||||
|
||||
|
||||
func enter():
|
||||
var input_direction = get_input_direction()
|
||||
func enter() -> void:
|
||||
var input_direction := get_input_direction()
|
||||
update_look_direction(input_direction)
|
||||
|
||||
if input_direction:
|
||||
@@ -36,36 +36,37 @@ func enter():
|
||||
horizontal_velocity = Vector2()
|
||||
vertical_speed = 600.0
|
||||
|
||||
owner.get_node("AnimationPlayer").play("idle")
|
||||
owner.get_node(^"AnimationPlayer").play("idle")
|
||||
|
||||
|
||||
func update(delta):
|
||||
var input_direction = get_input_direction()
|
||||
func update(delta: float) -> void:
|
||||
var input_direction := get_input_direction()
|
||||
update_look_direction(input_direction)
|
||||
|
||||
move_horizontally(delta, input_direction)
|
||||
animate_jump_height(delta)
|
||||
if height <= 0.0:
|
||||
emit_signal("finished", "previous")
|
||||
finished.emit("previous")
|
||||
|
||||
|
||||
func move_horizontally(delta, direction):
|
||||
func move_horizontally(delta: float, direction: Vector2) -> void:
|
||||
if direction:
|
||||
horizontal_speed += air_acceleration * delta
|
||||
else:
|
||||
horizontal_speed -= air_deceleration * delta
|
||||
horizontal_speed = clamp(horizontal_speed, 0, max_horizontal_speed)
|
||||
|
||||
var target_velocity = horizontal_speed * direction.normalized()
|
||||
var steering_velocity = (target_velocity - horizontal_velocity).normalized() * air_steering_power
|
||||
var target_velocity := horizontal_speed * direction.normalized()
|
||||
var steering_velocity := (target_velocity - horizontal_velocity).normalized() * air_steering_power
|
||||
horizontal_velocity += steering_velocity
|
||||
|
||||
owner.move_and_slide(horizontal_velocity)
|
||||
owner.velocity = horizontal_velocity
|
||||
owner.move_and_slide()
|
||||
|
||||
|
||||
func animate_jump_height(delta):
|
||||
func animate_jump_height(delta: float) -> void:
|
||||
vertical_speed -= gravity * delta
|
||||
height += vertical_speed * delta
|
||||
height = max(0.0, height)
|
||||
|
||||
owner.get_node("BodyPivot").position.y = -height
|
||||
owner.get_node(^"BodyPivot").position.y = -height
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
extends "res://state_machine/state.gd"
|
||||
# Collection of important methods to handle direction and animation.
|
||||
|
||||
func handle_input(event):
|
||||
func handle_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("simulate_damage"):
|
||||
emit_signal("finished", "stagger")
|
||||
finished.emit("stagger")
|
||||
|
||||
|
||||
func get_input_direction():
|
||||
var input_direction = Vector2(
|
||||
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
|
||||
Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
||||
func get_input_direction() -> Vector2:
|
||||
return Vector2(
|
||||
Input.get_axis(&"move_left", &"move_right"),
|
||||
Input.get_axis(&"move_up", &"move_down")
|
||||
)
|
||||
return input_direction
|
||||
|
||||
|
||||
func update_look_direction(direction):
|
||||
func update_look_direction(direction: Vector2) -> void:
|
||||
if direction and owner.look_direction != direction:
|
||||
owner.look_direction = direction
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
extends "on_ground.gd"
|
||||
|
||||
func enter():
|
||||
owner.get_node("AnimationPlayer").play("idle")
|
||||
func enter() -> void:
|
||||
owner.get_node(^"AnimationPlayer").play("idle")
|
||||
|
||||
|
||||
func handle_input(event):
|
||||
return .handle_input(event)
|
||||
func handle_input(event: InputEvent) -> void:
|
||||
return super.handle_input(event)
|
||||
|
||||
|
||||
func update(_delta):
|
||||
var input_direction = get_input_direction()
|
||||
func update(_delta: float) -> void:
|
||||
var input_direction: Vector2 = get_input_direction()
|
||||
if input_direction:
|
||||
emit_signal("finished", "move")
|
||||
finished.emit("move")
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
extends "on_ground.gd"
|
||||
|
||||
export(float) var max_walk_speed = 450
|
||||
export(float) var max_run_speed = 700
|
||||
@export var max_walk_speed := 450.0
|
||||
@export var max_run_speed := 700.0
|
||||
|
||||
func enter():
|
||||
func enter() -> void:
|
||||
speed = 0.0
|
||||
velocity = Vector2()
|
||||
|
||||
var input_direction = get_input_direction()
|
||||
var input_direction := get_input_direction()
|
||||
update_look_direction(input_direction)
|
||||
owner.get_node("AnimationPlayer").play("walk")
|
||||
owner.get_node(^"AnimationPlayer").play("walk")
|
||||
|
||||
|
||||
func handle_input(event):
|
||||
return .handle_input(event)
|
||||
func handle_input(event: InputEvent) -> void:
|
||||
return super.handle_input(event)
|
||||
|
||||
|
||||
func update(_delta):
|
||||
var input_direction = get_input_direction()
|
||||
if not input_direction:
|
||||
emit_signal("finished", "idle")
|
||||
func update(_delta: float) -> void:
|
||||
var input_direction := get_input_direction()
|
||||
if input_direction.is_zero_approx():
|
||||
finished.emit("idle")
|
||||
update_look_direction(input_direction)
|
||||
|
||||
if Input.is_action_pressed("run"):
|
||||
@@ -27,16 +27,17 @@ func update(_delta):
|
||||
else:
|
||||
speed = max_walk_speed
|
||||
|
||||
var collision_info = move(speed, input_direction)
|
||||
var collision_info := move(speed, input_direction)
|
||||
if not collision_info:
|
||||
return
|
||||
if speed == max_run_speed and collision_info.collider.is_in_group("environment"):
|
||||
return
|
||||
|
||||
|
||||
func move(p_speed: float, direction: Vector2) -> KinematicCollision2D:
|
||||
owner.velocity = direction.normalized() * p_speed
|
||||
owner.move_and_slide()
|
||||
if owner.get_slide_collision_count() == 0:
|
||||
return null
|
||||
|
||||
|
||||
func move(speed, direction):
|
||||
velocity = direction.normalized() * speed
|
||||
owner.move_and_slide(velocity, Vector2(), 5, 2)
|
||||
if owner.get_slide_count() == 0:
|
||||
return
|
||||
return owner.get_slide_collision(0)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
extends "../motion.gd"
|
||||
|
||||
# warning-ignore-all:unused_class_variable
|
||||
var speed = 0.0
|
||||
var velocity = Vector2()
|
||||
var speed := 0.0
|
||||
var velocity := Vector2()
|
||||
|
||||
func handle_input(event):
|
||||
func handle_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("jump"):
|
||||
emit_signal("finished", "jump")
|
||||
return .handle_input(event)
|
||||
finished.emit("jump")
|
||||
return super.handle_input(event)
|
||||
|
||||
@@ -1,243 +1,250 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://cdacdp11r3jua"]
|
||||
|
||||
[ext_resource path="res://player/weapon/sword.gd" type="Script" id=1]
|
||||
[ext_resource path="res://player/weapon/sword.png" type="Texture" id=2]
|
||||
[ext_resource type="Script" path="res://player/weapon/sword.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://7cfjw83v5m75" path="res://player/weapon/sword.png" id="2"]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
[sub_resource type="Animation" id="1"]
|
||||
resource_name = "SETUP"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [ 0.0 ]
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ) ]
|
||||
"values": [Vector2(1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
"values": [true]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath(".:monitoring")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
"values": [true]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/path = NodePath(".:monitorable")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
[sub_resource type="Animation" id="2"]
|
||||
resource_name = "attack_circular"
|
||||
length = 0.3
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.15, 0.2 ),
|
||||
"transitions": PoolRealArray( 0.439427, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.15, 0.2),
|
||||
"transitions": PackedFloat32Array(0.439427, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ -100.0, 100.0, 90.0 ]
|
||||
"values": [-100.0, 100.0, 90.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.05, 0.15, 0.2 ),
|
||||
"transitions": PoolRealArray( 1, 2.50795, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.05, 0.15, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 2.50795, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ), Vector2( 1, 1.3 ), Vector2( 1, 1 ), Vector2( 1, 1 ) ]
|
||||
"values": [Vector2(1, 1), Vector2(1, 1.3), Vector2(1, 1), Vector2(1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
"values": [true]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
[sub_resource type="Animation" id="3"]
|
||||
length = 0.45
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.15, 0.2 ),
|
||||
"transitions": PoolRealArray( 0.439427, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.15, 0.2),
|
||||
"transitions": PackedFloat32Array(0.439427, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ -80.0, 85.0, 75.0 ]
|
||||
"values": [-80.0, 85.0, 75.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.05, 0.15, 0.2 ),
|
||||
"transitions": PoolRealArray( 1, 2.50795, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.05, 0.15, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 2.50795, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ), Vector2( 1, 1.3 ), Vector2( 1, 1 ), Vector2( 1, 1 ) ]
|
||||
"values": [Vector2(1, 1), Vector2(1, 1.3), Vector2(1, 1), Vector2(1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
"values": [true]
|
||||
}
|
||||
tracks/3/type = "method"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath(".")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"times": PoolRealArray( 0.1, 0.25 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "set_attack_input_listening"
|
||||
"times": PackedFloat32Array(0.1, 0.25),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"set_attack_input_listening"
|
||||
}, {
|
||||
"args": [ ],
|
||||
"method": "set_ready_for_next_attack"
|
||||
} ]
|
||||
"args": [],
|
||||
"method": &"set_ready_for_next_attack"
|
||||
}]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
[sub_resource type="Animation" id="4"]
|
||||
resource_name = "attack_medium"
|
||||
length = 0.5
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0.05, 0.25, 0.35 ),
|
||||
"transitions": PoolRealArray( 0.439427, 1, 1 ),
|
||||
"times": PackedFloat32Array(0.05, 0.25, 0.35),
|
||||
"transitions": PackedFloat32Array(0.439427, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ 95.0, -95.0, -90.0 ]
|
||||
"values": [95.0, -95.0, -90.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.2, 0.25 ),
|
||||
"transitions": PoolRealArray( 1, 2.50795, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.25),
|
||||
"transitions": PackedFloat32Array(1, 2.50795, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ), Vector2( 1, 1.3 ), Vector2( 1, 1 ), Vector2( 1, 1 ) ]
|
||||
"values": [Vector2(1, 1), Vector2(1, 1.3), Vector2(1, 1), Vector2(1, 1)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
"values": [true]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
[sub_resource type="Animation" id="5"]
|
||||
length = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_6cp3i"]
|
||||
_data = {
|
||||
"SETUP": SubResource("1"),
|
||||
"attack_circular": SubResource("2"),
|
||||
"attack_fast": SubResource("3"),
|
||||
"attack_medium": SubResource("4"),
|
||||
"idle": SubResource("5")
|
||||
}
|
||||
|
||||
[node name="Sword" type="Area2D"]
|
||||
input_pickable = false
|
||||
monitorable = false
|
||||
collision_layer = 16
|
||||
collision_mask = 3
|
||||
script = ExtResource( 1 )
|
||||
input_pickable = false
|
||||
monitorable = false
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/SETUP = SubResource( 1 )
|
||||
anims/attack_circular = SubResource( 2 )
|
||||
anims/attack_fast = SubResource( 3 )
|
||||
anims/attack_medium = SubResource( 4 )
|
||||
anims/idle = SubResource( 5 )
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_6cp3i")
|
||||
}
|
||||
|
||||
[node name="Sword" type="Sprite" parent="."]
|
||||
position = Vector2( 4, 0 )
|
||||
texture = ExtResource( 2 )
|
||||
offset = Vector2( 67, 0 )
|
||||
[node name="Sword" type="Sprite2D" parent="."]
|
||||
position = Vector2(4, 0)
|
||||
texture = ExtResource("2")
|
||||
offset = Vector2(67, 0)
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
polygon = PoolVector2Array( 28.0001, -15.9999, 136, -15.9995, 160, 0, 136, 16.0005, 27.9999, 16.0001 )
|
||||
polygon = PackedVector2Array(28.0001, -15.9999, 136, -15.9995, 160, 0, 136, 16.0005, 27.9999, 16.0001)
|
||||
|
||||
@@ -2,43 +2,50 @@ extends Area2D
|
||||
|
||||
signal attack_finished
|
||||
|
||||
enum States { IDLE, ATTACK }
|
||||
var state = null
|
||||
enum States {
|
||||
IDLE,
|
||||
ATTACK,
|
||||
}
|
||||
|
||||
enum AttackInputStates { IDLE, LISTENING, REGISTERED }
|
||||
var attack_input_state = AttackInputStates.IDLE
|
||||
var ready_for_next_attack = false
|
||||
enum AttackInputStates {
|
||||
IDLE,
|
||||
LISTENING,
|
||||
REGISTERED,
|
||||
}
|
||||
|
||||
var state: States = States.IDLE
|
||||
var attack_input_state := AttackInputStates.IDLE
|
||||
var ready_for_next_attack := false
|
||||
const MAX_COMBO_COUNT = 3
|
||||
var combo_count = 0
|
||||
var combo_count := 0
|
||||
|
||||
var attack_current = {}
|
||||
var combo = [{
|
||||
var attack_current := {}
|
||||
var combo := [{
|
||||
"damage": 1,
|
||||
"animation": "attack_fast",
|
||||
"effect": null
|
||||
"effect": null,
|
||||
},
|
||||
{
|
||||
"damage": 1,
|
||||
"animation": "attack_fast",
|
||||
"effect": null
|
||||
"effect": null,
|
||||
},
|
||||
{
|
||||
"damage": 3,
|
||||
"animation": "attack_medium",
|
||||
"effect": null
|
||||
}]
|
||||
"effect": null,
|
||||
}
|
||||
]
|
||||
|
||||
var hit_objects = []
|
||||
var hit_objects := []
|
||||
|
||||
func _ready():
|
||||
# warning-ignore:return_value_discarded
|
||||
$AnimationPlayer.connect("animation_finished", self, "_on_animation_finished")
|
||||
# warning-ignore:return_value_discarded
|
||||
self.connect("body_entered", self, "_on_body_entered")
|
||||
func _ready() -> void:
|
||||
$AnimationPlayer.animation_finished.connect(_on_animation_finished)
|
||||
body_entered.connect(_on_body_entered)
|
||||
_change_state(States.IDLE)
|
||||
|
||||
|
||||
func _change_state(new_state):
|
||||
func _change_state(new_state: States) -> void:
|
||||
match state:
|
||||
States.ATTACK:
|
||||
hit_objects = []
|
||||
@@ -59,7 +66,7 @@ func _change_state(new_state):
|
||||
state = new_state
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not state == States.ATTACK:
|
||||
return
|
||||
if attack_input_state != AttackInputStates.LISTENING:
|
||||
@@ -68,46 +75,47 @@ func _unhandled_input(event):
|
||||
attack_input_state = AttackInputStates.REGISTERED
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if attack_input_state == AttackInputStates.REGISTERED and ready_for_next_attack:
|
||||
attack()
|
||||
|
||||
|
||||
func attack():
|
||||
func attack() -> void:
|
||||
combo_count += 1
|
||||
_change_state(States.ATTACK)
|
||||
|
||||
|
||||
# Use with AnimationPlayer func track.
|
||||
func set_attack_input_listening():
|
||||
func set_attack_input_listening() -> void:
|
||||
attack_input_state = AttackInputStates.LISTENING
|
||||
|
||||
|
||||
# Use with AnimationPlayer func track.
|
||||
func set_ready_for_next_attack():
|
||||
func set_ready_for_next_attack() -> void:
|
||||
ready_for_next_attack = true
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if not body.has_node("Health"):
|
||||
return
|
||||
if body.get_rid().get_id() in hit_objects:
|
||||
return
|
||||
|
||||
hit_objects.append(body.get_rid().get_id())
|
||||
body.take_damage(self, attack_current["damage"], attack_current["effect"])
|
||||
|
||||
|
||||
func _on_animation_finished(_name):
|
||||
if not attack_current:
|
||||
func _on_animation_finished(_name: String) -> void:
|
||||
if attack_current.is_empty():
|
||||
return
|
||||
|
||||
if attack_input_state == AttackInputStates.REGISTERED and combo_count < MAX_COMBO_COUNT:
|
||||
attack()
|
||||
else:
|
||||
_change_state(States.IDLE)
|
||||
emit_signal("attack_finished")
|
||||
attack_finished.emit()
|
||||
|
||||
|
||||
func _on_StateMachine_state_changed(current_state):
|
||||
func _on_StateMachine_state_changed(current_state: Node) -> void:
|
||||
if current_state.name == "Attack":
|
||||
attack()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/sword.png-fc7f0084cdf333c826eda2b33f2ec3cc.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://7cfjw83v5m75"
|
||||
path="res://.godot/imported/sword.png-fc7f0084cdf333c826eda2b33f2ec3cc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,25 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://player/weapon/sword.png"
|
||||
dest_files=[ "res://.import/sword.png-fc7f0084cdf333c826eda2b33f2ec3cc.stex" ]
|
||||
dest_files=["res://.godot/imported/sword.png-fc7f0084cdf333c826eda2b33f2ec3cc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
extends Position2D
|
||||
extends Marker2D
|
||||
|
||||
var z_index_start = 0
|
||||
var z_index_start := 0
|
||||
|
||||
func _ready():
|
||||
#warning-ignore:return_value_discarded
|
||||
owner.connect("direction_changed", self, "_on_Parent_direction_changed")
|
||||
func _ready() -> void:
|
||||
owner.direction_changed.connect(_on_Parent_direction_changed)
|
||||
z_index_start = z_index
|
||||
|
||||
|
||||
func _on_Parent_direction_changed(direction):
|
||||
func _on_Parent_direction_changed(direction: Vector2) -> void:
|
||||
rotation = direction.angle()
|
||||
match direction:
|
||||
Vector2.UP:
|
||||
|
||||