Pew Machine now a component

This commit is contained in:
Dustin 2025-04-10 19:27:58 -07:00
parent 35eb5b56fa
commit b1005379d7
5 changed files with 22 additions and 11 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=36 format=2] [gd_scene load_steps=35 format=2]
[ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1] [ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2] [ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
@ -27,8 +27,7 @@
[ext_resource path="res://assets_tmp/SE/tap.wav" type="AudioStream" id=25] [ext_resource path="res://assets_tmp/SE/tap.wav" type="AudioStream" id=25]
[ext_resource path="res://assets_tmp/SE/land.wav" type="AudioStream" id=26] [ext_resource path="res://assets_tmp/SE/land.wav" type="AudioStream" id=26]
[ext_resource path="res://src/actors/players/playerE/states/attack_punch.tres" type="Resource" id=27] [ext_resource path="res://src/actors/players/playerE/states/attack_punch.tres" type="Resource" id=27]
[ext_resource path="res://src/PewMachine.gd" type="Script" id=28] [ext_resource path="res://src/components/PewMachine.tscn" type="PackedScene" id=28]
[ext_resource path="res://src/projectiles/MushroomPew.tscn" type="PackedScene" id=29]
[sub_resource type="Resource" id=3] [sub_resource type="Resource" id=3]
resource_local_to_scene = true resource_local_to_scene = true
@ -148,8 +147,4 @@ shape = SubResource( 2 )
script = ExtResource( 21 ) script = ExtResource( 21 )
interactable_parent_callback = "touch_the_thing" interactable_parent_callback = "touch_the_thing"
[node name="PewMachine" type="Position2D" parent="." index="11"] [node name="PewMachine" parent="." index="11" instance=ExtResource( 28 )]
unique_name_in_owner = true
position = Vector2( 21, -7 )
script = ExtResource( 28 )
scene_path = ExtResource( 29 )

View File

@ -1,14 +1,17 @@
class_name Projectile class_name Projectile
extends Area2D extends Area2D
##TODO: Probably implement some sort of object pooling option
## so wen're not just deleting itself every timemout or screen exit.
# Declare member variables here. Examples: # Declare member variables here. Examples:
# var a = 2 # var a = 2
# var b = "text" # var b = "text"
export var velocity_pps :float = 1 export var velocity_pps :float = 1
export var lifespan :float = -1
var direction_normal := Vector2(0,0) var direction_normal := Vector2(0,0)
var time_alive :float = 0.0
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
@ -16,11 +19,13 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
if lifespan != -1:
time_alive += delta
if time_alive > lifespan:
queue_free()
rotate(delta * 10) rotate(delta * 10)
position += direction_normal * velocity_pps * delta position += direction_normal * velocity_pps * delta
func _on_body_entered(body): func _on_body_entered(body):
var colliding_node = body var colliding_node = body

View File

@ -0,0 +1,10 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/components/PewMachine.gd" type="Script" id=1]
[ext_resource path="res://src/projectiles/MushroomPew.tscn" type="PackedScene" id=2]
[node name="PewMachine" type="Position2D"]
unique_name_in_owner = true
position = Vector2( 21, -7 )
script = ExtResource( 1 )
scene_path = ExtResource( 2 )

View File

@ -9,6 +9,7 @@ height = 2.0
[node name="MushroomPew" instance=ExtResource( 1 )] [node name="MushroomPew" instance=ExtResource( 1 )]
velocity_pps = 300.0 velocity_pps = 300.0
lifespan = 0.5
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"] [node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"]
shape = SubResource( 1 ) shape = SubResource( 1 )