moveable
This commit is contained in:
parent
abb54d45ca
commit
6a9a99389c
8 changed files with 39 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=11 format=4 uid="uid://ctc0arg3efa5k"]
|
||||
[gd_scene load_steps=12 format=4 uid="uid://ctc0arg3efa5k"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ba6afuig8bqrg" path="res://levels/LevelBase.tscn" id="1_87xn7"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3m4os8kteaix" path="res://textures/level01-spritesheet.png" id="2_wqskp"]
|
||||
|
@ -7,6 +7,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://bki6ucvk6bjwk" path="res://textures/Level 01.png" id="5_4p03u"]
|
||||
[ext_resource type="PackedScene" uid="uid://d0gpnqknarkg7" path="res://objects/Goal.tscn" id="6_xhax5"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpa66thuxma15" path="res://objects/MirrorOrb.tscn" id="7_dyi0e"]
|
||||
[ext_resource type="PackedScene" uid="uid://d17jpcgayfg6i" path="res://objects/BoxPushable_1.tscn" id="8_o0q03"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_e817v"]
|
||||
texture = ExtResource("2_wqskp")
|
||||
|
@ -167,3 +168,6 @@ position = Vector2(582, -317)
|
|||
|
||||
[node name="MirrorOrb" parent="." index="12" instance=ExtResource("7_dyi0e")]
|
||||
position = Vector2(-431, -212)
|
||||
|
||||
[node name="BoxPushable1" parent="." index="13" instance=ExtResource("8_o0q03")]
|
||||
position = Vector2(-228, 320)
|
||||
|
|
18
gmtk_2024/objects/BoxPushable_1.tscn
Normal file
18
gmtk_2024/objects/BoxPushable_1.tscn
Normal file
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://d17jpcgayfg6i"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://buqgl7x10et1f" path="res://temp_assets/img.png" id="1_ocrks"]
|
||||
[ext_resource type="Script" path="res://scripts/pushable.gd" id="1_tf1fy"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_legx4"]
|
||||
size = Vector2(34, 32)
|
||||
|
||||
[node name="BoxPushable1" type="CharacterBody2D"]
|
||||
collision_layer = 16
|
||||
collision_mask = 5
|
||||
script = ExtResource("1_tf1fy")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_legx4")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_ocrks")
|
|
@ -9,7 +9,7 @@ height = 32.0
|
|||
|
||||
[node name="EnemyMover" type="CharacterBody2D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 7
|
||||
collision_mask = 23
|
||||
script = ExtResource("1_7kapi")
|
||||
speed = 75
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ radius = 12.0
|
|||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
collision_layer = 4
|
||||
collision_mask = 3
|
||||
collision_mask = 19
|
||||
script = ExtResource("1_a6lhy")
|
||||
jump_strength = 600
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ click={
|
|||
2d_physics/layer_2="Enemies"
|
||||
2d_physics/layer_3="Player"
|
||||
2d_physics/layer_4="Goal"
|
||||
2d_physics/layer_5="Pushable"
|
||||
|
||||
[rendering]
|
||||
|
||||
|
|
|
@ -54,6 +54,12 @@ func _physics_process(delta):
|
|||
get_input(delta)
|
||||
velocity.y += gravity
|
||||
move_and_slide()
|
||||
|
||||
if(get_slide_collision_count() > 0):
|
||||
for i in get_slide_collision_count():
|
||||
var box = get_slide_collision(i).get_collider() as Box
|
||||
if box and velocity.y >= 0:
|
||||
box.velocity.x = velocity.x*0.8
|
||||
# print(jump_count) # Uncomment for debugging
|
||||
|
||||
func Jump():
|
||||
|
|
7
gmtk_2024/scripts/pushable.gd
Normal file
7
gmtk_2024/scripts/pushable.gd
Normal file
|
@ -0,0 +1,7 @@
|
|||
extends CharacterBody2D
|
||||
class_name Box;
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity.y += 50
|
||||
velocity.x = velocity.x * 0.8
|
||||
move_and_slide()
|
|
@ -4,7 +4,6 @@ extends Node
|
|||
|
||||
var current_selected = "none";
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("click"):
|
||||
if current_selected == "scale_up":
|
||||
|
|
Loading…
Add table
Reference in a new issue