flappy-bird/Player.gd
2020-01-14 22:20:17 +01:00

31 lines
624 B
GDScript

extends Area2D
export var speed = 1 # How fast the player will move (pixels/sec).
export var jump_speed = 10
signal move
var screen_size
var speed_y = 0
func start():
position = screen_size / 2
# Called when the node enters the scene tree for the first time.
func _ready():
screen_size = get_viewport_rect().size
func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
print("HERE")
speed_y = min(speed_y, 0) - 1 * jump_speed
speed_y += 1
position.x += 1
position.y += speed_y * speed
emit_signal("move")
# TODO find the correct rotation, noob
rotation = atan(speed_y / speed) + PI / 2