Skip to content

Commit

Permalink
added light switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Matvey Sivachinski authored and Matvey Sivachinski committed Jan 22, 2024
1 parent 5cd951d commit ead39ec
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 5 deletions.
Binary file added LightSprite.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 LightSprite.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ch6w3mr4w7ueu"
path="res://.godot/imported/LightSprite.png-73ae155e50073ee4edddec7c4786da56.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://LightSprite.png"
dest_files=["res://.godot/imported/LightSprite.png-73ae155e50073ee4edddec7c4786da56.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
24 changes: 23 additions & 1 deletion addons/pronto/behaviors/CollisionBehavior.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var screen_entered_emitted = false
var screen_exited_emitted = false

func _ready():
var scene_b = preload("res://scenes/level2.tscn")
super._ready()
if not Engine.is_editor_hint():
var p = get_parent()
Expand All @@ -36,7 +37,8 @@ func _ready():
(p as RigidBody2D).max_contacts_reported = max((p as RigidBody2D).max_contacts_reported, 1)
if get_parent() is StaticBody2D:
push_error("StaticBody2D cannot report collisions in Godot. Move the Collision to the other collision partner.")



func _physics_process(delta):
if get_parent() is CharacterBody2D:
var parent = (get_parent() as CharacterBody2D)
Expand Down Expand Up @@ -80,3 +82,23 @@ func _get_configuration_warnings():
if not is_valid_parent():
return ["Collision only works with Area2D, RigidBody2D and CharacterBody2D"]
return ""

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

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

#var canvasModulate = dark.get_node("CanvasModulate")
#var canvasModulate = get_parent().get_parent().find_child("CanvasModulate")
#canvasModulate.hide()

#dark.hide()
#var flashLight = level2.get_node("Flashlight")
#flashLight.hide()
#var timer = get_parent().get_parent().get_parent().find_child("Timer")
#timer.set_one_shot(true)
#timer.start(3)
Binary file added background.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 background.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bauf77n1ppfno"
path="res://.godot/imported/background.png-98289422cd7d93003950872a7b97021f.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://background.png"
dest_files=["res://.godot/imported/background.png-98289422cd7d93003950872a7b97021f.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
2 changes: 1 addition & 1 deletion prototypes/game-shadows-of-surveillance/game_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"Matvey Sivashinski"
],
"description": "You are a brilliant scientist who just discovered time travel. Unfortunately, during your first test, something goes wrong and your mind is split into two parts, one part travels to the future and one is stuck in the present. \nIn this coop split screen game, your goal is to somehow recombine the two parts of your mind. But be careful: In the future, some things have changed...",
"time": "2024-01-21",
"time": "2024-01-22",
"title": "Shadows of Surveillance"
}
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.
15 changes: 15 additions & 0 deletions scenes/LightSwitch.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends Area2D


# Called when the node enters the scene tree for the first time.
func _ready():
pass
#var lightswitch_x = randf_range(100, 1200) #all values are 100 away from boundary
#var lightswitch_y = randf_range(100, 500)
#set_global_position(Vector2(lightswitch_x, lightswitch_y))
#get_node("SwitchPlaceholderBehavior").set_global_position(Vector2(lightswitch_x, lightswitch_y))


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
29 changes: 27 additions & 2 deletions scenes/level.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[gd_scene load_steps=4 format=3 uid="uid://dyvtu758xr2so"]
[gd_scene load_steps=8 format=3 uid="uid://dyvtu758xr2so"]

[ext_resource type="Texture2D" uid="uid://bhjxc5s34c3cu" path="res://prototypes/game-shadows-of-surveillance/10.png" id="1_elldh"]
[ext_resource type="Script" path="res://scenes/LightSwitch.gd" id="2_4klox"]
[ext_resource type="Script" path="res://addons/pronto/behaviors/PlaceholderBehavior.gd" id="3_euvp3"]
[ext_resource type="TileSet" uid="uid://dp12gfueqor5q" path="res://tileset.tres" id="3_r5ys7"]
[ext_resource type="PackedScene" uid="uid://c5c24526dtufn" path="res://scenes/player1.tscn" id="3_x2hlg"]
[ext_resource type="Texture2D" uid="uid://dn87bxukebfvu" path="res://icon.svg" id="4_rqfal"]
[ext_resource type="Script" path="res://addons/pronto/behaviors/CollisionBehavior.gd" id="6_i4obq"]

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

Expand All @@ -11,10 +15,31 @@ position = Vector2(577, 323.5)
scale = Vector2(0.499132, 0.500772)
texture = ExtResource("1_elldh")

[node name="Player1" parent="." instance=ExtResource("3_x2hlg")]
[node name="LightSwitch" type="Area2D" parent="." groups=["button"]]
position = Vector2(466, 480)
scale = Vector2(0.99, 0.99)
collision_layer = 2
collision_mask = 2
script = ExtResource("2_4klox")

[node name="SwitchPlaceholderBehavior" type="Node2D" parent="LightSwitch" groups=["button"]]
script = ExtResource("3_euvp3")
color = Color(1, 1, 0.0313726, 1)
sprite_texture = ExtResource("4_rqfal")
placeholder_size = Vector2(20, 20)

[node name="Player1" parent="." groups=["player"] instance=ExtResource("3_x2hlg")]
position = Vector2(99, 467)
collision_layer = 3
collision_mask = 3

[node name="LightSwitchBehavior" type="Node2D" parent="Player1"]
script = ExtResource("6_i4obq")
limit_to_group = "button"

[node name="TileMap" type="TileMap" parent="."]
tile_set = ExtResource("3_r5ys7")
format = 2
layer_0/tile_data = PackedInt32Array(2424834, 524288, 6, 2424835, 589824, 6, 2424836, 589824, 6, 2424837, 589824, 6, 2424838, 589824, 6, 2424839, 589824, 6, 2424840, 589824, 6, 2424841, 589824, 6, 2424842, 589824, 6, 2424843, 589824, 6, 2424844, 589824, 6, 2424845, 589824, 6, 2424846, 589824, 6, 2424847, 589824, 6, 2424848, 589824, 6, 2424849, 589824, 6, 2490370, 524288, 7, 2555906, 524288, 7, 2621442, 524288, 7, 2490371, 589824, 7, 2555907, 589824, 7, 2621443, 589824, 7, 2621444, 589824, 7, 2621445, 589824, 7, 2621446, 589824, 7, 2621447, 589824, 7, 2621448, 589824, 7, 2621449, 589824, 7, 2621450, 589824, 7, 2621451, 589824, 7, 2621452, 589824, 7, 2621453, 589824, 7, 2621454, 589824, 7, 2621455, 589824, 7, 2621456, 589824, 7, 2621457, 589824, 7, 2621458, 589824, 7, 2555922, 589824, 7, 2490386, 589824, 7, 2490385, 589824, 7, 2490384, 589824, 7, 2490383, 589824, 7, 2490382, 589824, 7, 2490381, 589824, 7, 2490380, 589824, 7, 2490379, 589824, 7, 2490378, 589824, 7, 2490377, 589824, 7, 2490376, 589824, 7, 2490375, 589824, 7, 2490374, 589824, 7, 2490373, 589824, 7, 2490372, 589824, 7, 2555908, 589824, 7, 2555909, 589824, 7, 2555910, 589824, 7, 2555911, 589824, 7, 2555912, 589824, 7, 2555913, 589824, 7, 2555914, 589824, 7, 2555915, 589824, 7, 2555916, 589824, 7, 2555917, 589824, 7, 2555918, 589824, 7, 2555919, 589824, 7, 2555920, 589824, 7, 2555921, 589824, 7, 2424850, 589824, 6, 2490387, 655360, 7, 2424851, 655360, 6, 2555923, 655360, 7, 2621459, 655360, 7, 2228250, 589824, 7, 2228251, 589824, 6, 2228252, 589824, 6, 2228253, 589824, 6, 2228254, 589824, 6, 2228255, 589824, 6, 2228256, 589824, 6, 2228257, 589824, 6, 2228258, 589824, 6, 2228259, 589824, 6, 2228260, 589824, 6, 2228261, 589824, 6, 2228262, 589824, 6, 2228263, 589824, 6, 2228264, 589824, 6, 2228249, 524288, 6, 2293785, 524288, 7, 2359321, 524288, 7, 2424857, 589824, 7, 2490393, 589824, 7, 2555928, 524288, 7, 2621464, 524288, 7, 2490392, 524288, 6, 2555929, 589824, 7, 2621465, 589824, 7, 2293786, 589824, 7, 2359322, 589824, 7, 2424858, 589824, 7, 2490394, 589824, 7, 2555930, 589824, 7, 2621466, 589824, 7, 2293787, 589824, 7, 2293788, 589824, 7, 2293789, 589824, 7, 2293790, 589824, 7, 2293791, 589824, 7, 2293792, 589824, 7, 2293793, 589824, 7, 2293794, 589824, 7, 2293795, 589824, 7, 2293796, 589824, 7, 2293797, 589824, 7, 2293798, 589824, 7, 2293799, 589824, 7, 2293800, 589824, 7, 2359336, 589824, 7, 2424872, 589824, 7, 2490408, 589824, 7, 2555944, 589824, 7, 2621480, 589824, 7, 2621479, 589824, 7, 2621478, 589824, 7, 2621477, 589824, 7, 2621476, 589824, 7, 2621475, 589824, 7, 2621474, 589824, 7, 2621473, 589824, 7, 2621472, 589824, 7, 2621471, 589824, 7, 2621470, 589824, 7, 2621469, 589824, 7, 2621468, 589824, 7, 2621467, 589824, 7, 2555931, 589824, 7, 2490396, 589824, 7, 2424859, 589824, 7, 2490395, 589824, 7, 2359323, 589824, 7, 2424860, 589824, 7, 2555933, 589824, 7, 2490397, 589824, 7, 2424861, 589824, 7, 2359325, 589824, 7, 2359324, 589824, 7, 2555932, 589824, 7, 2359327, 589824, 7, 2424863, 589824, 7, 2490399, 589824, 7, 2555935, 589824, 7, 2555934, 589824, 7, 2490398, 589824, 7, 2424862, 589824, 7, 2359326, 589824, 7, 2359328, 589824, 7, 2424864, 589824, 7, 2490400, 589824, 7, 2555936, 589824, 7, 2490401, 589824, 7, 2424865, 589824, 7, 2359329, 589824, 7, 2555937, 589824, 7, 2555938, 589824, 7, 2490402, 589824, 7, 2424866, 589824, 7, 2359330, 589824, 7, 2490403, 589824, 7, 2424867, 589824, 7, 2359331, 589824, 7, 2555939, 589824, 7, 2555940, 589824, 7, 2490404, 589824, 7, 2424868, 589824, 7, 2359332, 589824, 7, 2555941, 589824, 7, 2490405, 589824, 7, 2424869, 589824, 7, 2359333, 589824, 7, 2555942, 589824, 7, 2490406, 589824, 7, 2424870, 589824, 7, 2359334, 589824, 7, 2555943, 589824, 7, 2490407, 589824, 7, 2424871, 589824, 7, 2359335, 589824, 7, 2228265, 655360, 6, 2293801, 655360, 7, 2359337, 655360, 7, 2424873, 655360, 7, 2490409, 655360, 7, 2555945, 655360, 7, 2621481, 655360, 7)

[connection signal="body_entered" from="LightSwitch" to="Player1/LightSwitchBehavior" method="_on_area_2d_body_entered"]
10 changes: 9 additions & 1 deletion scenes/level2.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://bpgsybybj4jmh"]
[gd_scene load_steps=6 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"]
[ext_resource type="Texture2D" uid="uid://ch6w3mr4w7ueu" path="res://LightSprite.png" id="5_kwx7m"]

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

Expand All @@ -12,8 +13,15 @@ position = Vector2(578, 319)
scale = Vector2(2.01189, 2.01189)
texture = ExtResource("1_sm2i4")

[node name="CanvasModulate" type="CanvasModulate" parent="6" groups=["dark"]]
color = Color(0, 0, 0, 1)

[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)

[node name="Flashlight" type="PointLight2D" parent="Player2" groups=["light"]]
position = Vector2(3.87598, 31.0078)
texture = ExtResource("5_kwx7m")

0 comments on commit ead39ec

Please sign in to comment.