-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
391 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
extends CharacterBody2D | ||
|
||
|
||
@export var fetch_url: String = "https://via.placeholder.com/100" | ||
|
||
func _ready(): | ||
position = position.snapped(Vector2.ONE * 100) | ||
position += Vector2.ONE * 100 / 2 | ||
# Create an HTTP request node and connect its completion signal. | ||
var http_request = HTTPRequest.new() | ||
add_child(http_request) | ||
http_request.request_completed.connect(self._http_request_completed) | ||
|
||
# Perform the HTTP request. The URL below returns a PNG image as of writing. | ||
var error = http_request.request(fetch_url) | ||
if error != OK: | ||
push_error("An error occurred in the HTTP request.") | ||
|
||
# Called when the HTTP request is completed. | ||
func _http_request_completed(result, response_code, headers, body): | ||
if result != HTTPRequest.RESULT_SUCCESS: | ||
push_error("Image couldn't be downloaded. Try a different image.") | ||
|
||
var image = Image.new() | ||
var error = image.load_png_from_buffer(body) | ||
if error != OK: | ||
push_error("Couldn't load the image.") | ||
|
||
var texture = ImageTexture.create_from_image(image) | ||
|
||
# Display the image in a TextureRect node. | ||
var texture_rect = TextureRect.new() | ||
add_child(texture_rect) | ||
texture_rect.texture = texture | ||
texture_rect.position = Vector2(0.5,0.5)*100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://cv6rvnsd8jc4u"] | ||
[gd_scene load_steps=3 format=3 uid="uid://cv6rvnsd8jc4u"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://c6jm42o02gsfr" path="res://assets/box.png" id="1_blfj8"] | ||
[ext_resource type="Script" path="res://scenes/box/box.gd" id="1_so5sa"] | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pwdsl"] | ||
size = Vector2(100, 100) | ||
|
||
[node name="CharacterBody2D" type="CharacterBody2D"] | ||
script = ExtResource("1_so5sa") | ||
|
||
[node name="Box" type="Sprite2D" parent="."] | ||
position = Vector2(33, 52) | ||
texture = ExtResource("1_blfj8") | ||
|
||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] | ||
visible = false | ||
position = Vector2(36, 52) | ||
polygon = PackedVector2Array(16, -124.8, 16, -122.9, 29, -111.9, 29, -109.4, 40.2, -85, 41.1, -85, 51, -69.6, 51, -59, 48.7, -59, 47, -57.9, 47, -57, 49.1, -24, 47.8, -24, 45.8, -8, 45, -8, 45, -4, 43, -4, 36, 5, 33.2, 5, 12, 7.2, 12, 5.89999, -13, 4.10001, -13, 4.89999, -80, 8.10001, -80, 6.10001, -93, -1.89999, -93, -4.60001, -95.4, -11, -98.1, -11, -102.1, -17, -105.2, -17, -115, -19.4, -115, -21.3, -122, -31, -123.6, -31, -149, -46.9, -149, -54, -150, -91, -150, -128, -148.6, -128, -137.6, -135, -127.2, -135, -120, -135.8, -120, -137.2) | ||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource("RectangleShape2D_pwdsl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://2t2nbl4hrw8b"] | ||
[gd_scene load_steps=5 format=3 uid="uid://2t2nbl4hrw8b"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://xqoiyxrn10js" path="res://scenes/player_character/player_character.tscn" id="1_1c02b"] | ||
[ext_resource type="Script" path="res://scenes/main/main.gd" id="1_47q2m"] | ||
[ext_resource type="PackedScene" uid="uid://cv6rvnsd8jc4u" path="res://scenes/box/box.tscn" id="3_2p8op"] | ||
[ext_resource type="Script" path="res://WebSockets.gd" id="3_uxet7"] | ||
|
||
[node name="GameLevel" type="Node2D"] | ||
script = ExtResource("1_47q2m") | ||
|
||
[node name="PlayerCharacter" parent="." instance=ExtResource("1_1c02b")] | ||
position = Vector2(577, 325) | ||
scale = Vector2(2.9, 2.9) | ||
|
||
[node name="WebSocketClient" type="Node" parent="."] | ||
script = ExtResource("3_uxet7") | ||
|
||
[node name="CharacterBody2D" parent="." instance=ExtResource("3_2p8op")] | ||
position = Vector2(256, 168) | ||
|
||
[node name="OtherObjects" type="Node2D" parent="."] |
Oops, something went wrong.