Skip to content
Snippets Groups Projects
Commit 2003f6af authored by Pablau's avatar Pablau
Browse files

penguin testing

parent e2fae936
No related branches found
No related tags found
No related merge requests found
extends Node2D
extends CharacterBody2D
##hier muss der orca sich bewegen
@export var speed: float = 200.0 # Movement speed
@export var dash_speed: float = 400.0 # Dash speed
@export var dash_duration: float = 0.5 # Duration of the dash
@export var attack_interval: float = 7.0 # Time between dashes (attacks)
@export var points: Array = [] # The four points to move between
@export var center_of_board: Node2D # The center of the board
var is_dashing: bool = false
var dash_target_position: Vector2
var current_point_index: int = 0
var dash_timer: float = 0.0
# Get screen size and calculate 4 points for the orca to cycle through
func _ready() -> void:
# Defining the 4 points based on screen size (using edges of the screen and center)
var screen_size = get_viewport().get_size()
points = [
Vector2(0, 0), # Top-left
Vector2(screen_size.x, 0), # Top-right
Vector2(screen_size.x, screen_size.y), # Bottom-right
Vector2(0, screen_size.y) # Bottom-left
]
# Start the orca's movement
$OrcaTimer.start(attack_interval)
func _process(delta):
if is_dashing:
dash_timer += delta
if dash_timer >= dash_duration:
is_dashing = false # End dash after the duration
dash_timer = 0.0
_move_to_closest_point() # Move to the closest point after the dash
else:
var direction_to_target = (dash_target_position - position).normalized()
velocity = direction_to_target * dash_speed # Move towards the target with dash speed
move_and_slide() # Move with physics handling
else:
# Normal movement (Path following-like behavior, move between points)
var target_point = points[current_point_index]
var direction_to_target = (target_point - position).normalized()
velocity = direction_to_target * speed # Move with normal speed
move_and_slide() # Move with physics handling
# Check if we've reached the target point
if position.distance_to(target_point) < 10.0:
current_point_index = (current_point_index + 1) % points.size() # Cycle through the points
func _Attack() -> void:
is_dashing = true # Start dashing
dash_target_position = %PenguGroup.penguins[randi_range(0, %PenguGroup.penguins.size() - 1)].position # Random penguin
dash_timer = 0.0 # Reset the dash timer
$OrcaTimer.start(attack_interval) # Reset attack interval timer
func _on_orca_timer_timeout() -> void:
_Attack()
# Move the orca to the closest point, excluding the center
func _move_to_closest_point() -> void:
var closest_distance = INF
var closest_point = Vector2()
# Find the closest point that isn't the center
for point in points:
if point != center_of_board.position:
var distance = position.distance_to(point)
if distance < closest_distance:
closest_distance = distance
closest_point = point
# Set the orca to move towards the closest point
current_point_index = points.find(closest_point) # Set the target point as the closest point
[gd_scene load_steps=3 format=3 uid="uid://k0xsan4kntww"]
[ext_resource type="Script" uid="uid://vgm02fxo6pe3" path="res://NPC/orca/orca.gd" id="1_jmt3e"]
[ext_resource type="Texture2D" uid="uid://d3caevtq02wc3" path="res://NPC/orca/orca.png" id="2_113yi"]
[ext_resource type="Texture2D" uid="uid://dqmo5ufusgf76" path="res://NPC/orca/orcaShadow.png" id="2_jmt3e"]
[node name="Orca" type="Node2D"]
[node name="Orca" type="CharacterBody2D"]
script = ExtResource("1_jmt3e")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_113yi")
scale = Vector2(0.385, 0.385)
texture = ExtResource("2_jmt3e")
[node name="OrcaTimer" type="Timer" parent="."]
one_shot = true
[gd_scene load_steps=23 format=3 uid="uid://cwmunv68b7txk"]
[gd_scene load_steps=22 format=3 uid="uid://cwmunv68b7txk"]
[ext_resource type="Script" uid="uid://babk78kqf724a" path="res://Player/PlayerMovement.gd" id="1_ihrqt"]
[ext_resource type="PackedScene" uid="uid://dfe8d0dg2yioj" path="res://Player/FishScene.tscn" id="2_rded7"]
[ext_resource type="Texture2D" uid="uid://472cciaqjyp3" path="res://Player/Banana.png" id="3_b3kip"]
[ext_resource type="Gradient" uid="uid://cwy2rqwgq1wy1" path="res://Player/Rope.tres" id="5_b3kip"]
[ext_resource type="Texture2D" uid="uid://bup46wxrwb4oh" path="res://Player/fabrics_0066_color_1k.jpg" id="5_rldes"]
[ext_resource type="Texture2D" uid="uid://brhdmftlyosll" path="res://Player/bird_vertical.png" id="6_b3kip"]
[ext_resource type="Texture2D" uid="uid://c78fu5b3vs7nk" path="res://Player/bird_vertival_2.png" id="7_yjw77"]
[ext_resource type="Texture2D" uid="uid://cchfdi8s18chj" path="res://Player/bird_up.png" id="8_fkt56"]
......@@ -323,7 +322,6 @@ points = PackedVector2Array(364, 125)
width = 4.5
default_color = Color(0.695538, 0.630414, 0.443005, 1)
gradient = ExtResource("5_b3kip")
texture = ExtResource("5_rldes")
texture_mode = 2
[node name="Area2D" type="Area2D" parent="."]
......
pulsjam2025/Player/fabrics_0066_color_1k.jpg

106 KiB

[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bup46wxrwb4oh"
path="res://.godot/imported/fabrics_0066_color_1k.jpg-dc90a5c764a747a6c01d2ab9c8c86750.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Player/fabrics_0066_color_1k.jpg"
dest_files=["res://.godot/imported/fabrics_0066_color_1k.jpg-dc90a5c764a747a6c01d2ab9c8c86750.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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment