mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-21 23:18:11 +00:00
Refactored Small Crouching and Big Crouching
- Added new variables to `CharacterInfo.json` - Made it so `BlockCollision` area position is attached to top of `SmallCollision` and `BigCollision`
This commit is contained in:
@@ -34,8 +34,10 @@
|
||||
|
||||
"DEATH_JUMP_HEIGHT": 300.0,
|
||||
|
||||
"can_air_turn": false,
|
||||
"can_air_turn": false
|
||||
},
|
||||
"small_hitbox_scale": [1.0, 1.0],
|
||||
"big_hitbox_scale": [1.0, 1.0]
|
||||
"small_crouch_scale": 0.75,
|
||||
"big_hitbox_scale": [1.0, 1.0],
|
||||
"big_crouch_scale": 0.5
|
||||
}
|
||||
|
@@ -34,8 +34,10 @@
|
||||
|
||||
"DEATH_JUMP_HEIGHT": 300.0,
|
||||
|
||||
"can_air_turn": false,
|
||||
"can_air_turn": false
|
||||
},
|
||||
"small_hitbox_scale": [1, 1],
|
||||
"big_hitbox_scale": [1.0, 1.0]
|
||||
"small_hitbox_scale": [1.0, 1.0],
|
||||
"small_crouch_scale": 0.75,
|
||||
"big_hitbox_scale": [1.0, 1.0],
|
||||
"big_crouch_scale": 0.5
|
||||
}
|
||||
|
@@ -34,8 +34,10 @@
|
||||
|
||||
"DEATH_JUMP_HEIGHT": 300.0,
|
||||
|
||||
"can_air_turn": false,
|
||||
"can_air_turn": false
|
||||
},
|
||||
"small_hitbox_scale": [1.0, 1.0],
|
||||
"big_hitbox_scale": [1.0, 1.0]
|
||||
"small_crouch_scale": 0.75,
|
||||
"big_hitbox_scale": [1.0, 1.0],
|
||||
"big_crouch_scale": 0.5
|
||||
}
|
||||
|
@@ -34,8 +34,10 @@
|
||||
|
||||
"DEATH_JUMP_HEIGHT": 300.0,
|
||||
|
||||
"can_air_turn": false,
|
||||
"can_air_turn": false
|
||||
},
|
||||
"small_hitbox_scale": [1.0, 1.0],
|
||||
"big_hitbox_scale": [1.0, 1.0]
|
||||
"small_crouch_scale": 0.75,
|
||||
"big_hitbox_scale": [1.0, 1.0],
|
||||
"big_crouch_scale": 0.5
|
||||
}
|
||||
|
@@ -470,10 +470,6 @@ func _physics_process(_delta: float) -> void:
|
||||
print(Global.level_editor.entity_tiles)
|
||||
"
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fqdtv"]
|
||||
resource_local_to_scene = true
|
||||
size = Vector2(4, 4.5)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_d7xah"]
|
||||
resource_local_to_scene = true
|
||||
size = Vector2(4, 6.75)
|
||||
@@ -1048,19 +1044,12 @@ mode = 1
|
||||
resource_json = ExtResource("10_xy8gq")
|
||||
metadata/_custom_type_script = "uid://cbal8ms2oe1ik"
|
||||
|
||||
[node name="SmallCrouchCollision" type="CollisionPolygon2D" parent="." groups=["SmallCollisions"]]
|
||||
visible = false
|
||||
polygon = PackedVector2Array(4, -2, 4, -8, 1, -11, -1, -11, -4, -8, -4, -2, -2, 0, 2, 0)
|
||||
one_way_collision = true
|
||||
script = ExtResource("35_nbkfn")
|
||||
|
||||
[node name="SmallCollision" type="CollisionPolygon2D" parent="." groups=["SmallCollisions"]]
|
||||
polygon = PackedVector2Array(4, -2, 4, -8, 1, -14, -1, -14, -4, -8, -4, -2, -2, 0, 2, 0)
|
||||
one_way_collision = true
|
||||
script = ExtResource("35_nbkfn")
|
||||
|
||||
[node name="BigCollision" type="CollisionPolygon2D" parent="." groups=["BigCollisions"]]
|
||||
visible = false
|
||||
polygon = PackedVector2Array(-4, -2, -2, 0, 2, 0, 4, -2, 4, -23, 1, -28, -1, -28, -4, -23)
|
||||
one_way_collision = true
|
||||
script = ExtResource("35_nbkfn")
|
||||
@@ -1106,32 +1095,22 @@ hit_from_inside = true
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="SmallCrouchShape" type="CollisionShape2D" parent="BlockCollision" node_paths=PackedStringArray("link") groups=["SmallCollisions"]]
|
||||
visible = false
|
||||
position = Vector2(0, -12.75)
|
||||
shape = SubResource("RectangleShape2D_fqdtv")
|
||||
debug_color = Color(1, 0, 0, 0.419608)
|
||||
script = ExtResource("21_jl70t")
|
||||
offset = Vector2(0, 10.5)
|
||||
link = NodePath("../../SmallCrouchCollision")
|
||||
|
||||
[node name="SmallShape" type="CollisionShape2D" parent="BlockCollision" node_paths=PackedStringArray("link") groups=["SmallCollisions"]]
|
||||
visible = false
|
||||
position = Vector2(0, -16.875)
|
||||
position = Vector2(0, -3.375)
|
||||
shape = SubResource("RectangleShape2D_d7xah")
|
||||
debug_color = Color(1, 0, 0, 0.419608)
|
||||
script = ExtResource("21_jl70t")
|
||||
offset = Vector2(0, 13.5)
|
||||
link = NodePath("../../SmallCollision")
|
||||
metadata/scalable = false
|
||||
|
||||
[node name="BigShape" type="CollisionShape2D" parent="BlockCollision" node_paths=PackedStringArray("link") groups=["BigCollisions"]]
|
||||
position = Vector2(0, -32)
|
||||
position = Vector2(0, -6)
|
||||
shape = SubResource("RectangleShape2D_34tqy")
|
||||
disabled = true
|
||||
debug_color = Color(1, 0, 0, 0.419608)
|
||||
script = ExtResource("21_jl70t")
|
||||
offset = Vector2(0, 26)
|
||||
link = NodePath("../../BigCollision")
|
||||
metadata/scalable = false
|
||||
|
||||
[node name="TimerWarn" type="AudioStreamPlayer" parent="."]
|
||||
process_mode = 3
|
||||
|
@@ -3,10 +3,16 @@ extends CollisionPolygon2D
|
||||
|
||||
@export var offset := Vector2.ZERO
|
||||
@export var height := 0.0
|
||||
@export var hitbox := Vector3.ONE
|
||||
|
||||
var crouching := false
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
scale = Vector2(hitbox.x, hitbox.y)
|
||||
if crouching and get_meta("scalable", true): scale.y *= hitbox.z
|
||||
update()
|
||||
|
||||
func update() -> void:
|
||||
var height_to_use = height
|
||||
position.y = -height_to_use / 2 * scale.y - offset.y
|
||||
if get_meta("scalable", true):
|
||||
position.y = -height_to_use / 2 * scale.y - offset.y
|
||||
|
@@ -2,16 +2,19 @@
|
||||
extends CollisionShape2D
|
||||
|
||||
@export var offset := Vector2.ZERO
|
||||
@export var link: Node2D
|
||||
@export var link: CollisionPolygon2D
|
||||
@export var hitbox := Vector3.ONE
|
||||
|
||||
func _ready() -> void:
|
||||
set_process(Engine.is_editor_hint())
|
||||
var crouching := false
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
func _physics_process(_delta: float) -> void:
|
||||
scale = Vector2(hitbox.x, hitbox.y)
|
||||
if crouching and get_meta("scalable", true): scale.y *= hitbox.z
|
||||
update()
|
||||
|
||||
func update() -> void:
|
||||
var height_to_use = shape.size.y
|
||||
if link != null:
|
||||
height_to_use *= link.scale.y * link.scale.y
|
||||
position.y = -height_to_use / 2 * scale.y - offset.y
|
||||
if get_meta("scalable", true):
|
||||
position.y = -height_to_use / 2 * scale.y - offset.y
|
||||
|
@@ -231,12 +231,12 @@ func apply_character_physics() -> void:
|
||||
|
||||
for i in get_tree().get_nodes_in_group("SmallCollisions"):
|
||||
var hitbox_scale = json.get("small_hitbox_scale", [1, 1])
|
||||
i.scale = Vector2(hitbox_scale[0], hitbox_scale[1])
|
||||
i.update()
|
||||
i.hitbox = Vector3(hitbox_scale[0], hitbox_scale[1] if i.get_meta("scalable", true) else 1, json.get("small_crouch_scale", 0.75))
|
||||
i._physics_process(0)
|
||||
for i in get_tree().get_nodes_in_group("BigCollisions"):
|
||||
var hitbox_scale = json.get("big_hitbox_scale", [1, 1])
|
||||
i.scale = Vector2(hitbox_scale[0], hitbox_scale[1])
|
||||
i.update()
|
||||
i.hitbox = Vector3(hitbox_scale[0], hitbox_scale[1] if i.get_meta("scalable", true) else 1, json.get("big_crouch_scale", 0.5))
|
||||
i._physics_process(0)
|
||||
|
||||
func apply_classic_physics() -> void:
|
||||
var json = JSON.parse_string(FileAccess.open("res://Resources/ClassicPhysics.json", FileAccess.READ).get_as_text())
|
||||
@@ -470,7 +470,15 @@ func handle_invincible_palette() -> void:
|
||||
|
||||
func handle_block_collision_detection() -> void:
|
||||
if ["Pipe"].has(state_machine.state.name): return
|
||||
|
||||
match power_state.hitbox_size:
|
||||
"Small":
|
||||
var points: Array = $SmallCollision.polygon
|
||||
points.sort_custom(func(a, b): return a.y < b.y)
|
||||
$BlockCollision.position.y = points.front().y * $SmallCollision.scale.y
|
||||
"Big":
|
||||
var points: Array = $BigCollision.polygon
|
||||
points.sort_custom(func(a, b): return a.y < b.y)
|
||||
$BlockCollision.position.y = points.front().y * $BigCollision.scale.y
|
||||
if velocity.y <= FALL_GRAVITY:
|
||||
for i in $BlockCollision.get_overlapping_bodies():
|
||||
if i is Block:
|
||||
@@ -487,19 +495,15 @@ func handle_directions() -> void:
|
||||
var use_big_collision := false
|
||||
|
||||
func handle_power_up_states(delta) -> void:
|
||||
var small_crouch := power_state.hitbox_size == "Small" and crouching
|
||||
var big_crouch := power_state.hitbox_size == "Big" and crouching
|
||||
for i in get_tree().get_nodes_in_group("SmallCollisions"):
|
||||
if i.name.begins_with("SmallCrouch"):
|
||||
i.set_deferred("disabled", power_state.hitbox_size == "Small" and !crouching or power_state.hitbox_size == "Big")
|
||||
i.visible = not i.disabled
|
||||
else:
|
||||
i.set_deferred("disabled", small_crouch or power_state.hitbox_size == "Big" and !crouching)
|
||||
i.visible = not i.disabled
|
||||
for i in get_tree().get_nodes_in_group("BigCollisions"):
|
||||
i.set_deferred("disabled", power_state.hitbox_size == "Small" or big_crouch)
|
||||
i.disabled = power_state.hitbox_size != "Small"
|
||||
i.visible = not i.disabled
|
||||
$Checkpoint.position.y = -20 if small_crouch else -24 if power_state.hitbox_size == "Small" or big_crouch else -40
|
||||
i.crouching = crouching
|
||||
for i in get_tree().get_nodes_in_group("BigCollisions"):
|
||||
i.disabled = power_state.hitbox_size != "Big"
|
||||
i.visible = not i.disabled
|
||||
i.crouching = crouching
|
||||
$Checkpoint.position.y = -24 if power_state.hitbox_size == "Small" else -40
|
||||
power_state.update(delta)
|
||||
|
||||
func handle_wing_flight(delta: float) -> void:
|
||||
|
Reference in New Issue
Block a user