Compare commits
195 Commits
3.2-57baf0
...
3.2-5c154d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c154dac25 | ||
|
|
7f095a6092 | ||
|
|
35687c3ead | ||
|
|
f91fe01f3e | ||
|
|
43d29bfbbb | ||
|
|
7dff4e748d | ||
|
|
4913cd868a | ||
|
|
973c12264c | ||
|
|
fecbed5fb2 | ||
|
|
82e68e378b | ||
|
|
bbf4cff5f7 | ||
|
|
3d6ba65cfc | ||
|
|
ca0f74ee44 | ||
|
|
aa65867e43 | ||
|
|
c2e7a30e42 | ||
|
|
4dbfd92e6f | ||
|
|
c0d9e483c2 | ||
|
|
36db05c3b9 | ||
|
|
fc032119ca | ||
|
|
98ed996780 | ||
|
|
fa83ee0277 | ||
|
|
7c137510e7 | ||
|
|
10a7e3d301 | ||
|
|
feaf406fee | ||
|
|
d90e401d2a | ||
|
|
99ad90bd0d | ||
|
|
4adaaa2eb2 | ||
|
|
b946d20762 | ||
|
|
2a13307276 | ||
|
|
0b3e046953 | ||
|
|
68e095c4d6 | ||
|
|
fe54ebbb3a | ||
|
|
cdf0ed3be9 | ||
|
|
da9e24dfa7 | ||
|
|
1c1ad17b43 | ||
|
|
5618c2b45a | ||
|
|
3878948300 | ||
|
|
ca4cde1c26 | ||
|
|
6a738c1ede | ||
|
|
04e9afb4cf | ||
|
|
e73af12f49 | ||
|
|
6bdbeafca2 | ||
|
|
21cbaafb2f | ||
|
|
35426410d5 | ||
|
|
54a8d37e6c | ||
|
|
d5dae1cbb7 | ||
|
|
06dc40ba65 | ||
|
|
7c604f336d | ||
|
|
e3a31afe40 | ||
|
|
289d658baa | ||
|
|
7a437d1d23 | ||
|
|
08e3f1efd0 | ||
|
|
0d9c0d15c6 | ||
|
|
96baaa09e3 | ||
|
|
e004d2564e | ||
|
|
651ef54920 | ||
|
|
4a60286512 | ||
|
|
1148a6bda0 | ||
|
|
9ad473c633 | ||
|
|
e38be6dec0 | ||
|
|
8241be5817 | ||
|
|
1c836ecde9 | ||
|
|
6dd09308fa | ||
|
|
555e43c896 | ||
|
|
2bd5b1c8ee | ||
|
|
14f2f1a713 | ||
|
|
3d9bcc6d97 | ||
|
|
3147c6c5bd | ||
|
|
20a515153f | ||
|
|
5bd2bbfda9 | ||
|
|
fc54dd9c23 | ||
|
|
d38d18006b | ||
|
|
6fd3e4d525 | ||
|
|
2503599bed | ||
|
|
1aaa8e1fc6 | ||
|
|
2a98499935 | ||
|
|
159adfd421 | ||
|
|
4bba07257a | ||
|
|
ae02236e50 | ||
|
|
3f8567f920 | ||
|
|
c7610e9334 | ||
|
|
78c7a48422 | ||
|
|
31d54a3540 | ||
|
|
2259303ee7 | ||
|
|
76c1d850fb | ||
|
|
ebc79dec04 | ||
|
|
4af7fd5562 | ||
|
|
1a19c5c4e1 | ||
|
|
f8317d20d5 | ||
|
|
766cc97855 | ||
|
|
136db0b25b | ||
|
|
aba0372718 | ||
|
|
dd11042d95 | ||
|
|
4d205325ad | ||
|
|
0d1f16d073 | ||
|
|
2c0cbbaed0 | ||
|
|
918a289ee2 | ||
|
|
fe9fd7d7e4 | ||
|
|
c8149a703f | ||
|
|
2979f85185 | ||
|
|
bc10b69d65 | ||
|
|
f5960b2a7f | ||
|
|
fe6103256a | ||
|
|
768346a092 | ||
|
|
7a84acea76 | ||
|
|
c343b2f4f5 | ||
|
|
9184a36ec1 | ||
|
|
d4bf89d364 | ||
|
|
f74f7c52b6 | ||
|
|
76df39ab2e | ||
|
|
e4f69c3de0 | ||
|
|
4fe1930aab | ||
|
|
a582304ee7 | ||
|
|
97e00544a9 | ||
|
|
bc40a8d61d | ||
|
|
4aae4f657b | ||
|
|
78fe523b3c | ||
|
|
c6163b3d20 | ||
|
|
e30571c1ad | ||
|
|
fcc7d5c723 | ||
|
|
50fb2071a0 | ||
|
|
4b9a809912 | ||
|
|
68a2204c07 | ||
|
|
6e98353ce3 | ||
|
|
b5d4b277f4 | ||
|
|
6a325fb3a5 | ||
|
|
913de13ec9 | ||
|
|
f9c93b0d28 | ||
|
|
bc8dc740b5 | ||
|
|
ddffbd7599 | ||
|
|
b718574112 | ||
|
|
ae2a97976a | ||
|
|
2c138bd75f | ||
|
|
b7b3a75389 | ||
|
|
28ec746545 | ||
|
|
8d9d58f112 | ||
|
|
bd05e88ce0 | ||
|
|
2434876738 | ||
|
|
8dff86d370 | ||
|
|
6b11ca7302 | ||
|
|
cee39035e3 | ||
|
|
c33ce26a93 | ||
|
|
3fd13c1a82 | ||
|
|
f74217c1dc | ||
|
|
5215bc00f8 | ||
|
|
1ae23b63aa | ||
|
|
b99cd953d2 | ||
|
|
8823628b02 | ||
|
|
1ad95a443f | ||
|
|
79ad34dc0f | ||
|
|
aa390d1b30 | ||
|
|
ba44700ebe | ||
|
|
006309bd6f | ||
|
|
866f826124 | ||
|
|
c5c5fedec8 | ||
|
|
f34e61eaca | ||
|
|
189d6ac9b4 | ||
|
|
343669ca06 | ||
|
|
c13e56662f | ||
|
|
dc6efcd429 | ||
|
|
aaf3483618 | ||
|
|
e30b9d4c7d | ||
|
|
2ae60f3ac7 | ||
|
|
87f6a4e3fd | ||
|
|
eac96a9148 | ||
|
|
f0a07c43a8 | ||
|
|
7b465152dc | ||
|
|
4bafb96fcb | ||
|
|
d4a2a57834 | ||
|
|
d29fc74ae8 | ||
|
|
033a5338d5 | ||
|
|
35d44b5d85 | ||
|
|
9a3a831a34 | ||
|
|
d3317cc91d | ||
|
|
afd99e5aed | ||
|
|
b6c0283c22 | ||
|
|
3ea2246466 | ||
|
|
ea01309d56 | ||
|
|
9600d93a33 | ||
|
|
74924dd073 | ||
|
|
5363f8a75a | ||
|
|
5f1905e0d6 | ||
|
|
d1ed6dbd82 | ||
|
|
20c10dcb06 | ||
|
|
48eb973127 | ||
|
|
050fda3a4c | ||
|
|
ac5013f9ec | ||
|
|
ed2348080c | ||
|
|
a9c63035da | ||
|
|
7a5c0872d5 | ||
|
|
0eeaf0ecd8 | ||
|
|
7939f8e348 | ||
|
|
ee388dd5df | ||
|
|
b548a848b1 | ||
|
|
7a9b45f156 |
11
.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
||||
# Top-most EditorConfig file.
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file.
|
||||
[*.cs]
|
||||
insert_final_newline = true
|
||||
csharp_space_after_cast = false
|
||||
indent_size = 4
|
||||
|
||||
[*.csproj]
|
||||
indent_size = 2
|
||||
4
.gitattributes
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
||||
|
||||
*.hdr binary
|
||||
2
.github/CODEOWNERS
vendored
@@ -4,3 +4,5 @@
|
||||
|
||||
/misc/2.5d @aaronfranke
|
||||
/mono/2.5d @aaronfranke
|
||||
/2d/physics_tests @pouleyKetchoupp
|
||||
/3d/physics_tests @pouleyKetchoupp
|
||||
|
||||
2
.github/FUNDING.yml
vendored
@@ -1,2 +0,0 @@
|
||||
patreon: godotengine
|
||||
custom: https://godotengine.org/donate
|
||||
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
23
.github/dist/export_presets.cfg
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
[preset.0]
|
||||
|
||||
name="HTML5"
|
||||
platform="HTML5"
|
||||
runnable=true
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path=""
|
||||
script_export_mode=1
|
||||
script_encryption_key=""
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
variant/export_type=0
|
||||
vram_texture_compression/for_desktop=true
|
||||
vram_texture_compression/for_mobile=false
|
||||
html/custom_html_shell=""
|
||||
html/head_include=""
|
||||
html/full_window_size=true
|
||||
19
.github/dist/footer.html
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- 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>
|
||||
</body>
|
||||
</html>
|
||||
118
.github/dist/header.html
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Godot demos exported to HTML5</title>
|
||||
<style>
|
||||
:root {
|
||||
--background-color: #fff;
|
||||
--text-color: #222;
|
||||
--link-color: hsl(220, 100%, 45%);
|
||||
--link-underline-color: hsla(220, 100%, 45%, 0.3);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background-color: #222;
|
||||
--text-color: #eee;
|
||||
--link-color: hsl(200, 100%, 70%);
|
||||
--link-underline-color: hsla(200, 100%, 70%, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
*:focus {
|
||||
/* More visible outline for better keyboard navigation. */
|
||||
outline: 0.125rem solid hsl(220, 100%, 62.5%);
|
||||
/* Make the outline always appear above other elements. */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
html {
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
max-width: 50rem;
|
||||
margin: 0 auto;
|
||||
padding: 0.75rem;
|
||||
line-height: 1.618rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--link-color);
|
||||
text-decoration-color: var(--link-underline-color);
|
||||
text-decoration-thickness: 0.125rem;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
filter: brightness(117.5%);
|
||||
}
|
||||
|
||||
a:active {
|
||||
filter: brightness(82.5%);
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
display: block;
|
||||
}
|
||||
|
||||
li a {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: 4rem;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
li a:hover {
|
||||
background-color: hsla(0, 0%, 50%, 0.1);
|
||||
}
|
||||
|
||||
li a * {
|
||||
float: left;
|
||||
}
|
||||
|
||||
li a p {
|
||||
height: 24px;
|
||||
margin: 20px 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Godot demo projects</h1>
|
||||
<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
|
||||
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,
|
||||
especially on mobile devices.
|
||||
For best performance, it's recommended to
|
||||
<a href="https://godotengine.org/download">download</a> a native editor
|
||||
and run the demo project by importing its files in the project manager.
|
||||
</p>
|
||||
<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.
|
||||
</p>
|
||||
|
||||
<h2>List of demos</h2>
|
||||
<ul>
|
||||
<!-- The list of demos will be inserted below by the CI process. -->
|
||||
99
.github/workflows/export_html5.yml
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
name: Export projects to HTML5 and deploy to GitHub Pages
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
GODOT_VERSION: 3.2.3
|
||||
|
||||
jobs:
|
||||
export-html5:
|
||||
name: Export projects to HTML5 and deploy to GitHub Pages
|
||||
runs-on: ubuntu-20.04
|
||||
container:
|
||||
image: barichello/godot-ci:3.2.3
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Setup
|
||||
run: |
|
||||
mkdir -p ~/.local/share/godot/templates/
|
||||
mv /root/.local/share/godot/templates/$GODOT_VERSION.stable ~/.local/share/godot/templates/$GODOT_VERSION.stable
|
||||
|
||||
- name: Export projects to HTML5
|
||||
run: |
|
||||
apt-get update -qq && apt-get install -qqq imagemagick
|
||||
|
||||
# Don't export Mono demos (not supported yet), demos that can't be run in HTML5
|
||||
# since they're platform-specific or demos that are currently broken in HTML5.
|
||||
# Remember to update `.github/dist/footer.html` when updating the list of excluded demos.
|
||||
rm -rf \
|
||||
2d/hdr/ \
|
||||
3d/voxel/ \
|
||||
audio/device_changer/ \
|
||||
loading/background_load/ \
|
||||
loading/multiple_threads_loading/ \
|
||||
loading/threads/ \
|
||||
misc/matrix_transform/ \
|
||||
mobile/android_iap/ \
|
||||
mobile/sensors/ \
|
||||
mono/ \
|
||||
networking/ \
|
||||
plugins/
|
||||
|
||||
for panorama in 3d/material_testers/backgrounds/*.hdr; do
|
||||
# Decrease the resolution to get below the 20 MB per-file limit.
|
||||
# Otherwise, the website can't be deployed as files larger than 20 MB
|
||||
# can't be pushed to GitHub anymore.
|
||||
mogrify -resize 75% "$panorama"
|
||||
done
|
||||
|
||||
BASEDIR="$PWD"
|
||||
|
||||
# Use absolute paths so that we can `cd` without having to go back to the parent directory manually.
|
||||
for demo in */*/; do
|
||||
echo ""
|
||||
echo "================================"
|
||||
echo "Exporting demo $demo..."
|
||||
echo "================================"
|
||||
|
||||
mkdir -p "$BASEDIR/.github/dist/$demo"
|
||||
cd "$BASEDIR/$demo"
|
||||
|
||||
# Copy an export template preset file configured for HTML5 exporting.
|
||||
# This way, we don't have to commit `export_presets.cfg` for each project.
|
||||
cp "$BASEDIR/.github/dist/export_presets.cfg" .
|
||||
godot --export "HTML5" "$BASEDIR/.github/dist/$demo/index.html"
|
||||
|
||||
# Replace the WASM file with a symbolic link to avoid duplicating files in the pushed branch.
|
||||
# (WASM files are identical across projects, but not PCK or HTML files.)
|
||||
mv -f "$BASEDIR/.github/dist/$demo/index.wasm" "$BASEDIR/.github/dist/index.wasm"
|
||||
# The symlink must be relative as it needs to point to a file within the pushed repository.
|
||||
ln -s "../../index.wasm" "$BASEDIR/.github/dist/$demo/index.wasm"
|
||||
|
||||
# Append the demo to the list of demos for the website.
|
||||
PROJECT_NAME=$(cat project.godot | grep "config/name" | cut -d '"' -f 2 | tr -d "\n")
|
||||
echo "<li><a href='$demo'><img width="64" height="64" src="$demo/favicon.png" alt=""><p>$PROJECT_NAME</p></a></li>" >> "$BASEDIR/.github/dist/demos.html"
|
||||
done
|
||||
|
||||
cat "$BASEDIR/.github/dist/header.html" "$BASEDIR/.github/dist/demos.html" "$BASEDIR/.github/dist/footer.html" > "$BASEDIR/.github/dist/index.html"
|
||||
|
||||
# Clean up files that don't need to be deployed.
|
||||
rm -f "$BASEDIR/.github/dist/header.html" "$BASEDIR/.github/dist/demos.html" "$BASEDIR/.github/dist/footer.html" "$BASEDIR/.github/dist/export_presets.cfg"
|
||||
|
||||
# Installing rsync is needed in order to deploy to GitHub Pages. Without it, the build will fail.
|
||||
- name: Install rsync 📚
|
||||
run: |
|
||||
apt-get update -qq && apt-get install -qqq rsync
|
||||
- name: Deploy to GitHub Pages 🚀
|
||||
uses: JamesIves/github-pages-deploy-action@releases/v3
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# The branch the action should deploy to.
|
||||
BRANCH: gh-pages
|
||||
# The folder the action should deploy.
|
||||
FOLDER: .github/dist
|
||||
# Artifacts are large; don't keep the branch's history.
|
||||
SINGLE_COMMIT: true
|
||||
19
.github/workflows/static_checks.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Static Checks
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
format:
|
||||
name: File formatting (file_format.sh)
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -qq dos2unix recode
|
||||
|
||||
- name: File formatting checks (file_format.sh)
|
||||
run: |
|
||||
bash ./file_format.sh
|
||||
9
.gitignore
vendored
@@ -1,10 +1,19 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
|
||||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
# Dummy HTML5 export presets file for continuous integration
|
||||
!.github/dist/export_presets.cfg
|
||||
|
||||
# Imported translations (automatically generated from CSV files)
|
||||
*.translation
|
||||
|
||||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
||||
mono_crash.*.json
|
||||
|
||||
# System/tool-specific ignores
|
||||
|
||||
18
.travis.yml
@@ -1,18 +0,0 @@
|
||||
dist: bionic
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- name: Static checks (format.sh)
|
||||
stage: build
|
||||
os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- dos2unix
|
||||
- recode
|
||||
|
||||
script:
|
||||
- bash ./format.sh
|
||||
8
2d/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# 2D Demos
|
||||
|
||||
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)
|
||||
|
||||
Renderers: 6 of them are GLES 3, but most are GLES 2
|
||||
18
2d/bullet_shower/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Bullet Shower
|
||||
|
||||
This demonstrates how to manage large amounts of objects efficiently using
|
||||
low-level Servers.
|
||||
|
||||
See
|
||||
[Optimization using Servers](https://docs.godotengine.org/en/latest/tutorials/performance/using_servers.html)
|
||||
in the documentation for more information.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||

|
||||
BIN
2d/bullet_shower/bullet.png
Normal file
|
After Width: | Height: | Size: 312 B |
@@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex"
|
||||
path="res://.import/bullet.png-ff1424653e10246c11e3724e402c519e.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://PaintTools.png"
|
||||
dest_files=[ "res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex" ]
|
||||
source_file="res://bullet.png"
|
||||
dest_files=[ "res://.import/bullet.png-ff1424653e10246c11e3724e402c519e.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
86
2d/bullet_shower/bullets.gd
Normal file
@@ -0,0 +1,86 @@
|
||||
extends Node2D
|
||||
# This demo is an example of controling a high number of 2D objects with logic
|
||||
# and collision without using nodes in the scene. This technique is a lot more
|
||||
# efficient than using instancing and nodes, but requires more programming and
|
||||
# is less visual. Bullets are managed together in the `bullets.gd` script.
|
||||
|
||||
const BULLET_COUNT = 500
|
||||
const SPEED_MIN = 20
|
||||
const SPEED_MAX = 80
|
||||
|
||||
const bullet_image = preload("res://bullet.png")
|
||||
|
||||
var bullets = []
|
||||
var shape
|
||||
|
||||
|
||||
class Bullet:
|
||||
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()
|
||||
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
||||
shape = Physics2DServer.circle_shape_create()
|
||||
# Set the collision shape's radius for each bullet in pixels.
|
||||
Physics2DServer.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()
|
||||
|
||||
Physics2DServer.body_set_space(bullet.body, get_world_2d().get_space())
|
||||
Physics2DServer.body_add_shape(bullet.body, shape)
|
||||
|
||||
# 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)
|
||||
)
|
||||
var transform2d = Transform2D()
|
||||
transform2d.origin = bullet.position
|
||||
Physics2DServer.body_set_state(bullet.body, Physics2DServer.BODY_STATE_TRANSFORM, transform2d)
|
||||
|
||||
bullets.push_back(bullet)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
var transform2d = Transform2D()
|
||||
for 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.
|
||||
bullet.position.x = get_viewport_rect().size.x + 16
|
||||
|
||||
transform2d.origin = bullet.position
|
||||
|
||||
Physics2DServer.body_set_state(bullet.body, Physics2DServer.BODY_STATE_TRANSFORM, transform2d)
|
||||
|
||||
# Order the CanvasItem to update since bullets are moving every frame.
|
||||
update()
|
||||
|
||||
|
||||
# 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:
|
||||
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)
|
||||
|
||||
Physics2DServer.free_rid(shape)
|
||||
bullets.clear()
|
||||
BIN
2d/bullet_shower/face_happy.png
Normal file
|
After Width: | Height: | Size: 907 B |
@@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex"
|
||||
path="res://.import/face_happy.png-38d387d31ec13459f749c93ce3d75d80.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://left_pallete.png"
|
||||
dest_files=[ "res://.import/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex" ]
|
||||
source_file="res://face_happy.png"
|
||||
dest_files=[ "res://.import/face_happy.png-38d387d31ec13459f749c93ce3d75d80.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
BIN
2d/bullet_shower/face_sad.png
Normal file
|
After Width: | Height: | Size: 846 B |
@@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex"
|
||||
path="res://.import/face_sad.png-0ac7165eab24f595aba17a746a66c550.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://right_pallete.png"
|
||||
dest_files=[ "res://.import/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex" ]
|
||||
source_file="res://face_sad.png"
|
||||
dest_files=[ "res://.import/face_sad.png-0ac7165eab24f595aba17a746a66c550.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
BIN
2d/bullet_shower/icon.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
33
2d/bullet_shower/player.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends Node2D
|
||||
# This demo is an example of controling a high number of 2D objects with logic
|
||||
# and collision without using nodes in the scene. This technique is a lot more
|
||||
# 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
|
||||
|
||||
onready var sprite = $AnimatedSprite
|
||||
|
||||
|
||||
func _ready():
|
||||
# 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):
|
||||
if event is InputEventMouseMotion:
|
||||
position = event.position - Vector2(0, 16)
|
||||
|
||||
|
||||
func _on_body_shape_entered(_body_id, _body, _body_shape, _local_shape):
|
||||
touching += 1
|
||||
if touching >= 1:
|
||||
sprite.frame = 1
|
||||
|
||||
|
||||
func _on_body_shape_exited(_body_id, _body, _body_shape, _local_shape):
|
||||
touching -= 1
|
||||
if touching == 0:
|
||||
sprite.frame = 0
|
||||
41
2d/bullet_shower/project.godot
Normal file
@@ -0,0 +1,41 @@
|
||||
; 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=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Bullet Shower"
|
||||
config/description="Demonstrates how to manage large amounts of objects efficiently using low-level Servers."
|
||||
run/main_scene="res://shower.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[display]
|
||||
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
[physics]
|
||||
|
||||
2d/cell_size=64
|
||||
common/enable_pause_aware_picking=true
|
||||
|
||||
[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 )
|
||||
BIN
2d/bullet_shower/screenshots/collision.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
2d/bullet_shower/screenshots/no_collision.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
33
2d/bullet_shower/shower.tscn
Normal file
@@ -0,0 +1,33 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[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]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 3 ), ExtResource( 4 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
radius = 27.0
|
||||
|
||||
[node name="Shower" type="Node2D"]
|
||||
|
||||
[node name="Bullets" type="Node2D" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Player" type="Area2D" parent="."]
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="Player"]
|
||||
frames = SubResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
|
||||
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"]
|
||||
@@ -13,7 +13,7 @@ func show_game_over():
|
||||
yield($MessageTimer, "timeout")
|
||||
$MessageLabel.text = "Dodge the\nCreeps"
|
||||
$MessageLabel.show()
|
||||
yield(get_tree().create_timer(1), 'timeout')
|
||||
yield(get_tree().create_timer(1), "timeout")
|
||||
$StartButton.show()
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends Node
|
||||
|
||||
export (PackedScene) var Mob
|
||||
export(PackedScene) var mob_scene
|
||||
var score
|
||||
|
||||
func _ready():
|
||||
@@ -16,6 +16,7 @@ func game_over():
|
||||
|
||||
|
||||
func new_game():
|
||||
get_tree().call_group("mobs", "queue_free")
|
||||
score = 0
|
||||
$Player.start($StartPosition.position)
|
||||
$StartTimer.start()
|
||||
@@ -25,14 +26,27 @@ func new_game():
|
||||
|
||||
|
||||
func _on_MobTimer_timeout():
|
||||
$MobPath/MobSpawnLocation.offset = randi()
|
||||
var mob = Mob.instance()
|
||||
# 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)
|
||||
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
|
||||
mob.position = $MobPath/MobSpawnLocation.position
|
||||
|
||||
# Set the mob's direction perpendicular to the path direction.
|
||||
var direction = mob_spawn_location.rotation + PI / 2
|
||||
|
||||
# Set the mob's position to a random location.
|
||||
mob.position = mob_spawn_location.position
|
||||
|
||||
# Add some randomness to the direction.
|
||||
direction += rand_range(-PI / 4, PI / 4)
|
||||
mob.rotation = direction
|
||||
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0).rotated(direction)
|
||||
|
||||
# Choose the velocity.
|
||||
var velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
|
||||
mob.linear_velocity = velocity.rotated(direction)
|
||||
|
||||
|
||||
func _on_ScoreTimer_timeout():
|
||||
|
||||
@@ -14,7 +14,7 @@ _data = {
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
Mob = ExtResource( 2 )
|
||||
mob_scene = ExtResource( 2 )
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
|
||||
@@ -3,11 +3,16 @@ extends RigidBody2D
|
||||
#warning-ignore-all:unused_class_variable
|
||||
export var min_speed = 150
|
||||
export var max_speed = 250
|
||||
var mob_types = ["walk", "swim", "fly"]
|
||||
|
||||
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()
|
||||
|
||||
|
||||
func _on_start_game():
|
||||
queue_free()
|
||||
|
||||
@@ -15,22 +15,24 @@ animations = [ {
|
||||
"name": "fly",
|
||||
"speed": 3.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 4 ), ExtResource( 5 ) ],
|
||||
"loop": true,
|
||||
"name": "walk",
|
||||
"speed": 4.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"]
|
||||
[node name="Mob" type="RigidBody2D" groups=[
|
||||
"mobs",
|
||||
]]
|
||||
collision_mask = 0
|
||||
gravity_scale = 0.0
|
||||
script = ExtResource( 1 )
|
||||
@@ -42,8 +44,6 @@ __meta__ = {
|
||||
scale = Vector2( 0.75, 0.75 )
|
||||
frames = SubResource( 1 )
|
||||
animation = "walk"
|
||||
frame = 1
|
||||
playing = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
rotation = 1.5708
|
||||
|
||||
@@ -2,8 +2,8 @@ extends Area2D
|
||||
|
||||
signal hit
|
||||
|
||||
export var speed = 400
|
||||
var screen_size
|
||||
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
|
||||
@@ -11,15 +11,22 @@ func _ready():
|
||||
|
||||
|
||||
func _process(delta):
|
||||
var velocity = Vector2()
|
||||
velocity.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
||||
velocity.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
||||
|
||||
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)
|
||||
@@ -40,6 +47,7 @@ func start(pos):
|
||||
|
||||
|
||||
func _on_Player_body_entered(_body):
|
||||
hide()
|
||||
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)
|
||||
|
||||
@@ -14,14 +14,16 @@ Renderer: GLES 3 (particles are not available in GLES 2)
|
||||
|
||||
Note: There is a C# version available [here](https://github.com/godotengine/godot-demo-projects/tree/master/mono/dodge_the_creeps).
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/515
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## Licenses
|
||||
## Copying
|
||||
|
||||
`art/House In a Forest Loop.ogg` Copyright © 2012 [HorrorPen](https://opengameart.org/users/horrorpen), [CC-BY 3.0: Attribution](http://creativecommons.org/licenses/by/3.0/). Source: https://opengameart.org/content/loop-house-in-a-forest
|
||||
|
||||
Images are from "Abstract Platformer". Copyright © 2010-2020 kenney.nl, [CC0 1.0 Universal](http://creativecommons.org/publicdomain/zero/1.0/). Source: https://www.kenney.nl/assets/abstract-platformer
|
||||
Images are from "Abstract Platformer". Created in 2016 by kenney.nl, [CC0 1.0 Universal](http://creativecommons.org/publicdomain/zero/1.0/). Source: https://www.kenney.nl/assets/abstract-platformer
|
||||
|
||||
Font is "Xolonium". Copyright © 2011-2016 Severin Meyer <sev.ch@web.de>, with Reserved Font Name Xolonium, SIL open font license version 1.1. Details are in `fonts/LICENSE.txt`.
|
||||
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
0
2d/dodge_the_creeps/fonts/FONTLOG.txt
Executable file → Normal file
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -20,8 +20,8 @@ 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'
|
||||
tutorial in the documentation, but ported to C#. For more details,
|
||||
consider following the tutorial in the documentation."
|
||||
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"
|
||||
|
||||
@@ -64,7 +64,3 @@ move_down={
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/default_environment="res://default_env.tres"
|
||||
|
||||
@@ -8,6 +8,8 @@ Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/516
|
||||
|
||||
## Why use a state machine
|
||||
|
||||
States are common in games. You can use the pattern to:
|
||||
|
||||
@@ -16,7 +16,7 @@ size_flags_vertical = 4
|
||||
custom_fonts/bold_font = ExtResource( 1 )
|
||||
custom_fonts/normal_font = ExtResource( 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.
|
||||
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:
|
||||
|
||||
@@ -25,7 +25,7 @@ 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 [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.
|
||||
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:
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ func _process(_delta):
|
||||
var numbers = ""
|
||||
var index = 0
|
||||
for state in fsm_node.states_stack:
|
||||
states_names += state.get_name() + '\n'
|
||||
numbers += str(index) + '\n'
|
||||
states_names += state.get_name() + "\n"
|
||||
numbers += str(index) + "\n"
|
||||
index += 1
|
||||
$States.text = states_names
|
||||
$Numbers.text = numbers
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
|
||||
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
|
||||
sky_curve = 0.25
|
||||
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
|
||||
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
|
||||
ground_curve = 0.01
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.1 KiB |
@@ -115,7 +115,7 @@ align = 1
|
||||
valign = 1
|
||||
uppercase = true
|
||||
script = ExtResource( 15 )
|
||||
[connection signal="state_changed" from="StateMachine" to="StateNameDisplayer" method="_on_StateMachine_state_changed"]
|
||||
[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"]
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="StateMachine" method="_on_animation_finished"]
|
||||
[connection signal="attack_finished" from="BodyPivot/WeaponPivot/Offset/Sword" to="StateMachine/Attack" method="_on_Sword_attack_finished"]
|
||||
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -3,12 +3,14 @@ extends KinematicBody2D
|
||||
var direction = Vector2()
|
||||
export(float) var speed = 1000.0
|
||||
|
||||
onready var root = get_tree().root
|
||||
|
||||
func _ready():
|
||||
set_as_toplevel(true)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
if is_outside_view_bounds():
|
||||
if not root.get_visible_rect().has_point(position):
|
||||
queue_free()
|
||||
|
||||
var motion = direction * speed * delta
|
||||
@@ -17,10 +19,5 @@ func _physics_process(delta):
|
||||
queue_free()
|
||||
|
||||
|
||||
func is_outside_view_bounds():
|
||||
return position.x > OS.get_screen_size().x or position.x < 0.0 \
|
||||
or position.y > OS.get_screen_size().y or position.y < 0.0
|
||||
|
||||
|
||||
func _draw():
|
||||
draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.white)
|
||||
|
||||
@@ -2,7 +2,7 @@ extends Node2D
|
||||
|
||||
var bullet = preload("Bullet.tscn")
|
||||
|
||||
func _input(event):
|
||||
func _unhandled_input(event):
|
||||
if event.is_action_pressed("fire"):
|
||||
fire(owner.look_direction)
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
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
|
||||
|
||||
func _ready():
|
||||
states_map = {
|
||||
"idle": $Idle,
|
||||
"move": $Move,
|
||||
"jump": $Jump,
|
||||
"stagger": $Stagger,
|
||||
"attack": $Attack,
|
||||
"idle": idle,
|
||||
"move": move,
|
||||
"jump": jump,
|
||||
"stagger": stagger,
|
||||
"attack": attack,
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +22,16 @@ func _change_state(state_name):
|
||||
return
|
||||
if state_name in ["stagger", "jump", "attack"]:
|
||||
states_stack.push_front(states_map[state_name])
|
||||
if state_name == "jump" and current_state == $Move:
|
||||
$Jump.initialize($Move.speed, $Move.velocity)
|
||||
if state_name == "jump" and current_state == move:
|
||||
jump.initialize(move.speed, move.velocity)
|
||||
._change_state(state_name)
|
||||
|
||||
|
||||
func _input(event):
|
||||
func _unhandled_input(event):
|
||||
# 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"):
|
||||
if current_state in [$Attack, $Stagger]:
|
||||
if current_state in [attack, stagger]:
|
||||
return
|
||||
_change_state("attack")
|
||||
return
|
||||
|
||||
|
Before Width: | Height: | Size: 765 B After Width: | Height: | Size: 427 B |
@@ -22,6 +22,7 @@ func initialize(speed, velocity):
|
||||
max_horizontal_speed = speed if speed > 0.0 else base_max_horizontal_speed
|
||||
enter_velocity = velocity
|
||||
|
||||
|
||||
func enter():
|
||||
var input_direction = get_input_direction()
|
||||
update_look_direction(input_direction)
|
||||
@@ -31,6 +32,7 @@ func enter():
|
||||
|
||||
owner.get_node("AnimationPlayer").play("idle")
|
||||
|
||||
|
||||
func update(delta):
|
||||
var input_direction = get_input_direction()
|
||||
update_look_direction(input_direction)
|
||||
@@ -40,6 +42,7 @@ func update(delta):
|
||||
if height <= 0.0:
|
||||
emit_signal("finished", "previous")
|
||||
|
||||
|
||||
func move_horizontally(delta, direction):
|
||||
if direction:
|
||||
horizontal_speed += air_acceleration * delta
|
||||
@@ -53,6 +56,7 @@ func move_horizontally(delta, direction):
|
||||
|
||||
owner.move_and_slide(horizontal_velocity)
|
||||
|
||||
|
||||
func animate_jump_height(delta):
|
||||
vertical_speed -= gravity * delta
|
||||
height += vertical_speed * delta
|
||||
|
||||
@@ -7,9 +7,10 @@ func handle_input(event):
|
||||
|
||||
|
||||
func get_input_direction():
|
||||
var input_direction = Vector2()
|
||||
input_direction.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
||||
input_direction.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
||||
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")
|
||||
)
|
||||
return input_direction
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ func _change_state(new_state):
|
||||
state = new_state
|
||||
|
||||
|
||||
func _input(event):
|
||||
func _unhandled_input(event):
|
||||
if not state == States.ATTACK:
|
||||
return
|
||||
if attack_input_state != AttackInputStates.LISTENING:
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -26,6 +26,7 @@ config/icon="res://icon.png"
|
||||
|
||||
window/size/width=1280
|
||||
window/size/height=720
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
@@ -101,4 +102,3 @@ attack={
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
environment/default_environment="res://default_env.tres"
|
||||
|
||||
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 23 KiB |
@@ -21,7 +21,9 @@ func _ready():
|
||||
if not start_state:
|
||||
start_state = get_child(0).get_path()
|
||||
for child in get_children():
|
||||
child.connect("finished", self, "_change_state")
|
||||
var err = child.connect("finished", self, "_change_state")
|
||||
if err:
|
||||
printerr(err)
|
||||
initialize(start_state)
|
||||
|
||||
|
||||
@@ -41,7 +43,7 @@ func set_active(value):
|
||||
current_state = null
|
||||
|
||||
|
||||
func _input(event):
|
||||
func _unhandled_input(event):
|
||||
current_state.handle_input(event)
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 440 B |
@@ -8,6 +8,8 @@ Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/517
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
|
||||
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
|
||||
sky_curve = 0.25
|
||||
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
|
||||
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
|
||||
ground_curve = 0.01
|
||||
sun_energy = 16.0
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
|
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 474 B |
@@ -9,10 +9,15 @@ const IMAGE_SIZE = Vector2(930, 720)
|
||||
|
||||
# Enums for the various modes and brush shapes that can be applied.
|
||||
enum BrushModes {
|
||||
PENCIL, ERASER, CIRCLE_SHAPE, RECTANGLE_SHAPE
|
||||
PENCIL,
|
||||
ERASER,
|
||||
CIRCLE_SHAPE,
|
||||
RECTANGLE_SHAPE,
|
||||
}
|
||||
|
||||
enum BrushShapes {
|
||||
RECTANGLE, CIRCLE
|
||||
RECTANGLE,
|
||||
CIRCLE,
|
||||
}
|
||||
|
||||
# The top-left position of the canvas.
|
||||
@@ -51,20 +56,20 @@ func _ready():
|
||||
|
||||
func _process(_delta):
|
||||
var mouse_pos = get_viewport().get_mouse_position()
|
||||
|
||||
|
||||
# Check if the mouse is currently inside the canvas/drawing-area.
|
||||
is_mouse_in_drawing_area = false
|
||||
if mouse_pos.x > TL_node.global_position.x:
|
||||
if mouse_pos.y > TL_node.global_position.y:
|
||||
is_mouse_in_drawing_area = true
|
||||
|
||||
|
||||
if Input.is_mouse_button_pressed(BUTTON_LEFT):
|
||||
# If we do not have a position for when the mouse was first clicked, then this must
|
||||
# be the first time is_mouse_button_pressed has been called since the mouse button was
|
||||
# released, so we need to store the position.
|
||||
if mouse_click_start_pos == null:
|
||||
mouse_click_start_pos = mouse_pos
|
||||
|
||||
|
||||
# If the mouse is inside the canvas and the mouse is 1px away from the position of the mouse last _process call.
|
||||
if check_if_mouse_is_inside_canvas():
|
||||
if mouse_pos.distance_to(last_mouse_pos) >= 1:
|
||||
@@ -77,11 +82,11 @@ func _process(_delta):
|
||||
undo_element_list_num = brush_data_list.size()
|
||||
# Add the brush object to draw_elements_array.
|
||||
add_brush(mouse_pos, brush_mode)
|
||||
|
||||
|
||||
else:
|
||||
# We've finished our stroke, so we can set a new undo (if a new storke is made).
|
||||
undo_set = false
|
||||
|
||||
|
||||
# If the mouse is inside the canvas.
|
||||
if check_if_mouse_is_inside_canvas():
|
||||
# If we're using either the circle shape mode, or the rectangle shape mode, then
|
||||
@@ -94,7 +99,7 @@ func _process(_delta):
|
||||
# Since we've released the left mouse, we need to get a new mouse_click_start_pos next time
|
||||
#is_mouse_button_pressed is true.
|
||||
mouse_click_start_pos = null
|
||||
|
||||
|
||||
# Store mouse_pos as last_mouse_pos now that we're done with _process.
|
||||
last_mouse_pos = mouse_pos
|
||||
|
||||
@@ -108,7 +113,7 @@ func check_if_mouse_is_inside_canvas():
|
||||
if mouse_click_start_pos.x > TL_node.global_position.x:
|
||||
if mouse_click_start_pos.y > TL_node.global_position.y:
|
||||
# Make sure the current mouse position is inside the canvas.
|
||||
if is_mouse_in_drawing_area == true:
|
||||
if is_mouse_in_drawing_area:
|
||||
return true
|
||||
return false
|
||||
|
||||
@@ -117,17 +122,17 @@ func undo_stroke():
|
||||
# Only undo a stroke if we have one.
|
||||
if undo_element_list_num == UNDO_NONE:
|
||||
return
|
||||
|
||||
|
||||
# If we are undoing a shape, then we can just remove the latest brush.
|
||||
if undo_element_list_num == UNDO_MODE_SHAPE:
|
||||
if brush_data_list.size() > 0:
|
||||
brush_data_list.remove(brush_data_list.size() - 1)
|
||||
|
||||
|
||||
# Now that we've undone a shape, we cannot undo again until another stoke is added.
|
||||
undo_element_list_num = UNDO_NONE
|
||||
# NOTE: if we only had shape brushes, then we could remove the above line and could let the user
|
||||
# undo until we have a empty element list.
|
||||
|
||||
|
||||
# Otherwise we're removing a either a pencil stroke or a eraser stroke.
|
||||
else:
|
||||
# Figure out how many elements/brushes we've added in the last stroke.
|
||||
@@ -136,7 +141,7 @@ func undo_stroke():
|
||||
#warning-ignore:unused_variable
|
||||
for elment_num in range(0, elements_to_remove):
|
||||
brush_data_list.pop_back()
|
||||
|
||||
|
||||
# Now that we've undone a stoke, we cannot undo again until another stoke is added.
|
||||
undo_element_list_num = UNDO_NONE
|
||||
|
||||
@@ -147,7 +152,7 @@ func undo_stroke():
|
||||
func add_brush(mouse_pos, type):
|
||||
# Make new brush dictionary that will hold all of the data we need for the brush.
|
||||
var new_brush = {}
|
||||
|
||||
|
||||
# Populate the dictionary with values based on the global brush variables.
|
||||
# We will override these as needed if the brush is a rectange or circle.
|
||||
new_brush.brush_type = type
|
||||
@@ -155,13 +160,13 @@ func add_brush(mouse_pos, type):
|
||||
new_brush.brush_shape = brush_shape
|
||||
new_brush.brush_size = brush_size
|
||||
new_brush.brush_color = brush_color
|
||||
|
||||
|
||||
# If the new bursh is a rectangle shape, we need to calculate the top left corner of the rectangle and the
|
||||
# bottom right corner of the rectangle.
|
||||
if type == BrushModes.RECTANGLE_SHAPE:
|
||||
var TL_pos = Vector2()
|
||||
var BR_pos = Vector2()
|
||||
|
||||
|
||||
# Figure out the left and right positions of the corners and assign them to the proper variable.
|
||||
if mouse_pos.x < mouse_click_start_pos.x:
|
||||
TL_pos.x = mouse_pos.x
|
||||
@@ -169,7 +174,7 @@ func add_brush(mouse_pos, type):
|
||||
else:
|
||||
TL_pos.x = mouse_click_start_pos.x
|
||||
BR_pos.x = mouse_pos.x
|
||||
|
||||
|
||||
# Figure out the top and bottom positions of the corners and assign them to the proper variable.
|
||||
if mouse_pos.y < mouse_click_start_pos.y:
|
||||
TL_pos.y = mouse_pos.y
|
||||
@@ -177,11 +182,11 @@ func add_brush(mouse_pos, type):
|
||||
else:
|
||||
TL_pos.y = mouse_click_start_pos.y
|
||||
BR_pos.y = mouse_pos.y
|
||||
|
||||
|
||||
# Assign the positions to the brush.
|
||||
new_brush.brush_pos = TL_pos
|
||||
new_brush.brush_shape_rect_pos_BR = BR_pos
|
||||
|
||||
|
||||
# If the brush isa circle shape, then we need to calculate the radius of the circle.
|
||||
if type == BrushModes.CIRCLE_SHAPE:
|
||||
# Get the center point inbetween the mouse position and the position of the mouse when we clicked.
|
||||
@@ -190,7 +195,7 @@ func add_brush(mouse_pos, type):
|
||||
# the center to the top/bottom positon of the mouse.
|
||||
new_brush.brush_pos = center_pos
|
||||
new_brush.brush_shape_circle_radius = center_pos.distance_to(Vector2(center_pos.x, mouse_pos.y))
|
||||
|
||||
|
||||
# Add the brush and update/draw all of the brushes.
|
||||
brush_data_list.append(new_brush)
|
||||
update()
|
||||
@@ -214,7 +219,7 @@ func _draw():
|
||||
BrushModes.ERASER:
|
||||
# NOTE: this is a really cheap way of erasing that isn't really erasing!
|
||||
# However, this gives similar results in a fairy simple way!
|
||||
|
||||
|
||||
# Erasing works exactly the same was as pencil does for both the rectangle shape and the circle shape,
|
||||
# but instead of using brush.brush_color, we instead use bg_color instead.
|
||||
if brush.brush_shape == BrushShapes.RECTANGLE:
|
||||
@@ -232,18 +237,16 @@ func _draw():
|
||||
draw_circle(brush.brush_pos, brush.brush_shape_circle_radius, brush.brush_color)
|
||||
|
||||
|
||||
|
||||
func save_picture(path):
|
||||
# Wait a couple frames so the save dialog isn't in the way.
|
||||
yield (get_tree(), "idle_frame")
|
||||
yield (get_tree(), "idle_frame")
|
||||
|
||||
# Wait until the frame has finished before getting the texture.
|
||||
yield(VisualServer, "frame_post_draw")
|
||||
|
||||
# Get the viewport image.
|
||||
var img = get_viewport().get_texture().get_data()
|
||||
# Crop the image so we only have canvas area.
|
||||
var cropped_image = img.get_rect(Rect2(TL_node.global_position, IMAGE_SIZE))
|
||||
# Flip the image on the Y-axis (it's flipped upside down by default).
|
||||
cropped_image.flip_y()
|
||||
|
||||
|
||||
# Save the image with the passed in path we got from the save dialog.
|
||||
cropped_image.save_png(path)
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://PaintControl.gd" type="Script" id=1]
|
||||
[ext_resource path="res://ToolsPanel.gd" type="Script" id=2]
|
||||
[ext_resource path="res://PaintTools.png" type="Texture" id=3]
|
||||
[ext_resource path="res://paint_control.gd" type="Script" id=1]
|
||||
[ext_resource path="res://tools_panel.gd" type="Script" id=2]
|
||||
[ext_resource path="res://paint_tools.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 1, 1, 1, 1 )
|
||||
BIN
2d/gd_paint/paint_tools.png
Normal file
|
After Width: | Height: | Size: 273 B |
34
2d/gd_paint/paint_tools.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/paint_tools.png-224b64b7ddb26189a369199f6d686b79.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://paint_tools.png"
|
||||
dest_files=[ "res://.import/paint_tools.png-224b64b7ddb26189a369199f6d686b79.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
|
||||
@@ -19,13 +19,14 @@ config/name="GD Paint"
|
||||
config/description="GD Paint is a simple image editor made using Godot and GDScript.
|
||||
It supports different types of 'brushes': a basic pen/pencil
|
||||
and eraser, as well as a rectangle and a circle brush."
|
||||
run/main_scene="res://Paint_root.tscn"
|
||||
run/main_scene="res://paint_root.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/width=1280
|
||||
window/size/height=720
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="keep"
|
||||
|
||||
@@ -36,4 +37,3 @@ singletons=[ ]
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
environment/default_environment="res://default_env.tres"
|
||||
|
||||
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 31 KiB |
@@ -1,20 +1,16 @@
|
||||
extends Panel
|
||||
|
||||
var paint_control
|
||||
|
||||
onready var brush_settings = $BrushSettings
|
||||
onready var label_tools = $LabelTools
|
||||
onready var label_brush_size = $BrushSettings/LabelBrushSize
|
||||
onready var label_brush_shape = $BrushSettings/LabelBrushShape
|
||||
onready var label_brush_size = brush_settings.get_node(@"LabelBrushSize")
|
||||
onready var label_brush_shape = brush_settings.get_node(@"LabelBrushShape")
|
||||
onready var label_stats = $LabelStats
|
||||
onready var label_tools = $LabelTools
|
||||
|
||||
var save_dialog
|
||||
onready var _parent = get_parent()
|
||||
onready var save_dialog = _parent.get_node(@"SaveFileDialog")
|
||||
onready var paint_control = _parent.get_node(@"PaintControl")
|
||||
|
||||
func _ready():
|
||||
# Get PaintControl and SaveFileDialog.
|
||||
paint_control = get_parent().get_node("PaintControl")
|
||||
save_dialog = get_parent().get_node("SaveFileDialog")
|
||||
|
||||
# warning-ignore-all:return_value_discarded
|
||||
# Assign all of the needed signals for the oppersation buttons.
|
||||
$ButtonUndo.connect("pressed", self, "button_pressed", ["undo_stroke"])
|
||||
@@ -34,7 +30,7 @@ func _ready():
|
||||
$ColorPickerBackground.connect("color_changed", self, "background_color_changed")
|
||||
$BrushSettings/HScrollBarBrushSize.connect("value_changed", self, "brush_size_changed")
|
||||
|
||||
# Assign the 'file_selected' signal in SaveFileDialog.
|
||||
# Assign the "file_selected" signal in SaveFileDialog.
|
||||
save_dialog.connect("file_selected", self, "save_file_selected")
|
||||
|
||||
# Set physics process so we can update the status label.
|
||||
@@ -50,7 +46,7 @@ func button_pressed(button_name):
|
||||
# If a brush mode button is pressed.
|
||||
var tool_name = null
|
||||
var shape_name = null
|
||||
|
||||
|
||||
if button_name == "mode_pencil":
|
||||
paint_control.brush_mode = paint_control.BrushModes.PENCIL
|
||||
brush_settings.modulate = Color(1, 1, 1, 1)
|
||||
@@ -84,7 +80,7 @@ func button_pressed(button_name):
|
||||
save_dialog.popup_centered()
|
||||
elif button_name == "undo_stroke":
|
||||
paint_control.undo_stroke()
|
||||
|
||||
|
||||
# Update the labels (in case the brush mode or brush shape has changed).
|
||||
if tool_name != null:
|
||||
label_tools.text = "Selected tool: " + tool_name
|
||||
@@ -9,6 +9,8 @@ Language: GDScript
|
||||
|
||||
Renderer: GLES 3 (HDR is not available in GLES 2)
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/110
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
@@ -4,7 +4,7 @@ const CAVE_LIMIT = 1000
|
||||
|
||||
onready var cave = $Cave
|
||||
|
||||
func _input(event):
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventMouseMotion and event.button_mask > 0:
|
||||
var rel_x = event.relative.x
|
||||
var cavepos = cave.position
|
||||
|
||||
BIN
2d/hdr/icon.png
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 392 KiB After Width: | Height: | Size: 376 KiB |
|
Before Width: | Height: | Size: 610 KiB After Width: | Height: | Size: 597 KiB |
@@ -28,6 +28,7 @@ run/name=""
|
||||
|
||||
window/size/width=1080
|
||||
window/size/height=720
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 406 KiB After Width: | Height: | Size: 318 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 159 KiB |
@@ -6,6 +6,8 @@ Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/111
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 19 KiB |
@@ -22,6 +22,7 @@ config/icon="res://icon.png"
|
||||
|
||||
[display]
|
||||
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 401 KiB After Width: | Height: | Size: 340 KiB |
@@ -1,12 +1,13 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
const MOTION_SPEED = 160 # Pixels/second.
|
||||
const TAN30DEG = tan(deg2rad(30))
|
||||
|
||||
func _physics_process(_delta):
|
||||
var motion = Vector2()
|
||||
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
||||
motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
||||
motion.y *= 0.57735056839 # tan(30 degrees).
|
||||
motion.y *= TAN30DEG
|
||||
motion = motion.normalized() * MOTION_SPEED
|
||||
#warning-ignore:return_value_discarded
|
||||
move_and_slide(motion)
|
||||
|
||||
@@ -9,7 +9,7 @@ radius = 16.0
|
||||
[node name="Troll" type="KinematicBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
[node name="Sprite2D" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# Instancing Demo
|
||||
|
||||
A demo showing how to use scene instancing to
|
||||
make many duplicates of the same object.
|
||||
make many duplicates of the same object.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/148
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
@@ -24,6 +24,7 @@ config/icon="res://icon.png"
|
||||
[display]
|
||||
|
||||
window/size/width=800
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
BIN
2d/instancing/screenshots/instancing.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
@@ -3,12 +3,14 @@
|
||||
This demo shows a traditional isometric view with depth sorting.
|
||||
|
||||
A character can move around the level and will also slide around objects,
|
||||
as well as be occluded when standing in front or behind them.
|
||||
as well as be occluded when standing in front or behind them.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/112
|
||||
|
||||
## How does it work?
|
||||
|
||||
The level uses a [`TileMap`](https://docs.godotengine.org/en/latest/classes/class_tilemap.html#class-tilemap)
|
||||
|
||||
@@ -25,6 +25,7 @@ config/icon="res://icon.png"
|
||||
|
||||
[display]
|
||||
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
|
||||