Jam10/Scripts/PlayerRecorder.gd

26 lines
494 B
GDScript3
Raw Normal View History

2023-01-30 08:56:47 +00:00
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