feat: add a unmovable block as a scene; add it to gameScene;

This commit is contained in:
2026-08-24 08:20:45 +02:00
parent e87ebd3827
commit b2a7fa65ad
5 changed files with 37 additions and 1 deletions
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
[gd_scene format=3 uid="uid://orvnsdbeji56"]
[ext_resource type="Texture2D" uid="uid://c0v63n2kjtvvu" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetDungeon.png" id="1_83tkd"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bqpwv"]
size = Vector2(16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_bqpwv"]
atlas = ExtResource("1_83tkd")
region = Rect2(127.859436, 47.936436, 16.21347, 16.062302)
[node name="Block" type="RigidBody2D" unique_id=2096944035]
gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=195703280]
shape = SubResource("RectangleShape2D_bqpwv")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=605230206]
texture = SubResource("AtlasTexture_bqpwv")
File diff suppressed because one or more lines are too long
+4
View File
@@ -5,6 +5,7 @@
[ext_resource type="Texture2D" uid="uid://clv4i0q1nosad" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetNature.png" id="2_04h35"] [ext_resource type="Texture2D" uid="uid://clv4i0q1nosad" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetNature.png" id="2_04h35"]
[ext_resource type="Texture2D" uid="uid://c3l7w3n700qx3" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetReliefDetail.png" id="3_oi8ly"] [ext_resource type="Texture2D" uid="uid://c3l7w3n700qx3" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetReliefDetail.png" id="3_oi8ly"]
[ext_resource type="PackedScene" uid="uid://dhvuy8co661xo" path="res://Scenes/SceneEntrance/scene_entrance.tscn" id="5_oi8ly"] [ext_resource type="PackedScene" uid="uid://dhvuy8co661xo" path="res://Scenes/SceneEntrance/scene_entrance.tscn" id="5_oi8ly"]
[ext_resource type="PackedScene" uid="uid://orvnsdbeji56" path="res://Scenes/Block/block.tscn" id="6_12ovb"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_04h35"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_04h35"]
texture = ExtResource("1_l6yvh") texture = ExtResource("1_l6yvh")
@@ -800,3 +801,6 @@ zoom = Vector2(5, 5)
[node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("5_oi8ly")] [node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("5_oi8ly")]
position = Vector2(136, -108) position = Vector2(136, -108)
[node name="Block" parent="." unique_id=2096944035 instance=ExtResource("6_12ovb")]
position = Vector2(0, -33)
+13
View File
@@ -25,4 +25,17 @@ func _process(delta: float) -> void:
$AnimatedSprite2D.play("move_up") $AnimatedSprite2D.play("move_up")
else: else:
$AnimatedSprite2D.stop() $AnimatedSprite2D.stop()
# get the last collision
# check if it's the block
# if it is the block then push it
var collision: KinematicCollision2D = get_last_slide_collision()
if collision:
var collisision_node = collision.get_collider()
if collisision_node is RigidBody2D:
var collision_normal: Vector2 = collision.get_normal()
collisision_node.apply_central_force(-collision_normal)
move_and_slide() move_and_slide()