fixed the data_link length
This commit is contained in:
parent
0eb335e0bf
commit
55f4163ef0
11 changed files with 257 additions and 62 deletions
|
@ -33,7 +33,7 @@ visible = false
|
||||||
|
|
||||||
[node name="UILayer" type="CanvasLayer" parent="."]
|
[node name="UILayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="UI" type="Control" parent="UILayer" node_paths=PackedStringArray("player")]
|
[node name="UI" type="Control" parent="UILayer"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
@ -41,7 +41,6 @@ anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("3_b82rx")
|
script = ExtResource("3_b82rx")
|
||||||
player = NodePath("../../Player")
|
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="UILayer/UI"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="UILayer/UI"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
|
|
182
gmtk_2024/levels/lev877D.tmp
Normal file
182
gmtk_2024/levels/lev877D.tmp
Normal file
File diff suppressed because one or more lines are too long
|
@ -129,7 +129,6 @@ shader_parameter/scroll_speed = 0.02
|
||||||
[node name="Player" parent="." index="0"]
|
[node name="Player" parent="." index="0"]
|
||||||
position = Vector2(-542, 331)
|
position = Vector2(-542, 331)
|
||||||
scale = Vector2(2, 2)
|
scale = Vector2(2, 2)
|
||||||
jump_strength_max = 400
|
|
||||||
|
|
||||||
[node name="UI" parent="UILayer" index="0"]
|
[node name="UI" parent="UILayer" index="0"]
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
|
@ -170,9 +169,14 @@ position = Vector2(582, -317)
|
||||||
position = Vector2(-431, -212)
|
position = Vector2(-431, -212)
|
||||||
|
|
||||||
[node name="Block" parent="." index="9" node_paths=PackedStringArray("ui_actions") instance=ExtResource("8_ec71m")]
|
[node name="Block" parent="." index="9" node_paths=PackedStringArray("ui_actions") instance=ExtResource("8_ec71m")]
|
||||||
position = Vector2(476, 253)
|
position = Vector2(432, 186)
|
||||||
collision_layer = 1
|
collision_layer = 1
|
||||||
ui_actions = NodePath("../UILayer/UI")
|
ui_actions = NodePath("../UILayer/UI")
|
||||||
|
|
||||||
[node name="EnemyMover" parent="." index="10" instance=ExtResource("8_16072")]
|
[node name="EnemyMover" parent="." index="10" instance=ExtResource("8_16072")]
|
||||||
position = Vector2(-132, 311)
|
position = Vector2(-132, 311)
|
||||||
|
|
||||||
|
[node name="Block3" parent="." index="11" node_paths=PackedStringArray("ui_actions") instance=ExtResource("8_ec71m")]
|
||||||
|
position = Vector2(162, 124)
|
||||||
|
collision_layer = 1
|
||||||
|
ui_actions = NodePath("../UILayer/UI")
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://snxpqx0ony7s"]
|
[gd_scene load_steps=6 format=3 uid="uid://snxpqx0ony7s"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/player_movement.gd" id="1_a6lhy"]
|
[ext_resource type="Script" path="res://scripts/player_movement.gd" id="1_a6lhy"]
|
||||||
[ext_resource type="Texture2D" uid="uid://qcx482jc7pqr" path="res://textures/player.png" id="2_sscjv"]
|
[ext_resource type="Texture2D" uid="uid://qcx482jc7pqr" path="res://textures/player.png" id="2_sscjv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dfvxk0e8taj1d" path="res://textures/Eye Lase.png" id="3_yg3ur"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jqi2f"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jqi2f"]
|
||||||
radius = 9.0
|
radius = 9.0
|
||||||
|
@ -29,4 +30,12 @@ collision_mask = 2
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox"]
|
||||||
shape = SubResource("CircleShape2D_vxfel")
|
shape = SubResource("CircleShape2D_vxfel")
|
||||||
|
|
||||||
|
[node name="data_link" type="Line2D" parent="."]
|
||||||
|
visible = false
|
||||||
|
texture_repeat = 2
|
||||||
|
points = PackedVector2Array(0, 0, 0, 0)
|
||||||
|
default_color = Color(0.298039, 1, 0.141176, 1)
|
||||||
|
texture = ExtResource("3_yg3ur")
|
||||||
|
texture_mode = 1
|
||||||
|
|
||||||
[connection signal="body_entered" from="Hurtbox" to="." method="_on_hurtbox_body_entered"]
|
[connection signal="body_entered" from="Hurtbox" to="." method="_on_hurtbox_body_entered"]
|
||||||
|
|
|
@ -4,17 +4,20 @@ extends CharacterBody2D
|
||||||
@export var gravity = 50
|
@export var gravity = 50
|
||||||
var jump_count = 1
|
var jump_count = 1
|
||||||
@export var jump_strength = 100
|
@export var jump_strength = 100
|
||||||
@export var jump_strength_max = 300
|
|
||||||
var is_touching_floor : bool = true
|
var is_touching_floor : bool = true
|
||||||
var jump_buffer_timer : float
|
var jump_buffer_timer : float
|
||||||
var coyote_timer : float = 0.2 # 200 millisecond buffer
|
var coyote_timer : float = 0.2
|
||||||
var input_direction = 0 #To keep track of which direction we where moving in last frame
|
var input_direction = 0
|
||||||
|
@export var max_link_distance: float = 200.0
|
||||||
|
var data_link: Line2D
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
data_link = $data_link
|
||||||
|
|
||||||
func get_input(delta):
|
func get_input(delta):
|
||||||
|
|
||||||
var left = Input.is_action_pressed("player_left")
|
var left = Input.is_action_pressed("player_left")
|
||||||
var right = Input.is_action_pressed("player_right")
|
var right = Input.is_action_pressed("player_right")
|
||||||
|
|
||||||
if left and right:
|
if left and right:
|
||||||
input_direction = 0
|
input_direction = 0
|
||||||
elif left:
|
elif left:
|
||||||
|
@ -23,18 +26,16 @@ func get_input(delta):
|
||||||
input_direction = 1
|
input_direction = 1
|
||||||
else:
|
else:
|
||||||
input_direction = 0
|
input_direction = 0
|
||||||
|
|
||||||
# This line updates the player's velocity
|
|
||||||
velocity.x = input_direction * speed
|
velocity.x = input_direction * speed
|
||||||
|
|
||||||
if is_on_floor():
|
if is_on_floor():
|
||||||
# reset the jump count
|
|
||||||
is_touching_floor = true
|
is_touching_floor = true
|
||||||
jump_count = 1
|
jump_count = 1
|
||||||
coyote_timer = 0.2
|
coyote_timer = 0.2
|
||||||
if jump_buffer_timer > 0:
|
if jump_buffer_timer > 0:
|
||||||
Jump()
|
Jump()
|
||||||
|
|
||||||
if not is_on_floor():
|
if not is_on_floor():
|
||||||
if jump_buffer_timer > 0:
|
if jump_buffer_timer > 0:
|
||||||
jump_buffer_timer -= delta
|
jump_buffer_timer -= delta
|
||||||
|
@ -42,43 +43,44 @@ func get_input(delta):
|
||||||
coyote_timer -= delta
|
coyote_timer -= delta
|
||||||
else:
|
else:
|
||||||
jump_count = 0
|
jump_count = 0
|
||||||
|
|
||||||
if Input.is_action_just_pressed("player_jump"):
|
if Input.is_action_just_pressed("player_jump"):
|
||||||
if jump_count > 0:
|
if jump_count > 0:
|
||||||
Jump()
|
Jump()
|
||||||
else:
|
else:
|
||||||
jump_buffer_timer = 0.2 # set a timer to jump again once the player has reached the ground, provided the jump is is still being held down
|
jump_buffer_timer = 0.2
|
||||||
elif Input.is_action_pressed("player_jump"): #Fall less fast if we keep holding the button
|
elif Input.is_action_pressed("player_jump"):
|
||||||
velocity.y += -1 * 25
|
velocity.y += -1 * 25
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
get_input(delta)
|
get_input(delta)
|
||||||
velocity.y += gravity
|
velocity.y += gravity
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
update_data_link()
|
||||||
if(get_slide_collision_count() > 0):
|
|
||||||
for i in get_slide_collision_count():
|
|
||||||
var box = get_slide_collision(i).get_collider() as Box
|
|
||||||
if scale.x == 2:
|
|
||||||
if box and velocity.y >= 0:
|
|
||||||
box.velocity.x = velocity.x*0.8
|
|
||||||
else:
|
|
||||||
if box and velocity.y >= 0 and box.scale.x < 2:
|
|
||||||
box.velocity.x = velocity.x*0.8
|
|
||||||
# print(jump_count) # Uncomment for debugging
|
|
||||||
|
|
||||||
func Jump():
|
func Jump():
|
||||||
if scale.x == 1:
|
velocity.y = -1 * jump_strength
|
||||||
velocity.y = -1 * jump_strength
|
|
||||||
elif scale.x == 2:
|
|
||||||
velocity.y = -1 * jump_strength_max
|
|
||||||
jump_count = 0
|
jump_count = 0
|
||||||
is_touching_floor = false
|
is_touching_floor = false
|
||||||
|
|
||||||
|
|
||||||
func _on_hurtbox_body_entered(body: Node2D) -> void:
|
func _on_hurtbox_body_entered(body: Node2D) -> void:
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
|
func update_data_link():
|
||||||
|
var nearest_block = find_nearest_block()
|
||||||
|
if nearest_block:
|
||||||
|
data_link.visible = true
|
||||||
|
data_link.set_point_position(0, Vector2.ZERO)
|
||||||
|
data_link.set_point_position(1, get_transform().affine_inverse() * nearest_block.position)
|
||||||
|
else:
|
||||||
|
data_link.visible = false
|
||||||
|
|
||||||
func _on_area_2d_body_entered(body):
|
func find_nearest_block() -> Node2D:
|
||||||
print("Body entered")
|
var closest_distance = max_link_distance
|
||||||
|
var closest_block: Node2D = null
|
||||||
|
for block in get_tree().get_nodes_in_group("scalable_blocks"):
|
||||||
|
var distance = global_position.distance_to(block.global_position)
|
||||||
|
if distance <= closest_distance:
|
||||||
|
closest_distance = distance
|
||||||
|
closest_block = block
|
||||||
|
return closest_block
|
||||||
|
|
|
@ -6,18 +6,19 @@ extends StaticBody2D
|
||||||
@export var ui_actions: Node
|
@export var ui_actions: Node
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
add_to_group("scalable_blocks")
|
||||||
if ui_actions == null:
|
if ui_actions == null:
|
||||||
ui_actions = get_parent().get_node("Path/To/UiActionsNode")
|
ui_actions = get_parent().get_node("UILayer/UI")
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
#func _on_input_event(viewport, event, shape_idx):
|
||||||
if event is InputEventMouseButton and event.pressed:
|
#if event is InputEventMouseButton and event.pressed:
|
||||||
if event.is_action_pressed("click"):
|
#if event.is_action_pressed("click"):
|
||||||
if ui_actions.current_selected == "scale_up":
|
#if ui_actions.current_selected == "scale_up":
|
||||||
scale_up()
|
#scale_up()
|
||||||
ui_actions.scale_up_player()
|
#ui_actions.scale_up_player()
|
||||||
elif ui_actions.current_selected == "scale_down":
|
#elif ui_actions.current_selected == "scale_down":
|
||||||
scale_down()
|
#scale_down()
|
||||||
ui_actions.scale_down_player()
|
#ui_actions.scale_down_player()
|
||||||
|
|
||||||
func scale_up():
|
func scale_up():
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export var player: CharacterBody2D
|
@export var player : CharacterBody2D
|
||||||
|
@export var scale_duration: float = 0.5
|
||||||
var current_selected = "none"
|
var current_selected = "none"
|
||||||
@export var scale_duration: float = 0.5
|
|
||||||
var target_scale_player: Vector2 = Vector2(1, 1)
|
|
||||||
var target_scale_block: Vector2 = Vector2(1, 1)
|
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("click"):
|
if event.is_action_pressed("click"):
|
||||||
if current_selected == "scale_up":
|
var nearest_block = player.find_nearest_block()
|
||||||
current_selected = "scale_up"
|
if nearest_block and current_selected == "scale_up":
|
||||||
elif current_selected == "scale_down":
|
nearest_block.scale_up()
|
||||||
current_selected = "scale_down"
|
scale_up_player()
|
||||||
elif current_selected == "mirror":
|
elif nearest_block and current_selected == "scale_down":
|
||||||
mirror()
|
nearest_block.scale_down()
|
||||||
|
scale_down_player()
|
||||||
|
|
||||||
func select_up():
|
func select_up():
|
||||||
current_selected = "scale_up"
|
current_selected = "scale_up"
|
||||||
|
@ -30,12 +28,12 @@ func start_scaling(target_node: Node2D, scale_value: Vector2):
|
||||||
tween.tween_property(target_node, "scale", scale_value, scale_duration)
|
tween.tween_property(target_node, "scale", scale_value, scale_duration)
|
||||||
|
|
||||||
func scale_up_player():
|
func scale_up_player():
|
||||||
target_scale_player = Vector2(0.5, 0.5)
|
player.target_scale = Vector2(2.0, 2.0)
|
||||||
start_scaling(player, target_scale_player)
|
player.start_scaling()
|
||||||
|
|
||||||
func scale_down_player():
|
func scale_down_player():
|
||||||
target_scale_player = Vector2(2.0, 2.0)
|
player.target_scale = Vector2(0.5, 0.5)
|
||||||
start_scaling(player, target_scale_player)
|
player.start_scaling()
|
||||||
|
|
||||||
func mirror():
|
func mirror():
|
||||||
pass # Mirror-Funktionalität hier einfügen
|
pass # Mirror-Funktionalität hier einfügen
|
||||||
|
|
BIN
gmtk_2024/textures/Eye Lase.png
Normal file
BIN
gmtk_2024/textures/Eye Lase.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 B |
Binary file not shown.
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 7.3 KiB |
BIN
gmtk_2024/textures/Modifi Blocks-Sheet.png
Normal file
BIN
gmtk_2024/textures/Modifi Blocks-Sheet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1,012 B |
Binary file not shown.
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 4 KiB |
Loading…
Add table
Reference in a new issue