First trap initialized!
This commit is contained in:
28
Game/Traps/stick_trap.tscn
Normal file
28
Game/Traps/stick_trap.tscn
Normal file
@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://pqy8rrvjthgl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://4bah0c8unbl8" path="res://Assets/Traps/Sticks/Tile2_59.png" id="1_dnq4b"]
|
||||
[ext_resource type="Script" uid="uid://3gn70ilm20tw" path="res://Game/Traps/traps.gd" id="1_metvu"]
|
||||
[ext_resource type="Texture2D" uid="uid://l58s5yxh4f8n" path="res://Assets/Traps/Sticks/Tile2_60.png" id="2_metvu"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_m1bdk"]
|
||||
radius = 32.0
|
||||
|
||||
[node name="StickTrap" type="Node2D"]
|
||||
script = ExtResource("1_metvu")
|
||||
|
||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
|
||||
position = Vector2(8, 0)
|
||||
scale = Vector2(1.5, 1)
|
||||
texture = ExtResource("1_dnq4b")
|
||||
offset = Vector2(10, 0)
|
||||
|
||||
[node name="Sprite2D2" type="Sprite2D" parent="CharacterBody2D"]
|
||||
texture = ExtResource("2_metvu")
|
||||
offset = Vector2(-10, 0)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
|
||||
position = Vector2(5, 0)
|
||||
scale = Vector2(0.8, 0.8)
|
||||
shape = SubResource("CircleShape2D_m1bdk")
|
17
Game/Traps/traps.gd
Normal file
17
Game/Traps/traps.gd
Normal file
@ -0,0 +1,17 @@
|
||||
extends Node2D
|
||||
|
||||
var follower = false
|
||||
|
||||
func _ready() -> void:
|
||||
follower = true
|
||||
set_process_input(true)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if follower:
|
||||
position = get_viewport().get_mouse_position()
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
if abs(position) <= get_viewport().get_mouse_position():
|
||||
follower = false
|
1
Game/Traps/traps.gd.uid
Normal file
1
Game/Traps/traps.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://3gn70ilm20tw
|
Reference in New Issue
Block a user