Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PulsGameJam2025
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabian Keßler
PulsGameJam2025
Commits
b8d558d6
Commit
b8d558d6
authored
3 weeks ago
by
Pablau
Browse files
Options
Downloads
Patches
Plain Diff
Orca testing
parent
2003f6af
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pulsjam2025/NPC/orca/orca.gd
+53
-62
53 additions, 62 deletions
pulsjam2025/NPC/orca/orca.gd
pulsjam2025/NPC/orca/orca.tscn
+3
-1
3 additions, 1 deletion
pulsjam2025/NPC/orca/orca.tscn
pulsjam2025/Player/TestScene.tscn
+3
-0
3 additions, 0 deletions
pulsjam2025/Player/TestScene.tscn
with
59 additions
and
63 deletions
pulsjam2025/NPC/orca/orca.gd
+
53
−
62
View file @
b8d558d6
extends
CharacterBody2D
extends
CharacterBody2D
@
export
var
speed
:
float
=
200.0
# Movement speed
@
export
var
center
:
Vector2
=
Vector2
(
550
,
370
)
# The point to circle around
@
export
var
dash_speed
:
float
=
400.0
# Dash speed
@
export
var
radius
:
float
=
300.0
# Distance from the center
@
export
var
dash_duration
:
float
=
0.5
# Duration of the dash
@
export
var
speed
:
float
=
0.5
# Speed of rotation (radians per second)
@
export
var
attack_interval
:
float
=
7.0
# Time between dashes (attacks)
@
export
var
dash_speed
:
float
=
0.1
# Speed of the dash
@
export
var
points
:
Array
=
[]
# The four points to move between
@
export
var
return_speed
:
float
=
0.02
#Speed of returning to the circle
@
export
var
center_of_board
:
Node2D
# The center of the board
var
is_dashing
:
bool
=
false
var
angle
:
float
=
0.0
# Current angle of rotation
var
dash_target_position
:
Vector2
var
dashing
:
bool
=
false
var
current_point_index
:
int
=
0
var
dash_target
:
Vector2
var
dash_timer
:
float
=
0.0
var
returning
:
bool
=
false
var
return_target
:
Vector2
var
start_pos
:
Vector2
# Get screen size and calculate 4 points for the orca to cycle through
func
_ready
()
->
void
:
func
_ready
()
->
void
:
# Defining the 4 points based on screen size (using edges of the screen and center)
$
OrcaTimer
.
start
(
2
)
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
):
func
_process
(
delta
):
if
is_dashing
:
if
dashing
:
dash_timer
+=
delta
global_position
=
global_position
.
lerp
(
dash_target
,
dash_speed
)
if
dash_timer
>=
dash_duration
:
rotation
=
(
dash_target
-
global_position
)
.
angle
()
+
90
# Rotate towards dash direction
is_dashing
=
false
# End dash after the duration
dash_timer
=
0.0
if
global_position
.
distance_to
(
dash_target
)
<
10.0
:
_move_to_closest_point
()
# Move to the closest point after the dash
slice_floes
(
start_pos
,
dash_target
)
else
:
dashing
=
false
var
direction_to_target
=
(
dash_target_position
-
position
)
.
normalized
()
returning
=
true
velocity
=
direction_to_target
*
dash_speed
# Move towards the target with dash speed
return_target
=
find_closest_point_on_radius
()
move_and_slide
()
# Move with physics handling
else
:
else
:
# Normal movement (Path following-like behavior, move between points)
# Handle return to the circle if needed
var
target_point
=
points
[
current_point_index
]
if
returning
:
var
direction_to_target
=
(
target_point
-
position
)
.
normalized
()
global_position
=
global_position
.
lerp
(
return_target
,
return_speed
)
velocity
=
direction_to_target
*
speed
# Move with normal speed
rotation
=
(
return_target
-
global_position
)
.
angle
()
+
90
# Rotate towards return direction
move_and_slide
()
# Move with physics handling
# If close enough to the return target, stop returning and resume orbit
if
global_position
.
distance_to
(
return_target
)
<
10.0
:
# Check if we've reached the target point
returning
=
false
if
position
.
distance_to
(
target_point
)
<
10.0
:
$
OrcaTimer
.
start
(
8
)
current_point_index
=
(
current_point_index
+
1
)
%
points
.
size
()
# Cycle through the points
func
_Attack
()
->
void
:
# Otherwise continue with normal circular movement
is_dashing
=
true
# Start dashing
if
not
returning
:
dash_target_position
=
%
PenguGroup
.
penguins
[
randi_range
(
0
,
%
PenguGroup
.
penguins
.
size
()
-
1
)]
.
position
# Random penguin
angle
+=
speed
*
delta
# Update the angle
dash_timer
=
0.0
# Reset the dash timer
var
new_position
=
center
+
Vector2
(
cos
(
angle
),
sin
(
angle
))
*
radius
$
OrcaTimer
.
start
(
attack_interval
)
# Reset attack interval timer
global_position
=
new_position
rotation
=
angle
+
deg_to_rad
(
180
)
# Adjust rotation to move in the orbit
func
_on_orca_timer_timeout
()
->
void
:
func
dash
(
target
:
Vector2
):
_Attack
()
start_pos
=
position
dashing
=
true
dash_target
=
target
# Rotate towards dash direction
# Move the orca to the closest point, excluding the center
func
find_closest_point_on_radius
()
->
Vector2
:
func
_move_to_closest_point
()
->
void
:
angle
=
(
global_position
-
center
)
.
angle
()
var
closest_distance
=
INF
return
center
+
Vector2
(
cos
(
angle
),
sin
(
angle
))
*
radius
var
closest_point
=
Vector2
()
# Find the closest point that isn't the center
func
_on_orca_timer_timeout
()
->
void
:
for
point
in
points
:
dash
(
center
)
if
point
!=
center_of_board
.
position
:
var
distance
=
position
.
distance_to
(
point
)
func
slice_floes
(
splice_start
:
Vector2
,
splice_end
:
Vector2
)
->
void
:
if
distance
<
closest_distance
:
for
child
in
get_children
():
closest_distance
=
distance
if
child
is
IceFloe
:
closest_point
=
point
if
child
.
will_line_cut_polygon
(
splice_start
,
splice_end
):
var
poly_node
:
Polygon2D
=
child
.
get_node
(
"Polygon2D"
)
# Set the orca to move towards the closest point
child
.
splice_with_line
(
splice_start
,
splice_end
)
current_point_index
=
points
.
find
(
closest_point
)
# Set the target point as the closest point
This diff is collapsed.
Click to expand it.
pulsjam2025/NPC/orca/orca.tscn
+
3
−
1
View file @
b8d558d6
...
@@ -7,8 +7,10 @@
...
@@ -7,8 +7,10 @@
script = ExtResource("1_jmt3e")
script = ExtResource("1_jmt3e")
[node name="Sprite2D" type="Sprite2D" parent="."]
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.
385
, 0.
385
)
scale = Vector2(0.
22
, 0.
22
)
texture = ExtResource("2_jmt3e")
texture = ExtResource("2_jmt3e")
[node name="OrcaTimer" type="Timer" parent="."]
[node name="OrcaTimer" type="Timer" parent="."]
one_shot = true
one_shot = true
[connection signal="timeout" from="OrcaTimer" to="." method="_on_orca_timer_timeout"]
This diff is collapsed.
Click to expand it.
pulsjam2025/Player/TestScene.tscn
+
3
−
0
View file @
b8d558d6
...
@@ -5,6 +5,9 @@
...
@@ -5,6 +5,9 @@
[node name="TestScene" type="Node2D"]
[node name="TestScene" type="Node2D"]
[node name="Center" type="Node2D" parent="."]
position = Vector2(519, 378)
[node name="SchollenSpektakel" parent="." instance=ExtResource("2_oh42m")]
[node name="SchollenSpektakel" parent="." instance=ExtResource("2_oh42m")]
position = Vector2(-17, 66)
position = Vector2(-17, 66)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment