Skip to content

Commit

Permalink
Trying to get frog to workkkk
Browse files Browse the repository at this point in the history
  • Loading branch information
willow-carroll-polzin committed Jan 7, 2024
1 parent 4567ca3 commit 1cb74ee
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 46 deletions.
26 changes: 21 additions & 5 deletions Enemies/Frog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,50 @@ var chase_flag = false # Not chasing the player if false
func _on_player_detection_area_body_entered(body):
if body.name == "Player": # If player is detected
chase_flag = true
player = get_node("../../Player/Player")

# Detect the player exiting area
func _on_player_detection_area_body_exited(body):
if body.name == "Player": # If player is detected
chase_flag = false
player = get_node("../../Player/Player")

func _physics_process(delta):
# Add GRAVITY
velocity.y += GRAVITY * delta
self.velocity.y += GRAVITY * delta
var v2 = GRAVITY - 2

print("DIRECTION: ")
print(direction)
print("SELF: ", str(self.position))

# Check if we need to chase the player
if chase_flag == true:
# Determine direction to player
player = get_node("../../Player/Player")

print("self pre: ", str(self.position))
print("pre: ", str(player.position))
direction = (self.position-player.position).normalized()

print("self pre N: ", str(self.position.normalized()))
print("pre N: ", str(player.position.normalized()))
direction = self.position-player.position.normalized()

print("self post: ", str(self.position))
print("pre: ", str(player.position))
print("DIRECTIONNNN: ")
print(direction)
var d2 = self.position-player.position
print("DDDDDDD: ")
print(d2)

if direction.x > 0: # On the right of the player
get_node("AnimatedSprite2D").flip_h = true
velocity.x = direction.x * SPEED
#self.velocity.x = direction.x * SPEED
elif direction.x < 0: # On the left of the player
get_node("AnimatedSprite2D").flip_h = false
velocity.x = direction.x * SPEED
#self.velocity.x = direction.x * SPEED
else:
velocity.x = 0
self.velocity.x = 0
get_node("AnimatedSprite2D").play("Idle")
move_and_slide()
9 changes: 9 additions & 0 deletions Enemies/Frog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ animations = [{
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fhqta")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_837q8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_837q8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_837q8")
}],
"loop": true,
"name": &"Idle",
Expand Down
82 changes: 41 additions & 41 deletions Player/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ animations = [{
"speed": 5.0
}]

[sub_resource type="Animation" id="Animation_iix2o"]
length = 0.5
[sub_resource type="Animation" id="Animation_jb2vn"]
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand All @@ -126,7 +125,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"Jump"]
"values": [&"Climb"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand All @@ -135,14 +134,13 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"times": PackedFloat32Array(0, 0.1, 0.2),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 1,
"values": [0]
"values": [0, 1, 2]
}

[sub_resource type="Animation" id="Animation_ym81p"]
length = 0.6
[sub_resource type="Animation" id="Animation_bi1k4"]
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand All @@ -153,7 +151,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"Run"]
"values": [&"Crouch"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand All @@ -162,13 +160,14 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"times": PackedFloat32Array(0, 0.1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [0, 1, 2, 3, 4, 5]
"values": [0, 1]
}

[sub_resource type="Animation" id="Animation_bi1k4"]
[sub_resource type="Animation" id="Animation_oka38"]
resource_name = "Fall"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand All @@ -179,7 +178,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"Crouch"]
"values": [&"Jump"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand All @@ -188,13 +187,13 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1),
"transitions": PackedFloat32Array(1, 1),
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0, 1]
"values": [1]
}

[sub_resource type="Animation" id="Animation_jb2vn"]
[sub_resource type="Animation" id="Animation_2d1hq"]
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand All @@ -205,7 +204,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"Climb"]
"values": [&"Hurt"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand All @@ -214,13 +213,16 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2),
"transitions": PackedFloat32Array(1, 1, 1),
"times": PackedFloat32Array(0, 0.1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [0, 1, 2]
"values": [0, 1]
}

[sub_resource type="Animation" id="Animation_2d1hq"]
[sub_resource type="Animation" id="Animation_7k72r"]
resource_name = "Idle"
length = 0.7
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand All @@ -231,7 +233,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"Hurt"]
"values": [&"Idle"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand All @@ -240,16 +242,14 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1),
"transitions": PackedFloat32Array(1, 1),
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [0, 1]
"values": [0, 1, 2, 3]
}

[sub_resource type="Animation" id="Animation_7k72r"]
resource_name = "Idle"
length = 0.7
loop_mode = 1
[sub_resource type="Animation" id="Animation_iix2o"]
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand All @@ -260,7 +260,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"Idle"]
"values": [&"Jump"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand All @@ -269,10 +269,10 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0, 1, 2, 3]
"values": [0]
}

[sub_resource type="Animation" id="Animation_vstpm"]
Expand Down Expand Up @@ -302,8 +302,8 @@ tracks/1/keys = {
"values": [1]
}

[sub_resource type="Animation" id="Animation_oka38"]
resource_name = "Fall"
[sub_resource type="Animation" id="Animation_ym81p"]
length = 0.6
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand All @@ -314,7 +314,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"Jump"]
"values": [&"Run"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand All @@ -323,10 +323,10 @@ tracks/1/path = NodePath("AnimatedSprite2D:frame")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"update": 1,
"values": [1]
"values": [0, 1, 2, 3, 4, 5]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_0muhe"]
Expand Down

0 comments on commit 1cb74ee

Please sign in to comment.