28 lines
883 B
GDScript
Executable file
28 lines
883 B
GDScript
Executable file
extends Node2D
|
|
|
|
class_name Map
|
|
|
|
var ship_direction = 0
|
|
var ship_speed = 1000
|
|
|
|
var current_ship_direction = 0
|
|
var current_ship_speed = 0
|
|
|
|
const SPEED_EASE = 0.5
|
|
const DIRECTION_EASE = 0.5
|
|
const EPSILON = 0.01
|
|
|
|
export(NodePath) var tilemap_path
|
|
onready var tilemap = get_node(tilemap_path) as MapTiles
|
|
|
|
func _process(delta):
|
|
if abs(ship_direction - current_ship_direction) < EPSILON:
|
|
current_ship_direction = ship_direction
|
|
else:
|
|
current_ship_direction = lerp(current_ship_direction, ship_direction, delta * DIRECTION_EASE)
|
|
if abs(ship_speed - current_ship_speed) < EPSILON:
|
|
current_ship_speed = ship_speed
|
|
else:
|
|
current_ship_speed = lerp(current_ship_speed, ship_speed, delta * SPEED_EASE)
|
|
$deepspace.rotation = current_ship_direction-PI/2
|
|
$deepspace.region_rect.position += Vector2(sin(current_ship_direction), cos(current_ship_direction)) * current_ship_speed * delta
|