From 70f2ae010a6d32268fdd89a1cbc7ecc7e4416c2b Mon Sep 17 00:00:00 2001 From: EljakimHerrewijnen Date: Sat, 3 Oct 2020 19:01:48 +0200 Subject: [PATCH] Started Inventory screen --- Scenes/Inventory.gd | 28 ++++++++++++++++++++++++++ Scenes/Inventory.tscn | 34 +++++++++++++++++++++++++++++++ Scenes/Inventory_Script.gd | 41 ++++++++++++++++++++++++++++++++++++++ Scenes/TextureRect2.gd | 41 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 Scenes/Inventory.gd create mode 100644 Scenes/Inventory.tscn create mode 100644 Scenes/Inventory_Script.gd create mode 100644 Scenes/TextureRect2.gd diff --git a/Scenes/Inventory.gd b/Scenes/Inventory.gd new file mode 100644 index 0000000..d748ee6 --- /dev/null +++ b/Scenes/Inventory.gd @@ -0,0 +1,28 @@ +extends Node2D + +#func _draw(): +# var center = Vector2(200, 200) +# var radius = 80 +# var angle_from = 75 +# var angle_to = 195 +# var color = Color(1.0, 0.0, 0.0) +# draw_circle_arc(center, radius, angle_from, angle_to, color) +# +#func draw_circle_arc(center, radius, angle_from, angle_to, color): +# var nb_points = 32 +# var points_arc = PoolVector2Array() +# +# for i in range(nb_points + 1): +# var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90) +# points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius) +# +# for index_point in range(nb_points): +# draw_line(points_arc[index_point], points_arc[index_point + 1], color) + +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Scenes/Inventory.tscn b/Scenes/Inventory.tscn new file mode 100644 index 0000000..c48d79b --- /dev/null +++ b/Scenes/Inventory.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://pictures/gui/backgrounds/inventory/inventory_background.png" type="Texture" id=1] +[ext_resource path="res://Scenes/Inventory_Script.gd" type="Script" id=2] +[ext_resource path="res://Scenes/Inventory.gd" type="Script" id=3] +[ext_resource path="res://Scenes/TextureRect2.gd" type="Script" id=4] + +[node name="Inventory" type="Node2D"] +z_index = 1 +script = ExtResource( 3 ) + +[node name="TextureRect" type="TextureRect" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="inventory_background" type="Sprite" parent="TextureRect"] +position = Vector2( 617.053, 299.964 ) +scale = Vector2( 3.08457, 1.99938 ) +z_index = -1 +texture = ExtResource( 1 ) +script = ExtResource( 2 ) + +[node name="TextureRect2" type="TextureRect" parent="TextureRect/inventory_background"] +margin_left = -200.045 +margin_top = -150.028 +margin_right = -160.045 +margin_bottom = -110.028 +script = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/Scenes/Inventory_Script.gd b/Scenes/Inventory_Script.gd new file mode 100644 index 0000000..bd02679 --- /dev/null +++ b/Scenes/Inventory_Script.gd @@ -0,0 +1,41 @@ +extends Sprite + +var items = [1,2,3] + +func draw_circle_arc(center, radius, angle_from, angle_to, color): + var nb_points = 32 + var points_arc = PoolVector2Array() + + for i in range(nb_points + 1): + var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90) + points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius) + + for index_point in range(nb_points): + draw_line(points_arc[index_point], points_arc[index_point + 1], color) + +func draw_circle_arc_poly(center, radius, angle_from, angle_to, color): + var nb_points = 32 + var points_arc = PoolVector2Array() + points_arc.push_back(center) + var colors = PoolColorArray([color]) + + for i in range(nb_points + 1): + var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90) + points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius) + draw_polygon(points_arc, colors) + +func _draw(): + var center = Vector2(200, 200) + var radius = 80 + var angle_from = 75 + var angle_to = 195 + var color = Color(1.0, 0.0, 0.0) + draw_circle_arc_poly(center, radius, angle_from, angle_to, color) + + +# Called when the node enters the scene tree for the first time. +func _ready(): + _draw() +# for x in range(len(items)): +# _draw() + pass # Replace with function body. diff --git a/Scenes/TextureRect2.gd b/Scenes/TextureRect2.gd new file mode 100644 index 0000000..0a6b2a5 --- /dev/null +++ b/Scenes/TextureRect2.gd @@ -0,0 +1,41 @@ +extends TextureRect + +var items = [1,2,3] + +func draw_circle_arc(center, radius, angle_from, angle_to, color): + var nb_points = 32 + var points_arc = PoolVector2Array() + + for i in range(nb_points + 1): + var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90) + points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius) + + for index_point in range(nb_points): + draw_line(points_arc[index_point], points_arc[index_point + 1], color) + +func draw_circle_arc_poly(center, radius, angle_from, angle_to, color): + var nb_points = 32 + var points_arc = PoolVector2Array() + points_arc.push_back(center) + var colors = PoolColorArray([color]) + + for i in range(nb_points + 1): + var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90) + points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius) + draw_polygon(points_arc, colors) + +func _draw(): + var center = Vector2(200, 200) + var radius = 80 + var angle_from = 75 + var angle_to = 195 + var color = Color(1.0, 0.0, 0.0) + draw_circle_arc_poly(center, radius, angle_from, angle_to, color) + + +# Called when the node enters the scene tree for the first time. +func _ready(): + _draw() +# for x in range(len(items)): +# _draw() + pass # Replace with function body.