2017-06-26 01:40:04 +02:00
|
|
|
extends Area2D
|
|
|
|
export var ball_dir=1
|
|
|
|
|
|
|
|
const MOVE_SPEED=100
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
|
|
|
|
var which = get_name()
|
|
|
|
|
|
|
|
# move up and down based on input
|
|
|
|
if (Input.is_action_pressed(which+"_move_up") and position.y > 0):
|
|
|
|
position.y -= MOVE_SPEED * delta
|
2017-07-01 12:29:03 +02:00
|
|
|
if (Input.is_action_pressed(which+"_move_down") and position.y < get_viewport_rect().size.y):
|
2017-06-26 01:40:04 +02:00
|
|
|
position.y += MOVE_SPEED * delta
|
|
|
|
|
|
|
|
|
|
|
|
func _on_area_entered( area ):
|
|
|
|
if area.get_name() == "ball":
|
|
|
|
# assign new direction
|
|
|
|
area.direction = Vector2(ball_dir,randf() * 2 - 1).normalized()
|