Huge Update

Changes abound on pretty much everything.
This commit is contained in:
Skip 2022-07-16 18:09:42 -04:00
parent 1c5443a81c
commit bf45bf404c
7 changed files with 215 additions and 55 deletions

View File

@ -7,19 +7,21 @@ var destination # The position the fish will move to _on_SwimTimer_timeout()
var poisoned = false # Used in Hazards/Poison/Poison.gd to determine if fish is dying of poison
var poison_mutation = true # True when fish can eat and shoot poison pellets
var pellets = 0 # Tracks the number of poison pellets eaten but not shot yet
onready var mouth = $Positions/Mouth.position # Used for eating poison pellets
onready var mouth_inhale = $Positions/MouthInhale.position
onready var tail = $Positions/Booty
onready var mouth = $Positions/Mouth.position # Used for eating and shooting poison pellets
onready var mouth_inhale = $Positions/MouthInhale.position # Used for eating poison pellets
onready var tail = $Positions/Tail.position # Used for shooting poison pellets
func _ready():
$SwimTimer.wait_time = swim_cooldown
func _on_SwimTimer_timeout() -> void:
# Swim toward mouse
destination = Vector2(move_toward(position.x, get_global_mouse_position().x, swim_length), move_toward(position.y, get_global_mouse_position().y, swim_length))
$Tween.interpolate_property(self, "position", position, destination, 1, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
$Tween.start()
_fire_pellet()
func _process(delta: float) -> void:
@ -39,13 +41,16 @@ func _process(delta: float) -> void:
func _fire_pellet() -> void:
if pellets > 0:
pellets = 1 # This is just hax so we don't have to eat pellets first to fire them
if pellets > 0: # But usually we require fish to eat pellets before he shoots them
var poison_scene = load("res://Hazards/Poison/Poison.tscn")
var poison = poison_scene.instance()
add_child(poison)
poison.position = position
poison.friendly = true # This will prevent the fish from auto-eating it the second it spawns
get_parent().add_child(poison) # We add this projectile to the /tank/ so they don't move with the fish
poison.position = get_global_position() # 'position' returns the local position, but we need where it's at in relation to the tank
#poison.direction = position.angle_to_point(mouth)
poison.applied_force = Vector2(mouth.get_global_position(), tail.get_global_position())
poison.applied_force = 50 * ($Positions/Mouth.get_global_position() - $Positions/Tail.get_global_position())
pellets -= 1
func kill(cause: String) -> void:

BIN
Travesty/Hazards/Fork.7z Normal file

Binary file not shown.

View File

@ -1,32 +1,47 @@
extends Sprite
func _ready():
for i in 10000:
# $Tween.interpolate_property(self, "region_rect:position:y", region_rect.position.y, region_rect.position.y-200, 1, Tween.TRANS_CIRC, Tween.EASE_OUT)
# $Tween.interpolate_property($ForkAbove, "region_rect:position:y", 410, 200, 1, Tween.TRANS_CIRC, Tween.EASE_OUT)
# $Tween.start()
# yield($Tween,"tween_completed")
$Tween.interpolate_property(self, "region_rect:position:y", -500, 0, 1.5, Tween.TRANS_CIRC, Tween.EASE_OUT)
$Tween.interpolate_property($ForkAbove, "region_rect:position:y", -90, 410, 1.5, Tween.TRANS_CIRC, Tween.EASE_OUT)
$Tween.start()
yield($Tween,"tween_completed")
region_rect.position.y = 0
$ForkAbove.region_rect.position.y = 410
# $AnimationPlayer.play("Stab")
onready var tank = get_node("/root/Tank")
onready var spawner = get_node("/root/Tank/HazardSpawner")
var playingforwards = true
# rotateTween.interpolate_property( # rotateTween is the name of the Tween node. This is telling Godot to create a new animation using this Tween node object.
# hexagonTile, # hexagonTile is the 3D tile we want to animate.
# "rotation_degrees:y", # When the Tween runs its animation, we will change the Y value on the tile's rotation.
# rotation_degrees.y, # When the Tween runs its animation, it will start at the tile's current rotation.
# rotation_degrees.y+60 # When the Tween runs its animation, it will end at 60 degrees clockwise from the tile's last rotation.
# 0.25, # This is the amount of time in seconds you want the Tween to run the animation for. This means that on the first run,
# # the Tween's animation will rotate the tile from 0 degrees to 60 degrees in 1/4 of a second.
# Tween.TRANS_BACK, # This is the animations's "TransitionType". I'll talk about this in the next section.
# Tween.EASE_OUT # This is the animation's "EaseType". I'll talk about this in the next section.
#)
#func _rewind():
# $AnimationPlayer.play_backwards("Stab")
func _ready() -> void:
# _reposition()
# _rewind()
# print("rewinding")
# yield($AnimationPlayer, "animation_finished")
# print("rewound")
# $Timer.start()
pass
func _reposition() -> void:
var tween_duration = 0.5
$Tween.interpolate_property(self, "position:x", position.x, rand_range(400, 2000), tween_duration, Tween.TRANS_BACK, Tween.EASE_IN_OUT)
$Tween.start()
# yield($Tween, "finished")
func _on_Timer_timeout() -> void:
_stab()
func _stab() -> void:
playingforwards = true
$AnimationPlayer.play("Stab")
func _rewind() -> void:
if playingforwards:
playingforwards = false
$AnimationPlayer.play_backwards("Stab")
#yield($AnimationPlayer, "animation_finished")
#_reposition()
#static func random_position(area: CollisionShape2D) -> Vector2:
# var _topleft : Vector2 = area.global_position - area.shape.extents
# var _botright : Vector2 = area.global_position + area.shape.extents
# var _x = rand_range(_topleft.x, _botright.x)
# var _y = rand_range(_topleft.y, _botright.y)
# return Vector2(_x, _y)

View File

@ -1,8 +1,132 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Hazards/Fork/Fork.gd" type="Script" id=1]
[ext_resource path="res://Hazards/Fork/Fork.png" type="Texture" id=2]
[sub_resource type="Animation" id=1]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector2( 550, 577 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath(".:region_rect")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Rect2( 0, 0, 300, 470 ) ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("ForkAbove:region_enabled")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ true ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("ForkAbove:region_rect")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Rect2( 200, 410, 300, 100 ) ]
}
tracks/4/type = "value"
tracks/4/path = NodePath("Hitbox:position")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ) ]
}
[sub_resource type="Animation" id=2]
resource_name = "Stab"
length = 2.5
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath(".:region_rect")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Rect2( 0, -400, 300, 470 ), Rect2( 0, 0, 300, 470 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("ForkAbove:region_rect")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Rect2( 200, 10, 300, 100 ), Rect2( 200, 410, 300, 100 ) ]
}
tracks/2/type = "method"
tracks/2/path = NodePath(".")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 1.5, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"values": [ {
"args": [ ],
"method": "_rewind"
}, {
"args": [ ],
"method": "_reposition"
} ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Hitbox:position")
tracks/3/interp = 2
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( 0, -400 ) ]
}
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 22.25, 28.25 )
[node name="Fork" type="Sprite"]
position = Vector2( 550, 577 )
rotation = 3.14159
@ -18,4 +142,19 @@ texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 200, 410, 300, 100 )
[node name="Timer" type="Timer" parent="."]
wait_time = 3.0
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 1 )
anims/Stab = SubResource( 2 )
[node name="Hitbox" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
position = Vector2( 108.749, 205.75 )
shape = SubResource( 3 )
[node name="Tween" type="Tween" parent="."]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

View File

@ -3,6 +3,7 @@ extends RigidBody2D
export var poisoned_color : Color = Color(0,200,0,255)
var fish : Node
var direction
var friendly = false
func _ready():
fish = get_node("/root/Tank/Fish")
@ -10,22 +11,23 @@ func _ready():
func _on_Hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group("Fish") and fish.poisoned == false and not fish.poison_mutation:
print("A poison pellet has inflicted poison on the fish.")
fish.poisoned = true
visible = false
$Timer.start()
$TweenPoison.interpolate_property(area.get_parent(), "modulate", modulate, poisoned_color, 2.0, Tween.TRANS_LINEAR, Tween.EASE_IN)
$TweenPoison.start()
elif area.is_in_group("Fish") and fish.poison_mutation and fish.pellets < 10:
fish.pellets += 1
#$TweenEat.interpolate_property(self, "position", position, get_node("/root/Tank/Fish/Positions/MouthInhale").get_global_position(), 0.5, Tween.TRANS_EXPO, Tween.EASE_IN, 0.5)
$TweenEat.interpolate_property(self, "position", position, get_node("/root/Tank/Fish/Positions/Mouth").get_global_position(), 0.5, Tween.TRANS_EXPO, Tween.EASE_IN)
$TweenEat.interpolate_property(self, "scale", scale, Vector2(0.1, 0.1), 0.5, Tween.TRANS_LINEAR, Tween.EASE_IN)
$TweenEat.start()
print(get_node("/root/Tank/Fish/Positions/Mouth").get_global_position())
yield($TweenEat, "tween_completed")
queue_free()
if not friendly:
if area.is_in_group("Fish") and fish.poisoned == false and not fish.poison_mutation:
print("A poison pellet has inflicted poison on the fish.")
fish.poisoned = true
visible = false
$Timer.start()
$TweenPoison.interpolate_property(area.get_parent(), "modulate", modulate, poisoned_color, 2.0, Tween.TRANS_LINEAR, Tween.EASE_IN)
$TweenPoison.start()
elif area.is_in_group("Fish") and fish.poison_mutation and fish.pellets < 10:
fish.pellets += 1
#$TweenEat.interpolate_property(self, "position", position, get_node("/root/Tank/Fish/Positions/MouthInhale").get_global_position(), 0.5, Tween.TRANS_EXPO, Tween.EASE_IN, 0.5)
$TweenEat.interpolate_property(self, "position", position, get_node("/root/Tank/Fish/Positions/Mouth").get_global_position(), 0.5, Tween.TRANS_EXPO, Tween.EASE_IN)
$TweenEat.interpolate_property(self, "scale", scale, Vector2(0.1, 0.1), 0.5, Tween.TRANS_LINEAR, Tween.EASE_IN)
$TweenEat.start()
print(get_node("/root/Tank/Fish/Positions/Mouth").get_global_position())
yield($TweenEat, "tween_completed")
queue_free()
static func choose(choices):

View File

@ -11,7 +11,6 @@ func _ready() -> void:
static func random_position(area: CollisionShape2D) -> Vector2:
# Returns a random position found within the given CollisionShape2D.
var _topleft : Vector2 = area.global_position - area.shape.extents
var _botright : Vector2 = area.global_position + area.shape.extents
var _x = rand_range(_topleft.x, _botright.x)

View File

@ -21,8 +21,6 @@ script = ExtResource( 2 )
position = Vector2( 960, 540 )
texture = ExtResource( 1 )
[node name="Fork" parent="." instance=ExtResource( 3 )]
[node name="Edges" type="StaticBody2D" parent="." groups=["Tank"]]
collision_layer = 4
collision_mask = 18
@ -64,4 +62,6 @@ color = Color( 0.588235, 0.588235, 0.980392, 1 )
[node name="Fish" parent="." instance=ExtResource( 4 )]
position = Vector2( 596, 543 )
[node name="Fork" parent="." instance=ExtResource( 3 )]
[connection signal="timeout" from="HazardSpawner/HazardTimer" to="." method="_on_HazardTimer_timeout"]