Merge pull request 'Book_Movement' (#11) from Book_Movement into dev
Reviewed-on: https://code.booklordofthe.dev///Booklordofthedings/GMTK-2024/pulls/11
This commit is contained in:
commit
c7686e96ab
3 changed files with 17 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://o8wdfgnlp0ud"]
|
[gd_scene load_steps=6 format=3 uid="uid://o8wdfgnlp0ud"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" path="res://player.tscn" id="1_nvifn"]
|
[ext_resource type="PackedScene" uid="uid://cfnmiqovwwhry" path="res://player.tscn" id="1_nvifn"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cxbalfjqtp06t" path="res://canvas_layer.tscn" id="2_1gnwx"]
|
[ext_resource type="PackedScene" uid="uid://cxbalfjqtp06t" path="res://canvas_layer.tscn" id="2_1gnwx"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cyealb63c8uqg" path="res://temp_assets/background_commision.png" id="2_qherw"]
|
[ext_resource type="Texture2D" uid="uid://cyealb63c8uqg" path="res://temp_assets/background_commision.png" id="2_qherw"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bsu1bvlb0s8dp" path="res://temp_assets/Screenshot (1).png" id="3_es5ys"]
|
[ext_resource type="Texture2D" uid="uid://bsu1bvlb0s8dp" path="res://temp_assets/Screenshot (1).png" id="3_es5ys"]
|
||||||
|
|
|
@ -11,7 +11,6 @@ height = 32.0
|
||||||
|
|
||||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||||
script = ExtResource("1_otvu6")
|
script = ExtResource("1_otvu6")
|
||||||
speed = 340
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
|
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
|
||||||
texture = ExtResource("2_d4ig1")
|
texture = ExtResource("2_d4ig1")
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
@export var speed = 50
|
@export var speed = 340;
|
||||||
@export var gravity = 50
|
@export var gravity = 50;
|
||||||
@export var jump = 700
|
@export var jump_count = 2;
|
||||||
|
@export var jump_strength = 700;
|
||||||
|
|
||||||
var max_jumps = 2;
|
var jump_count_current = 2;
|
||||||
var jumpcount = 2;
|
var input_direction = 0 #To keep track of which direction we where moving in last frame
|
||||||
|
|
||||||
var input_direction = 0
|
|
||||||
|
|
||||||
func get_input():
|
func get_input():
|
||||||
|
|
||||||
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 = input_direction
|
input_direction = input_direction
|
||||||
elif left:
|
elif left:
|
||||||
|
@ -21,17 +22,18 @@ func get_input():
|
||||||
else :
|
else :
|
||||||
input_direction = 0
|
input_direction = 0
|
||||||
|
|
||||||
|
|
||||||
velocity.x = input_direction * speed
|
velocity.x = input_direction * speed
|
||||||
if Input.is_action_just_pressed("player_jump") and jumpcount > 0:
|
|
||||||
velocity.y = -1 *jump
|
if Input.is_action_just_pressed("player_jump") and jump_count_current > 0:
|
||||||
jumpcount = jumpcount-1
|
velocity.y = -1 * jump_strength
|
||||||
elif Input.is_action_pressed("player_jump"):
|
jump_count_current = jump_count_current-1
|
||||||
|
elif Input.is_action_pressed("player_jump"): #Fall less fast if we keep holding the button
|
||||||
velocity.y += -1 * 20
|
velocity.y += -1 * 20
|
||||||
|
|
||||||
|
if is_on_floor():
|
||||||
|
jump_count_current = jump_count
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if is_on_floor():
|
|
||||||
jumpcount = max_jumps
|
|
||||||
get_input()
|
get_input()
|
||||||
velocity.y += gravity
|
velocity.y += gravity
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
Loading…
Add table
Reference in a new issue