Progress on Heater

This commit is contained in:
Skip 2022-07-18 03:38:46 -04:00
parent 22d0f55d7b
commit 751b731896
7 changed files with 58 additions and 29 deletions

View File

@ -47,9 +47,7 @@ position = Vector2( -18, 3 )
rotation = 1.5708 rotation = 1.5708
shape = SubResource( 2 ) shape = SubResource( 2 )
[node name="Hitbox" type="Area2D" parent="." groups=[ [node name="Hitbox" type="Area2D" parent="." groups=["Fish"]]
"Fish",
]]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
position = Vector2( -8, 1 ) position = Vector2( -8, 1 )
@ -89,9 +87,9 @@ margin_left = -137.0
margin_top = -200.0 margin_top = -200.0
margin_right = 138.0 margin_right = 138.0
margin_bottom = -80.0 margin_bottom = -80.0
custom_fonts/normal_font = SubResource( 4 )
custom_colors/default_color = Color( 0.945098, 0.352941, 0.160784, 1 ) custom_colors/default_color = Color( 0.945098, 0.352941, 0.160784, 1 )
custom_constants/line_separation = -6 custom_constants/line_separation = -6
custom_fonts/normal_font = SubResource( 4 )
bbcode_enabled = true bbcode_enabled = true
bbcode_text = "[center]Wait, something's wrong with these flakes! [shake] bbcode_text = "[center]Wait, something's wrong with these flakes! [shake]
Must... resist... eating...!" Must... resist... eating...!"

View File

@ -34,15 +34,19 @@ func _on_Hitbox_area_entered(area):
func _spawn_piranha(): func _spawn_piranha():
print("Spawning the piranha now...")
#$AnimationPlayer.play("drop") #$AnimationPlayer.play("drop")
#yield($AnimationPlayer, "animation_finished") #yield($AnimationPlayer, "animation_finished")
var piranha_scene = load("res://Hazards/Piranha/Piranha.tscn") var piranha_scene = load("res://Hazards/Piranha/Piranha.tscn")
var piranha = piranha_scene.instance() var piranha = piranha_scene.instance()
# piranha.set_process(false) # piranha.set_process(false)
get_parent().add_child(piranha) #call_deferred("add_child", piranha)
piranha.position = Vector2(300, -300) add_child(piranha)
$TweenDrop.interpolate_property(piranha, "position:y", piranha.get_global_position().y, 600, 0.5, Tween.TRANS_BACK, Tween.EASE_IN) piranha.position = $Position2D.position
$TweenDrop.start() #piranha.global_position.x = position.x - 300
yield($TweenDrop, "tween_completed") #piranha.global_position.y = position.y + 300
print("dropped") #$TweenDrop.interpolate_property(piranha, "position:y", piranha.get_global_position().y, piranha.get_global_position().y+500, 1, Tween.TRANS_CIRC, Tween.EASE_IN)
#$TweenDrop.start()
#yield($TweenDrop, "tween_completed")
print("Piranha is now at " + str(piranha.get_global_position()))
# piranha.set_process(true) # piranha.set_process(true)

View File

@ -77,4 +77,7 @@ anims/recoil = SubResource( 3 )
[node name="TweenDrop" type="Tween" parent="."] [node name="TweenDrop" type="Tween" parent="."]
[node name="Position2D" type="Position2D" parent="."]
position = Vector2( -1399, 16 )
[connection signal="area_entered" from="Wire/Hitbox" to="." method="_on_Hitbox_area_entered"] [connection signal="area_entered" from="Wire/Hitbox" to="." method="_on_Hitbox_area_entered"]

View File

@ -8,20 +8,28 @@ var next_dest = 60
var destination : Vector2 var destination : Vector2
func _ready(): func _ready():
pass print("I liiiiive...!")
func _process(delta: float) -> void: func _process(delta: float) -> void:
$SwordPivot.rotation_degrees += 1 $SwordPivot.rotation_degrees += 1
if dest_counter >= next_dest:
destination = _select_destination() if destination:
next_dest = rand_range(60,1200) # second number lower = move more frequently var v = get_global_mouse_position() - global_position
dest_counter = 0 var angle = v.angle() + deg2rad(270)
# if global_position.x < get_global_mouse_position().x:
# $AnimatedSprite.flip_v = false
# else:
# $AnimatedSprite.flip_v = true
if rad2deg(angle) < 180 or rad2deg(angle) > 360:
$AnimatedSprite.flip_v = true
else: else:
dest_counter +=1 $AnimatedSprite.flip_v = false
if moving: var rotation_speed = PI * 0.75 # PI = 180 degrees
$TweenSwim.interpolate_property(self, "position", get_global_position(), destination, .175, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT) #number lower = faster var angle_delta = rotation_speed * delta
$TweenSwim.start() angle = lerp_angle(global_rotation, angle + 1.57, 1.0)
angle = clamp(angle, global_rotation - angle_delta, global_rotation + angle_delta)
global_rotation = angle
func _select_destination() -> Vector2: func _select_destination() -> Vector2:
@ -43,3 +51,19 @@ func _on_Blindzone_area_entered(area: Area2D) -> void:
func _on_Blindzone_area_exited(area): func _on_Blindzone_area_exited(area):
if area.is_in_group("Fish"): if area.is_in_group("Fish"):
moving = true moving = true
func _on_Timer_timeout() -> void:
#destination.x = move_toward(position.x, fish.get_global_position().x)
#destination.y = move_toward(position.y, fish.get_global_position().y)
destination.x = move_toward(global_position.x, get_global_mouse_position().x, 100)
destination.y = move_toward(global_position.y, get_global_mouse_position().y, 100)
# if dest_counter >= next_dest:
# destination = _select_destination()
# next_dest = rand_range(60,1200) # second number lower = move more frequently
# dest_counter = 0
# else:
# dest_counter +=1
if moving:
$TweenSwim.interpolate_property(self, "position", position, destination, 0.85, Tween.TRANS_EXPO, Tween.EASE_OUT) #number lower = faster
$TweenSwim.start()

View File

@ -45,8 +45,8 @@ rotation = 1.5708
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."] [node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 67, -25 ) position = Vector2( -44, -21 )
scale = Vector2( 0.5, 0.5 ) scale = Vector2( -0.5, 0.5 )
frames = SubResource( 2 ) frames = SubResource( 2 )
frame = 1 frame = 1
playing = true playing = true
@ -59,6 +59,10 @@ shape = SubResource( 3 )
[node name="TweenSwim" type="Tween" parent="."] [node name="TweenSwim" type="Tween" parent="."]
[node name="Timer" type="Timer" parent="."]
autostart = true
[connection signal="area_entered" from="SwordPivot/SwordHitbox" to="." method="_on_SwordHitbox_area_entered"] [connection signal="area_entered" from="SwordPivot/SwordHitbox" to="." method="_on_SwordHitbox_area_entered"]
[connection signal="area_entered" from="Blindzone" to="." method="_on_Blindzone_area_entered"] [connection signal="area_entered" from="Blindzone" to="." method="_on_Blindzone_area_entered"]
[connection signal="area_exited" from="Blindzone" to="." method="_on_Blindzone_area_exited"] [connection signal="area_exited" from="Blindzone" to="." method="_on_Blindzone_area_exited"]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

View File

@ -50,9 +50,7 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Edges" type="StaticBody2D" parent="." groups=[ [node name="Edges" type="StaticBody2D" parent="." groups=["Tank"]]
"Tank",
]]
visible = false visible = false
collision_layer = 4 collision_layer = 4
collision_mask = 18 collision_mask = 18
@ -104,9 +102,7 @@ __meta__ = {
[node name="Fish" parent="." instance=ExtResource( 4 )] [node name="Fish" parent="." instance=ExtResource( 4 )]
position = Vector2( 617, 494 ) position = Vector2( 617, 494 )
[node name="TankFloor" type="Area2D" parent="." groups=[ [node name="TankFloor" type="Area2D" parent="." groups=["TankFloor"]]
"TankFloor",
]]
visible = false visible = false
position = Vector2( 960, 1070 ) position = Vector2( 960, 1070 )

View File

@ -26,7 +26,7 @@ window/stretch/aspect="keep"
skip={ skip={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
] ]
} }