Skip to content

Commit 213549d

Browse files
committedMay 5, 2018
Merge remote-tracking branch 'origin/master'
2 parents 9fe70be + a5dfa4f commit 213549d

File tree

12 files changed

+219
-35
lines changed

12 files changed

+219
-35
lines changed
 

‎characters/enemies/angel/angel.gd

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func on_entered_light(player):
2222
enemy_state = ENEMY_STATE.blinded
2323

2424
func on_exited_light(player):
25+
if enemy_state != ENEMY_STATE.blinded:
26+
return
2527
followed_player = player
2628
enemy_state = ENEMY_STATE.following
2729

‎characters/enemies/hugger/hugger.gd

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func on_entered_light(player):
3030
enemy_state = ENEMY_STATE.following_in_light
3131

3232
func on_exited_light(player):
33+
if enemy_state != ENEMY_STATE.following_in_light:
34+
return
3335
followed_player = player
3436
enemy_state = ENEMY_STATE.following_out_of_light
3537
time_to_follow = MAX_TIME_TO_FOLLOW

‎characters/enemies/hugger/hugger.tscn

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ radius = 4.71644
1111
[node name="hugger" type="PathFollow2D"]
1212

1313
position = Vector2( 22.5455, 5.84727 )
14+
rotation = 3.14159
1415
offset = 0.0
1516
h_offset = 0.0
1617
v_offset = 0.0

‎characters/player/player.gd

+34-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ extends KinematicBody2D
22

33
export (float, 0, 100, 0.1) var speed = 40
44

5+
var enemies_in_flashlight_area = []
6+
var time_till_flashlight_toggleable = 0.2
7+
58
func _ready():
69
if (config.no_enemy_collision):
710
set_collision_mask_bit(1, false)
811
set_collision_layer_bit(1, false)
12+
$flashlight_animation_player.play("flickering")
913

1014
func _process(delta):
15+
time_till_flashlight_toggleable -= delta
16+
1117
var direction = Vector2()
1218
if(Input.is_action_pressed("move_left")):
1319
rotation_degrees = 180
@@ -22,16 +28,42 @@ func _process(delta):
2228
rotation_degrees = 270
2329
direction = Vector2(0, -1)
2430

31+
if Input.is_action_just_pressed("toggle_flashlight") and time_till_flashlight_toggleable <= 0:
32+
$flashlight.enabled = !$flashlight.enabled
33+
$flashlight/area/shape.disabled = !$flashlight/area/shape.disabled
34+
2535
var distance = speed * delta * direction
2636
move_and_collide(distance)
37+
38+
func _physics_process(delta):
39+
if $flashlight.enabled:
40+
for enemy in enemies_in_flashlight_area:
41+
if not is_something_in_between(global_position, enemy.global_position):
42+
enemy.on_entered_light(self)
43+
44+
45+
func is_something_in_between(pos1, pos2):
46+
var space_state = get_world_2d().direct_space_state
47+
var intersection = space_state.intersect_ray(pos1, pos2, [self, $flashlight/area/CollisionShape2D, $flashlight/area])
48+
#Debug code for ray casting, shows ray cast intersection point
49+
#var s = Sprite.new()
50+
#s.texture = preload("res://characters/player/lightcircle01.png")
51+
#s.position = intersection.position
52+
#s.scale = Vector2(0.01, 0.01)
53+
#get_parent().add_child(s)
54+
var distance = intersection.position.distance_to(pos2)
55+
# Magic value to take area of collision objects into account
56+
distance -= 8
57+
return distance > 1
2758

2859
func _on_flashlight_area_body_entered(body):
2960
if body.is_in_group("enemy_flashlight_collider"):
30-
body.on_entered_light(self)
61+
enemies_in_flashlight_area.push_back(body)
3162

3263

3364
func _on_flashlight_area_body_exited(body):
3465
if body.is_in_group("enemy_flashlight_collider"):
66+
enemies_in_flashlight_area.remove(enemies_in_flashlight_area.find(body))
3567
body.on_exited_light(self)
3668

3769

@@ -42,4 +74,4 @@ func _on_neighborhood_area_body_entered(body):
4274

4375
func _on_neighborhood_area_body_exited(body):
4476
if body.is_in_group("enemy_neighborhood_collider"):
45-
body.on_exited_neighborhood(self)
77+
body.on_exited_neighborhood(self)

‎characters/player/player.tscn

+37-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=8 format=2]
1+
[gd_scene load_steps=9 format=2]
22

33
[ext_resource path="res://characters/player/player.gd" type="Script" id=1]
44
[ext_resource path="res://characters/player/lightcone01.png" type="Texture" id=2]
@@ -15,12 +15,30 @@ extents = Vector2( 5.80276, 6.68023 )
1515
custom_solver_bias = 0.0
1616
points = PoolVector2Array( 0, -10, 8.66025, 5, -8.66025, 5 )
1717

18-
[sub_resource type="CircleShape2D" id=3]
18+
[sub_resource type="Animation" id=3]
19+
20+
length = 0.2
21+
loop = true
22+
step = 0.05
23+
tracks/0/type = "value"
24+
tracks/0/path = NodePath("flashlight:energy")
25+
tracks/0/interp = 1
26+
tracks/0/loop_wrap = true
27+
tracks/0/imported = false
28+
tracks/0/enabled = true
29+
tracks/0/keys = {
30+
"times": PoolRealArray( 0, 0.05, 0.1, 0.15, 0.2 ),
31+
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
32+
"update": 0,
33+
"values": [ 0.8, 0.9, 0.85, 1.1, 1.0 ]
34+
}
35+
36+
[sub_resource type="CircleShape2D" id=4]
1937

2038
custom_solver_bias = 0.0
2139
radius = 185.937
2240

23-
[node name="player" type="KinematicBody2D" index="0"]
41+
[node name="player" type="KinematicBody2D"]
2442

2543
input_pickable = false
2644
collision_layer = 2
@@ -77,20 +95,31 @@ audio_bus_override = false
7795
audio_bus_name = "Master"
7896
_sections_unfolded = [ "Transform" ]
7997

80-
[node name="CollisionShape2D" type="CollisionShape2D" parent="flashlight/area" index="0"]
98+
[node name="shape" type="CollisionShape2D" parent="flashlight/area" index="0"]
8199

82100
position = Vector2( -81.8826, 38.7309 )
83101
rotation = 4.71239
84102
scale = Vector2( 6.17808, 13.4807 )
85103
shape = SubResource( 2 )
86104
_sections_unfolded = [ "Transform" ]
87105

88-
[node name="Sprite" type="Sprite" parent="." index="2"]
106+
[node name="flashlight_animation_player" type="AnimationPlayer" parent="." index="2"]
107+
108+
root_node = NodePath("..")
109+
autoplay = ""
110+
playback_process_mode = 1
111+
playback_default_blend_time = 0.0
112+
playback_speed = 1.0
113+
anims/flickering = SubResource( 3 )
114+
blend_times = [ ]
115+
_sections_unfolded = [ "Playback Options" ]
116+
117+
[node name="Sprite" type="Sprite" parent="." index="3"]
89118

90119
texture = ExtResource( 3 )
91120
_sections_unfolded = [ "Transform" ]
92121

93-
[node name="personalLight" type="Light2D" parent="." index="3"]
122+
[node name="personalLight" type="Light2D" parent="." index="4"]
94123

95124
scale = Vector2( 0.121984, 0.120942 )
96125
enabled = true
@@ -116,7 +145,7 @@ shadow_filter_smooth = 0.0
116145
shadow_item_cull_mask = 1
117146
_sections_unfolded = [ "Transform" ]
118147

119-
[node name="neighborhood" type="Area2D" parent="." index="4"]
148+
[node name="neighborhood" type="Area2D" parent="." index="5"]
120149

121150
input_pickable = true
122151
gravity_vec = Vector2( 0, 1 )
@@ -128,7 +157,7 @@ audio_bus_name = "Master"
128157

129158
[node name="CollisionShape2D" type="CollisionShape2D" parent="neighborhood" index="0"]
130159

131-
shape = SubResource( 3 )
160+
shape = SubResource( 4 )
132161

133162
[connection signal="body_entered" from="flashlight/area" to="." method="_on_flashlight_area_body_entered"]
134163

‎characters/tapir.png.import

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ source_file="res://characters/tapir.png"
1010
source_md5="f3cd3b6fab7cd74e6488f2ba0e10d42c"
1111

1212
dest_files=[ "res://.import/tapir.png-d21c8d954ba0274a61e8cf1093c961c8.stex" ]
13-
dest_md5="b15e5a743eed8a067559eab71731748f"
13+
dest_md5="e5268f3fd75d0847e1e2b6525c03197c"
1414

1515
[params]
1616

@@ -19,7 +19,7 @@ compress/lossy_quality=0.7
1919
compress/hdr_mode=0
2020
compress/normal_map=0
2121
flags/repeat=0
22-
flags/filter=true
22+
flags/filter=false
2323
flags/mipmaps=false
2424
flags/anisotropic=false
2525
flags/srgb=2
@@ -28,5 +28,5 @@ process/premult_alpha=false
2828
process/HDR_as_SRGB=false
2929
stream=false
3030
size_limit=0
31-
detect_3d=true
31+
detect_3d=false
3232
svg/scale=1.0

‎game.gd

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
extends Node2D
22

33
func _ready():
4-
if OS.has_feature('JavaScript'):
5-
# Maximize game in browsers
6-
OS.set_window_maximized(true)
4+
pass

‎intro.gd

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
extends Node
22

33
func _ready():
4+
if OS.has_feature('JavaScript'):
5+
# Maximize game in browsers, because fullscreen
6+
# requires extra permissions
7+
OS.window_maximized = true
8+
elif not OS.is_debug_build():
9+
# Go fullscreen on desktop, but not when running
10+
# a debug build.
11+
OS.window_fullscreen = true
12+
413
$start_timer.start()
514

615
func _on_intro_player_animation_finished(anim_name):

‎intro.tscn

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tracks/0/keys = {
4141
"values": [ 0.0, 1.0 ]
4242
}
4343

44-
[node name="Node" type="Node" index="0"]
44+
[node name="Node" type="Node"]
4545

4646
script = ExtResource( 1 )
4747

‎project.godot

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ config_version=3
1111
[application]
1212

1313
config/name="TotallyTerrifyingTurns"
14-
run/main_scene="res://game.tscn"
14+
run/main_scene="res://intro.tscn"
1515
config/icon="res://icon.png"
1616

1717
[autoload]
@@ -32,6 +32,8 @@ move_up=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"
3232
move_down=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
3333
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
3434
]
35+
toggle_flashlight=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null)
36+
]
3537

3638
[rendering]
3739

‎torch/torch.gd

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extends StaticBody2D
2+
3+
func _ready():
4+
$light_animation_player.play("flickering")

‎torch/torch.tscn

+122-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
[gd_scene load_steps=12 format=2]
2-
3-
[ext_resource path="res://torch/tiles/tiles-72.png" type="Texture" id=1]
4-
[ext_resource path="res://torch/tiles/tiles-73.png" type="Texture" id=2]
5-
[ext_resource path="res://torch/tiles/tiles-74.png" type="Texture" id=3]
6-
[ext_resource path="res://torch/tiles/tiles-75.png" type="Texture" id=4]
7-
[ext_resource path="res://torch/tiles/tiles-76.png" type="Texture" id=5]
8-
[ext_resource path="res://torch/tiles/tiles-77.png" type="Texture" id=6]
9-
[ext_resource path="res://torch/tiles/tiles-78.png" type="Texture" id=7]
10-
[ext_resource path="res://torch/tiles/tiles-79.png" type="Texture" id=8]
11-
[ext_resource path="res://torch/LightSource.png" type="Texture" id=9]
1+
[gd_scene load_steps=17 format=2]
2+
3+
[ext_resource path="res://torch/torch.gd" type="Script" id=1]
4+
[ext_resource path="res://torch/tiles/tiles-72.png" type="Texture" id=2]
5+
[ext_resource path="res://torch/tiles/tiles-73.png" type="Texture" id=3]
6+
[ext_resource path="res://torch/tiles/tiles-74.png" type="Texture" id=4]
7+
[ext_resource path="res://torch/tiles/tiles-75.png" type="Texture" id=5]
8+
[ext_resource path="res://torch/tiles/tiles-76.png" type="Texture" id=6]
9+
[ext_resource path="res://torch/tiles/tiles-77.png" type="Texture" id=7]
10+
[ext_resource path="res://torch/tiles/tiles-78.png" type="Texture" id=8]
11+
[ext_resource path="res://torch/tiles/tiles-79.png" type="Texture" id=9]
12+
[ext_resource path="res://torch/LightSource.png" type="Texture" id=10]
1213

1314
[sub_resource type="SpriteFrames" id=1]
1415

1516
animations = [ {
16-
"frames": [ ExtResource( 1 ), ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ) ],
17+
"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ) ],
1718
"loop": true,
1819
"name": "default",
1920
"speed": 8.0
@@ -24,21 +25,92 @@ animations = [ {
2425
custom_solver_bias = 0.0
2526
extents = Vector2( 10, 11.084 )
2627

27-
[node name="torch" type="StaticBody2D"]
28+
[sub_resource type="Animation" id=3]
29+
30+
resource_name = "flickering"
31+
length = 0.2
32+
loop = true
33+
step = 0.1
34+
tracks/0/type = "value"
35+
tracks/0/path = NodePath("Light2D:energy")
36+
tracks/0/interp = 0
37+
tracks/0/loop_wrap = true
38+
tracks/0/imported = false
39+
tracks/0/enabled = true
40+
tracks/0/keys = {
41+
"times": PoolRealArray( 0, 0.1 ),
42+
"transitions": PoolRealArray( 1, 1 ),
43+
"update": 1,
44+
"values": [ 0.99, 1.02 ]
45+
}
46+
47+
[sub_resource type="Gradient" id=4]
48+
49+
offsets = PoolRealArray( 0, 0.0102828, 1 )
50+
colors = PoolColorArray( 0, 0, 0, 1, 0.9375, 0.772753, 0.0206498, 1, 0.914063, 0.354099, 0.0181202, 1 )
51+
52+
[sub_resource type="GradientTexture" id=5]
53+
54+
flags = 4
55+
gradient = SubResource( 4 )
56+
width = 2048
57+
58+
[sub_resource type="ParticlesMaterial" id=6]
59+
60+
render_priority = 0
61+
trail_divisor = 1
62+
emission_shape = 0
63+
flag_align_y = false
64+
flag_rotate_y = false
65+
flag_disable_z = true
66+
spread = 90.0
67+
flatness = 0.0
68+
gravity = Vector3( -5, -15, 0 )
69+
initial_velocity = 1.0
70+
initial_velocity_random = 0.0
71+
angular_velocity = 1.04537e-42
72+
angular_velocity_random = 0.0
73+
orbit_velocity = 0.0
74+
orbit_velocity_random = 0.0
75+
linear_accel = 0.0
76+
linear_accel_random = 0.0
77+
radial_accel = 12.0
78+
radial_accel_random = 0.0
79+
tangential_accel = 0.0
80+
tangential_accel_random = 0.0
81+
damping = 0.0
82+
damping_random = 0.0
83+
angle = 0.0
84+
angle_random = 0.0
85+
scale = 1.0
86+
scale_random = 0.0
87+
color_ramp = SubResource( 5 )
88+
hue_variation = 0.0
89+
hue_variation_random = 0.0
90+
anim_speed = 0.0
91+
anim_speed_random = 0.0
92+
anim_offset = 0.0
93+
anim_offset_random = 0.0
94+
anim_loop = false
95+
_sections_unfolded = [ "Color", "Emission Shape", "Flags", "Gravity", "Initial Velocity", "Radial Accel", "Spread", "Trail" ]
96+
97+
[node name="torch" type="StaticBody2D" index="0"]
2898

2999
input_pickable = false
30-
collision_layer = 2
31-
collision_mask = 3
100+
collision_layer = 1
101+
collision_mask = 1
32102
constant_linear_velocity = Vector2( 0, 0 )
33103
constant_angular_velocity = 0.0
34104
friction = 1.0
35105
bounce = 0.0
106+
script = ExtResource( 1 )
36107
_sections_unfolded = [ "Collision" ]
37108

38109
[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"]
39110

40111
frames = SubResource( 1 )
41112
animation = "default"
113+
frame = 5
42114
playing = true
43115

44116
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
@@ -50,11 +122,11 @@ shape = SubResource( 2 )
50122

51123
enabled = true
52124
editor_only = false
53-
texture = ExtResource( 9 )
125+
texture = ExtResource( 10 )
54126
offset = Vector2( 0, 0 )
55127
texture_scale = 1.0
56128
color = Color( 1, 1, 1, 1 )
57-
energy = 1.0
129+
energy = 0.99
58130
mode = 0
59131
range_height = 0.0
60132
range_z_min = -1024
@@ -71,4 +143,37 @@ shadow_filter_smooth = 4.0
71143
shadow_item_cull_mask = 1
72144
_sections_unfolded = [ "Shadow", "Visibility" ]
73145

146+
[node name="light_animation_player" type="AnimationPlayer" parent="." index="3"]
147+
148+
root_node = NodePath("..")
149+
autoplay = ""
150+
playback_process_mode = 1
151+
playback_default_blend_time = 0.0
152+
playback_speed = 1.0
153+
anims/flickering = SubResource( 3 )
154+
blend_times = [ ]
155+
156+
[node name="Particles2D" type="Particles2D" parent="." index="4"]
157+
158+
position = Vector2( -0.628052, 1.46544 )
159+
emitting = true
160+
amount = 3
161+
lifetime = 1.0
162+
one_shot = false
163+
preprocess = 0.0
164+
speed_scale = 1.0
165+
explosiveness = 0.0
166+
randomness = 0.3
167+
fixed_fps = 0
168+
fract_delta = true
169+
visibility_rect = Rect2( -100, -100, 200, 200 )
170+
local_coords = true
171+
draw_order = 0
172+
process_material = SubResource( 6 )
173+
texture = null
174+
normal_map = null
175+
h_frames = 1
176+
v_frames = 1
177+
_sections_unfolded = [ "Drawing", "Process Material", "Time" ]
178+
74179

0 commit comments

Comments
 (0)
Please sign in to comment.