Compare commits
77 Commits
3.2-5c154d
...
3.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf94d62472 | ||
|
|
95d97d9001 | ||
|
|
53ea602c07 | ||
|
|
874d3bcc33 | ||
|
|
cbb5c94c6f | ||
|
|
44aefaecb6 | ||
|
|
7a7af4cf4e | ||
|
|
1916f87ac5 | ||
|
|
36e8b45bd4 | ||
|
|
89b64e33e2 | ||
|
|
2b10e6724e | ||
|
|
b9685cb369 | ||
|
|
d1f25ca4aa | ||
|
|
11a72411cc | ||
|
|
5057fcff50 | ||
|
|
d791cd9bda | ||
|
|
7d7c728227 | ||
|
|
5fb81434e7 | ||
|
|
c3c4fdf4fa | ||
|
|
9ea18370d3 | ||
|
|
f9333dce01 | ||
|
|
84a87a5128 | ||
|
|
7d64830cfe | ||
|
|
f08916c90f | ||
|
|
89978a7421 | ||
|
|
6ca2a45a21 | ||
|
|
57f8628b50 | ||
|
|
a4e8231f5a | ||
|
|
f71816ed31 | ||
|
|
ef069d49ae | ||
|
|
742ea87708 | ||
|
|
45f5417822 | ||
|
|
f28a09ea0d | ||
|
|
85c1805d33 | ||
|
|
7e129db12e | ||
|
|
7bfc57d1ae | ||
|
|
cd48c9a9cc | ||
|
|
244b759787 | ||
|
|
6875a21545 | ||
|
|
694ee7fa36 | ||
|
|
6e3db7c64d | ||
|
|
2d4d23302a | ||
|
|
4456027f91 | ||
|
|
19312b2899 | ||
|
|
ca17967de1 | ||
|
|
491fb265b1 | ||
|
|
08be1b7f03 | ||
|
|
4ef90a836a | ||
|
|
bfd903a933 | ||
|
|
e0db0b8f6d | ||
|
|
4d21951b71 | ||
|
|
7656c08454 | ||
|
|
e894e4655a | ||
|
|
2ce76ff4e5 | ||
|
|
e5d829eb8f | ||
|
|
7f025e000e | ||
|
|
5132941a84 | ||
|
|
ef265cca0a | ||
|
|
31bb09233b | ||
|
|
57f5e0835d | ||
|
|
814909538f | ||
|
|
94ec2ea5d9 | ||
|
|
40aec7c068 | ||
|
|
ead2777f48 | ||
|
|
0a0d44d4f1 | ||
|
|
4911866f3d | ||
|
|
d7e1052205 | ||
|
|
8e2dbf3f55 | ||
|
|
2ee9b47f6c | ||
|
|
d8dc94c1ff | ||
|
|
d989bf6209 | ||
|
|
021070215c | ||
|
|
ac61cba05b | ||
|
|
21e829416f | ||
|
|
cf7e4b31f4 | ||
|
|
dc5c1016ce | ||
|
|
8a0824a948 |
@@ -2,10 +2,15 @@
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file.
|
||||
[*.cs]
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.cs]
|
||||
csharp_space_after_cast = false
|
||||
indent_size = 4
|
||||
|
||||
[*.csproj]
|
||||
insert_final_newline = false
|
||||
indent_size = 2
|
||||
|
||||
13
.github/CODEOWNERS
vendored
@@ -2,7 +2,12 @@
|
||||
# Each line is a file pattern followed by one or more owners.
|
||||
# Owners can be @users, @org/teams or emails
|
||||
|
||||
/misc/2.5d @aaronfranke
|
||||
/mono/2.5d @aaronfranke
|
||||
/2d/physics_tests @pouleyKetchoupp
|
||||
/3d/physics_tests @pouleyKetchoupp
|
||||
/.github/dist/ @Calinou
|
||||
|
||||
/3d/voxel/ @aaronfranke
|
||||
/misc/matrix_transform/ @aaronfranke
|
||||
/misc/2.5d/ @aaronfranke
|
||||
/mono/2.5d/ @aaronfranke
|
||||
|
||||
/2d/physics_tests/ @pouleyKetchoupp
|
||||
/3d/physics_tests/ @pouleyKetchoupp
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -1,9 +1,9 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Report a bug with one of the demo projects.
|
||||
title: ''
|
||||
title: ""
|
||||
labels: bug
|
||||
assignees: ''
|
||||
assignees: ""
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
name: Feature / Enhancement Request
|
||||
about: Adding new features or improving existing ones.
|
||||
title: ''
|
||||
title: ""
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
assignees: ""
|
||||
|
||||
---
|
||||
|
||||
|
||||
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.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
|
||||
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
@@ -18,4 +18,5 @@ mono_crash.*.json
|
||||
|
||||
# System/tool-specific ignores
|
||||
.directory
|
||||
.DS_Store
|
||||
*~
|
||||
|
||||
@@ -11,6 +11,8 @@ Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/887
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
@@ -38,6 +38,10 @@ func _ready():
|
||||
|
||||
Physics2DServer.body_set_space(bullet.body, get_world_2d().get_space())
|
||||
Physics2DServer.body_add_shape(bullet.body, shape)
|
||||
# Don't make bullets check collision with other bullets to improve performance.
|
||||
# Their collision mask is still configured to the default value, which allows
|
||||
# bullets to detect collisions with the player.
|
||||
Physics2DServer.body_set_collision_layer(bullet.body, 0)
|
||||
|
||||
# Place bullets randomly on the viewport and move bullets outside the
|
||||
# play area so that they fade in nicely.
|
||||
@@ -52,22 +56,25 @@ func _ready():
|
||||
bullets.push_back(bullet)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta):
|
||||
# Order the CanvasItem to update every frame.
|
||||
update()
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
var transform2d = Transform2D()
|
||||
var offset = get_viewport_rect().size.x + 16
|
||||
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
|
||||
bullet.position.x = offset
|
||||
|
||||
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.
|
||||
|
||||
@@ -29,5 +29,6 @@ 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"]
|
||||
|
||||
@@ -53,5 +53,6 @@ text = "Start"
|
||||
|
||||
[node name="MessageTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="pressed" from="StartButton" to="." method="_on_StartButton_pressed"]
|
||||
[connection signal="timeout" from="MessageTimer" to="." method="_on_MessageTimer_timeout"]
|
||||
|
||||
@@ -44,8 +44,8 @@ func _on_MobTimer_timeout():
|
||||
direction += rand_range(-PI / 4, PI / 4)
|
||||
mob.rotation = direction
|
||||
|
||||
# Choose the velocity.
|
||||
var velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
|
||||
# Choose the velocity for the mob.
|
||||
var velocity = Vector2(rand_range(150.0, 250.0), 0.0)
|
||||
mob.linear_velocity = velocity.rotated(direction)
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ stream = ExtResource( 5 )
|
||||
|
||||
[node name="DeathSound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 6 )
|
||||
|
||||
[connection signal="hit" from="Player" to="." method="game_over"]
|
||||
[connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]
|
||||
[connection signal="timeout" from="ScoreTimer" to="." method="_on_ScoreTimer_timeout"]
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
extends RigidBody2D
|
||||
|
||||
#warning-ignore-all:unused_class_variable
|
||||
export var min_speed = 150
|
||||
export var max_speed = 250
|
||||
|
||||
func _ready():
|
||||
$AnimatedSprite.playing = true
|
||||
var mob_types = $AnimatedSprite.frames.get_animation_names()
|
||||
@@ -12,7 +8,3 @@ func _ready():
|
||||
|
||||
func _on_VisibilityNotifier2D_screen_exited():
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_start_game():
|
||||
queue_free()
|
||||
|
||||
@@ -50,4 +50,5 @@ rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
|
||||
|
||||
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
||||
|
||||
@@ -67,4 +67,5 @@ speed_scale = 2.0
|
||||
local_coords = false
|
||||
process_material = SubResource( 7 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]
|
||||
|
||||
@@ -14,12 +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).
|
||||
|
||||
Note: There is a GDNative C++ version available [here](https://github.com/godotengine/gdnative-demos/tree/master/cpp/dodge_the_creeps).
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/515
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 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
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Dodge the Creeps"
|
||||
@@ -29,6 +24,8 @@ config/icon="res://icon.png"
|
||||
|
||||
window/size/width=480
|
||||
window/size/height=720
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="keep"
|
||||
|
||||
[input]
|
||||
|
||||
|
||||
0
2d/dodge_the_creeps/screenshots/.gdignore
Normal file
BIN
2d/dodge_the_creeps/screenshots/dodge.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
@@ -1,15 +1,50 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://player/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://debug/Explanations.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://fonts/source_code_pro_explanations.tres" type="DynamicFont" id=2]
|
||||
[ext_resource path="res://debug/StatesStackDiplayer.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://debug/ControlsPanel.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://fonts/source_code_pro_explanations_bold.tres" type="DynamicFont" id=5]
|
||||
|
||||
[node name="Demo" type="Node"]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 640, 400 )
|
||||
|
||||
[node name="Explanations" parent="." instance=ExtResource( 2 )]
|
||||
[node name="Explanations" type="RichTextLabel" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = -370.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -730.0
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
size_flags_vertical = 4
|
||||
custom_fonts/bold_font = ExtResource( 5 )
|
||||
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.
|
||||
|
||||
States are common in games. You can use the pattern to:
|
||||
|
||||
1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage
|
||||
2. Respect the Single Responsibility Principle. Each State object represents [b]one[/b] action
|
||||
3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
|
||||
|
||||
You can read more about States in the excellent [url=http://gameprogrammingpatterns.com/state.html]Game Programming Patterns ebook[/url]."
|
||||
text = "This example shows how to apply the State programming pattern in GDScript, including Hierarchical States, and a pushdown automaton.
|
||||
|
||||
States are common in games. You can use the pattern to:
|
||||
|
||||
1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage
|
||||
2. Respect the Single Responsibility Principle. Each State object represents one action
|
||||
3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
|
||||
|
||||
You can read more about States in the excellent Game Programming Patterns ebook."
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
anchor_right = 1.0
|
||||
|
||||
@@ -7,7 +7,7 @@ func _process(_delta):
|
||||
var numbers = ""
|
||||
var index = 0
|
||||
for state in fsm_node.states_stack:
|
||||
states_names += state.get_name() + "\n"
|
||||
states_names += String(state.get_name()) + "\n"
|
||||
numbers += str(index) + "\n"
|
||||
index += 1
|
||||
$States.text = states_names
|
||||
|
||||
@@ -41,7 +41,6 @@ use_filter = true
|
||||
font_data = ExtResource( 14 )
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
position = Vector2( 628.826, 391.266 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ ]
|
||||
@@ -81,11 +80,11 @@ texture = ExtResource( 9 )
|
||||
[node name="BodyPivot" type="Position2D" parent="."]
|
||||
|
||||
[node name="Body" type="Sprite" parent="BodyPivot"]
|
||||
position = Vector2( 0, -58.8242 )
|
||||
position = Vector2( 0, -58 )
|
||||
texture = ExtResource( 10 )
|
||||
|
||||
[node name="BulletSpawn" type="Node2D" parent="BodyPivot"]
|
||||
position = Vector2( 1.17401, -61.266 )
|
||||
position = Vector2( 0, -58 )
|
||||
script = ExtResource( 11 )
|
||||
|
||||
[node name="CooldownTimer" type="Timer" parent="BodyPivot/BulletSpawn"]
|
||||
@@ -93,7 +92,7 @@ wait_time = 0.2
|
||||
one_shot = true
|
||||
|
||||
[node name="WeaponPivot" type="Position2D" parent="BodyPivot"]
|
||||
position = Vector2( 1.17401, -61.266 )
|
||||
position = Vector2( 0, -58 )
|
||||
script = ExtResource( 12 )
|
||||
|
||||
[node name="Offset" type="Position2D" parent="BodyPivot/WeaponPivot"]
|
||||
@@ -110,11 +109,15 @@ margin_top = -172.0
|
||||
margin_right = 110.0
|
||||
margin_bottom = -138.0
|
||||
custom_fonts/font = SubResource( 4 )
|
||||
text = "Test"
|
||||
text = "Idle"
|
||||
align = 1
|
||||
valign = 1
|
||||
uppercase = true
|
||||
script = ExtResource( 15 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[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"]
|
||||
|
||||
@@ -4,14 +4,15 @@ var bullet = preload("Bullet.tscn")
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event.is_action_pressed("fire"):
|
||||
fire(owner.look_direction)
|
||||
fire()
|
||||
|
||||
|
||||
func fire(direction):
|
||||
func fire():
|
||||
if not $CooldownTimer.is_stopped():
|
||||
return
|
||||
|
||||
$CooldownTimer.start()
|
||||
var new_bullet = bullet.instance()
|
||||
new_bullet.direction = direction
|
||||
add_child(new_bullet)
|
||||
new_bullet.position = global_position
|
||||
new_bullet.direction = owner.look_direction
|
||||
|
||||
@@ -11,4 +11,4 @@ func _physics_process(_delta):
|
||||
|
||||
|
||||
func _on_StateMachine_state_changed(current_state):
|
||||
text = current_state.get_name()
|
||||
text = String(current_state.get_name())
|
||||
|
||||
@@ -19,7 +19,10 @@ var height = 0.0
|
||||
|
||||
func initialize(speed, velocity):
|
||||
horizontal_speed = speed
|
||||
max_horizontal_speed = speed if speed > 0.0 else base_max_horizontal_speed
|
||||
if speed > 0.0:
|
||||
max_horizontal_speed = speed
|
||||
else:
|
||||
max_horizontal_speed = base_max_horizontal_speed
|
||||
enter_velocity = velocity
|
||||
|
||||
|
||||
@@ -27,7 +30,10 @@ func enter():
|
||||
var input_direction = get_input_direction()
|
||||
update_look_direction(input_direction)
|
||||
|
||||
horizontal_velocity = enter_velocity if input_direction else Vector2()
|
||||
if input_direction:
|
||||
horizontal_velocity = enter_velocity
|
||||
else:
|
||||
horizontal_velocity = Vector2()
|
||||
vertical_speed = 600.0
|
||||
|
||||
owner.get_node("AnimationPlayer").play("idle")
|
||||
|
||||
@@ -22,7 +22,11 @@ func update(_delta):
|
||||
emit_signal("finished", "idle")
|
||||
update_look_direction(input_direction)
|
||||
|
||||
speed = max_run_speed if Input.is_action_pressed("run") else max_walk_speed
|
||||
if Input.is_action_pressed("run"):
|
||||
speed = max_run_speed
|
||||
else:
|
||||
speed = max_walk_speed
|
||||
|
||||
var collision_info = move(speed, input_direction)
|
||||
if not collision_info:
|
||||
return
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Hierarchical Finite State Machine"
|
||||
@@ -102,3 +97,5 @@ attack={
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="GD Paint"
|
||||
@@ -37,3 +32,5 @@ singletons=[ ]
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="HDR for 2D"
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Hexagonal Game"
|
||||
@@ -68,4 +63,6 @@ move_up={
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 0.172549, 0.219608, 0.129412, 1 )
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Scene Instancing Demo"
|
||||
@@ -39,4 +34,6 @@ singletons=[ ]
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 0.301961, 0.301961, 0.301961, 1 )
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Isometric Game"
|
||||
@@ -80,4 +75,6 @@ use_pixel_snap=true
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 0.0784314, 0.105882, 0.145098, 1 )
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Kinematic Character 2D"
|
||||
@@ -76,4 +71,6 @@ multithread/thread_rid_pool_prealloc=60
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 0.156, 0.1325, 0.25, 1 )
|
||||
|
||||
@@ -266,4 +266,5 @@ shape = SubResource( 12 )
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
offset = Vector2( 265, 247 )
|
||||
current = true
|
||||
|
||||
[connection signal="body_entered" from="Princess" to="Princess" method="_on_body_entered"]
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="2D Lights as Mask"
|
||||
@@ -37,3 +32,5 @@ shadow_filter=3
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="2D Lights and Shadows"
|
||||
@@ -41,3 +36,5 @@ shadow_filter=2
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Navigation Polygon 2D"
|
||||
@@ -46,4 +41,6 @@ click={
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 0.160784, 0.172549, 0.278431, 1 )
|
||||
|
||||
@@ -6,7 +6,7 @@ const MASS = 10.0
|
||||
const ARRIVE_DISTANCE = 10.0
|
||||
|
||||
export(float) var speed = 200.0
|
||||
var _state = null
|
||||
var _state = States.IDLE
|
||||
|
||||
var _path = []
|
||||
var _target_point_world = Vector2()
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Grid-based Pathfinding with Astar"
|
||||
@@ -38,3 +33,5 @@ click={
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="2D Particles"
|
||||
|
||||
@@ -142,4 +142,5 @@ texture = ExtResource( 4 )
|
||||
[node name="Enabler" type="VisibilityEnabler2D" parent="."]
|
||||
rect = Rect2( -5, -5, 10, 10 )
|
||||
pause_particles = false
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_enter"]
|
||||
|
||||
@@ -83,4 +83,5 @@ one_shot = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/shutdown = SubResource( 4 )
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="disable"]
|
||||
|
||||
@@ -215,8 +215,8 @@ script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
vframes = 2
|
||||
hframes = 16
|
||||
vframes = 2
|
||||
|
||||
[node name="Smoke" type="Particles2D" parent="Sprite"]
|
||||
self_modulate = Color( 1, 1, 1, 0.26702 )
|
||||
|
||||
@@ -156,10 +156,11 @@ mipmap_policy=1
|
||||
|
||||
quality/intended_usage/framebuffer_allocation=0
|
||||
quality/intended_usage/framebuffer_allocation.mobile=1
|
||||
quality/2d/use_pixel_snap=true
|
||||
2d/snapping/use_gpu_pixel_snap=true
|
||||
quality/filters/anisotropic_filter_level=2
|
||||
quality/filters/use_nearest_mipmap_filter=true
|
||||
quality/depth/hdr=false
|
||||
quality/2d/use_pixel_snap=true
|
||||
|
||||
[texture_import]
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ This demo contains a series of tests for the 2D
|
||||
physics engine.
|
||||
|
||||
They can be used for different purpose:
|
||||
|
||||
- Functional tests to check for regressions and
|
||||
behavior of the 2D physics engine
|
||||
- Performance tests to evaluate performance
|
||||
@@ -13,6 +14,8 @@ Language: GDScript
|
||||
|
||||
Renderer: GLES 2
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/888
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
@@ -193,5 +193,6 @@ max_lines_visible = 5
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="PanelLog/ButtonClear" to="PanelLog/ScrollLog/VBoxLog" method="clear"]
|
||||
[connection signal="toggled" from="PanelLog/CheckBoxScroll" to="PanelLog/ScrollLog" method="set_auto_scroll"]
|
||||
|
||||
@@ -33,6 +33,12 @@ _global_script_class_icons={
|
||||
[application]
|
||||
|
||||
config/name="2D Physics Tests"
|
||||
config/description="This demo contains a series of tests for the 2D physics engine.
|
||||
|
||||
They can be used for different purpose:
|
||||
|
||||
- Functional tests to check for regressions and behavior of the 2D physics engine
|
||||
- Performance tests to evaluate performance of the 2D physics engine"
|
||||
run/main_scene="res://main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
@@ -120,5 +126,7 @@ limits/message_queue/max_size_kb=10240
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_clear_color=Color( 0.184314, 0.184314, 0.184314, 1 )
|
||||
quality/filters/msaa=2
|
||||
|
||||
@@ -68,12 +68,10 @@ func clear_drawn_nodes():
|
||||
_drawn_nodes.clear()
|
||||
|
||||
|
||||
func create_rigidbody_box(size, pickable = false, use_icon = false):
|
||||
var shape = RectangleShape2D.new()
|
||||
shape.extents = 0.5 * size
|
||||
|
||||
func create_rigidbody(shape, pickable = false, transform = Transform.IDENTITY):
|
||||
var collision = CollisionShape2D.new()
|
||||
collision.shape = shape
|
||||
collision.transform = transform
|
||||
|
||||
var body = RigidBody2D.new()
|
||||
body.add_child(collision)
|
||||
@@ -82,6 +80,15 @@ func create_rigidbody_box(size, pickable = false, use_icon = false):
|
||||
var script = load("res://utils/rigidbody_pick.gd")
|
||||
body.set_script(script)
|
||||
|
||||
return body
|
||||
|
||||
|
||||
func create_rigidbody_box(size, pickable = false, use_icon = false, transform = Transform.IDENTITY):
|
||||
var shape = RectangleShape2D.new()
|
||||
shape.extents = 0.5 * size
|
||||
|
||||
var body = create_rigidbody(shape, pickable, transform)
|
||||
|
||||
if use_icon:
|
||||
var texture = load("res://icon.png")
|
||||
var icon = Sprite.new()
|
||||
|
||||
@@ -50,6 +50,10 @@ var _tests = [
|
||||
"id": "Performance Tests/Contacts",
|
||||
"path": "res://tests/performance/test_perf_contacts.tscn",
|
||||
},
|
||||
{
|
||||
"id" : "Performance Tests/Contact Islands",
|
||||
"path" : "res://tests/performance/test_perf_contact_islands.tscn",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ func _initialize_collision_shapes():
|
||||
for node in $Shapes.get_children():
|
||||
var body = node as PhysicsBody2D
|
||||
var shape = body.shape_owner_get_shape(0, 0)
|
||||
shape.resource_name = node.name.substr("RigidBody".length())
|
||||
shape.resource_name = String(node.name).substr("RigidBody".length())
|
||||
|
||||
_collision_shapes.push_back(shape)
|
||||
|
||||
@@ -167,7 +167,7 @@ func _on_option_selected(option):
|
||||
|
||||
|
||||
func _find_type_index(type_name):
|
||||
for type_index in _collision_shapes.size():
|
||||
for type_index in range(_collision_shapes.size()):
|
||||
var type_shape = _collision_shapes[type_index]
|
||||
if type_shape.resource_name.find(type_name) > -1:
|
||||
return type_index
|
||||
|
||||
@@ -146,5 +146,6 @@ rect_min_size = Vector2( 120, 0 )
|
||||
min_value = -1.0
|
||||
max_value = 1.0
|
||||
step = 0.01
|
||||
|
||||
[connection signal="value_changed" from="Controls/OffsetH/HSlider" to="." method="set_h_offset"]
|
||||
[connection signal="value_changed" from="Controls/OffsetV/HSlider" to="." method="set_v_offset"]
|
||||
|
||||
@@ -11,8 +11,6 @@ const OPTION_TEST_CASE_CHANGE_POSITIONS = "Test case/Set body positions after ad
|
||||
|
||||
const BOX_SIZE = Vector2(64, 64)
|
||||
|
||||
onready var options = $Options
|
||||
|
||||
var _update_joint = false
|
||||
var _selected_joint = null
|
||||
|
||||
@@ -27,8 +25,10 @@ var _joint_types = {}
|
||||
|
||||
|
||||
func _ready():
|
||||
var options = $Options
|
||||
|
||||
var joints = $Joints
|
||||
for joint_index in joints.get_child_count():
|
||||
for joint_index in range(joints.get_child_count()):
|
||||
var joint_node = joints.get_child(joint_index)
|
||||
joint_node.visible = false
|
||||
var joint_name = joint_node.name
|
||||
|
||||
@@ -17,13 +17,6 @@ extents = Vector2( 32, 32 )
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
_enable_debug_collision = true
|
||||
_platform_size = 64.0
|
||||
_platform_angle = 0.0
|
||||
_platform_speed = 0.0
|
||||
_body_angle = 0.0
|
||||
_body_velocity = Vector2( 400, 0 )
|
||||
_use_kinematic_body = false
|
||||
|
||||
[node name="LabelTestType" type="Label" parent="."]
|
||||
margin_left = 14.0
|
||||
@@ -245,6 +238,7 @@ texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"]
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[connection signal="value_changed" from="Controls/PlatformSize/HSlider" to="." method="_set_platform_size"]
|
||||
[connection signal="value_changed" from="Controls/PlatformAngle/HSlider" to="." method="_set_platform_angle"]
|
||||
[connection signal="value_changed" from="Controls/BodyAngle/HSlider" to="." method="_set_rigidbody_angle"]
|
||||
|
||||
@@ -28,7 +28,7 @@ func _create_pyramid():
|
||||
|
||||
var pos_x = -0.5 * (num_boxes - 1) * (box_size.x + box_spacing.x)
|
||||
|
||||
for box_index in num_boxes:
|
||||
for box_index in range(num_boxes):
|
||||
var box = template_body.duplicate()
|
||||
box.position = Vector2(pos_x, 0.0)
|
||||
box.name = "Box%02d" % (box_index + 1)
|
||||
|
||||
@@ -25,7 +25,7 @@ func _physics_process(_delta):
|
||||
for node in $Shapes.get_children():
|
||||
var body = node as PhysicsBody2D
|
||||
var space_state = body.get_world_2d().direct_space_state
|
||||
var body_name = body.name.substr("RigidBody".length())
|
||||
var body_name = String(body.name).substr("RigidBody".length())
|
||||
|
||||
Log.print_log("* Testing: %s" % body_name)
|
||||
|
||||
@@ -45,7 +45,7 @@ func _physics_process(_delta):
|
||||
res = _add_raycast(space_state, center, center + Vector2(0, 40))
|
||||
Log.print_log("Raycast inside: %s" % ("HIT" if res else "NO HIT"))
|
||||
|
||||
if body.name.ends_with("ConcavePolygon"):
|
||||
if String(body.name).ends_with("ConcavePolygon"):
|
||||
# Raycast inside an internal face.
|
||||
center.x += 20
|
||||
res = _add_raycast(space_state, center, center + Vector2(0, 40))
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=1]
|
||||
[ext_resource path="res://test.gd" type="Script" id=2]
|
||||
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=3]
|
||||
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=6]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
@@ -21,6 +22,7 @@ script = ExtResource( 2 )
|
||||
|
||||
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 96, 127 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
|
||||
rotation = 0.675442
|
||||
@@ -28,6 +30,7 @@ shape = SubResource( 1 )
|
||||
|
||||
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 270.165, 139.444 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
|
||||
rotation = -0.202458
|
||||
@@ -35,6 +38,7 @@ shape = SubResource( 2 )
|
||||
|
||||
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 683.614, 132.749 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
@@ -47,6 +51,7 @@ texture = ExtResource( 1 )
|
||||
|
||||
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 473.536, 134.336 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
@@ -59,6 +64,7 @@ texture = ExtResource( 1 )
|
||||
|
||||
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 919.968, 115.129 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
|
||||
shape = SubResource( 3 )
|
||||
|
||||
@@ -26,7 +26,7 @@ func _create_stack():
|
||||
|
||||
var pos_x = -0.5 * (width - 1) * (box_size.x + box_spacing.x)
|
||||
|
||||
for box_index in width:
|
||||
for box_index in range(width):
|
||||
var box = template_body.duplicate()
|
||||
box.position = Vector2(pos_x, 0.0)
|
||||
box.name = "Box%02d" % (box_index + 1)
|
||||
|
||||
@@ -148,7 +148,7 @@ func _remove_objects():
|
||||
|
||||
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
|
||||
var object_count = _objects.size()
|
||||
for object_index in object_count:
|
||||
for object_index in range(object_count):
|
||||
root_node.remove_child(_objects[object_count - object_index - 1])
|
||||
|
||||
timer = OS.get_ticks_usec() - timer
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://tests/static_scene.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://tests/performance/test_perf_contacts.gd" type="Script" id=2]
|
||||
[ext_resource path="res://assets/texture/godot-head.png" type="Texture" id=3]
|
||||
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 5, 7 )
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
radius = 5.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=3]
|
||||
radius = 5.0
|
||||
height = 7.0
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
_enable_debug_collision = false
|
||||
spawns = [ NodePath("SpawnTarget1"), NodePath("SpawnTarget2"), NodePath("SpawnTarget3"), NodePath("SpawnTarget4"), NodePath("SpawnTarget5"), NodePath("SpawnTarget6"), NodePath("SpawnTarget7"), NodePath("SpawnTarget8"), NodePath("SpawnTarget9") ]
|
||||
spawn_count = 300
|
||||
spawn_randomize = Vector2( 10, 10 )
|
||||
|
||||
[node name="Options" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
[node name="SpawnTarget1" type="Node2D" parent="."]
|
||||
position = Vector2( 145.646, 109.462 )
|
||||
|
||||
[node name="SpawnTarget2" type="Node2D" parent="."]
|
||||
position = Vector2( 508.14, 109.113 )
|
||||
|
||||
[node name="SpawnTarget3" type="Node2D" parent="."]
|
||||
position = Vector2( 873.995, 110.042 )
|
||||
|
||||
[node name="SpawnTarget4" type="Node2D" parent="."]
|
||||
position = Vector2( 149.646, 301.462 )
|
||||
|
||||
[node name="SpawnTarget5" type="Node2D" parent="."]
|
||||
position = Vector2( 512.14, 301.113 )
|
||||
|
||||
[node name="SpawnTarget6" type="Node2D" parent="."]
|
||||
position = Vector2( 877.995, 302.042 )
|
||||
|
||||
[node name="SpawnTarget7" type="Node2D" parent="."]
|
||||
position = Vector2( 165.646, 507.462 )
|
||||
|
||||
[node name="SpawnTarget8" type="Node2D" parent="."]
|
||||
position = Vector2( 528.14, 507.113 )
|
||||
|
||||
[node name="SpawnTarget9" type="Node2D" parent="."]
|
||||
position = Vector2( 893.995, 508.042 )
|
||||
|
||||
[node name="StaticScene" parent="." instance=ExtResource( 1 )]
|
||||
visible = false
|
||||
position = Vector2( 0, 125.017 )
|
||||
|
||||
[node name="DynamicShapes" type="Node2D" parent="."]
|
||||
|
||||
[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 0, 1024 )
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 100, 1024 )
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 200, 1024 )
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 300, 1024 )
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
|
||||
scale = Vector2( 0.1, 0.1 )
|
||||
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
|
||||
|
||||
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConvexPolygon"]
|
||||
self_modulate = Color( 1, 1, 1, 0.392157 )
|
||||
scale = Vector2( 0.1, 0.1 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 400, 1024 )
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
|
||||
scale = Vector2( 0.1, 0.1 )
|
||||
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
|
||||
|
||||
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConcavePolygon"]
|
||||
self_modulate = Color( 1, 1, 1, 0.392157 )
|
||||
scale = Vector2( 0.1, 0.1 )
|
||||
texture = ExtResource( 3 )
|
||||
@@ -8,14 +8,18 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
|
||||
const OPTION_TYPE_CONVEX_POLYGON = "Shape type/Convex Polygon"
|
||||
const OPTION_TYPE_CONCAVE_POLYGON = "Shape type/Concave Polygon"
|
||||
|
||||
export(Array) var spawns = Array()
|
||||
export(Array, NodePath) var spawns = Array()
|
||||
export(int) var spawn_count = 100
|
||||
export(int, 1, 10) var spawn_multiplier = 5
|
||||
export(Vector2) var spawn_randomize
|
||||
|
||||
onready var options = $Options
|
||||
|
||||
var _object_templates = []
|
||||
|
||||
var _log_physics = false
|
||||
var _log_physics_time = 0
|
||||
var _log_physics_time_start = 0
|
||||
|
||||
|
||||
func _ready():
|
||||
yield(start_timer(0.5), "timeout")
|
||||
@@ -40,6 +44,25 @@ func _ready():
|
||||
_start_all_types()
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
if _log_physics:
|
||||
var time = OS.get_ticks_usec()
|
||||
var time_delta = time - _log_physics_time
|
||||
var time_total = time - _log_physics_time_start
|
||||
_log_physics_time = time
|
||||
Log.print_log(" Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
|
||||
|
||||
|
||||
func _log_physics_start():
|
||||
_log_physics = true
|
||||
_log_physics_time_start = OS.get_ticks_usec()
|
||||
_log_physics_time = _log_physics_time_start
|
||||
|
||||
|
||||
func _log_physics_stop():
|
||||
_log_physics = false
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
for object_template in _object_templates:
|
||||
object_template.free()
|
||||
@@ -66,9 +89,9 @@ func _on_option_selected(option):
|
||||
|
||||
|
||||
func _find_type_index(type_name):
|
||||
for type_index in _object_templates.size():
|
||||
for type_index in range(_object_templates.size()):
|
||||
var type_node = _object_templates[type_index]
|
||||
if type_node.name.find(type_name) > -1:
|
||||
if String(type_node.name).find(type_name) > -1:
|
||||
return type_index
|
||||
|
||||
Log.print_error("Invalid shape type: " + type_name)
|
||||
@@ -85,80 +108,98 @@ func _start_type(type_index):
|
||||
if is_timer_canceled():
|
||||
return
|
||||
|
||||
_log_physics_start()
|
||||
|
||||
_spawn_objects(type_index)
|
||||
|
||||
yield(wait_for_physics_ticks(5), "wait_done")
|
||||
_log_physics_stop()
|
||||
|
||||
yield(start_timer(1.0), "timeout")
|
||||
if is_timer_canceled():
|
||||
return
|
||||
|
||||
_log_physics_start()
|
||||
|
||||
_activate_objects()
|
||||
|
||||
yield(wait_for_physics_ticks(5), "wait_done")
|
||||
_log_physics_stop()
|
||||
|
||||
yield(start_timer(5.0), "timeout")
|
||||
if is_timer_canceled():
|
||||
return
|
||||
|
||||
_log_physics_start()
|
||||
|
||||
_despawn_objects()
|
||||
|
||||
Log.print_log("* Done.")
|
||||
yield(wait_for_physics_ticks(5), "wait_done")
|
||||
_log_physics_stop()
|
||||
|
||||
yield(start_timer(1.0), "timeout")
|
||||
|
||||
|
||||
func _start_all_types():
|
||||
for type_index in _object_templates.size():
|
||||
yield(start_timer(1.0), "timeout")
|
||||
Log.print_log("* Start all types.")
|
||||
|
||||
for type_index in range(_object_templates.size()):
|
||||
yield(_start_type(type_index), "completed")
|
||||
if is_timer_canceled():
|
||||
return
|
||||
|
||||
_spawn_objects(type_index)
|
||||
|
||||
yield(start_timer(1.0), "timeout")
|
||||
if is_timer_canceled():
|
||||
return
|
||||
|
||||
_activate_objects()
|
||||
|
||||
yield(start_timer(5.0), "timeout")
|
||||
if is_timer_canceled():
|
||||
return
|
||||
|
||||
_despawn_objects()
|
||||
|
||||
Log.print_log("* Done.")
|
||||
Log.print_log("* Done all types.")
|
||||
|
||||
|
||||
func _spawn_objects(type_index):
|
||||
var template_node = _object_templates[type_index]
|
||||
|
||||
Log.print_log("* Spawning: " + template_node.name)
|
||||
|
||||
for spawn in spawns:
|
||||
var spawn_parent = get_node(spawn)
|
||||
|
||||
Log.print_log("* Spawning: " + template_node.name)
|
||||
|
||||
for _index in range(spawn_multiplier):
|
||||
for _node_index in spawn_count / spawn_multiplier:
|
||||
var node = template_node.duplicate() as Node2D
|
||||
spawn_parent.add_child(node)
|
||||
for _node_index in range(spawn_count):
|
||||
# Create a new object and shape every time to avoid the overhead of connecting many bodies to the same shape.
|
||||
var collision = template_node.get_child(0).duplicate()
|
||||
if collision is CollisionShape2D:
|
||||
collision.shape = collision.shape.duplicate()
|
||||
var body = template_node.duplicate()
|
||||
body.transform = Transform.IDENTITY
|
||||
if spawn_randomize != Vector2.ZERO:
|
||||
body.position.x = randf() * spawn_randomize.x
|
||||
body.position.y = randf() * spawn_randomize.y
|
||||
var prev_collision = body.get_child(0)
|
||||
body.remove_child(prev_collision)
|
||||
prev_collision.queue_free()
|
||||
body.add_child(collision)
|
||||
body.set_sleeping(true)
|
||||
spawn_parent.add_child(body)
|
||||
|
||||
|
||||
func _activate_objects():
|
||||
var spawn_parent = $SpawnTarget1
|
||||
|
||||
Log.print_log("* Activating")
|
||||
|
||||
for node_index in spawn_parent.get_child_count():
|
||||
var node = spawn_parent.get_child(node_index) as RigidBody2D
|
||||
node.set_sleeping(false)
|
||||
|
||||
|
||||
func _despawn_objects():
|
||||
for spawn in spawns:
|
||||
var spawn_parent = get_node(spawn)
|
||||
|
||||
if spawn_parent.get_child_count() == 0:
|
||||
return
|
||||
for node_index in range(spawn_parent.get_child_count()):
|
||||
var node = spawn_parent.get_child(node_index) as RigidBody2D
|
||||
node.set_sleeping(false)
|
||||
|
||||
Log.print_log("* Despawning")
|
||||
|
||||
while spawn_parent.get_child_count():
|
||||
var node_index = spawn_parent.get_child_count() - 1
|
||||
var node = spawn_parent.get_child(node_index)
|
||||
func _despawn_objects():
|
||||
Log.print_log("* Despawning")
|
||||
|
||||
for spawn in spawns:
|
||||
var spawn_parent = get_node(spawn)
|
||||
|
||||
var object_count = spawn_parent.get_child_count()
|
||||
if object_count == 0:
|
||||
continue
|
||||
|
||||
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
|
||||
for object_index in range(object_count):
|
||||
var node = spawn_parent.get_child(object_count - object_index - 1)
|
||||
spawn_parent.remove_child(node)
|
||||
node.queue_free()
|
||||
|
||||
@@ -6,18 +6,20 @@
|
||||
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 20, 30 )
|
||||
extents = Vector2( 10, 15 )
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
radius = 30.0
|
||||
radius = 15.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=3]
|
||||
radius = 20.0
|
||||
height = 30.0
|
||||
height = 15.0
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
_enable_debug_collision = false
|
||||
spawns = [ NodePath("SpawnTarget1") ]
|
||||
spawn_count = 500
|
||||
spawn_randomize = Vector2( 10, 10 )
|
||||
|
||||
[node name="Options" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
@@ -51,22 +53,22 @@ shape = SubResource( 3 )
|
||||
position = Vector2( 300, 1024 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
scale = Vector2( 0.25, 0.25 )
|
||||
polygon = PoolVector2Array( 10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806, 57.9717, -20.9447, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -58.0115, -20.515, -46.9473, -34.7342, -26.0876, -50.1138, -11.4152, -54.5332 )
|
||||
|
||||
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConvexPolygon"]
|
||||
self_modulate = Color( 1, 1, 1, 0.392157 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
scale = Vector2( 0.25, 0.25 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
|
||||
position = Vector2( 400, 1024 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
scale = Vector2( 0.25, 0.25 )
|
||||
polygon = PoolVector2Array( -5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.3941, 26.9528, -49.4309, 26.2037, -36.508, 37.5346, -28.1737, 47.6282, -34.3806, 58.0427, -20.9631, 51.113, -10.2876, 50.9869, 35.2694, 38.8, 47.5, 15.9852, 54.3613, -14.9507, 54.1845, -36.5, 48.1, -50.4828, 36.33, -51.3668, -9.98545, -57.8889, -20.5885, -46.9473, -34.7342, -37.4014, -28.547, -26.0876, -37.0323, -26.9862, -49.15, -11.4152, -54.5332 )
|
||||
|
||||
[node name="GodotIcon" type="Sprite" parent="DynamicShapes/RigidBodyConcavePolygon"]
|
||||
self_modulate = Color( 1, 1, 1, 0.392157 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
scale = Vector2( 0.25, 0.25 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -13,7 +13,7 @@ func add_menu_item(item_path, checkbox = false, checked = false, radio = false):
|
||||
|
||||
var path = ""
|
||||
var popup = get_popup()
|
||||
for element_index in path_element_count - 1:
|
||||
for element_index in range(path_element_count - 1):
|
||||
var popup_label = path_elements[element_index]
|
||||
path += popup_label + "/"
|
||||
popup = _add_popup(popup, path, popup_label)
|
||||
@@ -59,7 +59,7 @@ func _on_item_pressed(item_index, popup_menu, path):
|
||||
var checked = popup_menu.is_item_checked(item_index)
|
||||
if not checked:
|
||||
popup_menu.set_item_checked(item_index, true)
|
||||
for other_index in popup_menu.get_item_count():
|
||||
for other_index in range(popup_menu.get_item_count()):
|
||||
if other_index != item_index:
|
||||
popup_menu.set_item_checked(other_index, false)
|
||||
emit_signal("option_selected", item_path)
|
||||
|
||||
@@ -242,10 +242,11 @@ mipmap_policy=1
|
||||
|
||||
quality/intended_usage/framebuffer_allocation=0
|
||||
quality/intended_usage/framebuffer_allocation.mobile=1
|
||||
quality/2d/use_pixel_snap=true
|
||||
2d/snapping/use_gpu_pixel_snap=true
|
||||
quality/filters/anisotropic_filter_level=2
|
||||
quality/filters/use_nearest_mipmap_filter=true
|
||||
quality/depth/hdr=false
|
||||
quality/2d/use_pixel_snap=true
|
||||
|
||||
[texture_import]
|
||||
|
||||
|
||||
@@ -49,7 +49,10 @@ func _physics_process(_delta):
|
||||
_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y
|
||||
|
||||
# We flip the Sprite depending on which way the enemy is moving.
|
||||
sprite.scale.x = 1 if _velocity.x > 0 else -1
|
||||
if _velocity.x > 0:
|
||||
sprite.scale.x = 1
|
||||
else:
|
||||
sprite.scale.x = -1
|
||||
|
||||
var animation = get_new_animation()
|
||||
if animation != animation_player.current_animation:
|
||||
@@ -64,7 +67,10 @@ func destroy():
|
||||
func get_new_animation():
|
||||
var animation_new = ""
|
||||
if _state == State.WALKING:
|
||||
animation_new = "walk" if abs(_velocity.x) > 0 else "idle"
|
||||
if _velocity.x == 0:
|
||||
animation_new = "idle"
|
||||
else:
|
||||
animation_new = "walk"
|
||||
else:
|
||||
animation_new = "destroy"
|
||||
return animation_new
|
||||
|
||||
@@ -13,6 +13,7 @@ onready var platform_detector = $PlatformDetector
|
||||
onready var animation_player = $AnimationPlayer
|
||||
onready var shoot_timer = $ShootAnimation
|
||||
onready var sprite = $Sprite
|
||||
onready var sound_jump = $Jump
|
||||
onready var gun = sprite.get_node(@"Gun")
|
||||
|
||||
|
||||
@@ -46,12 +47,18 @@ func _ready():
|
||||
# - If you split the character into a state machine or more advanced pattern,
|
||||
# you can easily move individual functions.
|
||||
func _physics_process(_delta):
|
||||
# Play jump sound
|
||||
if Input.is_action_just_pressed("jump" + action_suffix) and is_on_floor():
|
||||
sound_jump.play()
|
||||
|
||||
var direction = get_direction()
|
||||
|
||||
var is_jump_interrupted = Input.is_action_just_released("jump" + action_suffix) and _velocity.y < 0.0
|
||||
_velocity = calculate_move_velocity(_velocity, direction, speed, is_jump_interrupted)
|
||||
|
||||
var snap_vector = Vector2.DOWN * FLOOR_DETECT_DISTANCE if direction.y == 0.0 else Vector2.ZERO
|
||||
var snap_vector = Vector2.ZERO
|
||||
if direction.y == 0.0:
|
||||
snap_vector = Vector2.DOWN * FLOOR_DETECT_DISTANCE
|
||||
var is_on_platform = platform_detector.is_colliding()
|
||||
_velocity = move_and_slide_with_snap(
|
||||
_velocity, snap_vector, FLOOR_NORMAL, not is_on_platform, 4, 0.9, false
|
||||
@@ -60,7 +67,10 @@ func _physics_process(_delta):
|
||||
# When the character’s direction changes, we want to to scale the Sprite accordingly to flip it.
|
||||
# This will make Robi face left or right depending on the direction you move.
|
||||
if direction.x != 0:
|
||||
sprite.scale.x = 1 if direction.x > 0 else -1
|
||||
if direction.x > 0:
|
||||
sprite.scale.x = 1
|
||||
else:
|
||||
sprite.scale.x = -1
|
||||
|
||||
# We use the sprite's scale to store Robi’s look direction which allows us to shoot
|
||||
# bullets forward.
|
||||
@@ -106,9 +116,15 @@ func calculate_move_velocity(
|
||||
func get_new_animation(is_shooting = false):
|
||||
var animation_new = ""
|
||||
if is_on_floor():
|
||||
animation_new = "run" if abs(_velocity.x) > 0.1 else "idle"
|
||||
if abs(_velocity.x) > 0.1:
|
||||
animation_new = "run"
|
||||
else:
|
||||
animation_new = "idle"
|
||||
else:
|
||||
animation_new = "falling" if _velocity.y > 0 else "jumping"
|
||||
if _velocity.y > 0:
|
||||
animation_new = "falling"
|
||||
else:
|
||||
animation_new = "jumping"
|
||||
if is_shooting:
|
||||
animation_new += "_weapon"
|
||||
return animation_new
|
||||
|
||||
@@ -203,8 +203,8 @@ collision_mask = 8
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -14 )
|
||||
texture = ExtResource( 2 )
|
||||
vframes = 2
|
||||
hframes = 16
|
||||
vframes = 2
|
||||
frame = 16
|
||||
|
||||
[node name="Gun" type="Position2D" parent="Sprite"]
|
||||
|
||||
@@ -2,7 +2,7 @@ extends AudioStreamPlayer
|
||||
|
||||
const DOUBLE_VOLUME_DB = 6 # Do not change. Represents doubling of sound pressure.
|
||||
|
||||
export(int) var base_volume_db = -4
|
||||
export(int) var base_volume_db = -14
|
||||
|
||||
func _ready():
|
||||
# To avoid AudioStreamPlayer2D sounds playing on top of each other and
|
||||
|
||||
@@ -94,5 +94,6 @@ autostart = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/destroy = SubResource( 6 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="timeout" from="Timer" to="." method="destroy"]
|
||||
|
||||
@@ -160,4 +160,5 @@ shape = SubResource( 3 )
|
||||
|
||||
[node name="Pickup" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource( 3 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
|
||||
@@ -84,6 +84,7 @@ margin_right = 105.0
|
||||
margin_bottom = 50.0
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
||||
|
||||
[connection signal="pressed" from="ColorRect/CenterContainer/VBoxContainer/ResumeButton" to="." method="_on_ResumeButton_pressed"]
|
||||
[connection signal="pressed" from="ColorRect/CenterContainer/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"]
|
||||
[connection signal="tween_all_completed" from="Tween" to="." method="_on_Tween_all_completed"]
|
||||
|
||||
@@ -12,6 +12,8 @@ Note: There is a C# version available [here](https://github.com/godotengine/godo
|
||||
|
||||
Note: There is a VisualScript version available [here](https://github.com/godotengine/godot-demo-projects/tree/master/visual_script/pong).
|
||||
|
||||
Note: There is a GDNative C++ version available [here](https://github.com/godotengine/gdnative-demos/tree/master/cpp/pong).
|
||||
|
||||
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/121
|
||||
|
||||
## How does it work?
|
||||
|
||||
@@ -2,10 +2,10 @@ extends Area2D
|
||||
|
||||
const DEFAULT_SPEED = 100
|
||||
|
||||
var _speed = DEFAULT_SPEED
|
||||
var direction = Vector2.LEFT
|
||||
|
||||
onready var _initial_pos = position
|
||||
onready var _speed = DEFAULT_SPEED
|
||||
|
||||
func _process(delta):
|
||||
_speed += delta * 2
|
||||
|
||||
@@ -9,10 +9,13 @@ var _down
|
||||
onready var _screen_size_y = get_viewport_rect().size.y
|
||||
|
||||
func _ready():
|
||||
var n = name.to_lower()
|
||||
var n = String(name).to_lower()
|
||||
_up = n + "_move_up"
|
||||
_down = n + "_move_down"
|
||||
_ball_dir = 1 if n == "left" else -1
|
||||
if n == "left":
|
||||
_ball_dir = 1
|
||||
else:
|
||||
_ball_dir = -1
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
||||
@@ -98,6 +98,7 @@ shape = SubResource( 4 )
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
offset = Vector2( 320, 200 )
|
||||
current = true
|
||||
|
||||
[connection signal="area_entered" from="Left" to="Left" method="_on_area_entered"]
|
||||
[connection signal="area_entered" from="Right" to="Right" method="_on_area_entered"]
|
||||
[connection signal="area_entered" from="LeftWall" to="LeftWall" method="_on_wall_area_entered"]
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Pong with GDScript"
|
||||
@@ -70,5 +65,8 @@ right_move_up={
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
2d/snapping/use_gpu_pixel_snap=true
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
quality/2d/use_pixel_snap=true
|
||||
viewport/default_clear_color=Color( 0, 0, 0, 1 )
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Game.gd" type="Script" id=1]
|
||||
[ext_resource path="res://screens/combat/Combat.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://screens/exploration/Exploration.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://combat/Combat.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://grid_movement/Exploration.tscn" type="PackedScene" id=3]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
length = 0.5
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
extends Node
|
||||
|
||||
signal combat_finished(winner, loser)
|
||||
const Combatant = preload("res://turn_combat/combatants/Combatant.gd")
|
||||
|
||||
func initialize(combat_combatants):
|
||||
for combatant in combat_combatants:
|
||||
@@ -1,10 +1,10 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://screens/combat/Combat.gd" type="Script" id=1]
|
||||
[ext_resource path="res://turn_combat/turn_queue/TurnQueue.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://combat/Combat.gd" type="Script" id=1]
|
||||
[ext_resource path="res://combat/TurnQueue.gd" type="Script" id=2]
|
||||
[ext_resource path="res://theme/theme.tres" type="Theme" id=3]
|
||||
[ext_resource path="res://screens/combat/interface/UI.gd" type="Script" id=4]
|
||||
[ext_resource path="res://screens/combat/interface/Info.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://combat/interface/UI.gd" type="Script" id=4]
|
||||
[ext_resource path="res://combat/interface/Info.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Node2D
|
||||
@@ -21,7 +21,8 @@ script = ExtResource( 1 )
|
||||
position = Vector2( 539, 275 )
|
||||
script = SubResource( 1 )
|
||||
|
||||
[node name="TurnQueue" parent="." instance=ExtResource( 2 )]
|
||||
[node name="TurnQueue" type="Node" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
combatants_list = NodePath("../Combatants")
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
@@ -78,6 +79,7 @@ margin_bottom = 242.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Flee"
|
||||
|
||||
[connection signal="button_up" from="UI/Buttons/GridContainer/Attack" to="UI" method="_on_Attack_button_up"]
|
||||
[connection signal="button_up" from="UI/Buttons/GridContainer/Defend" to="UI" method="_on_Defend_button_up"]
|
||||
[connection signal="button_up" from="UI/Buttons/GridContainer/Flee" to="UI" method="_on_Flee_button_up"]
|
||||
@@ -1,7 +1,5 @@
|
||||
extends Node
|
||||
|
||||
const combatant = preload("../combatants/Combatant.gd")
|
||||
|
||||
export(NodePath) var combatants_list
|
||||
var queue = [] setget set_queue
|
||||
var active_combatant = null setget _set_active_combatant
|
||||
@@ -43,7 +41,7 @@ func remove(combatant):
|
||||
func set_queue(new_queue):
|
||||
queue.clear()
|
||||
for node in new_queue:
|
||||
if not node is combatant:
|
||||
if not node is Combatant:
|
||||
continue
|
||||
queue.append(node)
|
||||
node.active = false
|
||||
@@ -1,3 +1,4 @@
|
||||
class_name Combatant
|
||||
extends Node
|
||||
|
||||
export(int) var damage = 1
|
||||
15
2d/role_playing_game/combat/combatants/Combatant.tscn
Normal file
@@ -0,0 +1,15 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://combat/combatants/Combatant.gd" type="Script" id=1]
|
||||
[ext_resource path="res://combat/combatants/Health.gd" type="Script" id=2]
|
||||
[ext_resource path="res://combat/combatants/sprites/Sprite.tscn" type="PackedScene" id=3]
|
||||
|
||||
[node name="Combatant" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
damage = 2
|
||||
|
||||
[node name="Health" type="Node" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
life = 10
|
||||
|
||||
[node name="Sprite" parent="." instance=ExtResource( 3 )]
|
||||
@@ -1,10 +1,12 @@
|
||||
extends "Combatant.gd"
|
||||
extends Combatant
|
||||
|
||||
func set_active(value):
|
||||
.set_active(value)
|
||||
if not active:
|
||||
return
|
||||
|
||||
if not $Timer.is_inside_tree():
|
||||
return
|
||||
$Timer.start()
|
||||
yield($Timer, "timeout")
|
||||
var target
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://turn_combat/combatants/Combatant.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://turn_combat/combatants/Opponent.gd" type="Script" id=2]
|
||||
[ext_resource path="res://turn_combat/combatants/sprites/green.png" type="Texture" id=3]
|
||||
[ext_resource path="res://combat/combatants/Combatant.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://combat/combatants/Opponent.gd" type="Script" id=2]
|
||||
[ext_resource path="res://combat/combatants/sprites/green.png" type="Texture" id=3]
|
||||
|
||||
[node name="Opponent" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://turn_combat/combatants/Combatant.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://combat/combatants/Combatant.tscn" type="PackedScene" id=1]
|
||||
|
||||
[node name="Player" instance=ExtResource( 1 )]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://turn_combat/combatants/health/Health.gd" type="Script" id=1]
|
||||
[ext_resource path="res://combat/combatants/Health.gd" type="Script" id=1]
|
||||
|
||||
[node name="Health" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://screens/combat/actors/sprites/shadow.png" type="Texture" id=1]
|
||||
[ext_resource path="res://screens/combat/actors/sprites/blue.png" type="Texture" id=2]
|
||||
[ext_resource path="res://combat/combatants/sprites/shadow.png" type="Texture" id=1]
|
||||
[ext_resource path="res://combat/combatants/sprites/blue.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "take_damage"
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/blue.png-127e2b8d7aa8f4a7572c4923c2b20228.stex"
|
||||
path="res://.import/blue.png-8092cf6d59f8b71b187a850a15aa9759.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://screens/combat/actors/sprites/blue.png"
|
||||
dest_files=[ "res://.import/blue.png-127e2b8d7aa8f4a7572c4923c2b20228.stex" ]
|
||||
source_file="res://combat/combatants/sprites/blue.png"
|
||||
dest_files=[ "res://.import/blue.png-8092cf6d59f8b71b187a850a15aa9759.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/green.png-7937ec3931675b5dd0f218cbb8ae006a.stex"
|
||||
path="res://.import/green.png-d2deadceb974a66b9f9b9df11dc41501.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://screens/combat/actors/sprites/green.png"
|
||||
dest_files=[ "res://.import/green.png-7937ec3931675b5dd0f218cbb8ae006a.stex" ]
|
||||
source_file="res://combat/combatants/sprites/green.png"
|
||||
dest_files=[ "res://.import/green.png-d2deadceb974a66b9f9b9df11dc41501.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 741 B After Width: | Height: | Size: 741 B |
@@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/object.png-f9ec4c5540ae154e2e73d50438312f26.stex"
|
||||
path="res://.import/shadow.png-d8772fa49c8867b55809e76164b76188.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://grid_movement/tilesets/grid/object.png"
|
||||
dest_files=[ "res://.import/object.png-f9ec4c5540ae154e2e73d50438312f26.stex" ]
|
||||
source_file="res://combat/combatants/sprites/shadow.png"
|
||||
dest_files=[ "res://.import/shadow.png-d8772fa49c8867b55809e76164b76188.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://theme/labels/Title.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://theme/fonts/montserrat_extra_bold_48.tres" type="DynamicFont" id=1]
|
||||
|
||||
[node name="Info" type="PanelContainer"]
|
||||
margin_right = 409.0
|
||||
@@ -17,12 +17,22 @@ margin_top = 7.0
|
||||
margin_right = 402.0
|
||||
margin_bottom = 232.0
|
||||
|
||||
[node name="Name" parent="VBoxContainer" instance=ExtResource( 1 )]
|
||||
[node name="Name" type="Label" parent="VBoxContainer"]
|
||||
margin_right = 395.0
|
||||
margin_bottom = 110.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 7
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
custom_colors/font_color_shadow = Color( 1, 0.596078, 0, 1 )
|
||||
custom_constants/shadow_offset_y = 5
|
||||
text = "{name}"
|
||||
align = 1
|
||||
autowrap = true
|
||||
clip_text = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Health" type="ProgressBar" parent="VBoxContainer"]
|
||||
margin_top = 168.0
|
||||
@@ -34,4 +34,5 @@ margin_top = 32.0
|
||||
margin_right = 1264.0
|
||||
margin_bottom = 151.0
|
||||
text = "Next"
|
||||
|
||||
[connection signal="button_up" from="Button" to="." method="_on_Button_button_up"]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://grid_movement/tilesets/grid_lines/grid_lines_tileset.tres" type="TileSet" id=1]
|
||||
[ext_resource path="res://grid_movement/tilesets/grid/grid_tileset.tres" type="TileSet" id=2]
|
||||
[ext_resource path="res://grid_movement/grid/lines/grid_lines_tileset.tres" type="TileSet" id=1]
|
||||
[ext_resource path="res://grid_movement/grid/tiles/grid_tileset.tres" type="TileSet" id=2]
|
||||
[ext_resource path="res://grid_movement/grid/Grid.gd" type="Script" id=3]
|
||||
[ext_resource path="res://grid_movement/pawns/Character.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://turn_combat/combatants/Player.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://grid_movement/pawns/Character.gd" type="Script" id=6]
|
||||
[ext_resource path="res://turn_combat/combatants/Opponent.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://combat/combatants/Player.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://grid_movement/pawns/Opponent.gd" type="Script" id=6]
|
||||
[ext_resource path="res://combat/combatants/Opponent.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://dialogue/dialogue_player/DialoguePlayer.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://grid_movement/pawns/Pawn.gd" type="Script" id=9]
|
||||
[ext_resource path="res://dialogue/interface/Interface.tscn" type="PackedScene" id=10]
|
||||
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
@@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/obstacle.png-303025fbfb0bdc414a247e8ee1624a90.stex"
|
||||
path="res://.import/grid_lines.png-52aa706884a3dba960110e63cdf54a8c.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://grid_movement/tilesets/grid/obstacle.png"
|
||||
dest_files=[ "res://.import/obstacle.png-303025fbfb0bdc414a247e8ee1624a90.stex" ]
|
||||
source_file="res://grid_movement/grid/lines/grid_lines.png"
|
||||
dest_files=[ "res://.import/grid_lines.png-52aa706884a3dba960110e63cdf54a8c.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||