Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
extends Node2D
|
||||
|
||||
var cards = []
|
||||
var width: float
|
||||
var cardScene
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
width = 500.0
|
||||
cardScene = preload("res://Objects/Card.tscn")
|
||||
draw_cards()
|
||||
|
||||
func draw_cards() -> void:
|
||||
if (cards.size() == 0):
|
||||
return
|
||||
var card_width = width / cards.size()
|
||||
for i in range(cards.size()):
|
||||
var c = cards[i]
|
||||
print(card_width)
|
||||
var card = cardScene.instantiate()
|
||||
card.position.x = card_width * i
|
||||
self.add_child(card)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# 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._http_request_completed)
|
||||
|
||||
self.request_completed.connect(self._http_request_completed)
|
||||
var error = http_request.request("http://localhost:8765/api/games")
|
||||
if error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
|
||||
func _http_request_completed(_result, _response_code, _headers, body):
|
||||
var json = JSON.new()
|
||||
json.parse(body.get_string_from_utf8())
|
||||
var response := json.get_data() as Array
|
||||
|
||||
print(response)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
# func _process(delta: float) -> void:
|
||||
# pass
|
||||
@@ -0,0 +1 @@
|
||||
class_name HeronContainer
|
||||
@@ -0,0 +1,3 @@
|
||||
class_name HeronTeam
|
||||
|
||||
var health: int
|
||||
Reference in New Issue
Block a user