Merge branch 'dev' into Rycarus_Menu

This commit is contained in:
Fabio 2024-08-17 20:45:51 +02:00
commit 0d58464b3e
18 changed files with 245 additions and 36 deletions

View file

@ -2,8 +2,7 @@ extends CharacterBody2D
@export var speed = 200;
@export var gravity = 50;
var direction = 1;
@export var direction = 1;
func _physics_process(delta):

15
gmtk_2024/scripts/goal.gd Normal file
View file

@ -0,0 +1,15 @@
extends Node
@export var next : PackedScene
@export var img : Sprite2D
@export var img2 : Sprite2D
func _process(delta: float) -> void:
img.rotate(2 * delta)
img2.rotate(1 * delta)
func _on_body_entered(body: Node2D) -> void:
get_tree().change_scene_to_packed(next)

View file

@ -1,41 +1,66 @@
extends CharacterBody2D
@export var speed = 340;
@export var gravity = 50;
@export var jump_count = 2;
@export var speed = 340
@export var gravity = 50
var jump_count = 1
@export var jump_strength = 100
var jump_count_current = 2;
var is_touching_floor : bool = true
var jump_buffer_timer : float
var coyote_timer : float = 0.2 # 200 millisecond buffer
var input_direction = 0 #To keep track of which direction we where moving in last frame
func get_input():
func get_input(delta):
var left = Input.is_action_pressed("player_left")
var right = Input.is_action_pressed("player_right")
if left and right:
input_direction = input_direction
input_direction = 0
elif left:
input_direction = -1
elif right:
input_direction = 1
else :
else:
input_direction = 0
# This line updates the player's velocity
velocity.x = input_direction * speed
if is_on_floor(): # rest the jump count
jump_count_current = jump_count
if is_on_floor():
# reset the jump count
is_touching_floor = true
jump_count = 1
coyote_timer = 0.2
if jump_buffer_timer > 0:
Jump()
if Input.is_action_just_pressed("player_jump") and jump_count_current > 0:
velocity.y = -1 * jump_strength
jump_count_current = jump_count_current-1
elif Input.is_action_pressed("player_jump"): #Fall less fast if we keep holding the button
if not is_on_floor():
if jump_buffer_timer > 0:
jump_buffer_timer -= delta
if coyote_timer > 0.0:
coyote_timer -= delta
else:
jump_count = 0
if Input.is_action_just_pressed("player_jump"):
if jump_count > 0:
Jump()
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
elif Input.is_action_pressed("player_jump"): #Fall less fast if we keep holding the button
velocity.y += -1 * 25
func _physics_process(delta):
get_input()
get_input(delta)
velocity.y += gravity
move_and_slide()
# print(jump_count) # Uncomment for debugging
func Jump():
velocity.y = -1 * jump_strength
jump_count = 0
is_touching_floor = false
func _on_hurtbox_body_entered(body: Node2D) -> void:
get_tree().reload_current_scene()

View file

@ -0,0 +1,34 @@
extends Node
@export var player : CharacterBody2D;
var current_selected = "none";
func _process(delta: float) -> void:
if Input.is_action_just_pressed("click"):
if current_selected == "scale_up":
scale_up()
elif current_selected == "scale_down":
scale_down()
elif current_selected == "mirror":
mirror();
func select_up():
current_selected = "scale_up"
func select_down():
current_selected = "scale_down"
func select_mirror():
current_selected = "mirror"
func scale_up():
pass #Hir hochscalieren einbauen
func scale_down():
pass #Hir runterscalieren einbauen
func mirror():
pass #Hir mirror einbauen einbauen