develop #30
@ -1,11 +1,15 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
export var enabled: bool = false
|
||||||
export var development_url: String = "http://localhost:4050/api/v1"
|
export var development_url: String = "http://localhost:4050/api/v1"
|
||||||
var url_real: String = "https://alai.cromer.cl/api/v1"
|
var url_real: String = "https://alai.cromer.cl/api/v1"
|
||||||
export var use_development_url: bool = false
|
export var use_development_url: bool = false
|
||||||
onready var url: String = development_url if use_development_url else url_real
|
onready var url: String = development_url if use_development_url else url_real
|
||||||
|
|
||||||
|
var start_time: int = 0
|
||||||
|
var started: bool = false
|
||||||
|
|
||||||
var player: Dictionary = {}
|
var player: Dictionary = {}
|
||||||
var level_id: int = 2 # PrototypeR
|
var level_id: int = 2 # PrototypeR
|
||||||
var os_id: int = 0
|
var os_id: int = 0
|
||||||
@ -23,7 +27,6 @@ var frames: Array = []
|
|||||||
|
|
||||||
var coins: int = 0
|
var coins: int = 0
|
||||||
var points: int = 0
|
var points: int = 0
|
||||||
onready var start_time: int = OS.get_ticks_msec()
|
|
||||||
var objects: Array = []
|
var objects: Array = []
|
||||||
|
|
||||||
const empty_object: Dictionary = {
|
const empty_object: Dictionary = {
|
||||||
@ -96,32 +99,45 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
var frame = empty_frame.duplicate(true)
|
if enabled and started:
|
||||||
frame["coins"] = coins
|
var frame = empty_frame.duplicate(true)
|
||||||
frame["points"] = points
|
frame["coins"] = coins
|
||||||
frame["fps"] = Engine.get_frames_per_second()
|
frame["points"] = points
|
||||||
frame["elapsed_time"] = OS.get_ticks_msec() - start_time
|
frame["fps"] = Engine.get_frames_per_second()
|
||||||
|
frame["elapsed_time"] = OS.get_ticks_msec() - start_time
|
||||||
|
|
||||||
var frame_objects = objects.duplicate()
|
var frame_objects = objects.duplicate()
|
||||||
frame["objects"] = frame_objects
|
frame["objects"] = frame_objects
|
||||||
|
|
||||||
frames.append(frame)
|
frames.append(frame)
|
||||||
|
|
||||||
if Input.is_action_just_pressed("Send"):
|
if Input.is_action_just_pressed("Send"):
|
||||||
send_data()
|
send_data()
|
||||||
|
|
||||||
|
|
||||||
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
||||||
add_object(name, state, position, velocity)
|
if enabled and started:
|
||||||
|
add_object(name, state, position, velocity)
|
||||||
|
|
||||||
|
|
||||||
func _object_updated(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
func _object_updated(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
||||||
remove_object(name)
|
if enabled and started:
|
||||||
add_object(name, state, position, velocity)
|
remove_object(name)
|
||||||
|
add_object(name, state, position, velocity)
|
||||||
|
|
||||||
|
|
||||||
func _object_removed(name: String) -> void:
|
func _object_removed(name: String) -> void:
|
||||||
remove_object(name)
|
if enabled and started:
|
||||||
|
remove_object(name)
|
||||||
|
|
||||||
|
|
||||||
|
func start_monitor() -> void:
|
||||||
|
start_time = OS.get_ticks_msec()
|
||||||
|
started = true
|
||||||
|
|
||||||
|
|
||||||
|
func stop_monitor() -> void:
|
||||||
|
started = false
|
||||||
|
|
||||||
|
|
||||||
func add_object(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
func add_object(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
||||||
|
Loading…
Reference in New Issue
Block a user