move code into the start monitor function instead of setting it during initialization

This commit is contained in:
Chris Cromer 2022-07-07 13:01:47 -04:00 committed by Gitea
parent cf20410bc8
commit 298298359b
2 changed files with 24 additions and 17 deletions

View File

@ -9,3 +9,4 @@ script = ExtResource( 1 )
level = ExtResource( 2 ) level = ExtResource( 2 )
[node name="Monitor" parent="." instance=ExtResource( 3 )] [node name="Monitor" parent="." instance=ExtResource( 3 )]
enabled = true

View File

@ -11,7 +11,6 @@ var start_time: int = 0
var started: bool = false var started: bool = false
var player: Dictionary = {} var player: Dictionary = {}
var level_id: int = 2 # PrototypeR
var os_id: int = 0 var os_id: int = 0
var godot_version: Dictionary = Engine.get_version_info() var godot_version: Dictionary = Engine.get_version_info()
var processor_count: int = OS.get_processor_count() var processor_count: int = OS.get_processor_count()
@ -21,8 +20,6 @@ var screen_size: Vector2 = OS.get_screen_size()
var machine_id: String = OS.get_unique_id() var machine_id: String = OS.get_unique_id()
var locale: String = OS.get_locale() var locale: String = OS.get_locale()
var game_version: String var game_version: String
var won: bool = false
var timestamp: int = OS.get_unix_time()
var frames: Array = [] var frames: Array = []
var coins: int = 0 var coins: int = 0
@ -79,7 +76,7 @@ func _ready() -> void:
player["rut"] = clean_rut(player["rut"]) player["rut"] = clean_rut(player["rut"])
game["player"] = player game["player"] = player
game["level_id"] = level_id game["level_id"] = 0
game["os_id"] = os_id game["os_id"] = os_id
game["godot_version"] = godot_version game["godot_version"] = godot_version
game["processor_count"] = processor_count game["processor_count"] = processor_count
@ -89,8 +86,8 @@ func _ready() -> void:
game["screen_dpi"] = screen_dpi game["screen_dpi"] = screen_dpi
game["screen_size"] = screen_size game["screen_size"] = screen_size
game["game_version"] = game_version game["game_version"] = game_version
game["won"] = won game["won"] = false
game["timestamp"] = timestamp game["timestamp"] = OS.get_unix_time()
game["frames"] = frames game["frames"] = frames
var err = $HTTPRequest.connect("request_completed", self, "_on_request_completed") var err = $HTTPRequest.connect("request_completed", self, "_on_request_completed")
@ -99,7 +96,8 @@ func _ready() -> void:
func _physics_process(_delta: float) -> void: func _physics_process(_delta: float) -> void:
if enabled and started: if enabled:
if started:
var frame = empty_frame.duplicate(true) var frame = empty_frame.duplicate(true)
frame["coins"] = coins frame["coins"] = coins
frame["points"] = points frame["points"] = points
@ -112,7 +110,11 @@ func _physics_process(_delta: float) -> void:
frames.append(frame) frames.append(frame)
if Input.is_action_just_pressed("Send"): if Input.is_action_just_pressed("Send"):
stop_monitor()
send_data() send_data()
else:
if Input.is_action_just_pressed("Send"):
start_monitor()
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void: func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
@ -132,6 +134,10 @@ func _object_removed(name: String) -> void:
func start_monitor() -> void: func start_monitor() -> void:
frames.clear()
game["level_id"] = 2 # PrototypeR
game["won"] = false
game["timestamp"] = OS.get_unix_time()
start_time = OS.get_ticks_msec() start_time = OS.get_ticks_msec()
started = true started = true