rotoboy mechanic

This commit is contained in:
Haze Weathers 2025-03-08 22:04:56 -05:00
parent dd54e286d8
commit aaf9278350
4 changed files with 89 additions and 31 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=4 uid="uid://cccb8wltupasj"] [gd_scene load_steps=8 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"]
@ -6,6 +6,7 @@
[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"] [ext_resource type="PackedScene" uid="uid://68lav5rke5ag" path="res://objects/spring/spring.tscn" id="6_tlqas"]
[ext_resource type="PackedScene" uid="uid://bwtjfpfkykfdr" path="res://objects/rotoboy/roto_boy.tscn" id="7_j1102"]
[node name="LevelZ" type="Node2D"] [node name="LevelZ" type="Node2D"]
script = ExtResource("1_hcs1r") script = ExtResource("1_hcs1r")
@ -20,7 +21,7 @@ texture = ExtResource("1_h5jcm")
[node name="TileMap" type="TileMapLayer" parent="."] [node name="TileMap" type="TileMapLayer" parent="."]
use_parent_material = true use_parent_material = true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AAAAAAAAAADAAkAAAAAAAAAAAACAAkAAAAAAAAAAAABAAkAAAAAAAAAAAABAAoAAAAAAAAAAAACAAoAAAAAAAAAAAADAAoAAAAAAAAAAAAEAAoAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAkAAAAAAAAAAAABAAgAAAAAAAAAAAABAAcAAAAAAAAAAAABAAYAAAAAAAAAAAABAAUAAAAAAAAAAAABAAQAAAAAAAAAAAABAAMAAAAAAAAAAAABAAIAAAAAAAAAAAA=")
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")]
@ -31,3 +32,6 @@ position = Vector2(120, 144)
[node name="Spring" parent="." instance=ExtResource("6_tlqas")] [node name="Spring" parent="." instance=ExtResource("6_tlqas")]
position = Vector2(96, 144) position = Vector2(96, 144)
[node name="RotoBoy" parent="." instance=ExtResource("7_j1102")]
position = Vector2(152, 104)

View file

@ -0,0 +1,35 @@
extends Node2D
@export var speed: float = 0.0
@export_custom(0, "radians_as_degrees") var rotation_speed: float
@export var launch_speed: float
@export_group("Internal References")
@export var rotation_pivot: Node2D
@export var collision_shape: CollisionShape2D
var _player: Player = null
func _physics_process(delta: float) -> void:
if is_zero_approx(speed):
collision_shape.disabled = false
rotation_pivot.rotation = 0.0
else:
collision_shape.disabled = true
rotation_pivot.rotation += rotation_speed * delta
if _player:
var dir = -to_local(_player.global_position).orthogonal()
_player.launch(_player.velocity + dir * launch_speed * speed * delta)
func _on_player_detector_body_entered(body: Node2D) -> void:
if body is Player:
_player = body
func _on_player_detector_body_exited(body: Node2D) -> void:
if body is Player:
_player = null

View file

@ -0,0 +1 @@
uid://doitxsfhjpfh0

View file

@ -1,20 +1,40 @@
[gd_scene load_steps=9 format=3 uid="uid://bwtjfpfkykfdr"] [gd_scene load_steps=10 format=3 uid="uid://bwtjfpfkykfdr"]
[ext_resource type="Script" uid="uid://bt4bdjyekgh53" path="res://scripts/ball_snake/ball_snake.gd" id="1_7ck2q"] [ext_resource type="Script" uid="uid://bt4bdjyekgh53" path="res://scripts/ball_snake/ball_snake.gd" id="1_7ck2q"]
[ext_resource type="Script" uid="uid://doitxsfhjpfh0" path="res://objects/rotoboy/roto_boy.gd" id="1_pwab3"]
[ext_resource type="Texture2D" uid="uid://cvgdwf28yr7fw" path="res://assets/textures/rotoboy/rotoboy.png" id="2_3s2uc"] [ext_resource type="Texture2D" uid="uid://cvgdwf28yr7fw" path="res://assets/textures/rotoboy/rotoboy.png" id="2_3s2uc"]
[ext_resource type="Texture2D" uid="uid://ckfu1u3qxssrj" path="res://assets/textures/rotoboy/rotoboy_face.png" id="3_gp51k"] [ext_resource type="Texture2D" uid="uid://ckfu1u3qxssrj" path="res://assets/textures/rotoboy/rotoboy_face.png" id="3_gp51k"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_sc2kd"] [sub_resource type="CircleShape2D" id="CircleShape2D_pwab3"]
radius = 24.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8o2cr"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_8o2cr"]
size = Vector2(48, 8) size = Vector2(48, 8)
[sub_resource type="Animation" id="Animation_bsslc"] [sub_resource type="Animation" id="Animation_pwab3"]
resource_name = "on_off"
length = 3.0
loop_mode = 1
step = 0.1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:speed")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1, 1.1, 2.9, 3),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 0,
"values": [0.0, 0.0, 1.0, 1.0, 1.0]
}
[sub_resource type="Animation" id="Animation_qes26"]
length = 0.001 length = 0.001
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
tracks/0/path = NodePath("RotatingPiece:rotation") tracks/0/path = NodePath(".:speed")
tracks/0/interp = 1 tracks/0/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/keys = { tracks/0/keys = {
@ -24,30 +44,26 @@ tracks/0/keys = {
"values": [0.0] "values": [0.0]
} }
[sub_resource type="Animation" id="Animation_eby5m"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_5ig0v"]
resource_name = "spin"
length = 5.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("RotatingPiece:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = false
tracks/0/keys = {
"times": PackedFloat32Array(-0.0333333, 3, 4.2),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [0.0, 0.0, 12.5664]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_l3464"]
_data = { _data = {
&"RESET": SubResource("Animation_bsslc"), &"RESET": SubResource("Animation_qes26"),
&"spin": SubResource("Animation_eby5m") &"on_off": SubResource("Animation_pwab3")
} }
[node name="RotoBoy" type="Node2D"] [node name="RotoBoy" type="Node2D" node_paths=PackedStringArray("rotation_pivot", "collision_shape")]
script = ExtResource("1_pwab3")
rotation_speed = 18.8496
launch_speed = 50.0
rotation_pivot = NodePath("RotatingPiece")
collision_shape = NodePath("RotatingPiece/AnimatableBody2D/CollisionShape2D")
[node name="PlayerDetector" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 16
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerDetector"]
shape = SubResource("CircleShape2D_pwab3")
debug_color = Color(0.752941, 0.196078, 1, 0.25098)
[node name="RotatingPiece" type="Node2D" parent="."] [node name="RotatingPiece" type="Node2D" parent="."]
@ -58,7 +74,6 @@ position = Vector2(-20, 0)
position = Vector2(20, 0) position = Vector2(20, 0)
[node name="AnimatableBody2D" type="AnimatableBody2D" parent="RotatingPiece"] [node name="AnimatableBody2D" type="AnimatableBody2D" parent="RotatingPiece"]
physics_material_override = SubResource("PhysicsMaterial_sc2kd")
[node name="CollisionShape2D" type="CollisionShape2D" parent="RotatingPiece/AnimatableBody2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="RotatingPiece/AnimatableBody2D"]
shape = SubResource("RectangleShape2D_8o2cr") shape = SubResource("RectangleShape2D_8o2cr")
@ -81,11 +96,14 @@ tail_segment = false
auto_density = true auto_density = true
pixels_per_segment = 6.0 pixels_per_segment = 6.0
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Head" type="Sprite2D" parent="."]
texture = ExtResource("3_gp51k") texture = ExtResource("3_gp51k")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = { libraries = {
&"": SubResource("AnimationLibrary_l3464") &"": SubResource("AnimationLibrary_5ig0v")
} }
autoplay = "spin" autoplay = "on_off"
[connection signal="body_entered" from="PlayerDetector" to="." method="_on_player_detector_body_entered"]
[connection signal="body_exited" from="PlayerDetector" to="." method="_on_player_detector_body_exited"]