player script to proper folder
This commit is contained in:
1 parent
ccdc54f587
commit
20f76abae2
3 files changed
+1
-1
No files matched your search
@@ -1,35 +0,0 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
const SPEED = 300.0
|
||||
const JUMP_VELOCITY = -400.0
|
||||
|
||||
@export var BUMP_POWER = 100
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var direction := Input.get_axis("ui_left", "ui_right")
|
||||
if direction:
|
||||
velocity.x = direction * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
# handle world reactions
|
||||
for i in get_slide_collision_count():
|
||||
var c = get_slide_collision(i)
|
||||
if c.get_collider() is RigidBody2D:
|
||||
c.get_collider().apply_central_impulse(-c.get_normal()*BUMP_POWER)
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
uid://bpcy1rfota5tu
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://b1yy0sybg66hh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpcy1rfota5tu" path="res://scenes/player.gd" id="1_3vyb7"]
|
||||
[ext_resource type="Script" uid="uid://bpcy1rfota5tu" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_3vyb7"]
|
||||
|
||||
|
||||
Reference in new issue
Block a user