"splat-launch" move :3
This commit is contained in:
parent
20f35ab240
commit
7779e241f6
6 changed files with 97 additions and 11 deletions
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
|
@ -1,10 +1,11 @@
|
||||||
[gd_scene load_steps=6 format=4 uid="uid://cccb8wltupasj"]
|
[gd_scene load_steps=7 format=4 uid="uid://cccb8wltupasj"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://b6a7l24y30iht" path="res://assets/textures/backgrounds/chocomint.png" id="1_h5jcm"]
|
[ext_resource type="Texture2D" uid="uid://b6a7l24y30iht" path="res://assets/textures/backgrounds/chocomint.png" id="1_h5jcm"]
|
||||||
[ext_resource type="Script" uid="uid://d3v13a4er2h1x" path="res://scripts/level/level.gd" id="1_hcs1r"]
|
[ext_resource type="Script" uid="uid://d3v13a4er2h1x" path="res://scripts/level/level.gd" id="1_hcs1r"]
|
||||||
[ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="2_dj7w1"]
|
[ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="2_dj7w1"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c8r040r4glui4" path="res://objects/enemies/lashy/lashy.tscn" id="4_gykx6"]
|
[ext_resource type="PackedScene" uid="uid://c8r040r4glui4" path="res://objects/enemies/lashy/lashy.tscn" id="4_gykx6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bwtpsjpe2lf7l" path="res://objects/player/player.tscn" id="5_5v7mr"]
|
[ext_resource type="PackedScene" uid="uid://bwtpsjpe2lf7l" path="res://objects/player/player.tscn" id="5_5v7mr"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://68lav5rke5ag" path="res://objects/spring/spring.tscn" id="6_tlqas"]
|
||||||
|
|
||||||
[node name="LevelZ" type="Node2D"]
|
[node name="LevelZ" type="Node2D"]
|
||||||
script = ExtResource("1_hcs1r")
|
script = ExtResource("1_hcs1r")
|
||||||
|
@ -19,11 +20,14 @@ texture = ExtResource("1_h5jcm")
|
||||||
|
|
||||||
[node name="TileMap" type="TileMapLayer" parent="."]
|
[node name="TileMap" type="TileMapLayer" parent="."]
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
tile_map_data = PackedByteArray("AAAAAAsAAAAAAAAAAAABAAsAAAAAAAAAAAACAAsAAAAAAAAAAAAHAAsAAAAAAAAAAAAIAAsAAAAAAAAAAAAJAAsAAAAAAAAAAAAKAAsAAAAAAAAAAAALAAsAAAAAAAAAAAANAAsAAAAAAAAAAAAOAAsAAAAAAAAAAAAPAAsAAAAAAAAAAAAQAAsAAAAAAAAAAAARAAsAAAAAAAAAAAADAAsAAAAAAAAAAAAEAAsAAAAAAAAAAAAFAAsAAAAAAAAAAAAGAAsAAAAAAAAAAAAMAAsAAAAAAAAAAAAFAAoAAAAAAAAAAAAGAAoAAAAAAAAAAAAGAAkAAAAAAAAAAAAHAAkAAAAAAAAAAAAIAAkAAAAAAAAAAAAJAAkAAAAAAAAAAAAKAAkAAAAAAAAAAAALAAkAAAAAAAAAAAAMAAkAAAAAAAAAAAALAAoAAAAAAAAAAAAKAAoAAAAAAAAAAAAJAAoAAAAAAAAAAAAIAAoAAAAAAAAAAAAHAAoAAAAAAAAAAAAMAAoAAAAAAAAAAAANAAoAAAAAAAAAAAAOAAoAAAAAAAAAAAAPAAoAAAAAAAAAAAAPAAkAAAAAAAAAAAAQAAkAAAAAAAAAAAAQAAgAAAAAAAAAAAAQAAcAAAAAAAAAAAAQAAYAAAAAAAAAAAARAAcAAAAAAAAAAAAQAAoAAAAAAAAAAAARAAkAAAAAAAAAAAARAAgAAAAAAAAAAAARAAoAAAAAAAAAAAARAAYAAAAAAAAAAAARAAUAAAAAAAAAAAARAAQAAAAAAAAAAAAQAAQAAAAAAAAAAAAQAAUAAAAAAAAAAAAFAAkAAAAAAAAAAAAEAAkAAAAAAAAAAAADAAkAAAAAAAAAAAACA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oAAAAAAAAAAAACAAoAAAAAAAAAAAADAAoAAAAAAAAAAAAEAAoAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAkAAAAAAAAAAAAJAAgAAAAAAAAAAAAJAAcAAAAAAAAAAAAJAAYAAAAAAAAAAAAJAAUAAAAAAAAAAAAJAAQAAAAAAAAAAAAJAAMAAAAAAAAAAAAJAAIAAAAAAAAAAAABAAgAAAAAAAAAAAABAAcAAAAAAAAAAAABAAYAAAAAAAAAAAABAAUAAAAAAAAAAAABAAQAAAAAAAAAAAABAAMAAAAAAAAAAAABAAIAAAAAAAAAAAA=")
|
||||||
tile_set = ExtResource("2_dj7w1")
|
tile_set = ExtResource("2_dj7w1")
|
||||||
|
|
||||||
[node name="Lashy" parent="." instance=ExtResource("4_gykx6")]
|
[node name="Lashy" parent="." instance=ExtResource("4_gykx6")]
|
||||||
position = Vector2(141, 99)
|
position = Vector2(264, 72)
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("5_5v7mr")]
|
[node name="Player" parent="." instance=ExtResource("5_5v7mr")]
|
||||||
position = Vector2(40, 144)
|
position = Vector2(120, 144)
|
||||||
|
|
||||||
|
[node name="Spring" parent="." instance=ExtResource("6_tlqas")]
|
||||||
|
position = Vector2(96, 144)
|
||||||
|
|
|
@ -13,8 +13,8 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||||
if body is Player:
|
if body is Player:
|
||||||
body.ices_touched += 1
|
pass
|
||||||
|
|
||||||
|
|
||||||
func _on_area_2d_body_exited(body: Node2D) -> void:
|
func _on_area_2d_body_exited(body: Node2D) -> void:
|
||||||
body.ices_touched -= 1
|
pass
|
||||||
|
|
|
@ -11,6 +11,8 @@ extends CharacterBody2D
|
||||||
@export_group("Air Movement")
|
@export_group("Air Movement")
|
||||||
@export var gravity: float
|
@export var gravity: float
|
||||||
@export var jump_power: float
|
@export var jump_power: float
|
||||||
|
@export var splat_launch_power: float
|
||||||
|
@export var splat_offset: float
|
||||||
|
|
||||||
@export_group("Internal References")
|
@export_group("Internal References")
|
||||||
@export var state_chart: StateChart
|
@export var state_chart: StateChart
|
||||||
|
@ -26,8 +28,12 @@ var input_dir: Vector2 = Vector2.ZERO:
|
||||||
input_dir = value.sign()
|
input_dir = value.sign()
|
||||||
state_chart.set_expression_property(&"input_dir", input_dir)
|
state_chart.set_expression_property(&"input_dir", input_dir)
|
||||||
|
|
||||||
|
var _last_velocity: Vector2 = Vector2.ZERO
|
||||||
|
var _splat_normal: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
_last_velocity = velocity
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
state_chart.set_expression_property(&"velocity", velocity)
|
state_chart.set_expression_property(&"velocity", velocity)
|
||||||
if velocity.x != 0.0:
|
if velocity.x != 0.0:
|
||||||
|
@ -88,11 +94,35 @@ func _start_jump() -> void:
|
||||||
|
|
||||||
|
|
||||||
#region Missile
|
#region Missile
|
||||||
|
func _restore_graphics_rotation() -> void:
|
||||||
|
graphics.rotation = 0.0
|
||||||
|
|
||||||
|
|
||||||
func _face_towards_velocity(_delta: float) -> void:
|
func _face_towards_velocity(_delta: float) -> void:
|
||||||
graphics.rotation = Vector2(graphics.scale.x, 0.0).angle_to(velocity)
|
graphics.rotation = Vector2(graphics.scale.x, 0.0).angle_to(velocity)
|
||||||
|
|
||||||
func _restore_graphics_rotation() -> void:
|
func _check_for_splat(delta: float) -> void:
|
||||||
graphics.rotation = 0.0
|
var col = move_and_collide(_last_velocity * delta, true)
|
||||||
|
if col:
|
||||||
|
velocity = Vector2.ZERO
|
||||||
|
global_position += col.get_travel()
|
||||||
|
_splat_normal = col.get_normal()
|
||||||
|
var angle = col.get_normal().angle()
|
||||||
|
if graphics.scale.x > 0.0:
|
||||||
|
angle += PI
|
||||||
|
graphics.set_deferred(&"rotation", angle)
|
||||||
|
state_chart.send_event(&"splatted")
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Splatting
|
||||||
|
func _do_splat_launch() -> void:
|
||||||
|
var dir = input_dir.project(_splat_normal.orthogonal()).normalized()
|
||||||
|
if dir == Vector2.ZERO:
|
||||||
|
dir = _splat_normal
|
||||||
|
dir = dir.rotated(dir.angle_to(_splat_normal) * 0.5)
|
||||||
|
|
||||||
|
launch(dir * splat_launch_power)
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,23 +79,24 @@ turn_acceleration = 300.0
|
||||||
stopping_force = 200.0
|
stopping_force = 200.0
|
||||||
gravity = 450.0
|
gravity = 450.0
|
||||||
jump_power = 180.0
|
jump_power = 180.0
|
||||||
|
splat_launch_power = 240.0
|
||||||
|
splat_offset = 6.0
|
||||||
state_chart = NodePath("StateChart")
|
state_chart = NodePath("StateChart")
|
||||||
graphics = NodePath("Graphics")
|
graphics = NodePath("Graphics")
|
||||||
run_animation = NodePath("Graphics/Sprite/Run")
|
run_animation = NodePath("Graphics/Sprite/Run")
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2(0, -6)
|
|
||||||
shape = SubResource("CircleShape2D_tvyy1")
|
shape = SubResource("CircleShape2D_tvyy1")
|
||||||
debug_color = Color(3.32102e-06, 0.648976, 0.161954, 0.42)
|
debug_color = Color(3.32102e-06, 0.648976, 0.161954, 0.42)
|
||||||
|
|
||||||
[node name="Graphics" type="Node2D" parent="."]
|
[node name="Graphics" type="Node2D" parent="."]
|
||||||
position = Vector2(0, -6)
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="Graphics"]
|
[node name="Sprite" type="Sprite2D" parent="Graphics"]
|
||||||
texture = ExtResource("3_trcll")
|
texture = ExtResource("3_trcll")
|
||||||
offset = Vector2(0, -2)
|
offset = Vector2(0, -2)
|
||||||
hframes = 4
|
hframes = 4
|
||||||
vframes = 4
|
vframes = 4
|
||||||
|
frame = 10
|
||||||
region_rect = Rect2(0, 0, 64, 64)
|
region_rect = Rect2(0, 0, 64, 64)
|
||||||
|
|
||||||
[node name="Idle" type="Node" parent="Graphics/Sprite"]
|
[node name="Idle" type="Node" parent="Graphics/Sprite"]
|
||||||
|
@ -128,6 +129,18 @@ first_frame = Vector2i(1, 2)
|
||||||
script = ExtResource("4_bsdw5")
|
script = ExtResource("4_bsdw5")
|
||||||
first_frame = Vector2i(2, 2)
|
first_frame = Vector2i(2, 2)
|
||||||
|
|
||||||
|
[node name="Splat" type="Node" parent="Graphics/Sprite"]
|
||||||
|
script = ExtResource("4_bsdw5")
|
||||||
|
first_frame = Vector2i(0, 3)
|
||||||
|
frames = 2
|
||||||
|
fps = 8.0
|
||||||
|
|
||||||
|
[node name="UnSplat" type="Node" parent="Graphics/Sprite"]
|
||||||
|
script = ExtResource("4_bsdw5")
|
||||||
|
first_frame = Vector2i(2, 3)
|
||||||
|
frames = 2
|
||||||
|
fps = 8.0
|
||||||
|
|
||||||
[node name="Sounds" type="Node" parent="."]
|
[node name="Sounds" type="Node" parent="."]
|
||||||
|
|
||||||
[node name="Voice" type="AudioStreamPlayer" parent="Sounds"]
|
[node name="Voice" type="AudioStreamPlayer" parent="Sounds"]
|
||||||
|
@ -140,7 +153,6 @@ bus = &"Capri"
|
||||||
|
|
||||||
[node name="StateChart" type="Node" parent="."]
|
[node name="StateChart" type="Node" parent="."]
|
||||||
script = ExtResource("5_bcjtl")
|
script = ExtResource("5_bcjtl")
|
||||||
track_in_editor = true
|
|
||||||
initial_expression_properties = {
|
initial_expression_properties = {
|
||||||
&"input_dir": Vector2(0, 0),
|
&"input_dir": Vector2(0, 0),
|
||||||
&"on_floor": false,
|
&"on_floor": false,
|
||||||
|
@ -285,6 +297,41 @@ delay_in_seconds = "0.0"
|
||||||
editor_description = "Player is hurtling through the air and ricocheting off of surfaces."
|
editor_description = "Player is hurtling through the air and ricocheting off of surfaces."
|
||||||
script = ExtResource("10_mvu25")
|
script = ExtResource("10_mvu25")
|
||||||
|
|
||||||
|
[node name="on Splatted" type="Node" parent="StateChart/Root/Airborne/Missile"]
|
||||||
|
editor_description = "Transition to splat state when the player hits a wall"
|
||||||
|
script = ExtResource("7_rgjdc")
|
||||||
|
to = NodePath("../../../Floating/Splat")
|
||||||
|
event = &"splatted"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="Floating" type="Node" parent="StateChart/Root"]
|
||||||
|
script = ExtResource("6_jnxnd")
|
||||||
|
initial_state = NodePath("UnSplat")
|
||||||
|
|
||||||
|
[node name="Splat" type="Node" parent="StateChart/Root/Floating"]
|
||||||
|
editor_description = "Player has slammed into a surface (and has a moment to perform an action?)"
|
||||||
|
script = ExtResource("10_mvu25")
|
||||||
|
|
||||||
|
[node name="on JumpPressed" type="Node" parent="StateChart/Root/Floating/Splat"]
|
||||||
|
script = ExtResource("7_rgjdc")
|
||||||
|
to = NodePath("..")
|
||||||
|
event = &"jump_pressed"
|
||||||
|
delay_in_seconds = ""
|
||||||
|
|
||||||
|
[node name="on TimeOut" type="Node" parent="StateChart/Root/Floating/Splat"]
|
||||||
|
script = ExtResource("7_rgjdc")
|
||||||
|
to = NodePath("../../UnSplat")
|
||||||
|
delay_in_seconds = "0.75"
|
||||||
|
|
||||||
|
[node name="UnSplat" type="Node" parent="StateChart/Root/Floating"]
|
||||||
|
editor_description = "Player is unsticking from a surface."
|
||||||
|
script = ExtResource("10_mvu25")
|
||||||
|
|
||||||
|
[node name="on TimeOut" type="Node" parent="StateChart/Root/Floating/UnSplat"]
|
||||||
|
script = ExtResource("7_rgjdc")
|
||||||
|
to = NodePath("../../../Airborne/Falling")
|
||||||
|
delay_in_seconds = ".25"
|
||||||
|
|
||||||
[connection signal="taken" from="StateChart/Root/on Killed" to="." method="_reset_position"]
|
[connection signal="taken" from="StateChart/Root/on Killed" to="." method="_reset_position"]
|
||||||
[connection signal="taken" from="StateChart/Root/on Killed" to="Sounds/Death" method="play"]
|
[connection signal="taken" from="StateChart/Root/on Killed" to="Sounds/Death" method="play"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Idle" to="Graphics/Sprite/Idle" method="play"]
|
[connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Idle" to="Graphics/Sprite/Idle" method="play"]
|
||||||
|
@ -304,3 +351,8 @@ script = ExtResource("10_mvu25")
|
||||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Graphics/Sprite/Missile" method="play"]
|
[connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Graphics/Sprite/Missile" method="play"]
|
||||||
[connection signal="state_exited" from="StateChart/Root/Airborne/Missile" to="." method="_restore_graphics_rotation"]
|
[connection signal="state_exited" from="StateChart/Root/Airborne/Missile" to="." method="_restore_graphics_rotation"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_face_towards_velocity"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_face_towards_velocity"]
|
||||||
|
[connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_check_for_splat"]
|
||||||
|
[connection signal="state_entered" from="StateChart/Root/Floating/Splat" to="Graphics/Sprite/Splat" method="play"]
|
||||||
|
[connection signal="taken" from="StateChart/Root/Floating/Splat/on JumpPressed" to="." method="_do_splat_launch"]
|
||||||
|
[connection signal="state_entered" from="StateChart/Root/Floating/UnSplat" to="Graphics/Sprite/UnSplat" method="play"]
|
||||||
|
[connection signal="state_exited" from="StateChart/Root/Floating/UnSplat" to="." method="_restore_graphics_rotation"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue