Files
godot/Scripts/Game.gd
T
2024-08-27 23:59:08 +02:00

32 lines
920 B
GDScript

extends Node
var game_id: String = "66cdb65deb38979bdfa8098a"
var containerScene
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var http_request = HTTPRequest.new()
add_child(http_request)
http_request.request_completed.connect(self.draw_game)
containerScene = preload("res://Objects/CardContainer.tscn")
var error = http_request.request("http://localhost:8765/api/games/" + game_id)
if error != OK:
push_error("An error occurred in the HTTP request.")
func draw_game(_result, _response_code, _headers, body):
var json = JSON.new()
json.parse(body.get_string_from_utf8())
var response = json.get_data()
# print(response)
var container = containerScene.instantiate()
container.cards = response.market.cards
self.add_child(container)
# Called every frame. 'delta' is the elapsed time since the previous frame.
# func _process(delta: float) -> void:
# pass