Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3607e63548 | ||
|
|
8768909429 |
No files matched your search
@@ -27,6 +27,14 @@ folder_colors={
|
|||||||
"res://scripts/": "red"
|
"res://scripts/": "red"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
shove={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
3d/physics_engine="Jolt Physics"
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bdd87ih2rf4yk"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ryrc3a88d0nh" path="res://scripts/bullet.gd" id="1_v7oki"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rk402"]
|
||||||
|
size = Vector2(48, 6)
|
||||||
|
|
||||||
|
[node name="Bullet" type="Area2D" unique_id=1365507081]
|
||||||
|
script = ExtResource("1_v7oki")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=789397651]
|
||||||
|
shape = SubResource("RectangleShape2D_rk402")
|
||||||
|
debug_color = Color(0.8214046, 0, 0.03968804, 0.41960785)
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_scene format=3 uid="uid://5xgx7qarkj3o"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://rp1f47ytyerd" path="res://scripts/crate.gd" id="1_b66cd"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3udav"]
|
||||||
|
|
||||||
|
[node name="Crate" type="RigidBody2D" unique_id=643245962]
|
||||||
|
script = ExtResource("1_b66cd")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=712768436]
|
||||||
|
shape = SubResource("RectangleShape2D_3udav")
|
||||||
|
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
|
||||||
+28
-63
@@ -1,24 +1,23 @@
|
|||||||
[gd_scene format=3 uid="uid://cexci4ob8r45g"]
|
[gd_scene format=3 uid="uid://cexci4ob8r45g"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ct51411gsine2" path="res://scripts/gamecontroller.gd" id="1_lnu2h"]
|
[ext_resource type="Script" uid="uid://ct51411gsine2" path="res://scripts/gamecontroller.gd" id="1_lnu2h"]
|
||||||
[ext_resource type="Script" uid="uid://ct34rf6jscqmo" path="res://scripts/player.gd" id="1_uwrxv"]
|
[ext_resource type="Script" uid="uid://dv2q4p6jb8h4s" path="res://scripts/scene_manager.gd" id="2_lbhrr"]
|
||||||
[ext_resource type="Script" uid="uid://ck2uw1e2b0646" path="res://scripts/trigger.gd" id="1_yqjtg"]
|
[ext_resource type="PackedScene" uid="uid://b22qsgmtr231s" path="res://scenes/trigger.tscn" id="2_lnu2h"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://5xgx7qarkj3o" path="res://scenes/crate.tscn" id="3_iywne"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dtegcgc8xcxfg" path="res://scenes/player.tscn" id="4_iywne"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bdd87ih2rf4yk" path="res://scenes/bullet.tscn" id="6_p57ef"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rk402"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rk402"]
|
||||||
size = Vector2(336, 20)
|
size = Vector2(336, 20)
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3udav"]
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_rk402"]
|
|
||||||
radius = 21.0
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_3udav"]
|
|
||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_rk402"]
|
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_rk402"]
|
||||||
|
|
||||||
[node name="Game" type="Node2D" unique_id=55511178]
|
[node name="Game" type="Node2D" unique_id=55511178]
|
||||||
script = ExtResource("1_lnu2h")
|
script = ExtResource("1_lnu2h")
|
||||||
|
|
||||||
|
[node name="SceneManager" type="Node2D" parent="." unique_id=1159498670]
|
||||||
|
script = ExtResource("2_lbhrr")
|
||||||
|
|
||||||
[node name="StaticBody2D" type="StaticBody2D" parent="." unique_id=704028978]
|
[node name="StaticBody2D" type="StaticBody2D" parent="." unique_id=704028978]
|
||||||
position = Vector2(512, 413)
|
position = Vector2(512, 413)
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
@@ -27,59 +26,11 @@ metadata/_edit_group_ = true
|
|||||||
position = Vector2(134, 0)
|
position = Vector2(134, 0)
|
||||||
shape = SubResource("RectangleShape2D_rk402")
|
shape = SubResource("RectangleShape2D_rk402")
|
||||||
|
|
||||||
[node name="RigidBody2D" type="RigidBody2D" parent="." unique_id=1467136223]
|
[node name="Crate2" parent="." unique_id=643245962 instance=ExtResource("3_iywne")]
|
||||||
position = Vector2(520, -51)
|
position = Vector2(565, 386)
|
||||||
rotation = -0.5400262
|
|
||||||
metadata/_edit_group_ = true
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D" unique_id=2111742955]
|
[node name="Player" parent="." unique_id=196049189 instance=ExtResource("4_iywne")]
|
||||||
shape = SubResource("RectangleShape2D_3udav")
|
position = Vector2(649, 388)
|
||||||
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
|
|
||||||
|
|
||||||
[node name="RigidBody2D2" type="RigidBody2D" parent="." unique_id=375764923]
|
|
||||||
position = Vector2(512, 309)
|
|
||||||
rotation = -0.5400262
|
|
||||||
metadata/_edit_group_ = true
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D2" unique_id=1689937601]
|
|
||||||
shape = SubResource("RectangleShape2D_3udav")
|
|
||||||
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
|
|
||||||
|
|
||||||
[node name="RigidBody2D3" type="RigidBody2D" parent="." unique_id=1851225816]
|
|
||||||
position = Vector2(513, 269)
|
|
||||||
rotation = -0.5400262
|
|
||||||
metadata/_edit_group_ = true
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D3" unique_id=1720572197]
|
|
||||||
shape = SubResource("RectangleShape2D_3udav")
|
|
||||||
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
|
|
||||||
|
|
||||||
[node name="RigidBody2D4" type="RigidBody2D" parent="." unique_id=190350635]
|
|
||||||
position = Vector2(507, 236.99997)
|
|
||||||
rotation = -0.5400262
|
|
||||||
metadata/_edit_group_ = true
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D4" unique_id=938737972]
|
|
||||||
shape = SubResource("RectangleShape2D_3udav")
|
|
||||||
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
|
|
||||||
|
|
||||||
[node name="Trigger" type="Area2D" parent="." unique_id=644670290]
|
|
||||||
position = Vector2(442, 424)
|
|
||||||
script = ExtResource("1_yqjtg")
|
|
||||||
metadata/_edit_group_ = true
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Trigger" unique_id=258207955]
|
|
||||||
shape = SubResource("CircleShape2D_rk402")
|
|
||||||
debug_color = Color(0.7183221, 0.30049416, 0.93278134, 0.41960785)
|
|
||||||
|
|
||||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="." unique_id=1639753258]
|
|
||||||
position = Vector2(743, 389)
|
|
||||||
script = ExtResource("1_uwrxv")
|
|
||||||
metadata/_edit_group_ = true
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D" unique_id=1073881258]
|
|
||||||
shape = SubResource("CircleShape2D_3udav")
|
|
||||||
debug_color = Color(0.3147444, 0.626224, 7.70092e-07, 0.41960785)
|
|
||||||
|
|
||||||
[node name="StaticBody2D2" type="StaticBody2D" parent="." unique_id=220630225]
|
[node name="StaticBody2D2" type="StaticBody2D" parent="." unique_id=220630225]
|
||||||
position = Vector2(622, 483)
|
position = Vector2(622, 483)
|
||||||
@@ -96,5 +47,19 @@ metadata/_edit_group_ = true
|
|||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D3" unique_id=1824150982]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D3" unique_id=1824150982]
|
||||||
shape = SubResource("WorldBoundaryShape2D_rk402")
|
shape = SubResource("WorldBoundaryShape2D_rk402")
|
||||||
|
|
||||||
[connection signal="areaTriggered" from="Trigger" to="." method="_on_trigger"]
|
[node name="Triggers" type="Node2D" parent="." unique_id=262196455]
|
||||||
[connection signal="body_entered" from="Trigger" to="Trigger" method="_on_body_entered"]
|
|
||||||
|
[node name="Trigger" parent="Triggers" unique_id=976913827 instance=ExtResource("2_lnu2h")]
|
||||||
|
position = Vector2(321, 403)
|
||||||
|
effect = "teleport"
|
||||||
|
|
||||||
|
[node name="Trigger2" parent="Triggers" unique_id=1872559968 instance=ExtResource("2_lnu2h")]
|
||||||
|
position = Vector2(407, 406)
|
||||||
|
|
||||||
|
[node name="Crate" parent="." unique_id=329828405 instance=ExtResource("3_iywne")]
|
||||||
|
position = Vector2(742, 388)
|
||||||
|
|
||||||
|
[node name="Bullet" parent="." unique_id=1365507081 instance=ExtResource("6_p57ef")]
|
||||||
|
position = Vector2(469, 384)
|
||||||
|
|
||||||
|
[connection signal="areaTriggered" from="Triggers/Trigger" to="." method="_on_trigger"]
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dtegcgc8xcxfg"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ct34rf6jscqmo" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_3udav"]
|
||||||
|
|
||||||
|
[node name="Player" type="CharacterBody2D" unique_id=196049189]
|
||||||
|
script = ExtResource("1_3vyb7")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2119336955]
|
||||||
|
shape = SubResource("CircleShape2D_3udav")
|
||||||
|
debug_color = Color(0.3147444, 0.626224, 7.70092e-07, 0.41960785)
|
||||||
|
|
||||||
|
[node name="RightCast" type="RayCast2D" parent="." unique_id=2094112178]
|
||||||
|
target_position = Vector2(21, 0)
|
||||||
|
|
||||||
|
[node name="LeftCast" type="RayCast2D" parent="." unique_id=696595381]
|
||||||
|
target_position = Vector2(-22, 0)
|
||||||
|
|
||||||
|
[node name="RightSpawn" type="Marker2D" parent="." unique_id=1840944729]
|
||||||
|
position = Vector2(14, -6)
|
||||||
|
|
||||||
|
[node name="LeftSpawn" type="Marker2D" parent="." unique_id=441180819]
|
||||||
|
position = Vector2(-13, -6)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
[gd_scene format=3 uid="uid://b22qsgmtr231s"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ck2uw1e2b0646" path="res://scripts/trigger.gd" id="1_du5ex"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_rk402"]
|
||||||
|
radius = 21.0
|
||||||
|
|
||||||
|
[node name="Trigger" type="Area2D" unique_id=976913827]
|
||||||
|
script = ExtResource("1_du5ex")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1617755137]
|
||||||
|
shape = SubResource("CircleShape2D_rk402")
|
||||||
|
debug_color = Color(0.7183221, 0.30049416, 0.93278134, 0.41960785)
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
class_name Bullet extends Area2D
|
||||||
|
|
||||||
|
var speed := 700
|
||||||
|
signal bulletDamageSignal(body, bullet)
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
position += transform.x * speed * delta
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
|
print("Bullet hit something " + body.to_string())
|
||||||
|
bulletDamageSignal.emit(body, self)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://ryrc3a88d0nh
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
class_name Crate extends RigidBody2D
|
||||||
|
|
||||||
|
var teleport_target: Vector2 = Vector2.ZERO
|
||||||
|
var should_teleport: bool = false
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func teleport_to(position: Vector2):
|
||||||
|
teleport_target = position
|
||||||
|
should_teleport = true
|
||||||
|
|
||||||
|
func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
|
||||||
|
if should_teleport:
|
||||||
|
state.transform = Transform2D.IDENTITY.translated(teleport_target)
|
||||||
|
should_teleport = false
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://rp1f47ytyerd
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
extends Node2D
|
class_name GameController extends Node2D
|
||||||
|
|
||||||
|
signal teleportSignal(body)
|
||||||
|
|
||||||
# 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() -> void:
|
func _ready() -> void:
|
||||||
@@ -12,7 +13,19 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_trigger(effect: Variant, Object: Variant) -> void:
|
func _on_trigger(effect: Variant, Object: Variant) -> void:
|
||||||
print("GC knows about trigger")
|
print("GC knows about trigger: " + effect)
|
||||||
if effect == "destroy":
|
match effect:
|
||||||
|
"destroy":
|
||||||
if not Object is Player:
|
if not Object is Player:
|
||||||
Object.queue_free()
|
Object.queue_free()
|
||||||
|
"teleport":
|
||||||
|
print("Trigger wants to teleport")
|
||||||
|
if Object is Crate:
|
||||||
|
teleportSignal.emit(Object)
|
||||||
|
|
||||||
|
func _on_bullet_hit(body, bullet) -> void:
|
||||||
|
print("GC knows bullet hit")
|
||||||
|
if body is Crate:
|
||||||
|
body.queue_free()
|
||||||
|
bullet.queue_free()
|
||||||
|
|
||||||
+53
-2
@@ -1,15 +1,39 @@
|
|||||||
class_name Player extends CharacterBody2D
|
class_name Player extends CharacterBody2D
|
||||||
|
|
||||||
|
@onready var right_cast: RayCast2D = $RightCast
|
||||||
|
@onready var left_cast: RayCast2D = $LeftCast
|
||||||
|
@onready var right_spawn: Marker2D = $RightSpawn
|
||||||
|
@onready var left_spawn: Marker2D = $LeftSpawn
|
||||||
|
|
||||||
|
@export var shove_power:= 800
|
||||||
|
@export var bump_power:= 50
|
||||||
|
|
||||||
|
enum FaceDirection {LEFT, RIGHT}
|
||||||
|
var facing: FaceDirection = FaceDirection.RIGHT
|
||||||
|
|
||||||
|
var pushRightEnabled = false
|
||||||
|
var pushLeftEnabled = false
|
||||||
|
var pushTarget:Crate
|
||||||
|
|
||||||
const SPEED = 300.0
|
const SPEED = 300.0
|
||||||
const JUMP_VELOCITY = -400.0
|
const JUMP_VELOCITY = -400.0
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
if not is_on_floor():
|
if not is_on_floor():
|
||||||
velocity += get_gravity() * delta
|
velocity += get_gravity() * delta
|
||||||
|
|
||||||
|
# Handle shove.
|
||||||
|
if Input.is_action_just_pressed("shove"):
|
||||||
|
print("Player shove!")
|
||||||
|
if pushRightEnabled and facing==FaceDirection.RIGHT:
|
||||||
|
# shove it right
|
||||||
|
pushTarget.apply_central_impulse(Vector2(1,0) * shove_power)
|
||||||
|
if pushLeftEnabled and facing==FaceDirection.LEFT:
|
||||||
|
# shove it left
|
||||||
|
pushTarget.apply_central_impulse(Vector2(-1,0) * shove_power)
|
||||||
|
|
||||||
|
|
||||||
# Handle jump.
|
# Handle jump.
|
||||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||||
velocity.y = JUMP_VELOCITY
|
velocity.y = JUMP_VELOCITY
|
||||||
@@ -19,6 +43,11 @@ func _physics_process(delta: float) -> void:
|
|||||||
var direction := Input.get_axis("ui_left", "ui_right")
|
var direction := Input.get_axis("ui_left", "ui_right")
|
||||||
if direction:
|
if direction:
|
||||||
velocity.x = direction * SPEED
|
velocity.x = direction * SPEED
|
||||||
|
# set player direction
|
||||||
|
if direction < 0:
|
||||||
|
facing = FaceDirection.LEFT
|
||||||
|
if direction > 0:
|
||||||
|
facing = FaceDirection.RIGHT
|
||||||
else:
|
else:
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||||
|
|
||||||
@@ -27,4 +56,26 @@ func _physics_process(delta: float) -> void:
|
|||||||
for i in get_slide_collision_count():
|
for i in get_slide_collision_count():
|
||||||
var c = get_slide_collision(i)
|
var c = get_slide_collision(i)
|
||||||
if c.get_collider() is RigidBody2D:
|
if c.get_collider() is RigidBody2D:
|
||||||
c.get_collider().apply_central_impulse(-c.get_normal() * 200)
|
c.get_collider().apply_central_impulse(-c.get_normal() * bump_power)
|
||||||
|
|
||||||
|
if right_cast.is_colliding():
|
||||||
|
print("Something on my right")
|
||||||
|
# get the thing i can shove
|
||||||
|
var collider = right_cast.get_collider()
|
||||||
|
if collider is Node:
|
||||||
|
pushRightEnabled = true
|
||||||
|
pushTarget = collider
|
||||||
|
else:
|
||||||
|
pushRightEnabled = false
|
||||||
|
|
||||||
|
if left_cast.is_colliding():
|
||||||
|
print("Something on my left")
|
||||||
|
# get the thing i can shove
|
||||||
|
var collider = left_cast.get_collider()
|
||||||
|
if collider is Node:
|
||||||
|
pushLeftEnabled = true
|
||||||
|
pushTarget = collider
|
||||||
|
else:
|
||||||
|
pushLeftEnabled = false
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
class_name SceneManager extends Node2D
|
||||||
|
|
||||||
|
@onready var triggers: Node2D = $"../Triggers"
|
||||||
|
@onready var game: GameController = $".."
|
||||||
|
@onready var bullet: Bullet = $"../Bullet"
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
buildLevel()
|
||||||
|
game.teleportSignal.connect(teleport)
|
||||||
|
bullet.bulletDamageSignal.connect(game._on_bullet_hit)
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func buildLevel() -> void:
|
||||||
|
if triggers:
|
||||||
|
for obj in triggers.get_children():
|
||||||
|
if obj is Trigger:
|
||||||
|
if not obj.areaTriggered.is_connected(game._on_trigger):
|
||||||
|
obj.areaTriggered.connect(game._on_trigger)
|
||||||
|
|
||||||
|
func teleport(body, _bodyposition = null) -> void:
|
||||||
|
if body is Crate:
|
||||||
|
var viewport_size = get_viewport().get_visible_rect().size
|
||||||
|
var random_x = randf_range(0, viewport_size.x)
|
||||||
|
var random_y = randf_range(0, viewport_size.y)
|
||||||
|
var newPosition = Vector2(random_x, random_y)
|
||||||
|
body.teleport_to(newPosition)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dv2q4p6jb8h4s
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
extends Area2D
|
class_name Trigger extends Area2D
|
||||||
|
|
||||||
var effect="destroy"
|
@export var effect:String = "destroy"
|
||||||
signal areaTriggered(effect, Object)
|
signal areaTriggered(effect, Object)
|
||||||
# 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() -> void:
|
func _ready() -> void:
|
||||||
|
|||||||
Reference in new issue
Block a user