Compare commits
No commits in common. "92ab2b424885bac535e9c1b3347b1a98b3648499" and "2cdd7f876a89b73f418c7aef1a147c837732ae32" have entirely different histories.
92ab2b4248
...
2cdd7f876a
93
dem8633.tmp
93
dem8633.tmp
File diff suppressed because one or more lines are too long
@ -2,7 +2,8 @@ extends CharacterBody2D
|
|||||||
@onready var global = $"/root/Player"
|
@onready var global = $"/root/Player"
|
||||||
|
|
||||||
const SPEED = 350.0
|
const SPEED = 350.0
|
||||||
var charAngle = 0.0
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
global.emit_signal("playerPosition",self.global_position)
|
global.emit_signal("playerPosition",self.global_position)
|
||||||
movement()
|
movement()
|
||||||
@ -13,10 +14,6 @@ func animation():
|
|||||||
func movement():
|
func movement():
|
||||||
var vertical = Input.get_axis("up","down")
|
var vertical = Input.get_axis("up","down")
|
||||||
var horizontal = Input.get_axis("left","right")
|
var horizontal = Input.get_axis("left","right")
|
||||||
var rotVector = Vector2(vertical*-1,horizontal)
|
|
||||||
if rotVector != Vector2(0,0):
|
|
||||||
self.set_rotation(rotVector.angle())
|
|
||||||
#limiting diagonal speed
|
|
||||||
if is_equal_approx(abs(vertical),1.0) and is_equal_approx(abs(horizontal),1.0):
|
if is_equal_approx(abs(vertical),1.0) and is_equal_approx(abs(horizontal),1.0):
|
||||||
velocity.y = SPEED*vertical/2
|
velocity.y = SPEED*vertical/2
|
||||||
velocity.x = SPEED*horizontal/2
|
velocity.x = SPEED*horizontal/2
|
||||||
@ -24,4 +21,4 @@ func movement():
|
|||||||
velocity.y = SPEED * vertical
|
velocity.y = SPEED * vertical
|
||||||
velocity.x = SPEED * horizontal
|
velocity.x = SPEED * horizontal
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
$"../Camera2D/Label".text = (str(charAngle*180/PI))
|
$"../Camera2D/Label".text = (str(self.global_position))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user