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
5049088b
Commit
5049088b
authored
3 weeks ago
by
Fabian Keßler
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
https://gitlab.informatik.uni-wuerzburg.de/s476696/pulsgamejam2025
parents
aefc521c
01a63eaa
Loading
Loading
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 @
5049088b
extends
CharacterBody2D
@
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
@
export
var
center
:
Vector2
=
Vector2
(
550
,
370
)
# The point to circle around
@
export
var
radius
:
float
=
300.0
# Distance from the center
@
export
var
speed
:
float
=
0.5
# Speed of rotation (radians per second)
@
export
var
dash_speed
:
float
=
0.1
# Speed of the dash
@
export
var
return_speed
:
float
=
0.02
#Speed of returning to the circle
var
is_dashing
:
bool
=
false
var
dash_target_position
:
Vector2
var
current_point_index
:
int
=
0
var
dash_timer
:
float
=
0.0
var
angle
:
float
=
0.0
# Current angle of rotation
var
dashing
:
bool
=
false
var
dash_target
:
Vector2
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
:
# 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
)
$
OrcaTimer
.
start
(
2
)
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
if
dashing
:
global_position
=
global_position
.
lerp
(
dash_target
,
dash_speed
)
rotation
=
(
dash_target
-
global_position
)
.
angle
()
+
90
# Rotate towards dash direction
if
global_position
.
distance_to
(
dash_target
)
<
10.0
:
slice_floes
(
start_pos
,
dash_target
)
dashing
=
false
returning
=
true
return_target
=
find_closest_point_on_radius
()
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
# Handle return to the circle if needed
if
returning
:
global_position
=
global_position
.
lerp
(
return_target
,
return_speed
)
rotation
=
(
return_target
-
global_position
)
.
angle
()
+
90
# Rotate towards return direction
# If close enough to the return target, stop returning and resume orbit
if
global_position
.
distance_to
(
return_target
)
<
10.0
:
returning
=
false
$
OrcaTimer
.
start
(
8
)
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
# Otherwise continue with normal circular movement
if
not
returning
:
angle
+=
speed
*
delta
# Update the angle
var
new_position
=
center
+
Vector2
(
cos
(
angle
),
sin
(
angle
))
*
radius
global_position
=
new_position
rotation
=
angle
+
deg_to_rad
(
180
)
# Adjust rotation to move in the orbit
func
_on_orca_timer_timeout
()
->
void
:
_Attack
()
func
dash
(
target
:
Vector2
):
start_pos
=
position
dashing
=
true
dash_target
=
target
# Rotate towards dash direction
# Move the orca to the closest point, excluding the center
func
_move_to_closest_point
()
->
void
:
var
closest_distance
=
INF
var
closest_point
=
Vector2
()
func
find_closest_point_on_radius
()
->
Vector2
:
angle
=
(
global_position
-
center
)
.
angle
()
return
center
+
Vector2
(
cos
(
angle
),
sin
(
angle
))
*
radius
# 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
func
_on_orca_timer_timeout
()
->
void
:
dash
(
center
)
func
slice_floes
(
splice_start
:
Vector2
,
splice_end
:
Vector2
)
->
void
:
for
child
in
get_children
():
if
child
is
IceFloe
:
if
child
.
will_line_cut_polygon
(
splice_start
,
splice_end
):
var
poly_node
:
Polygon2D
=
child
.
get_node
(
"Polygon2D"
)
child
.
splice_with_line
(
splice_start
,
splice_end
)
This diff is collapsed.
Click to expand it.
pulsjam2025/NPC/orca/orca.tscn
+
3
−
1
View file @
5049088b
...
...
@@ -7,8 +7,10 @@
script = ExtResource("1_jmt3e")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.
385
, 0.
385
)
scale = Vector2(0.
22
, 0.
22
)
texture = ExtResource("2_jmt3e")
[node name="OrcaTimer" type="Timer" parent="."]
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 @
5049088b
...
...
@@ -5,6 +5,9 @@
[node name="TestScene" type="Node2D"]
[node name="Center" type="Node2D" parent="."]
position = Vector2(519, 378)
[node name="SchollenSpektakel" parent="." instance=ExtResource("2_oh42m")]
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