Pew Machine now a component
This commit is contained in:
parent
35eb5b56fa
commit
b1005379d7
|
|
@ -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://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/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/PewMachine.gd" type="Script" id=28]
|
||||
[ext_resource path="res://src/projectiles/MushroomPew.tscn" type="PackedScene" id=29]
|
||||
[ext_resource path="res://src/components/PewMachine.tscn" type="PackedScene" id=28]
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
resource_local_to_scene = true
|
||||
|
|
@ -148,8 +147,4 @@ shape = SubResource( 2 )
|
|||
script = ExtResource( 21 )
|
||||
interactable_parent_callback = "touch_the_thing"
|
||||
|
||||
[node name="PewMachine" type="Position2D" parent="." index="11"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2( 21, -7 )
|
||||
script = ExtResource( 28 )
|
||||
scene_path = ExtResource( 29 )
|
||||
[node name="PewMachine" parent="." index="11" instance=ExtResource( 28 )]
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
class_name Projectile
|
||||
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:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
export var velocity_pps :float = 1
|
||||
export var lifespan :float = -1
|
||||
var direction_normal := Vector2(0,0)
|
||||
|
||||
var time_alive :float = 0.0
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
|
@ -16,11 +19,13 @@ func _ready():
|
|||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if lifespan != -1:
|
||||
time_alive += delta
|
||||
if time_alive > lifespan:
|
||||
queue_free()
|
||||
rotate(delta * 10)
|
||||
position += direction_normal * velocity_pps * delta
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
var colliding_node = body
|
||||
|
|
|
|||
10
src/components/PewMachine.tscn
Normal file
10
src/components/PewMachine.tscn
Normal 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 )
|
||||
|
|
@ -9,6 +9,7 @@ height = 2.0
|
|||
|
||||
[node name="MushroomPew" instance=ExtResource( 1 )]
|
||||
velocity_pps = 300.0
|
||||
lifespan = 0.5
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource( 1 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user