-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See goostengine/goost#28.
- Loading branch information
Showing
6 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
extends Node2D | ||
|
||
enum Type { | ||
CIRCLE, | ||
RING, | ||
} | ||
export(Type) var type = Type.CIRCLE setget set_type | ||
export var count := 500 setget set_count | ||
export var min_radius := 0.0 setget set_min_radius | ||
export var max_radius := 0.0 setget set_max_radius | ||
|
||
|
||
func set_type(p_type): | ||
type = p_type | ||
call_deferred("spawn") | ||
|
||
|
||
func set_count(p_count): | ||
count = p_count | ||
call_deferred("spawn") | ||
|
||
|
||
func set_min_radius(p_min_radius): | ||
min_radius = p_min_radius | ||
call_deferred("spawn") | ||
|
||
|
||
func set_max_radius(p_max_radius): | ||
max_radius = p_max_radius | ||
call_deferred("spawn") | ||
|
||
|
||
func _ready(): | ||
randomize() | ||
if max_radius <= 0.0: | ||
# Fit screen size. | ||
max_radius = get_viewport().size.y / 2 | ||
# Make sure sprites are not clipped by viewport. | ||
max_radius -= preload("res://icon.png").get_size().length() | ||
if min_radius <= 0.0: | ||
min_radius = max_radius / 2 | ||
spawn() | ||
|
||
|
||
func spawn(): | ||
for child in get_children(): | ||
if child is Sprite: | ||
child.queue_free() | ||
for i in count: | ||
var goost = preload("res://goost.tscn").instance() | ||
add_child(goost) | ||
# Spawn a sprite at random position within a circle radius. | ||
var point = Vector2() | ||
match type: | ||
Type.CIRCLE: | ||
point = GoostGeometry2D.rand_point_in_circle(max_radius) | ||
Type.RING: | ||
point = GoostGeometry2D.rand_point_in_ring(min_radius, max_radius) | ||
goost.global_position = point |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://circle_spawn.gd" type="Script" id=1] | ||
|
||
[node name="circle_spawn" type="Node2D"] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="camera" type="Camera2D" parent="."] | ||
current = true | ||
__meta__ = { | ||
"_editor_description_": "Displays sprites centered." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://icon.png" type="Texture" id=1] | ||
|
||
[node name="goost" type="Sprite"] | ||
texture = ExtResource( 1 ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://icon.png" | ||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
; Engine configuration file. | ||
; It's best edited using the editor UI and not directly, | ||
; since the parameters that go here are not all obvious. | ||
; | ||
; Format: | ||
; [section] ; section goes between [] | ||
; param=value ; assign values to parameters | ||
|
||
config_version=4 | ||
|
||
[application] | ||
|
||
config/name="Goost Spawn" | ||
run/main_scene="res://circle_spawn.tscn" | ||
boot_splash/image="res://icon.png" | ||
boot_splash/fullsize=false | ||
config/icon="res://icon.png" |