Skip to content

Commit

Permalink
Update to Godot 4.X
Browse files Browse the repository at this point in the history
  • Loading branch information
VSeryi committed Apr 12, 2024
1 parent 9a97158 commit 51d746b
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 82 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store

# Godot-specific ignores
.godot/
.import/
export.cfg
export_presets.cfg
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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).
[MIT License](LICENSE).
6 changes: 3 additions & 3 deletions default_env.tres
Original file line number Diff line number Diff line change
@@ -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")
32 changes: 16 additions & 16 deletions examples/parameters.png.import
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[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
}

[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
74 changes: 37 additions & 37 deletions fake_explosion_particles.gd
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Expand All @@ -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:
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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


Expand All @@ -151,28 +151,28 @@ 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


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

Expand All @@ -187,27 +187,27 @@ 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


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


Expand Down
6 changes: 3 additions & 3 deletions fake_explosion_particles.tscn
Original file line number Diff line number Diff line change
@@ -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")
21 changes: 8 additions & 13 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 4 additions & 4 deletions test.tscn
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 51d746b

Please sign in to comment.