Skip to content

Commit

Permalink
add drone following player 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ole1711 committed Jan 22, 2024
1 parent ead39ec commit 09ca3cf
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 7 deletions.
11 changes: 7 additions & 4 deletions addons/pronto/behaviors/CollisionBehavior.gd
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ func _get_configuration_warnings():

func _on_area_2d_body_entered(body):
var dark = get_tree().get_nodes_in_group("dark")
var canvasModulate = dark[0]
canvasModulate.hide()
print("dark:", dark)
if dark:
var canvasModulate = dark[0]
canvasModulate.hide()

var light = get_tree().get_nodes_in_group("light")
var flashlight = light[0]
flashlight.hide()
if light:
var flashlight = light[0]
flashlight.hide()

#var canvasModulate = dark.get_node("CanvasModulate")
#var canvasModulate = get_parent().get_parent().find_child("CanvasModulate")
Expand Down
19 changes: 19 additions & 0 deletions level2.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[gd_scene load_steps=5 format=3 uid="uid://bpgsybybj4jmh"]

[ext_resource type="Texture2D" uid="uid://ej3g6agmjf0x" path="res://scenes/6.png" id="1_sm2i4"]
[ext_resource type="PackedScene" uid="uid://4j52c4ucysq5" path="res://Tilemap.tscn" id="2_7nhks"]
[ext_resource type="TileSet" uid="uid://dp12gfueqor5q" path="res://tileset.tres" id="3_34qp1"]
[ext_resource type="PackedScene" uid="uid://dxp4mlvvs0g2" path="res://scenes/player2.tscn" id="3_lafji"]

[node name="Level2" type="Node2D"]

[node name="6" type="Sprite2D" parent="."]
position = Vector2(578, 319)
scale = Vector2(2.01189, 2.01189)
texture = ExtResource("1_sm2i4")

[node name="TileMap" parent="." instance=ExtResource("2_7nhks")]
tile_set = ExtResource("3_34qp1")

[node name="Player2" parent="." instance=ExtResource("3_lafji")]
position = Vector2(313, 419)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://addons/pronto/behaviors/ExportBehavior.gd" id="1"]
[ext_resource type="Script" path="res://prototypes/game-shadows-of-surveillance/game-shadows-of-surveillance.gd" id="1_odj0a"]
[ext_resource type="PackedScene" uid="uid://dyvtu758xr2so" path="res://scenes/level.tscn" id="3_3xcs3"]
[ext_resource type="PackedScene" uid="uid://bpgsybybj4jmh" path="res://scenes/level2.tscn" id="4_l12nx"]
[ext_resource type="PackedScene" uid="uid://c7nvl73x1g6ig" path="res://scenes/level2.tscn" id="4_bj0tv"]

[node name="Game" type="Node2D"]
script = ExtResource("1_odj0a")
Expand Down Expand Up @@ -43,7 +43,7 @@ render_target_update_mode = 4

[node name="Camera2D" type="Camera2D" parent="RightSubViewportContainer/SubViewport"]

[node name="Level2" parent="RightSubViewportContainer/SubViewport" instance=ExtResource("4_l12nx")]
[node name="Level2" parent="RightSubViewportContainer/SubViewport" instance=ExtResource("4_bj0tv")]

[node name="ColorRect" type="ColorRect" parent="."]
offset_left = 566.0
Expand Down
Binary file modified prototypes/game-shadows-of-surveillance/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scenes/drone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions scenes/drone.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dn1e3hoeursu"
path="res://.godot/imported/drone.png-9944b21944f7dbd30dc9e145ede24a7f.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://scenes/drone.png"
dest_files=["res://.godot/imported/drone.png-9944b21944f7dbd30dc9e145ede24a7f.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
1 change: 1 addition & 0 deletions scenes/level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ collision_layer = 3
collision_mask = 3

[node name="LightSwitchBehavior" type="Node2D" parent="Player1"]
position = Vector2(1.74846e-05, -200)
script = ExtResource("6_i4obq")
limit_to_group = "button"

Expand Down
76 changes: 75 additions & 1 deletion scenes/level2.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
[gd_scene load_steps=6 format=3 uid="uid://bpgsybybj4jmh"]
[gd_scene load_steps=17 format=3 uid="uid://c7nvl73x1g6ig"]

[ext_resource type="Texture2D" uid="uid://ej3g6agmjf0x" path="res://scenes/6.png" id="1_sm2i4"]
[ext_resource type="PackedScene" uid="uid://4j52c4ucysq5" path="res://Tilemap.tscn" id="2_7nhks"]
[ext_resource type="TileSet" uid="uid://dp12gfueqor5q" path="res://tileset.tres" id="3_34qp1"]
[ext_resource type="PackedScene" uid="uid://dxp4mlvvs0g2" path="res://scenes/player2.tscn" id="3_lafji"]
[ext_resource type="Texture2D" uid="uid://ch6w3mr4w7ueu" path="res://LightSprite.png" id="5_kwx7m"]
[ext_resource type="Texture2D" uid="uid://dn1e3hoeursu" path="res://scenes/drone.png" id="6_yo0f5"]
[ext_resource type="Script" path="res://addons/pronto/behaviors/MoveBehavior.gd" id="7_ooonu"]
[ext_resource type="Script" path="res://addons/pronto/behaviors/AlwaysBehavior.gd" id="8_wsqn2"]
[ext_resource type="Script" path="res://addons/pronto/helpers/ConnectionScript.gd" id="9_6atqn"]
[ext_resource type="Script" path="res://addons/pronto/helpers/Connection.gd" id="10_wl7i3"]

[sub_resource type="CircleShape2D" id="CircleShape2D_kvhpb"]

[sub_resource type="GDScript" id="GDScript_6kxwn"]
script/source = "@tool
extends U
@warning_ignore(\"unused_parameter\")
func run(delta, from: Node2D, to: Node2D):
var player = get_parent().get_parent().get_parent().get_node(\"Player2\")
var random_x = randf_range(-50, 50)
var random_y = randf_range(-50, 50)
return (player.position - to.get_parent().position + Vector2(random_x, random_y)).normalized()
"
[sub_resource type="Resource" id="Resource_htvxy"]
script = ExtResource("9_6atqn")
nested_script = SubResource("GDScript_6kxwn")
argument_names = ["delta", "from", "to"]
return_value = true
[sub_resource type="GDScript" id="GDScript_jvn02"]
script/source = "@tool
extends U
@warning_ignore(\"unused_parameter\")
func run(delta, from: Node2D, to: Node2D):
return true
"
[sub_resource type="Resource" id="Resource_lsqwp"]
script = ExtResource("9_6atqn")
nested_script = SubResource("GDScript_jvn02")
argument_names = ["delta", "from", "to"]
return_value = true
[sub_resource type="Resource" id="Resource_81ot0"]
script = ExtResource("10_wl7i3")
signal_name = "always"
to = NodePath("..")
more_references = []
invoke = "move_direction"
arguments = [SubResource("Resource_htvxy")]
only_if = SubResource("Resource_lsqwp")
deferred = false
enabled = true
trigger = ""
[node name="Level2" type="Node2D"]
Expand All @@ -25,3 +75,27 @@ position = Vector2(313, 419)
[node name="Flashlight" type="PointLight2D" parent="Player2" groups=["light"]]
position = Vector2(3.87598, 31.0078)
texture = ExtResource("5_kwx7m")
[node name="Enemy" type="CharacterBody2D" parent="."]
position = Vector2(637, 360)
scale = Vector2(0.274855, 0.274855)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Enemy"]
position = Vector2(7.27649, -10.9149)
scale = Vector2(8.32211, 8.32211)
shape = SubResource("CircleShape2D_kvhpb")
[node name="Sprite2D" type="Sprite2D" parent="Enemy"]
texture = ExtResource("6_yo0f5")
[node name="MoveBehavior" type="Node2D" parent="Enemy"]
position = Vector2(4.34964e-06, -49.7541)
script = ExtResource("7_ooonu")
max_velocity = 100.0
acceleration = 20.0
[node name="AlwaysBehavior" type="Node2D" parent="Enemy/MoveBehavior"]
position = Vector2(-35.1815, 14.5728)
scale = Vector2(1, 1)
script = ExtResource("8_wsqn2")
metadata/pronto_connections = [SubResource("Resource_81ot0")]

0 comments on commit 09ca3cf

Please sign in to comment.