Skip to content

Instantly share code, notes, and snippets.

@pdaug
Created July 13, 2022 13:46
Show Gist options
  • Save pdaug/1aec0cba1e2b07fdd90c55a13d798ffc to your computer and use it in GitHub Desktop.
Save pdaug/1aec0cba1e2b07fdd90c55a13d798ffc to your computer and use it in GitHub Desktop.
extends KinematicBody2D
var velocidade = 200
var pulo = 500
var gravidade = 20
var movimento = Vector2()
func _physics_process(_delta):
movimento.y += gravidade
if Input.is_action_pressed("ui_left"):
movimento.x = -velocidade
elif Input.is_action_pressed("ui_right"):
movimento.x = velocidade
else:
movimento.x = 0
if Input.is_action_just_pressed("ui_up") and is_on_floor():
movimento.y = -pulo
movimento = move_and_slide(movimento, Vector2.UP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment