0 votes

extends KinematicBody2D

var vel = Vector2()
var ACCELLERATION = 500
var SPEED = 80
var FRICTION = 500
var GRAVITY = 100
var JUMPFORCE = 200

enum{
IDLE,
MOVE,
ATTACK
}

var state = IDLE

func physicsprocess(delta):
match state:
MOVE:
attack()
applygarvity()
move(delta)
jump()
IDLE:
move(delta)
attack()
apply
gravity()
jump()

    ATTACK:
        move(delta)
        apply_garvity()
        jump()  
vel = move_and_slide(vel)

func move(delta):
var inputvector = Vector2()
input
vector.x = Input.getactionstrength("playerright") - Input.getactionstrength("playerleft")
input_vector.normalized()

if vel != input_vector:
    state = MOVE
    $AnimatedSprite.play("Walk")
    vel = vel.move_toward(input_vector * SPEED, ACCELLERATION * delta)

else:
    state = IDLE
    $AnimatedSprite.play("Idle")
    vel = vel.move_toward(Vector2.ZERO, FRICTION * delta)

if vel.x > 0:
    $AnimatedSprite.flip_h = true

else:
    $AnimatedSprite.flip_h = false

func jump():
$AnimatedSprite.play("Jump")
if Input.isactionpressed("player_up"):
vel.y = -JUMPFORCE

func attack():
state = ATTACK

func apply_gravity():
vel.y += GRAVITY

in Engine by (12 points)

Hi! Sorry, what is the question? And could you use the code block to paste code? (it is the button with curly braces in the editor).

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.