26 lines
494 B
GDScript
26 lines
494 B
GDScript
extends Node
|
|
class_name PlayerRecorder
|
|
|
|
var replay: ReplayRecording
|
|
var this_frame: bool = true
|
|
var sprite: int = 0
|
|
var player: DownhillAutoscrollerPlayer
|
|
|
|
export var save_to: String
|
|
|
|
func _ready():
|
|
replay = ReplayRecording.new()
|
|
replay.time_per_frame = 1.0 / 30.0
|
|
player = get_parent()
|
|
player.recorder = self
|
|
|
|
func _process(delta):
|
|
if this_frame:
|
|
this_frame = false
|
|
replay.positions.append(player.pos)
|
|
replay.sprites.append(sprite)
|
|
replay.frames += 1
|
|
|
|
else:
|
|
this_frame = true
|