mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 07:28:14 +00:00
Merge pull request #342 from KirbyKid256/pulls/small-crouch-hitbox-fix
Hitbox Change for When Small and Crouching
This commit is contained in:
@@ -34,8 +34,10 @@
|
|||||||
|
|
||||||
"DEATH_JUMP_HEIGHT": 300.0,
|
"DEATH_JUMP_HEIGHT": 300.0,
|
||||||
|
|
||||||
"can_air_turn": false,
|
"can_air_turn": false
|
||||||
},
|
},
|
||||||
"small_hitbox_scale": [1.0, 1.0],
|
"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,
|
"DEATH_JUMP_HEIGHT": 300.0,
|
||||||
|
|
||||||
"can_air_turn": false,
|
"can_air_turn": false
|
||||||
},
|
},
|
||||||
"small_hitbox_scale": [1, 1],
|
"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,
|
"DEATH_JUMP_HEIGHT": 300.0,
|
||||||
|
|
||||||
"can_air_turn": false,
|
"can_air_turn": false
|
||||||
},
|
},
|
||||||
"small_hitbox_scale": [1.0, 1.0],
|
"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,
|
"DEATH_JUMP_HEIGHT": 300.0,
|
||||||
|
|
||||||
"can_air_turn": false,
|
"can_air_turn": false
|
||||||
},
|
},
|
||||||
"small_hitbox_scale": [1.0, 1.0],
|
"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
|
||||||
}
|
}
|
||||||
|
@@ -712,7 +712,7 @@ position = Vector2(0, -13)
|
|||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 384
|
collision_mask = 384
|
||||||
|
|
||||||
[node name="SmallShape" type="CollisionShape2D" parent="LavaPoisonDetect"]
|
[node name="SmallShape" type="CollisionShape2D" parent="LavaPoisonDetect" groups=["SmallCollisions"]]
|
||||||
position = Vector2(0, 5.75)
|
position = Vector2(0, 5.75)
|
||||||
shape = SubResource("RectangleShape2D_uwhl4")
|
shape = SubResource("RectangleShape2D_uwhl4")
|
||||||
debug_color = Color(1, 0, 0, 0.419608)
|
debug_color = Color(1, 0, 0, 0.419608)
|
||||||
@@ -1050,8 +1050,8 @@ one_way_collision = true
|
|||||||
script = ExtResource("35_nbkfn")
|
script = ExtResource("35_nbkfn")
|
||||||
|
|
||||||
[node name="BigCollision" type="CollisionPolygon2D" parent="." groups=["BigCollisions"]]
|
[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)
|
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")
|
script = ExtResource("35_nbkfn")
|
||||||
|
|
||||||
[node name="FootL" type="CollisionShape2D" parent="." groups=["StepCollision"]]
|
[node name="FootL" type="CollisionShape2D" parent="." groups=["StepCollision"]]
|
||||||
@@ -1096,22 +1096,21 @@ collision_layer = 0
|
|||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
|
|
||||||
[node name="SmallShape" type="CollisionShape2D" parent="BlockCollision" node_paths=PackedStringArray("link") groups=["SmallCollisions"]]
|
[node name="SmallShape" type="CollisionShape2D" parent="BlockCollision" node_paths=PackedStringArray("link") groups=["SmallCollisions"]]
|
||||||
visible = false
|
position = Vector2(0, -3.375)
|
||||||
position = Vector2(0, -16.875)
|
|
||||||
shape = SubResource("RectangleShape2D_d7xah")
|
shape = SubResource("RectangleShape2D_d7xah")
|
||||||
debug_color = Color(1, 0, 0, 0.419608)
|
debug_color = Color(1, 0, 0, 0.419608)
|
||||||
script = ExtResource("21_jl70t")
|
script = ExtResource("21_jl70t")
|
||||||
offset = Vector2(0, 13.5)
|
|
||||||
link = NodePath("../../SmallCollision")
|
link = NodePath("../../SmallCollision")
|
||||||
|
metadata/scalable = false
|
||||||
|
|
||||||
[node name="BigShape" type="CollisionShape2D" parent="BlockCollision" node_paths=PackedStringArray("link") groups=["BigCollisions"]]
|
[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")
|
shape = SubResource("RectangleShape2D_34tqy")
|
||||||
disabled = true
|
disabled = true
|
||||||
debug_color = Color(1, 0, 0, 0.419608)
|
debug_color = Color(1, 0, 0, 0.419608)
|
||||||
script = ExtResource("21_jl70t")
|
script = ExtResource("21_jl70t")
|
||||||
offset = Vector2(0, 26)
|
|
||||||
link = NodePath("../../BigCollision")
|
link = NodePath("../../BigCollision")
|
||||||
|
metadata/scalable = false
|
||||||
|
|
||||||
[node name="TimerWarn" type="AudioStreamPlayer" parent="."]
|
[node name="TimerWarn" type="AudioStreamPlayer" parent="."]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
|
@@ -3,10 +3,16 @@ extends CollisionPolygon2D
|
|||||||
|
|
||||||
@export var offset := Vector2.ZERO
|
@export var offset := Vector2.ZERO
|
||||||
@export var height := 0.0
|
@export var height := 0.0
|
||||||
|
@export var hitbox := Vector3.ONE
|
||||||
|
|
||||||
|
var crouching := false
|
||||||
|
|
||||||
func _physics_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()
|
update()
|
||||||
|
|
||||||
func update() -> void:
|
func update() -> void:
|
||||||
var height_to_use = height
|
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
|
extends CollisionShape2D
|
||||||
|
|
||||||
@export var offset := Vector2.ZERO
|
@export var offset := Vector2.ZERO
|
||||||
@export var link: Node2D
|
@export var link: CollisionPolygon2D
|
||||||
|
@export var hitbox := Vector3.ONE
|
||||||
|
|
||||||
func _ready() -> void:
|
var crouching := false
|
||||||
set_process(Engine.is_editor_hint())
|
|
||||||
|
|
||||||
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()
|
update()
|
||||||
|
|
||||||
func update() -> void:
|
func update() -> void:
|
||||||
var height_to_use = shape.size.y
|
var height_to_use = shape.size.y
|
||||||
if link != null:
|
if link != null:
|
||||||
height_to_use *= link.scale.y * link.scale.y
|
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
|
||||||
|
@@ -61,7 +61,10 @@ var total_keys := 0
|
|||||||
set_power_state_frame()
|
set_power_state_frame()
|
||||||
var character := "Mario"
|
var character := "Mario"
|
||||||
|
|
||||||
var crouching := false
|
var crouching := false:
|
||||||
|
get(): # You can't crouch if the animation somehow doesn't exist.
|
||||||
|
if not sprite.sprite_frames.has_animation("Crouch"): return false
|
||||||
|
return crouching
|
||||||
var skidding := false
|
var skidding := false
|
||||||
|
|
||||||
var bumping := false
|
var bumping := false
|
||||||
@@ -145,6 +148,7 @@ const ANIMATION_FALLBACKS := {
|
|||||||
"Run": "Move",
|
"Run": "Move",
|
||||||
"PipeWalk": "Move",
|
"PipeWalk": "Move",
|
||||||
"LookUp": "Idle",
|
"LookUp": "Idle",
|
||||||
|
"Crouch": "Idle",
|
||||||
"CrouchFall": "Crouch",
|
"CrouchFall": "Crouch",
|
||||||
"CrouchJump": "Crouch",
|
"CrouchJump": "Crouch",
|
||||||
"CrouchBump": "Bump",
|
"CrouchBump": "Bump",
|
||||||
@@ -227,12 +231,12 @@ func apply_character_physics() -> void:
|
|||||||
|
|
||||||
for i in get_tree().get_nodes_in_group("SmallCollisions"):
|
for i in get_tree().get_nodes_in_group("SmallCollisions"):
|
||||||
var hitbox_scale = json.get("small_hitbox_scale", [1, 1])
|
var hitbox_scale = json.get("small_hitbox_scale", [1, 1])
|
||||||
i.scale = Vector2(hitbox_scale[0], hitbox_scale[1])
|
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.update()
|
i._physics_process(0)
|
||||||
for i in get_tree().get_nodes_in_group("BigCollisions"):
|
for i in get_tree().get_nodes_in_group("BigCollisions"):
|
||||||
var hitbox_scale = json.get("big_hitbox_scale", [1, 1])
|
var hitbox_scale = json.get("big_hitbox_scale", [1, 1])
|
||||||
i.scale = Vector2(hitbox_scale[0], hitbox_scale[1])
|
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.update()
|
i._physics_process(0)
|
||||||
|
|
||||||
func apply_classic_physics() -> void:
|
func apply_classic_physics() -> void:
|
||||||
var json = JSON.parse_string(FileAccess.open("res://Resources/ClassicPhysics.json", FileAccess.READ).get_as_text())
|
var json = JSON.parse_string(FileAccess.open("res://Resources/ClassicPhysics.json", FileAccess.READ).get_as_text())
|
||||||
@@ -466,7 +470,15 @@ func handle_invincible_palette() -> void:
|
|||||||
|
|
||||||
func handle_block_collision_detection() -> void:
|
func handle_block_collision_detection() -> void:
|
||||||
if ["Pipe"].has(state_machine.state.name): return
|
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:
|
if velocity.y <= FALL_GRAVITY:
|
||||||
for i in $BlockCollision.get_overlapping_bodies():
|
for i in $BlockCollision.get_overlapping_bodies():
|
||||||
if i is Block:
|
if i is Block:
|
||||||
@@ -483,10 +495,15 @@ func handle_directions() -> void:
|
|||||||
var use_big_collision := false
|
var use_big_collision := false
|
||||||
|
|
||||||
func handle_power_up_states(delta) -> void:
|
func handle_power_up_states(delta) -> void:
|
||||||
|
for i in get_tree().get_nodes_in_group("SmallCollisions"):
|
||||||
|
i.disabled = power_state.hitbox_size != "Small"
|
||||||
|
i.visible = not i.disabled
|
||||||
|
i.crouching = crouching
|
||||||
for i in get_tree().get_nodes_in_group("BigCollisions"):
|
for i in get_tree().get_nodes_in_group("BigCollisions"):
|
||||||
if i.owner == self:
|
i.disabled = power_state.hitbox_size != "Big"
|
||||||
i.set_deferred("disabled", power_state.hitbox_size == "Small" or crouching)
|
i.visible = not i.disabled
|
||||||
$Checkpoint.position.y = -24 if power_state.hitbox_size == "Small" or crouching else -40
|
i.crouching = crouching
|
||||||
|
$Checkpoint.position.y = -24 if power_state.hitbox_size == "Small" else -40
|
||||||
power_state.update(delta)
|
power_state.update(delta)
|
||||||
|
|
||||||
func handle_wing_flight(delta: float) -> void:
|
func handle_wing_flight(delta: float) -> void:
|
||||||
|
Reference in New Issue
Block a user