Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends CharacterBody2D
- class_name Player
- signal player_died
- @export var speed = 1000
- @export var acceleration = 0.1
- @export var friction = 0.05
- var direction = Vector2()
- # TODO : Ajouter timer au jeu
- var bullet_speed = 1000
- var bullet = preload("res://Bullet.tscn")
- func _physics_process(_delta):
- direction.x = Input.get_action_strength("right") - Input.get_action_strength("left")
- direction.y = Input.get_action_strength("down") - Input.get_action_strength("up")
- direction = direction.normalized()
- #look_at(get_global_mouse_position())
- #if (Input.is_action_just_pressed("fire")):
- # fire()
- if (direction.length() > 0):
- velocity = velocity.lerp(direction * speed, acceleration)
- else :
- velocity = velocity.lerp(Vector2.ZERO, friction)
- move_and_slide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement