Compare commits

..

No commits in common. "2dd7404263f18bc275478dc11cdfbad1f53b4ad0" and "ed854ba96bba0fe25174d73704b8ceb89a644615" have entirely different histories.

2 changed files with 8 additions and 32 deletions

View file

@ -17,8 +17,8 @@ config/icon="res://icon.svg"
[display]
window/size/viewport_width=320
window/size/viewport_height=240
window/size/viewport_width=480
window/size/viewport_height=320
window/stretch/mode="viewport"
window/stretch/scale_mode="integer"

View file

@ -1,42 +1,18 @@
extends CharacterBody2D
const MAX_SPEED: float = 150
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
var was_moving: bool = false
var anim_dir: String = 'down'
const MAX_SPEED: float = 200
func _ready() -> void:
sprite.play('down')
sprite.frame = 1
sprite.pause()
pass
func _physics_process(_delta: float) -> void:
func _process(delta: float) -> void:
var movement_vector: Vector2 = get_movement_vector()
var direction: Vector2 = movement_vector.normalized()
velocity = direction * MAX_SPEED
move_and_slide()
var is_moving: bool = velocity.length() > 10
if is_moving:
if abs(velocity.x) > abs(velocity.y):
anim_dir = 'right' if velocity.x > 0 else 'left'
else:
anim_dir = 'down' if velocity.y > 0 else 'up'
sprite.play(anim_dir)
else:
if was_moving:
sprite.play('down')
sprite.frame = 1
sprite.pause()
was_moving = is_moving
func get_movement_vector() -> Vector2:
var x_mov: float = Input.get_action_strength('move_right') - Input.get_action_strength('move_left')
var y_mov: float = Input.get_action_strength('move_down') - Input.get_action_strength('move_up')
var x_mov: float = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
var y_mov: float = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
return Vector2(x_mov, y_mov)