RingOfRaces/KinematicBody2D.gd

44 lines
1.2 KiB
GDScript3
Raw Normal View History

2020-08-29 14:36:49 +00:00
extends KinematicBody2D
const GRAVITY = 0.0
const WALK_SPEED = 200
2020-09-24 19:34:34 +00:00
const interaction_circle_size = 150
onready var background_map = get_node("/root/Map1/background")
onready var player = get_node("/root/Map1/Player")
onready var cell_size = background_map._get_cell_size()
2020-08-29 14:36:49 +00:00
var velocity = Vector2()
2020-09-24 19:34:34 +00:00
#Moving buttons
2020-08-29 14:36:49 +00:00
func _physics_process(delta):
velocity.y += delta * GRAVITY
if Input.is_action_pressed("move_left"):
2020-08-29 14:36:49 +00:00
velocity.x = -WALK_SPEED
elif Input.is_action_pressed("move_right"):
2020-08-29 14:36:49 +00:00
velocity.x = WALK_SPEED
elif Input.is_action_pressed("move_up"):
2020-08-29 14:36:49 +00:00
velocity.y = -WALK_SPEED
elif Input.is_action_pressed("move_down"):
2020-08-29 14:36:49 +00:00
velocity.y = WALK_SPEED
2020-09-24 19:34:34 +00:00
# elif Input.is_action_pressed("map_interaction"):
# print("Interacted")
# print(InputEventMouseButton.position)
2020-08-29 14:36:49 +00:00
else:
velocity.x = 0
velocity.y = 0
2020-08-29 14:36:49 +00:00
move_and_slide(velocity, Vector2(0, -1))
2020-09-21 21:13:11 +00:00
2020-09-24 19:34:34 +00:00
func _input(event):
# Mouse in viewport coordinates.
if event is InputEventMouseButton:
var pos = event.position
if Input.is_action_pressed("map_interaction"):
pass
# elif event is InputEventMouseMotion:
# print("Mouse Motion at: ", event.position)
#
# # Print the size of the viewport.
# print("Viewport Resolution is: ", get_viewport_rect().size)