fx: food wrappign sprites
This commit is contained in:
@@ -1,21 +1,15 @@
|
|||||||
@abstract
|
@abstract
|
||||||
class_name AbstractFood
|
class_name AbstractFood
|
||||||
extends Node2D
|
extends Node
|
||||||
|
|
||||||
@export var val: int = 1
|
@export var val: int = 1
|
||||||
@export var food_name: String = "Food"
|
@export var food_name: String = "Food"
|
||||||
|
|
||||||
|
|
||||||
@export var flow_carry_speed: float = 10.0
|
@export var flow_carry_speed: float = 10.0
|
||||||
|
|
||||||
signal consumed
|
signal consumed
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
|
||||||
var dpos = Vector2(GameManager.flow_x, GameManager.flow_y) * delta * flow_carry_speed
|
|
||||||
position += dpos
|
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends Node
|
extends Node
|
||||||
class_name FoodManager2D
|
class_name FoodManager2D
|
||||||
|
|
||||||
var minCount: int = 20
|
var minCount: int = 0
|
||||||
var _currentCount: int = 0
|
var _currentCount: int = 0
|
||||||
|
|
||||||
var rng = RandomNumberGenerator.new()
|
var rng = RandomNumberGenerator.new()
|
||||||
@@ -19,10 +19,6 @@ func _ready() -> void:
|
|||||||
spawnRange = GameManager.extent
|
spawnRange = GameManager.extent
|
||||||
call_deferred("_spawn_minimum")
|
call_deferred("_spawn_minimum")
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _process(delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
func _spawn_minimum() -> void:
|
func _spawn_minimum() -> void:
|
||||||
while _currentCount < minCount:
|
while _currentCount < minCount:
|
||||||
_spawn_random()
|
_spawn_random()
|
||||||
|
|||||||
@@ -2,11 +2,19 @@ extends AbstractFood
|
|||||||
class_name FoodMolecular
|
class_name FoodMolecular
|
||||||
|
|
||||||
@onready var collision: Area2D = $Collision
|
@onready var collision: Area2D = $Collision
|
||||||
@onready var sprite: AnimatedSprite2D = $"Collision/Sprite"
|
@onready var sprite: AnimatedSprite2D = $Collision/Sprite
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
sprite.play()
|
sprite.play()
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
var dpos = Vector2(GameManager.flow_x, GameManager.flow_y) * delta * flow_carry_speed
|
||||||
|
collision.position = GameManager.get_boundaried_position(collision.position + dpos)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
collision.position = GameManager.get_boundaried_position(collision.position)
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
eat(body)
|
eat(body)
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ radius = 5.0
|
|||||||
|
|
||||||
[node name="FoodMol" type="Node2D" unique_id=742430243]
|
[node name="FoodMol" type="Node2D" unique_id=742430243]
|
||||||
script = ExtResource("1_0vfbj")
|
script = ExtResource("1_0vfbj")
|
||||||
collision_layer = 8
|
|
||||||
collision_mask = 7
|
|
||||||
val = null
|
val = null
|
||||||
food_name = null
|
food_name = null
|
||||||
flow_carry_speed = null
|
flow_carry_speed = null
|
||||||
@@ -75,11 +73,8 @@ texture = ExtResource("2_68e2u")
|
|||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Collision" unique_id=762721134]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Collision" unique_id=762721134]
|
||||||
shape = SubResource("CircleShape2D_0vfbj")
|
shape = SubResource("CircleShape2D_0vfbj")
|
||||||
|
|
||||||
[node name="WrappingManager" type="Node" parent="." unique_id=1406150436 node_paths=PackedStringArray("sprite", "shape")]
|
[node name="WrappingManager" type="Node" parent="." unique_id=1406150436]
|
||||||
script = ExtResource("3_8lhj0")
|
script = ExtResource("3_8lhj0")
|
||||||
sprite = NodePath("../Collision/Sprite")
|
|
||||||
shape = NodePath("../Collision/CollisionShape2D")
|
|
||||||
dupFlags = 0
|
|
||||||
metadata/_custom_type_script = "uid://bvbc0n0pslq7p"
|
metadata/_custom_type_script = "uid://bvbc0n0pslq7p"
|
||||||
|
|
||||||
[connection signal="body_entered" from="Collision" to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="Collision" to="." method="_on_body_entered"]
|
||||||
|
|||||||
Reference in New Issue
Block a user