![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | toxcm 22 |
extends KinematicBody2D
const gravity=200
var PlayerName=“tobi”
var hp=100
var denage=16.5
var velocity=Vector2()
var speed=100
onready var animatedSprite=$AnimatedSprite
func _ready():
pass
func _process(_delta):
animation()
func _physics_process(delta):
move(delta)
move_and_slide(velocity, Vector2(0, -1))
func move(_delta):
velocity.x=0
if(Input.is_action_pressed("Left")):
velocity.x -=speed
if(Input.is_action_pressed("Right")):
velocity.x +=speed
if(!is_on_floor()):
velocity.y += gravity
elif(Input.is_action_pressed("up")):
velocity.y = -200
func animation():
if(velocity.x < 0):
animatedSprite.animation="MoveRight"
animatedSprite.flip_h=true
if(velocity.x > 0):
animatedSprite.animation="MoveRight"
animatedSprite.flip_h=false
if(velocity.x ==0):
animatedSprite.animation="Idle"
if(velocity.y > 0):
animatedSprite.animation = "Fall"
if (velocity.y < 0):
animatedSprite.animation = "Jump"
func danage():
pass
func attack():
pass