mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 06:09:46 +03:00
Compare commits
69 Commits
3.4-585455
...
3.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
023845b0dd | ||
|
|
c0180d20d1 | ||
|
|
edee4413e3 | ||
|
|
3a23fdbe6a | ||
|
|
c8bb3b874a | ||
|
|
c8f0706055 | ||
|
|
ccc4354331 | ||
|
|
1849640ff8 | ||
|
|
3ae7f01a23 | ||
|
|
690dd395fd | ||
|
|
f85f8b2b4d | ||
|
|
7ddaf29f8d | ||
|
|
b626d3e628 | ||
|
|
a39928fc55 | ||
|
|
9e68af38d9 | ||
|
|
4357b5b620 | ||
|
|
24519e58a8 | ||
|
|
219e37b592 | ||
|
|
fe6f646c9d | ||
|
|
06bdeb97dc | ||
|
|
b1f9f2da48 | ||
|
|
d7c7e4ede3 | ||
|
|
0550497e60 | ||
|
|
5c13d21260 | ||
|
|
2f60828e6e | ||
|
|
61d9e0f1ab | ||
|
|
cd72b05a7d | ||
|
|
69758f2523 | ||
|
|
0f848370fe | ||
|
|
4618c9b04e | ||
|
|
6ddead591a | ||
|
|
6eec19b9af | ||
|
|
935e9bbc44 | ||
|
|
59d443e889 | ||
|
|
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 | ||
|
|
0fc59325ab | ||
|
|
eba852bbde | ||
|
|
f82dd94089 | ||
|
|
3e9e2079a7 | ||
|
|
87cfcb7a4f |
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,8 +1,7 @@
|
||||
<!--
|
||||
Only submit a pull request if all of the following conditions are met:
|
||||
|
||||
* 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 work with the latest Godot version of the branch you're submitting to.
|
||||
|
||||
* It must follow all of the Godot style guides, including the GDScript
|
||||
style guide and the C# style guide.
|
||||
|
||||
2
.github/dist/export_presets.cfg
vendored
2
.github/dist/export_presets.cfg
vendored
@@ -5,7 +5,7 @@ platform="HTML5"
|
||||
runnable=true
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
include_filter="*.json"
|
||||
exclude_filter=""
|
||||
export_path=""
|
||||
script_export_mode=1
|
||||
|
||||
19
.github/dist/footer.html
vendored
19
.github/dist/footer.html
vendored
@@ -2,15 +2,16 @@
|
||||
</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>2d/hdr/</code>: Not supported on HTML5 yet.</li>
|
||||
<li><code>3d/global_illumination/</code>: Not supported on HTML5 yet (freezes the browser).</li>
|
||||
<li><code>3d/voxel/</code>: Not supported on HTML5 yet.</li>
|
||||
<li><code>audio/device_changer/</code>: Not supported on HTML5 due to browser limitations.</li>
|
||||
<li><code>loading/background_load/</code>: Not supported on HTML5 yet.</li>
|
||||
<li><code>loading/multiple_threads_loading/</code>: Not supported on HTML5 yet.</li>
|
||||
<li><code>loading/threads/</code>: Not supported on HTML5 yet.</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 HTML5 yet.</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>
|
||||
|
||||
99
.github/workflows/export_html5.yml
vendored
99
.github/workflows/export_html5.yml
vendored
@@ -1,99 +0,0 @@
|
||||
name: Export projects to HTML5 and deploy to GitHub Pages
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
GODOT_VERSION: 3.3.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.3.3
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- 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
|
||||
4
.github/workflows/static_checks.yml
vendored
4
.github/workflows/static_checks.yml
vendored
@@ -4,10 +4,10 @@ on: [push, pull_request]
|
||||
jobs:
|
||||
format:
|
||||
name: File formatting (file_format.sh)
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,4 +18,5 @@ mono_crash.*.json
|
||||
|
||||
# System/tool-specific ignores
|
||||
.directory
|
||||
.DS_Store
|
||||
*~
|
||||
|
||||
@@ -5,4 +5,4 @@ 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
|
||||
Renderers: 4 of them are GLES 3, but most are GLES 2
|
||||
|
||||
@@ -2,6 +2,7 @@ extends CanvasLayer
|
||||
|
||||
signal start_game
|
||||
|
||||
|
||||
func show_message(text):
|
||||
$MessageLabel.text = text
|
||||
$MessageLabel.show()
|
||||
|
||||
@@ -12,7 +12,7 @@ size = 64
|
||||
font_data = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="InputEventAction" id=3]
|
||||
action = "ui_select"
|
||||
action = "start_game"
|
||||
|
||||
[sub_resource type="ShortCut" id=4]
|
||||
shortcut = SubResource( 3 )
|
||||
@@ -50,6 +50,9 @@ margin_bottom = -100.0
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
shortcut = SubResource( 4 )
|
||||
text = "Start"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MessageTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
@@ -3,6 +3,7 @@ extends Node
|
||||
export(PackedScene) var mob_scene
|
||||
var score
|
||||
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
||||
@@ -26,14 +27,13 @@ func new_game():
|
||||
|
||||
|
||||
func _on_MobTimer_timeout():
|
||||
# Create a new instance of the Mob scene.
|
||||
var mob = mob_scene.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)
|
||||
|
||||
# Set the mob's direction perpendicular to the path direction.
|
||||
var direction = mob_spawn_location.rotation + PI / 2
|
||||
|
||||
@@ -48,6 +48,9 @@ func _on_MobTimer_timeout():
|
||||
var velocity = Vector2(rand_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
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends RigidBody2D
|
||||
|
||||
|
||||
func _ready():
|
||||
$AnimatedSprite.playing = true
|
||||
var mob_types = $AnimatedSprite.frames.get_animation_names()
|
||||
|
||||
@@ -5,6 +5,7 @@ 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()
|
||||
|
||||
@@ -4,7 +4,7 @@ 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.
|
||||
|
||||
|
||||
@@ -17,5 +17,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
|
||||
|
||||
@@ -14,7 +14,7 @@ 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"
|
||||
@@ -61,3 +61,8 @@ move_down={
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
start_game={
|
||||
"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":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -220.0
|
||||
margin_bottom = 170.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Keys" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
|
||||
@@ -2,6 +2,7 @@ extends Panel
|
||||
|
||||
onready var fsm_node = get_node("../../Player/StateMachine")
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
var states_names = ""
|
||||
var numbers = ""
|
||||
|
||||
@@ -5,6 +5,7 @@ export(float) var speed = 1000.0
|
||||
|
||||
onready var root = get_tree().root
|
||||
|
||||
|
||||
func _ready():
|
||||
set_as_toplevel(true)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ extends Node2D
|
||||
|
||||
var bullet = preload("Bullet.tscn")
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event.is_action_pressed("fire"):
|
||||
fire()
|
||||
|
||||
@@ -7,6 +7,7 @@ signal direction_changed(new_direction)
|
||||
|
||||
var look_direction = Vector2.RIGHT setget set_look_direction
|
||||
|
||||
|
||||
func take_damage(attacker, amount, effect = null):
|
||||
if is_a_parent_of(attacker):
|
||||
return
|
||||
|
||||
@@ -6,6 +6,7 @@ onready var jump = $Jump
|
||||
onready var stagger = $Stagger
|
||||
onready var attack = $Attack
|
||||
|
||||
|
||||
func _ready():
|
||||
states_map = {
|
||||
"idle": idle,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends "res://state_machine/state.gd"
|
||||
|
||||
|
||||
func enter():
|
||||
owner.get_node("AnimationPlayer").play("idle")
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ extends "res://state_machine/state.gd"
|
||||
# The animation only affects the Body Sprite's modulate property so it
|
||||
# could stack with other animations if we had two AnimationPlayer nodes.
|
||||
|
||||
|
||||
func enter():
|
||||
owner.get_node("AnimationPlayer").play("stagger")
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ extends Label
|
||||
|
||||
var start_position = Vector2()
|
||||
|
||||
|
||||
func _ready():
|
||||
start_position = rect_position
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends "res://state_machine/state.gd"
|
||||
|
||||
|
||||
# Initialize the state. E.g. change the animation.
|
||||
func enter():
|
||||
owner.set_dead(true)
|
||||
|
||||
@@ -17,6 +17,7 @@ var horizontal_velocity = Vector2()
|
||||
var vertical_speed = 0.0
|
||||
var height = 0.0
|
||||
|
||||
|
||||
func initialize(speed, velocity):
|
||||
horizontal_speed = speed
|
||||
if speed > 0.0:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
extends "res://state_machine/state.gd"
|
||||
# Collection of important methods to handle direction and animation.
|
||||
|
||||
|
||||
func handle_input(event):
|
||||
if event.is_action_pressed("simulate_damage"):
|
||||
emit_signal("finished", "stagger")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends "on_ground.gd"
|
||||
|
||||
|
||||
func enter():
|
||||
owner.get_node("AnimationPlayer").play("idle")
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
extends "on_ground.gd"
|
||||
|
||||
export(float) var max_walk_speed = 450
|
||||
export(float) var max_run_speed = 700
|
||||
|
||||
export(float) var max_walk_speed = 450.0
|
||||
export(float) var max_run_speed = 700.0
|
||||
|
||||
|
||||
func enter():
|
||||
speed = 0.0
|
||||
|
||||
@@ -4,6 +4,7 @@ extends "../motion.gd"
|
||||
var speed = 0.0
|
||||
var velocity = Vector2()
|
||||
|
||||
|
||||
func handle_input(event):
|
||||
if event.is_action_pressed("jump"):
|
||||
emit_signal("finished", "jump")
|
||||
|
||||
@@ -30,6 +30,7 @@ var combo = [{
|
||||
|
||||
var hit_objects = []
|
||||
|
||||
|
||||
func _ready():
|
||||
# warning-ignore:return_value_discarded
|
||||
$AnimationPlayer.connect("animation_finished", self, "_on_animation_finished")
|
||||
|
||||
@@ -2,6 +2,7 @@ extends Position2D
|
||||
|
||||
var z_index_start = 0
|
||||
|
||||
|
||||
func _ready():
|
||||
#warning-ignore:return_value_discarded
|
||||
owner.connect("direction_changed", self, "_on_Parent_direction_changed")
|
||||
|
||||
@@ -6,6 +6,7 @@ extends Node
|
||||
# warning-ignore:unused_signal
|
||||
signal finished(next_state_name)
|
||||
|
||||
|
||||
# Initialize the state. E.g. change the animation.
|
||||
func enter():
|
||||
pass
|
||||
|
||||
@@ -17,6 +17,7 @@ var states_stack = []
|
||||
var current_state = null
|
||||
var _active = false setget set_active
|
||||
|
||||
|
||||
func _ready():
|
||||
if not start_state:
|
||||
start_state = get_child(0).get_path()
|
||||
|
||||
@@ -48,6 +48,7 @@ var brush_shape = BrushShapes.CIRCLE;
|
||||
# in the _draw function for more details).
|
||||
var bg_color = Color.white
|
||||
|
||||
|
||||
func _ready():
|
||||
# Get the top left position node. We need this to find out whether or not the mouse is inside the canvas.
|
||||
TL_node = get_node("TLPos")
|
||||
|
||||
@@ -215,8 +215,7 @@ text = "Clear picture"
|
||||
[node name="SaveFileDialog" type="FileDialog" parent="."]
|
||||
margin_right = 600.0
|
||||
margin_bottom = 400.0
|
||||
rect_min_size = Vector2( 300, 105 )
|
||||
resizable = true
|
||||
access = 2
|
||||
filters = PoolStringArray( "*.png" )
|
||||
current_dir = "/home/aaronfranke/workspace/godot-demo-projects/2d/gd_paint"
|
||||
current_path = "/home/aaronfranke/workspace/godot-demo-projects/2d/gd_paint/"
|
||||
|
||||
@@ -10,6 +10,7 @@ onready var _parent = get_parent()
|
||||
onready var save_dialog = _parent.get_node(@"SaveFileDialog")
|
||||
onready var paint_control = _parent.get_node(@"PaintControl")
|
||||
|
||||
|
||||
func _ready():
|
||||
# warning-ignore-all:return_value_discarded
|
||||
# Assign all of the needed signals for the oppersation buttons.
|
||||
|
||||
@@ -4,6 +4,7 @@ const CAVE_LIMIT = 1000
|
||||
|
||||
onready var cave = $Cave
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventMouseMotion and event.button_mask > 0:
|
||||
var rel_x = event.relative.x
|
||||
|
||||
@@ -3,6 +3,7 @@ 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")
|
||||
|
||||
@@ -2,6 +2,7 @@ extends Node2D
|
||||
|
||||
export(PackedScene) var ball_scene = preload("res://ball.tscn")
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event.is_echo():
|
||||
return
|
||||
|
||||
@@ -2,6 +2,7 @@ extends KinematicBody2D
|
||||
|
||||
const MOTION_SPEED = 160 # Pixels/second.
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
var motion = Vector2()
|
||||
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.name == "Player":
|
||||
$"../WinText".show()
|
||||
|
||||
@@ -9,6 +9,7 @@ var velocity = Vector2()
|
||||
|
||||
onready var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# Horizontal movement code. First, get the player's input.
|
||||
var walk = WALK_FORCE * (Input.get_action_strength("move_right") - Input.get_action_strength("move_left"))
|
||||
|
||||
33
2d/navigation/character.gd
Normal file
33
2d/navigation/character.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends Sprite
|
||||
|
||||
export(float) var character_speed = 400.0
|
||||
|
||||
onready var navigation_agent: NavigationAgent2D = $NavigationAgent2D
|
||||
onready var navigation_path_debug_line: Line2D = $Line2D
|
||||
|
||||
|
||||
func _ready():
|
||||
navigation_path_debug_line.set_as_toplevel(true)
|
||||
|
||||
|
||||
func set_target_location(target_location: Vector2):
|
||||
navigation_agent.set_target_location(target_location)
|
||||
# Alternative way to get a full navigation path with Server API.
|
||||
var navigation_map: RID = get_world_2d().get_navigation_map()
|
||||
var start_position: Vector2 = get_global_transform().get_origin()
|
||||
var target_position: Vector2 = target_location
|
||||
var optimize: bool = true
|
||||
navigation_path_debug_line.points = Navigation2DServer.map_get_path(
|
||||
navigation_map,
|
||||
start_position,
|
||||
target_position,
|
||||
optimize
|
||||
)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
if navigation_agent.is_navigation_finished():
|
||||
return
|
||||
|
||||
var next_position: Vector2 = navigation_agent.get_next_location()
|
||||
global_position = global_position.move_toward(next_position, delta * character_speed)
|
||||
@@ -1,18 +1,19 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://navigation.gd" type="Script" id=1]
|
||||
[ext_resource path="res://map.png" type="Texture" id=2]
|
||||
[ext_resource path="res://character.png" type="Texture" id=3]
|
||||
[ext_resource path="res://character.gd" type="Script" id=4]
|
||||
|
||||
[sub_resource type="NavigationPolygon" id=1]
|
||||
vertices = PoolVector2Array( 587.833, 271.924, 530.464, 284.878, 508.256, 281.177, 497.153, 255.269, 624.926, 359.595, 648.903, 394.065, 620.443, 383.995, 669.26, 297.833, 648.903, 321.891, 650.754, 251.567, 619.293, 510.654, 676.663, 493.998, 706.272, 501.401, 669.26, 529.16, 602.638, 523.608, 587.833, 179.393, 573.028, 140.53, 645.202, 159.036, 710.106, 179.216, 630.397, 212.704, 597.086, 192.348, 471.244, 251.567, 421.277, 270.074, 428.68, 246.015, 502.704, 97.9661, 517.509, 55.4019, 537.866, 99.8167, 536.016, 175.692, 495.302, 164.588, 487.899, 85.0117, 310.24, 75.7586, 308.39, 92.4142, 345.402, 210.854, 360.207, 223.808, 297.286, 258.97, 288.033, 231.211, 319.493, 190.497, 193.651, 423.675, 245.469, 477.343, 221.41, 488.446, 147.386, 408.87, 182.548, 382.961, 145.584, 224.311, 175.145, 332.995, 202.904, 99.8167, 310.24, 62.8043, 695.169, 303.385, 682.214, 284.878, 598.937, 492.148, 571.177, 501.401, 605.437, 456.366, 621.144, 486.596, 538.077, 499.891, 395.879, 501.87, 536.407, 524.944, 371.311, 518.056, 573.028, 94.2648, 582.281, 47.9994, 667.409, 75.7586, 350.954, 447.733, 363.908, 351.501, 384.265, 351.501, 376.862, 418.123, 373.441, 436.494, 424.978, 334.845, 421.277, 360.754, 352.804, 320.04, 321.344, 338.546, 299.136, 283.028, 241.767, 327.443, 234.365, 244.165, 325.228, 486.302, 300.441, 497.494, 317.643, 447.733, 332.441, 457.494, 524.608, 359.37, 526.762, 342.248, 366.441, 467.494, 480.497, 434.779, 496.638, 439.381, 476.441, 468.494, 265.825, 407.019, 184.398, 349.65, 310.24, 112.771, 267.676, 153.485, 221.41, 171.991, 700.721, 268.223, 397.219, 188.646, 415.725, 177.543, 465.692, 179.393, 476.796, 207.152, 443.485, 192.348, 437.933, 170.14, 452.738, 166.439, 460.14, 123.875, 476.796, 149.783, 189.95, 231.211 )
|
||||
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 6 ), PoolIntArray( 7, 8, 9 ), PoolIntArray( 10, 11, 12, 13, 14 ), PoolIntArray( 15, 16, 17, 18, 19, 20 ), PoolIntArray( 21, 3, 2, 22, 23 ), PoolIntArray( 24, 25, 26, 27, 28 ), PoolIntArray( 25, 24, 29 ), PoolIntArray( 30, 25, 29, 31 ), PoolIntArray( 32, 33, 34, 35, 36 ), PoolIntArray( 37, 38, 39, 40 ), PoolIntArray( 41, 37, 40 ), PoolIntArray( 41, 40, 42, 43 ), PoolIntArray( 44, 45, 30, 31 ), PoolIntArray( 46, 12, 11, 7, 47 ), PoolIntArray( 47, 7, 9 ), PoolIntArray( 48, 10, 14, 49 ), PoolIntArray( 50, 6, 5, 51, 48 ), PoolIntArray( 52, 50, 48, 49 ), PoolIntArray( 53, 52, 49, 54, 55 ), PoolIntArray( 17, 56, 57, 58, 18 ), PoolIntArray( 59, 60, 61, 62, 63 ), PoolIntArray( 64, 65, 61, 66 ), PoolIntArray( 66, 61, 60, 67, 68 ), PoolIntArray( 68, 67, 69, 70 ), PoolIntArray( 68, 70, 35, 34 ), PoolIntArray( 71, 53, 55, 72 ), PoolIntArray( 71, 72, 73, 74 ), PoolIntArray( 4, 6, 75, 76 ), PoolIntArray( 63, 77, 74, 59 ), PoolIntArray( 78, 2, 1, 76, 75, 79, 80 ), PoolIntArray( 78, 80, 63, 62 ), PoolIntArray( 81, 59, 74, 73 ), PoolIntArray( 81, 73, 41, 82 ), PoolIntArray( 44, 31, 83, 84, 85 ), PoolIntArray( 18, 86, 47, 9, 19 ), PoolIntArray( 15, 20, 3, 21 ), PoolIntArray( 23, 22, 87, 88 ), PoolIntArray( 89, 28, 27, 90, 91 ), PoolIntArray( 89, 91, 92, 93 ), PoolIntArray( 36, 94, 95, 93, 92 ), PoolIntArray( 36, 92, 88 ), PoolIntArray( 36, 88, 87, 32 ), PoolIntArray( 36, 35, 85, 84 ), PoolIntArray( 42, 44, 85, 96 ), PoolIntArray( 42, 96, 43 ), PoolIntArray( 41, 43, 82 ) ]
|
||||
outlines = [ PoolVector2Array( 221.41, 488.446, 147.386, 408.87, 145.584, 224.311, 202.904, 99.8167, 310.24, 62.8043, 310.24, 75.7586, 517.509, 55.4019, 537.866, 99.8167, 536.016, 175.692, 476.796, 207.152, 443.485, 192.348, 437.933, 170.14, 415.725, 177.543, 428.68, 246.015, 471.244, 251.567, 587.833, 179.393, 573.028, 140.53, 645.202, 159.036, 573.028, 94.2648, 582.281, 47.9994, 667.409, 75.7586, 710.106, 179.216, 700.721, 268.223, 682.214, 284.878, 695.169, 303.385, 706.272, 501.401, 669.26, 529.16, 602.638, 523.608, 571.177, 501.401, 536.407, 524.944, 371.311, 518.056, 300.441, 497.494, 317.643, 447.733, 182.548, 382.961, 193.651, 423.675, 245.469, 477.343 ), PoolVector2Array( 350.954, 447.733, 363.908, 351.501, 321.344, 338.546, 241.767, 327.443, 234.365, 244.165, 288.033, 231.211, 221.41, 171.991, 189.95, 231.211, 175.145, 332.995, 184.398, 349.65, 265.825, 407.019 ), PoolVector2Array( 267.676, 153.485, 310.24, 112.771, 308.39, 92.4142, 487.899, 85.0117, 502.704, 97.9661, 495.302, 164.588, 465.692, 179.393, 452.738, 166.439, 476.796, 149.783, 460.14, 123.875, 319.493, 190.497 ), PoolVector2Array( 397.219, 188.646, 345.402, 210.854, 360.207, 223.808, 297.286, 258.97, 299.136, 283.028, 352.804, 320.04, 424.978, 334.845, 421.277, 360.754, 384.265, 351.501, 376.862, 418.123, 480.497, 434.779, 508.256, 281.177, 421.277, 270.074 ), PoolVector2Array( 497.153, 255.269, 597.086, 192.348, 630.397, 212.704, 650.754, 251.567, 648.903, 321.891, 669.26, 297.833, 676.663, 493.998, 619.293, 510.654, 598.937, 492.148, 621.144, 486.596, 648.903, 394.065, 624.926, 359.595, 526.762, 342.248, 530.464, 284.878, 587.833, 271.924 ), PoolVector2Array( 325.228, 486.302, 332.441, 457.494, 366.441, 467.494, 373.441, 436.494, 476.441, 468.494, 496.638, 439.381, 524.608, 359.37, 620.443, 383.995, 605.437, 456.366, 538.077, 499.891, 395.879, 501.87 ) ]
|
||||
|
||||
[node name="Navigation2D" type="Navigation2D"]
|
||||
[node name="NavigationDemo" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Navmesh" type="NavigationPolygonInstance" parent="."]
|
||||
[node name="NavigationPolygonInstance" type="NavigationPolygonInstance" parent="."]
|
||||
navpoly = SubResource( 1 )
|
||||
|
||||
[node name="Map" type="Sprite" parent="."]
|
||||
@@ -24,6 +25,13 @@ position = Vector2( 228.464, 132.594 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
texture = ExtResource( 3 )
|
||||
offset = Vector2( 0, -26 )
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="Character"]
|
||||
|
||||
[node name="Line2D" type="Line2D" parent="Character"]
|
||||
width = 4.0
|
||||
default_color = Color( 1, 0, 0, 1 )
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
offset = Vector2( 420, 300 )
|
||||
|
||||
@@ -1,46 +1,10 @@
|
||||
extends Navigation2D
|
||||
extends Node2D
|
||||
|
||||
export(float) var character_speed = 400.0
|
||||
var path = []
|
||||
|
||||
onready var character = $Character
|
||||
|
||||
func _process(delta):
|
||||
var walk_distance = character_speed * delta
|
||||
move_along_path(walk_distance)
|
||||
|
||||
|
||||
# The "click" event is a custom input action defined in
|
||||
# Project > Project Settings > Input Map tab.
|
||||
func _unhandled_input(event):
|
||||
if not event.is_action_pressed("click"):
|
||||
return
|
||||
_update_navigation_path(character.position, get_local_mouse_position())
|
||||
|
||||
|
||||
func move_along_path(distance):
|
||||
var last_point = character.position
|
||||
while path.size():
|
||||
var distance_between_points = last_point.distance_to(path[0])
|
||||
# The position to move to falls between two points.
|
||||
if distance <= distance_between_points:
|
||||
character.position = last_point.linear_interpolate(path[0], distance / distance_between_points)
|
||||
return
|
||||
# The position is past the end of the segment.
|
||||
distance -= distance_between_points
|
||||
last_point = path[0]
|
||||
path.remove(0)
|
||||
# The character reached the end of the path.
|
||||
character.position = last_point
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _update_navigation_path(start_position, end_position):
|
||||
# get_simple_path is part of the Navigation2D class.
|
||||
# It returns a PoolVector2Array of points that lead you
|
||||
# from the start_position to the end_position.
|
||||
path = get_simple_path(start_position, end_position, true)
|
||||
# The first point is always the start_position.
|
||||
# We don't need it in this example as it corresponds to the character's position.
|
||||
path.remove(0)
|
||||
set_process(true)
|
||||
character.set_target_location(get_global_mouse_position())
|
||||
|
||||
@@ -14,6 +14,7 @@ var _target_position = Vector2()
|
||||
|
||||
var _velocity = Vector2()
|
||||
|
||||
|
||||
func _ready():
|
||||
_change_state(States.IDLE)
|
||||
|
||||
@@ -33,7 +34,7 @@ func _process(_delta):
|
||||
func _unhandled_input(event):
|
||||
if event.is_action_pressed("click"):
|
||||
var global_mouse_pos = get_global_mouse_position()
|
||||
if Input.is_key_pressed(KEY_SHIFT):
|
||||
if Input.is_key_pressed(KEY_SHIFT) and get_parent().get_node("TileMap").check_start_position(global_mouse_pos):
|
||||
global_position = global_mouse_pos
|
||||
else:
|
||||
_target_position = global_mouse_pos
|
||||
|
||||
@@ -20,6 +20,7 @@ onready var astar_node = AStar.new()
|
||||
onready var obstacles = get_used_cells_by_id(0)
|
||||
onready var _half_cell_size = cell_size / 2
|
||||
|
||||
|
||||
func _ready():
|
||||
var walkable_cells_list = astar_add_walkable_cells(obstacles)
|
||||
astar_connect_walkable_cells(walkable_cells_list)
|
||||
@@ -126,6 +127,14 @@ func is_outside_map_bounds(point):
|
||||
return point.x < 0 or point.y < 0 or point.x >= map_size.x or point.y >= map_size.y
|
||||
|
||||
|
||||
func check_start_position(world_start):
|
||||
var start_point = world_to_map(world_start)
|
||||
if start_point in obstacles:
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
|
||||
func get_astar_path(world_start, world_end):
|
||||
self.path_start_position = world_to_map(world_start)
|
||||
self.path_end_position = world_to_map(world_end)
|
||||
|
||||
@@ -9,7 +9,7 @@ manual modification of the RigidBody velocity.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 3 (particles are not available in GLES 2)
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/119
|
||||
|
||||
|
||||
@@ -17,5 +17,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
|
||||
|
||||
@@ -17,5 +17,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
|
||||
|
||||
@@ -17,5 +17,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
|
||||
|
||||
@@ -17,5 +17,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
|
||||
|
||||
@@ -17,5 +17,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,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://coin/coin.gd" type="Script" id=1]
|
||||
[ext_resource path="res://coin/coin.png" type="Texture" id=2]
|
||||
@@ -97,21 +97,6 @@ blend_mode = 1
|
||||
|
||||
[sub_resource type="Curve" id=5]
|
||||
|
||||
[sub_resource type="CurveTexture" id=6]
|
||||
curve = SubResource( 5 )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=7]
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 20.0
|
||||
flag_disable_z = true
|
||||
gravity = Vector3( 0, 0, 0 )
|
||||
initial_velocity = 1.0
|
||||
angular_velocity = 0.0191222
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
scale = 0.3
|
||||
scale_curve = SubResource( 6 )
|
||||
|
||||
[node name="Coin" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
@@ -130,14 +115,20 @@ shape = SubResource( 3 )
|
||||
[node name="Sound" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource( 3 )
|
||||
|
||||
[node name="Particles" type="Particles2D" parent="."]
|
||||
[node name="Particles" type="CPUParticles2D" parent="."]
|
||||
modulate = Color( 0.596863, 0.638745, 1, 1 )
|
||||
material = SubResource( 4 )
|
||||
emitting = false
|
||||
one_shot = true
|
||||
explosiveness = 0.7
|
||||
process_material = SubResource( 7 )
|
||||
texture = ExtResource( 4 )
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 20.0
|
||||
gravity = Vector2( 0, 0 )
|
||||
initial_velocity = 1.0
|
||||
angular_velocity = 0.0191222
|
||||
scale_amount = 0.3
|
||||
scale_amount_curve = SubResource( 5 )
|
||||
|
||||
[node name="Enabler" type="VisibilityEnabler2D" parent="."]
|
||||
rect = Rect2( -5, -5, 10, 10 )
|
||||
|
||||
@@ -3,6 +3,7 @@ extends Area2D
|
||||
|
||||
var taken = false
|
||||
|
||||
|
||||
func _on_body_enter(body):
|
||||
if not taken and body is Player:
|
||||
($AnimationPlayer as AnimationPlayer).play("taken")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=14 format=2]
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://enemy/enemy.gd" type="Script" id=1]
|
||||
[ext_resource path="res://enemy/enemy.png" type="Texture" id=2]
|
||||
@@ -106,23 +106,6 @@ radius = 7.0
|
||||
offsets = PoolRealArray( 0.5, 1 )
|
||||
colors = PoolColorArray( 1, 1, 1, 0.501961, 0, 0, 0, 0 )
|
||||
|
||||
[sub_resource type="GradientTexture" id=7]
|
||||
gradient = SubResource( 6 )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=8]
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 8.0
|
||||
flag_disable_z = true
|
||||
spread = 180.0
|
||||
gravity = Vector3( 0, 0, 0 )
|
||||
initial_velocity = 120.0
|
||||
initial_velocity_random = 0.5
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
angle_random = 1.0
|
||||
scale_random = 1.0
|
||||
color_ramp = SubResource( 7 )
|
||||
|
||||
[node name="Enemy" type="RigidBody2D"]
|
||||
mode = 2
|
||||
physics_material_override = SubResource( 1 )
|
||||
@@ -166,7 +149,7 @@ position = Vector2( 11, -4.672 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, 22.5 )
|
||||
|
||||
[node name="Explosion" type="Particles2D" parent="."]
|
||||
[node name="Explosion" type="CPUParticles2D" parent="."]
|
||||
modulate = Color( 1, 1, 1, 0.685843 )
|
||||
emitting = false
|
||||
amount = 32
|
||||
@@ -174,8 +157,16 @@ lifetime = 0.5
|
||||
one_shot = true
|
||||
speed_scale = 1.2
|
||||
explosiveness = 0.76
|
||||
process_material = SubResource( 8 )
|
||||
texture = ExtResource( 3 )
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 8.0
|
||||
spread = 180.0
|
||||
gravity = Vector2( 0, 0 )
|
||||
initial_velocity = 120.0
|
||||
initial_velocity_random = 0.5
|
||||
angle_random = 1.0
|
||||
scale_amount_random = 1.0
|
||||
color_ramp = SubResource( 6 )
|
||||
|
||||
[node name="SoundHit" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource( 4 )
|
||||
|
||||
@@ -18,6 +18,7 @@ var Bullet = preload("res://player/bullet.gd")
|
||||
onready var rc_left = $RaycastLeft
|
||||
onready var rc_right = $RaycastRight
|
||||
|
||||
|
||||
func _integrate_forces(s):
|
||||
var lv = s.get_linear_velocity()
|
||||
var new_anim = anim
|
||||
|
||||
@@ -6,6 +6,7 @@ export var cycle = 1.0
|
||||
|
||||
var accum = 0.0
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
accum += delta * (1.0 / cycle) * TAU
|
||||
accum = fmod(accum, TAU)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://player/bullet.gd" type="Script" id=1]
|
||||
[ext_resource path="res://player/bullet.png" type="Texture" id=2]
|
||||
@@ -6,20 +6,10 @@
|
||||
[sub_resource type="CanvasItemMaterial" id=1]
|
||||
blend_mode = 1
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=2]
|
||||
flag_disable_z = true
|
||||
spread = 0.0
|
||||
gravity = Vector3( 0, 0, 0 )
|
||||
initial_velocity = 1.0
|
||||
angular_velocity = 38.0
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
scale = 0.8
|
||||
|
||||
[sub_resource type="CircleShape2D" id=3]
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
radius = 4.5
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
[sub_resource type="Animation" id=3]
|
||||
length = 1.5
|
||||
tracks/0/type = "method"
|
||||
tracks/0/path = NodePath(".")
|
||||
@@ -64,24 +54,29 @@ tracks/2/keys = {
|
||||
continuous_cd = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Particles2D" type="Particles2D" parent="."]
|
||||
[node name="Particles2D" type="CPUParticles2D" parent="."]
|
||||
material = SubResource( 1 )
|
||||
emitting = false
|
||||
lifetime = 0.3
|
||||
speed_scale = 3.0
|
||||
local_coords = false
|
||||
process_material = SubResource( 2 )
|
||||
texture = ExtResource( 2 )
|
||||
spread = 0.0
|
||||
gravity = Vector2( 0, 0 )
|
||||
initial_velocity = 1.0
|
||||
angular_velocity = 38.0
|
||||
scale_amount = 0.8
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 3 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/shutdown = SubResource( 4 )
|
||||
anims/shutdown = SubResource( 3 )
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="disable"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=25 format=2]
|
||||
[gd_scene load_steps=23 format=2]
|
||||
|
||||
[ext_resource path="res://player/player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://player/robot_demo.png" type="Texture" id=2]
|
||||
@@ -16,22 +16,7 @@ friction = 0.0
|
||||
[sub_resource type="Gradient" id=2]
|
||||
colors = PoolColorArray( 0.708353, 0.72498, 1, 1, 1, 1, 1, 0 )
|
||||
|
||||
[sub_resource type="GradientTexture" id=3]
|
||||
gradient = SubResource( 2 )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=4]
|
||||
flag_disable_z = true
|
||||
spread = 65.84
|
||||
gravity = Vector3( 0, -15, 0 )
|
||||
initial_velocity = 10.14
|
||||
angular_velocity = 200.0
|
||||
angular_velocity_random = 1.0
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
linear_accel = 100.0
|
||||
color_ramp = SubResource( 3 )
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
[sub_resource type="Animation" id=3]
|
||||
length = 0.01
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -48,7 +33,7 @@ tracks/0/keys = {
|
||||
"values": [ 22 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=6]
|
||||
[sub_resource type="Animation" id=4]
|
||||
length = 0.01
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -65,7 +50,7 @@ tracks/0/keys = {
|
||||
"values": [ 21 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=7]
|
||||
[sub_resource type="Animation" id=5]
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -82,7 +67,7 @@ tracks/0/keys = {
|
||||
"values": [ 26 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
[sub_resource type="Animation" id=6]
|
||||
length = 7.0
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -99,7 +84,7 @@ tracks/0/keys = {
|
||||
"values": [ 16, 17, 18, 16, 19, 20, 19, 16 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=9]
|
||||
[sub_resource type="Animation" id=7]
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -116,7 +101,7 @@ tracks/0/keys = {
|
||||
"values": [ 25 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=10]
|
||||
[sub_resource type="Animation" id=8]
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -133,7 +118,7 @@ tracks/0/keys = {
|
||||
"values": [ 23, 24, 23 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=11]
|
||||
[sub_resource type="Animation" id=9]
|
||||
length = 0.5
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -150,7 +135,7 @@ tracks/0/keys = {
|
||||
"values": [ 26 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=12]
|
||||
[sub_resource type="Animation" id=10]
|
||||
length = 1.25
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -167,7 +152,7 @@ tracks/0/keys = {
|
||||
"values": [ 0, 1, 2, 3, 4, 0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=13]
|
||||
[sub_resource type="Animation" id=11]
|
||||
length = 1.25
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -184,7 +169,7 @@ tracks/0/keys = {
|
||||
"values": [ 5, 6, 7, 8, 9, 5 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=14]
|
||||
[sub_resource type="Animation" id=12]
|
||||
length = 1.25
|
||||
loop = true
|
||||
step = 0.25
|
||||
@@ -201,7 +186,7 @@ tracks/0/keys = {
|
||||
"values": [ 10, 11, 12, 13, 14, 5 ]
|
||||
}
|
||||
|
||||
[sub_resource type="RayShape2D" id=15]
|
||||
[sub_resource type="RayShape2D" id=13]
|
||||
custom_solver_bias = 0.5
|
||||
length = 18.0
|
||||
|
||||
@@ -218,7 +203,7 @@ texture = ExtResource( 2 )
|
||||
hframes = 16
|
||||
vframes = 2
|
||||
|
||||
[node name="Smoke" type="Particles2D" parent="Sprite"]
|
||||
[node name="Smoke" type="CPUParticles2D" parent="Sprite"]
|
||||
self_modulate = Color( 1, 1, 1, 0.26702 )
|
||||
position = Vector2( 10, 1.5 )
|
||||
rotation = -1.45648
|
||||
@@ -227,20 +212,26 @@ lifetime = 0.3
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
local_coords = false
|
||||
process_material = SubResource( 4 )
|
||||
texture = ExtResource( 3 )
|
||||
spread = 65.84
|
||||
gravity = Vector2( 0, -15 )
|
||||
initial_velocity = 10.14
|
||||
angular_velocity = 200.0
|
||||
angular_velocity_random = 1.0
|
||||
linear_accel = 100.0
|
||||
color_ramp = SubResource( 2 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/crouch = SubResource( 5 )
|
||||
anims/falling = SubResource( 6 )
|
||||
anims/falling_weapon = SubResource( 7 )
|
||||
anims/idle = SubResource( 8 )
|
||||
anims/idle_weapon = SubResource( 9 )
|
||||
anims/jumping = SubResource( 10 )
|
||||
anims/jumping_weapon = SubResource( 11 )
|
||||
anims/run = SubResource( 12 )
|
||||
anims/run_weapon = SubResource( 13 )
|
||||
anims/standing_weapon_ready = SubResource( 14 )
|
||||
anims/crouch = SubResource( 3 )
|
||||
anims/falling = SubResource( 4 )
|
||||
anims/falling_weapon = SubResource( 5 )
|
||||
anims/idle = SubResource( 6 )
|
||||
anims/idle_weapon = SubResource( 7 )
|
||||
anims/jumping = SubResource( 8 )
|
||||
anims/jumping_weapon = SubResource( 9 )
|
||||
anims/run = SubResource( 10 )
|
||||
anims/run_weapon = SubResource( 11 )
|
||||
anims/standing_weapon_ready = SubResource( 12 )
|
||||
|
||||
[node name="Camera" type="Camera2D" parent="."]
|
||||
current = true
|
||||
@@ -253,7 +244,7 @@ position = Vector2( 15, 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0.15, -6 )
|
||||
shape = SubResource( 15 )
|
||||
shape = SubResource( 13 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
polygon = PoolVector2Array( -0.138, 8.25, -10, -12, 11, -12 )
|
||||
|
||||
@@ -3,6 +3,7 @@ extends RigidBody2D
|
||||
|
||||
var disabled = false
|
||||
|
||||
|
||||
func _ready():
|
||||
($Timer as Timer).start()
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ onready var sprite_smoke = sprite.get_node(@"Smoke")
|
||||
onready var animation_player = $AnimationPlayer
|
||||
onready var bullet_shoot = $BulletShoot
|
||||
|
||||
|
||||
func _integrate_forces(s):
|
||||
var lv = s.get_linear_velocity()
|
||||
var step = s.get_step()
|
||||
|
||||
@@ -66,7 +66,7 @@ window/size/width=800
|
||||
window/size/height=480
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="keep"
|
||||
window/stretch/aspect="keep_height"
|
||||
|
||||
[gdnative]
|
||||
|
||||
@@ -154,6 +154,7 @@ mipmap_policy=1
|
||||
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
quality/intended_usage/framebuffer_allocation=0
|
||||
quality/intended_usage/framebuffer_allocation.mobile=1
|
||||
2d/snapping/use_gpu_pixel_snap=true
|
||||
|
||||
@@ -21,6 +21,7 @@ func _ready():
|
||||
options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP)
|
||||
options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES)
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
if _moving_body:
|
||||
if _moving_body.is_on_floor():
|
||||
|
||||
@@ -12,6 +12,3 @@ text = "TEST OPTIONS"
|
||||
flat = false
|
||||
align = 0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ they contain a lot of comments that explain how each class works.
|
||||
|
||||
Language: GDScript
|
||||
|
||||
Renderer: GLES 3 (particles are not available in GLES 2)
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/120
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
[ext_resource path="res://assets/theme/fonts/kenney_mini_square.tres" type="DynamicFontData" id=1]
|
||||
|
||||
[sub_resource type="DynamicFont" id=6]
|
||||
size = 30
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
content_margin_left = 6.0
|
||||
content_margin_right = 6.0
|
||||
@@ -62,10 +66,6 @@ border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color( 0.41, 0.61, 0.91, 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=6]
|
||||
size = 30
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[resource]
|
||||
default_font = SubResource( 6 )
|
||||
Button/colors/font_color = Color( 0.8, 0.8075, 0.8275, 1 )
|
||||
@@ -75,7 +75,7 @@ Button/colors/font_color_pressed = Color( 0.411765, 0.611765, 0.909804, 1 )
|
||||
Button/colors/icon_color_hover = Color( 1.15, 1.15, 1.15, 1 )
|
||||
Button/colors/icon_color_pressed = Color( 0.4715, 0.7015, 1.0465, 1 )
|
||||
Button/constants/hseparation = 2
|
||||
Button/fonts/font = null
|
||||
Button/fonts/font = SubResource( 6 )
|
||||
Button/styles/disabled = SubResource( 1 )
|
||||
Button/styles/focus = SubResource( 2 )
|
||||
Button/styles/hover = SubResource( 3 )
|
||||
|
||||
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
||||
@@ -240,6 +240,7 @@ mipmap_policy=1
|
||||
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
quality/intended_usage/framebuffer_allocation=0
|
||||
quality/intended_usage/framebuffer_allocation.mobile=1
|
||||
2d/snapping/use_gpu_pixel_snap=true
|
||||
|
||||
@@ -12,6 +12,7 @@ const FLOOR_NORMAL = Vector2.UP
|
||||
|
||||
var _velocity = Vector2.ZERO
|
||||
|
||||
|
||||
# _physics_process is called after the inherited _physics_process function.
|
||||
# This allows the Player and Enemy scenes to be affected by gravity.
|
||||
func _physics_process(delta):
|
||||
|
||||
@@ -15,11 +15,13 @@ onready var floor_detector_right = $FloorDetectorRight
|
||||
onready var sprite = $Sprite
|
||||
onready var animation_player = $AnimationPlayer
|
||||
|
||||
|
||||
# This function is called when the scene enters the scene tree.
|
||||
# We can initialize variables here.
|
||||
func _ready():
|
||||
_velocity.x = speed.x
|
||||
|
||||
|
||||
# Physics process is a built-in loop in Godot.
|
||||
# If you define _physics_process on a node, Godot will call it every frame.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=15 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://assets/art/player/bullet/bullet.png" type="Texture" id=1]
|
||||
[ext_resource path="res://assets/audio/sfx/explode.wav" type="AudioStream" id=2]
|
||||
@@ -8,6 +8,21 @@
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id=1]
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Explosion:scale_amount")
|
||||
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 ),
|
||||
"update": 0,
|
||||
"values": [ 4.0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "destroy"
|
||||
length = 1.5
|
||||
@@ -60,48 +75,36 @@ tracks/3/keys = {
|
||||
"values": [ false, true ]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/path = NodePath("Explosion:process_material:scale")
|
||||
tracks/4/path = NodePath("Hit:playing")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/keys = {
|
||||
"times": PoolRealArray( 0.6, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 1.0, 4.0 ]
|
||||
}
|
||||
tracks/5/type = "value"
|
||||
tracks/5/path = NodePath("Hit:playing")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/keys = {
|
||||
"times": PoolRealArray( 0.00999999 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/6/type = "value"
|
||||
tracks/6/path = NodePath("Explode:playing")
|
||||
tracks/6/interp = 1
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/imported = false
|
||||
tracks/6/enabled = true
|
||||
tracks/6/keys = {
|
||||
tracks/5/type = "value"
|
||||
tracks/5/path = NodePath("Explode:playing")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/keys = {
|
||||
"times": PoolRealArray( 0.8 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/7/type = "method"
|
||||
tracks/7/path = NodePath(".")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/imported = false
|
||||
tracks/7/enabled = true
|
||||
tracks/7/keys = {
|
||||
tracks/6/type = "method"
|
||||
tracks/6/path = NodePath(".")
|
||||
tracks/6/interp = 1
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/imported = false
|
||||
tracks/6/enabled = true
|
||||
tracks/6/keys = {
|
||||
"times": PoolRealArray( 1.5 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
@@ -109,29 +112,41 @@ tracks/7/keys = {
|
||||
"method": "queue_free"
|
||||
} ]
|
||||
}
|
||||
tracks/8/type = "value"
|
||||
tracks/8/path = NodePath(".:collision_layer")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/imported = false
|
||||
tracks/8/enabled = true
|
||||
tracks/8/keys = {
|
||||
tracks/7/type = "value"
|
||||
tracks/7/path = NodePath(".:collision_layer")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/imported = false
|
||||
tracks/7/enabled = true
|
||||
tracks/7/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 0 ]
|
||||
}
|
||||
tracks/8/type = "value"
|
||||
tracks/8/path = NodePath("Sprite:position")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/imported = false
|
||||
tracks/8/enabled = true
|
||||
tracks/8/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.4 ),
|
||||
"transitions": PoolRealArray( 2.2974, 0.183011, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, -32 ), Vector2( 0, 0 ) ]
|
||||
}
|
||||
tracks/9/type = "value"
|
||||
tracks/9/path = NodePath("Sprite:position")
|
||||
tracks/9/path = NodePath("Explosion:scale_amount")
|
||||
tracks/9/interp = 1
|
||||
tracks/9/loop_wrap = true
|
||||
tracks/9/imported = false
|
||||
tracks/9/enabled = true
|
||||
tracks/9/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.4 ),
|
||||
"transitions": PoolRealArray( 2.2974, 0.183011, 1 ),
|
||||
"times": PoolRealArray( 0.6, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, -32 ), Vector2( 0, 0 ) ]
|
||||
"values": [ 1.0, 4.0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
@@ -179,26 +194,6 @@ blend_mode = 1
|
||||
offsets = PoolRealArray( 0.5, 1 )
|
||||
colors = PoolColorArray( 1, 1, 1, 1, 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="GradientTexture" id=8]
|
||||
gradient = SubResource( 7 )
|
||||
width = 256
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=9]
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 8.0
|
||||
flag_disable_z = true
|
||||
spread = 180.0
|
||||
gravity = Vector3( 0, 250, 0 )
|
||||
initial_velocity = 120.0
|
||||
initial_velocity_random = 0.5
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
angle_random = 1.0
|
||||
scale_random = 1.0
|
||||
color_ramp = SubResource( 8 )
|
||||
hue_variation = 0.05
|
||||
hue_variation_random = 0.46
|
||||
|
||||
[node name="Enemy" type="KinematicBody2D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 24
|
||||
@@ -231,6 +226,7 @@ hframes = 8
|
||||
frame = 7
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/RESET = SubResource( 8 )
|
||||
anims/destroy = SubResource( 2 )
|
||||
anims/idle = SubResource( 3 )
|
||||
anims/walk = SubResource( 4 )
|
||||
@@ -239,7 +235,7 @@ anims/walk = SubResource( 4 )
|
||||
rotation = -1.5708
|
||||
shape = SubResource( 5 )
|
||||
|
||||
[node name="Explosion" type="Particles2D" parent="."]
|
||||
[node name="Explosion" type="CPUParticles2D" parent="."]
|
||||
self_modulate = Color( 1, 1, 1, 0.12 )
|
||||
material = SubResource( 6 )
|
||||
emitting = false
|
||||
@@ -249,8 +245,19 @@ one_shot = true
|
||||
speed_scale = 1.2
|
||||
explosiveness = 0.76
|
||||
draw_order = 215832976
|
||||
process_material = SubResource( 9 )
|
||||
texture = ExtResource( 1 )
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 8.0
|
||||
spread = 180.0
|
||||
gravity = Vector2( 0, 250 )
|
||||
initial_velocity = 120.0
|
||||
initial_velocity_random = 0.5
|
||||
angle_random = 1.0
|
||||
scale_amount = 4.0
|
||||
scale_amount_random = 1.0
|
||||
color_ramp = SubResource( 7 )
|
||||
hue_variation = 0.05
|
||||
hue_variation_random = 0.46
|
||||
|
||||
[node name="Hit" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource( 3 )
|
||||
|
||||
@@ -22,4 +22,5 @@ func shoot(direction = 1):
|
||||
bullet.set_as_toplevel(true)
|
||||
add_child(bullet)
|
||||
sound_shoot.play()
|
||||
timer.start()
|
||||
return true
|
||||
|
||||
@@ -22,10 +22,14 @@ func _ready():
|
||||
var camera: Camera2D = $Camera
|
||||
if action_suffix == "_p1":
|
||||
camera.custom_viewport = $"../.."
|
||||
yield(get_tree(), "idle_frame")
|
||||
camera.make_current()
|
||||
elif action_suffix == "_p2":
|
||||
var viewport: Viewport = $"../../../../ViewportContainer2/Viewport"
|
||||
var viewport: Viewport = $"../../../../ViewportContainer2/Viewport2"
|
||||
viewport.world_2d = ($"../.." as Viewport).world_2d
|
||||
camera.custom_viewport = viewport
|
||||
yield(get_tree(), "idle_frame")
|
||||
camera.make_current()
|
||||
|
||||
|
||||
# Physics process is a built-in loop in Godot.
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
const LIMIT_LEFT = -315
|
||||
const LIMIT_TOP = -250
|
||||
const LIMIT_RIGHT = 955
|
||||
const LIMIT_BOTTOM = 690
|
||||
|
||||
|
||||
func _ready():
|
||||
for child in get_children():
|
||||
if child is Player:
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
extends AudioStreamPlayer
|
||||
|
||||
|
||||
const DOUBLE_VOLUME_DB = 6 # Do not change. Represents doubling of sound pressure.
|
||||
|
||||
export(int) var base_volume_db = -14
|
||||
|
||||
|
||||
func _ready():
|
||||
# To avoid AudioStreamPlayer2D sounds playing on top of each other and
|
||||
# being very loud, let's decrease the volume for splitscreen mode, but
|
||||
|
||||
@@ -25,10 +25,18 @@ func _unhandled_input(event):
|
||||
if event.is_action_pressed("toggle_fullscreen"):
|
||||
OS.window_fullscreen = not OS.window_fullscreen
|
||||
get_tree().set_input_as_handled()
|
||||
# The GlobalControls node, in the Stage scene, is set to process even
|
||||
# when the game is paused, so this code keeps running.
|
||||
# To see that, select GlobalControls, and scroll down to the Pause category
|
||||
# in the inspector.
|
||||
# The desired behavior is when pausing is to pause the gamplay,
|
||||
# but the Pause Menu should continue to process.
|
||||
# To achieve this, the "Pause Mode" field is used on nodes in the Game scene:
|
||||
# 1. The root node in the Game scene is set to process even when the game is paused
|
||||
# (via Pause Mode = Process), so this Game script keeps running in order to open/close
|
||||
# the Pause Menu when the player presses the "toggle_pause" action.
|
||||
# 2. The Level scene has Pause Mode = Stop (and its child Player scene has Pause Mode = Inherit),
|
||||
# so the gameplay will stop.
|
||||
# 3. The InterfaceLayer node has Pause Mode = Inherit, with its child PauseMenu scene having
|
||||
# Pause Mode = Process, so it will continue to process even when the game is paused.
|
||||
# To see the Pause Mode of any node, select the node and you'll see "Pause Mode" near the bottom
|
||||
# of the Inspector under "Node" fields.
|
||||
elif event.is_action_pressed("toggle_pause"):
|
||||
var tree = get_tree()
|
||||
tree.paused = not tree.paused
|
||||
|
||||
@@ -40,7 +40,7 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="Black/SplitContainer/ViewportContainer1"]
|
||||
[node name="Viewport1" type="Viewport" parent="Black/SplitContainer/ViewportContainer1"]
|
||||
size = Vector2( 394, 480 )
|
||||
size_override_stretch = true
|
||||
handle_input_locally = false
|
||||
@@ -48,13 +48,13 @@ usage = 0
|
||||
render_target_update_mode = 3
|
||||
audio_listener_enable_2d = true
|
||||
|
||||
[node name="Level" parent="Black/SplitContainer/ViewportContainer1/Viewport" instance=ExtResource( 3 )]
|
||||
[node name="Level" parent="Black/SplitContainer/ViewportContainer1/Viewport1" instance=ExtResource( 3 )]
|
||||
|
||||
[node name="Player1" parent="Black/SplitContainer/ViewportContainer1/Viewport/Level" instance=ExtResource( 4 )]
|
||||
[node name="Player1" parent="Black/SplitContainer/ViewportContainer1/Viewport1/Level" instance=ExtResource( 4 )]
|
||||
position = Vector2( 90, 546 )
|
||||
action_suffix = "_p1"
|
||||
|
||||
[node name="Player2" parent="Black/SplitContainer/ViewportContainer1/Viewport/Level" instance=ExtResource( 4 )]
|
||||
[node name="Player2" parent="Black/SplitContainer/ViewportContainer1/Viewport1/Level" instance=ExtResource( 4 )]
|
||||
position = Vector2( 120, 546 )
|
||||
action_suffix = "_p2"
|
||||
|
||||
@@ -69,7 +69,7 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="Black/SplitContainer/ViewportContainer2"]
|
||||
[node name="Viewport2" type="Viewport" parent="Black/SplitContainer/ViewportContainer2"]
|
||||
size = Vector2( 394, 480 )
|
||||
size_override_stretch = true
|
||||
handle_input_locally = false
|
||||
@@ -77,4 +77,4 @@ usage = 0
|
||||
render_target_update_mode = 3
|
||||
audio_listener_enable_2d = true
|
||||
|
||||
[node name="ParallaxBackground" parent="Black/SplitContainer/ViewportContainer2/Viewport" instance=ExtResource( 5 )]
|
||||
[node name="ParallaxBackground" parent="Black/SplitContainer/ViewportContainer2/Viewport2" instance=ExtResource( 5 )]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://assets/art/player/bullet/bullet.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/Objects/Bullet.gd" type="Script" id=2]
|
||||
@@ -8,21 +8,12 @@
|
||||
[sub_resource type="CanvasItemMaterial" id=2]
|
||||
blend_mode = 1
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=3]
|
||||
flag_disable_z = true
|
||||
spread = 0.0
|
||||
gravity = Vector3( 0, 0, 0 )
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
scale = 0.8
|
||||
color = Color( 1, 1, 1, 0.705882 )
|
||||
[sub_resource type="CanvasItemMaterial" id=3]
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id=4]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=5]
|
||||
[sub_resource type="CircleShape2D" id=4]
|
||||
radius = 4.5
|
||||
|
||||
[sub_resource type="Animation" id=6]
|
||||
[sub_resource type="Animation" id=5]
|
||||
resource_name = "destroy"
|
||||
length = 0.3
|
||||
tracks/0/type = "method"
|
||||
@@ -73,27 +64,31 @@ contacts_reported = 1
|
||||
contact_monitor = true
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Particles2D" type="Particles2D" parent="."]
|
||||
[node name="Particles2D" type="CPUParticles2D" parent="."]
|
||||
material = SubResource( 2 )
|
||||
emitting = false
|
||||
lifetime = 0.3
|
||||
speed_scale = 3.0
|
||||
local_coords = false
|
||||
process_material = SubResource( 3 )
|
||||
texture = ExtResource( 1 )
|
||||
spread = 0.0
|
||||
gravity = Vector2( 0, 0 )
|
||||
scale_amount = 0.8
|
||||
color = Color( 1, 1, 1, 0.705882 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 4 )
|
||||
material = SubResource( 3 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 5 )
|
||||
shape = SubResource( 4 )
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/destroy = SubResource( 6 )
|
||||
anims/destroy = SubResource( 5 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="timeout" from="Timer" to="." method="destroy"]
|
||||
|
||||
@@ -2,6 +2,7 @@ class_name Coin
|
||||
extends Area2D
|
||||
# Collectible that disappears when the player touches it.
|
||||
|
||||
|
||||
onready var animation_player = $AnimationPlayer
|
||||
|
||||
# The Coins only detects collisions with the Player thanks to its collision mask.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Panel
|
||||
|
||||
|
||||
var coins_collected = 0
|
||||
|
||||
onready var coins_label = $Label
|
||||
@@ -12,7 +13,7 @@ func _ready():
|
||||
anim_sprite.play()
|
||||
# Check if the game is in splitscreen mode by checking the scene root name.
|
||||
if get_tree().get_root().get_child(0).name == "Splitscreen":
|
||||
var _level_node = get_node(@"../../../../Black/SplitContainer/ViewportContainer1/Viewport/Level")
|
||||
var _level_node = get_node(@"../../../../Black/SplitContainer/ViewportContainer1/Viewport1/Level")
|
||||
_level_node.get_node("Player1").connect("collect_coin", self, "_collect_coin")
|
||||
_level_node.get_node("Player2").connect("collect_coin", self, "_collect_coin")
|
||||
else:
|
||||
|
||||
@@ -40,9 +40,6 @@ rect_min_size = Vector2( 100, 45 )
|
||||
theme = ExtResource( 1 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user