diff --git a/.gitignore b/.gitignore index 011bedc..c1c3df1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store # Godot-specific ignores +.godot/ .import/ export.cfg export_presets.cfg diff --git a/CHANGELOG.md b/CHANGELOG.md index 032a070..8ac718e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ * Up to date +## [1.1.0] - 2024-04-12 + +* Update to Godot 4.X. + ## [1.0.0] - 2019-12-09 * Released stable version. diff --git a/README.md b/README.md index 75f783b..22b2144 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Godot 3 2D Fake Explosion Particles +# Godot 4 2D Fake Explosion Particles A script to simulate exploding particles. -![Godot-3-2D-Fake-Explosion-Particles-GIF](examples/Godot-3-2D-Fake-Explosion-Particles.gif) +![Godot-4-2D-Fake-Explosion-Particles-GIF](examples/Godot-4-2D-Fake-Explosion-Particles.gif) ## Instalation -* [Download](https://github.com/hiulit/Godot-3-2D-Fake-Explosion-Particles/archive/master.zip) the repository ZIP file. +* [Download](https://github.com/VSeryi/Godot-4-2D-Fake-Explosion-Particles/archive/master.zip) the repository ZIP file. * Copy `fake_explosion_particles.tscn` and `fake_explosion_particles.gd`. ## Usage @@ -67,7 +67,7 @@ var particles_colors_with_weights = [ ## Parameters -![Godot-3-2D-Fake-Explosion-Particles-Parameters](examples/parameters.png) +![Godot-4-2D-Fake-Explosion-Particles-Parameters](examples/parameters.png) The minimum and maximum variables values are used to generate random values. If you don't want to use random values, set the minimum and maximum variables values with the same value. @@ -173,14 +173,16 @@ See [CHANGELOG](CHANGELOG.md). ## Authors -* Me 😛 [hiulit](https://github.com/hiulit). +* Me 😛 [VSeryi](https://github.com/hiulit). +* [hiulit](https://github.com/hiulit). ## Credits Thanks to: +* [hiulit](https://github.com/hiulit) - For the [original version compatible with Godot 3](https://github.com/hiulit/Godot-3-2D-Fake-Explosion-Particles) * [CowThing](https://github.com/CowThing) - For the `_rand_array` function. ## License -[MIT License](LICENSE). \ No newline at end of file +[MIT License](LICENSE). diff --git a/default_env.tres b/default_env.tres index 20207a4..1f30a29 100644 --- a/default_env.tres +++ b/default_env.tres @@ -1,7 +1,7 @@ -[gd_resource type="Environment" load_steps=2 format=2] +[gd_resource type="Environment" load_steps=2 format=3 uid="uid://dlx4e1y8c86o0"] -[sub_resource type="ProceduralSky" id=1] +[sub_resource type="Sky" id="1"] [resource] background_mode = 2 -background_sky = SubResource( 1 ) +sky = SubResource("1") diff --git a/examples/parameters.png.import b/examples/parameters.png.import index 3fd9430..927f247 100644 --- a/examples/parameters.png.import +++ b/examples/parameters.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture" -path="res://.import/parameters.png-9053545c3e359bec86bda0f3a13d608f.stex" +type="CompressedTexture2D" +uid="uid://0t76s727pbjk" +path="res://.godot/imported/parameters.png-9053545c3e359bec86bda0f3a13d608f.ctex" metadata={ "vram_texture": false } @@ -10,25 +11,24 @@ metadata={ [deps] source_file="res://examples/parameters.png" -dest_files=[ "res://.import/parameters.png-9053545c3e359bec86bda0f3a13d608f.stex" ] +dest_files=["res://.godot/imported/parameters.png-9053545c3e359bec86bda0f3a13d608f.ctex"] [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 +compress/hdr_compression=1 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/fake_explosion_particles.gd b/fake_explosion_particles.gd index 22a04c0..63e542e 100644 --- a/fake_explosion_particles.gd +++ b/fake_explosion_particles.gd @@ -1,25 +1,25 @@ extends Node2D -export (int) var min_particles_number = 200 -export (int) var max_particles_number = 400 +@export var min_particles_number: int = 200 +@export var max_particles_number: int = 400 -export (float) var min_particles_gravity = 200.0 -export (float) var max_particles_gravity = 600.0 +@export var min_particles_gravity: float = 200.0 +@export var max_particles_gravity: float = 600.0 -export (float) var min_particles_velocity = 200.0 -export (float) var max_particles_velocity = 600.0 +@export var min_particles_velocity: float = 200.0 +@export var max_particles_velocity: float = 600.0 -export (int) var max_particles_position_x = ProjectSettings.get_setting("display/window/size/width") -export (int) var max_particles_position_y = ProjectSettings.get_setting("display/window/size/height") +@export var max_particles_position_x: int = ProjectSettings.get_setting("display/window/size/viewport_width") +@export var max_particles_position_y: int = ProjectSettings.get_setting("display/window/size/viewport_height") -export (int) var min_particles_size = 1 -export (int) var max_particles_size = 3 +@export var min_particles_size: int = 1 +@export var max_particles_size: int = 3 -export (bool) var get_random_position = false -export (bool) var start_timer = false -export (float) var timer_wait_time = 1.0 -export (bool) var particles_explode = false -export (String) var group_name = "fake_explosion_particles" +@export var get_random_position: bool = false +@export var start_timer: bool = false +@export var timer_wait_time: float = 1.0 +@export var particles_explode: bool = false +@export var group_name: String = "fake_explosion_particles" var particles = [] var particles_number @@ -46,8 +46,8 @@ func _ready(): particles_timer = Timer.new() particles_timer.one_shot = false particles_timer.wait_time = timer_wait_time - particles_timer.set_timer_process_mode(1) - particles_timer.connect("timeout", self, "_on_particles_timer_timeout") + particles_timer.set_timer_process_callback(1) + particles_timer.connect("timeout", Callable(self, "_on_particles_timer_timeout")) add_child(particles_timer, true) @@ -62,7 +62,7 @@ func _process(delta): _particles_explode(delta) # Redraw the particles every frame. - update() + queue_redraw() # If there are no particles in the particles array, free the node. if particles.size() == 0 and not start_timer: @@ -98,7 +98,7 @@ func _particles_explode(delta): # ... find the particle in the particles array... var i = particles.find(particle) # ... and remove it from the particles array. - particles.remove(i) + particles.remove_at(i) func _create_particles(): @@ -138,7 +138,7 @@ func _create_particles(): func _get_random_alpha(): randomize() - var random_alpha = rand_range(2, 10) + var random_alpha = randf_range(2, 10) return random_alpha @@ -151,13 +151,13 @@ func _get_random_color(): func _get_random_gravity(): randomize() var random_gravity = Vector2( - rand_range( - -rand_range(min_particles_gravity, max_particles_gravity), - rand_range(min_particles_gravity, max_particles_gravity) + randf_range( + -randf_range(min_particles_gravity, max_particles_gravity), + randf_range(min_particles_gravity, max_particles_gravity) ), - rand_range( - rand_range(min_particles_gravity * 2, max_particles_gravity * 2), - rand_range(min_particles_gravity * 2, max_particles_gravity * 2) + randf_range( + randf_range(min_particles_gravity * 2, max_particles_gravity * 2), + randf_range(min_particles_gravity * 2, max_particles_gravity * 2) ) ) return random_gravity @@ -165,14 +165,14 @@ func _get_random_gravity(): func _get_random_number(): randomize() - var random_number = round(rand_range(min_particles_number, max_particles_number)) + var random_number = round(randf_range(min_particles_number, max_particles_number)) return random_number func _get_random_position(): randomize() - var random_position_x = rand_range(0, max_particles_position_x) - var random_position_y = rand_range(0, max_particles_position_y) + var random_position_x = randf_range(0, max_particles_position_x) + var random_position_y = randf_range(0, max_particles_position_y) var random_position = Vector2(random_position_x, random_position_y) return random_position @@ -187,13 +187,13 @@ func _get_random_size(): func _get_random_velocity(): randomize() var random_velocity = Vector2( - rand_range( - -rand_range(min_particles_velocity, max_particles_velocity), - rand_range(min_particles_velocity, max_particles_velocity) + randf_range( + -randf_range(min_particles_velocity, max_particles_velocity), + randf_range(min_particles_velocity, max_particles_velocity) ), - rand_range( - -rand_range(min_particles_velocity * 2, max_particles_velocity * 2), - -rand_range(min_particles_velocity * 2, max_particles_velocity * 2) + randf_range( + -randf_range(min_particles_velocity * 2, max_particles_velocity * 2), + -randf_range(min_particles_velocity * 2, max_particles_velocity * 2) ) ) return random_velocity @@ -201,13 +201,13 @@ func _get_random_velocity(): func _get_random_velocity_increment(): randomize() - var random_velocity_increment = Vector2(rand_range(0.991, 1.009), rand_range(0.991, 1.009)) + var random_velocity_increment = Vector2(randf_range(0.991, 1.009), randf_range(0.991, 1.009)) return random_velocity_increment func _get_random_time(): randomize() - var random_time = rand_range(0.05, 0.1) + var random_time = randf_range(0.05, 0.1) return random_time diff --git a/fake_explosion_particles.tscn b/fake_explosion_particles.tscn index 2b3955c..b834191 100644 --- a/fake_explosion_particles.tscn +++ b/fake_explosion_particles.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://rgllydtafknq"] -[ext_resource path="res://fake_explosion_particles.gd" type="Script" id=1] +[ext_resource type="Script" path="res://fake_explosion_particles.gd" id="1"] [node name="fake_explosion_particles" type="Node2D"] -script = ExtResource( 1 ) +script = ExtResource("1") diff --git a/project.godot b/project.godot index 0eee741..784e7d5 100644 --- a/project.godot +++ b/project.godot @@ -6,28 +6,23 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 - -_global_script_classes=[ ] -_global_script_class_icons={ - -} +config_version=5 [application] -config/name="Godot-3-2D-Fake-Explosion-Particles" +config/name="Godot-4-2D-Fake-Explosion-Particles" run/main_scene="res://test.tscn" +config/features=PackedStringArray("4.2") [display] -window/size/width=320 -window/size/height=180 -window/size/test_width=640 -window/size/test_height=360 +window/size/viewport_width=320 +window/size/viewport_height=180 +window/size/window_width_override=640 +window/size/window_height_override=360 window/stretch/mode="2d" -window/stretch/aspect="keep" [rendering] +environment/defaults/default_environment="res://default_env.tres" quality/2d/use_pixel_snap=true -environment/default_environment="res://default_env.tres" diff --git a/test.tscn b/test.tscn index 83747cc..f425790 100644 --- a/test.tscn +++ b/test.tscn @@ -1,8 +1,8 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://d141yw6hqkxga"] -[ext_resource path="res://fake_explosion_particles.tscn" type="PackedScene" id=1] +[ext_resource type="PackedScene" uid="uid://rgllydtafknq" path="res://fake_explosion_particles.tscn" id="1"] [node name="test" type="Node2D"] -[node name="fake_explosion_particles" parent="." instance=ExtResource( 1 )] -position = Vector2( 160, 90 ) +[node name="fake_explosion_particles" parent="." instance=ExtResource("1")] +position = Vector2(160, 90)