Basic infoscreen functionnality

This commit is contained in:
Victor Turgeon 2022-10-12 13:17:07 -04:00
parent 6469c6969f
commit 82932225d1
3 changed files with 58 additions and 4 deletions

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Materials/Dark_ProtoMat.tres" type="Material" id=1]
[ext_resource path="res://Scenes/InfoScreen.tscn" type="PackedScene" id=2]
[ext_resource path="res://Player.tscn" type="PackedScene" id=3]
[node name="Spatial" type="Spatial"]
@ -9,7 +10,7 @@
use_collision = true
[node name="Floor" type="CSGBox" parent="CSGCombiner"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -6 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, -6 )
snap = 1.0
width = 20.0
height = 6.0
@ -17,7 +18,7 @@ depth = 30.0
material = ExtResource( 1 )
[node name="FloorClear" type="CSGBox" parent="CSGCombiner"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7, -6 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 10, -6 )
operation = 2
width = 18.0
height = 19.0
@ -28,4 +29,7 @@ material = ExtResource( 1 )
transform = Transform( 0.707107, -0.353553, 0.612372, 0, 0.866025, 0.5, -0.707107, -0.353553, 0.612372, 7.99925, 6, 7.97141 )
[node name="Player" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.17456, 5 )
transform = Transform( 0.258819, 0, 0.965926, 0, 1, 0, -0.965926, 0, 0.258819, -3, 4.17456, 4 )
[node name="InfoScreen" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.67344, 0 )

24
Scenes/InfoScreen.gd Normal file
View File

@ -0,0 +1,24 @@
tool
extends Spatial
export(String, MULTILINE) var text = " " setget set_text_to_screen
export(Vector2) var offset = Vector2(1.0, 0.5) setget set_screen_offset
func set_screen_offset(new_offest):
offset = new_offest
set_text_to_screen(text)
func set_text_to_screen(new_text):
text = new_text
$ScreenText.text = text
var lines = text.split('\n',false)
var string_size: Vector2 = Vector2(0,0)
for line in lines:
if $ScreenText.font.get_string_size(line).x > string_size.x:
string_size = $ScreenText.font.get_string_size(line)
var pixel_size = $ScreenText.pixel_size
var number_of_line = text.split('\n',false).size()
$ScreenBackGround.scale = Vector3(string_size.x * pixel_size + offset.x,
string_size.y * pixel_size * number_of_line + offset.y,1);

26
Scenes/InfoScreen.tscn Normal file
View File

@ -0,0 +1,26 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Scenes/InfoScreen.gd" type="Script" id=1]
[ext_resource path="res://fonts/TorontoSubwayRegular.ttf" type="DynamicFontData" id=2]
[sub_resource type="DynamicFont" id=3]
size = 100
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 2 )
[sub_resource type="QuadMesh" id=2]
[node name="InfoScreen" type="Spatial"]
script = ExtResource( 1 )
[node name="ScreenText" type="Label3D" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.00113499 )
cast_shadow = 0
double_sided = false
modulate = Color( 0, 0, 0, 1 )
text = " "
font = SubResource( 3 )
[node name="ScreenBackGround" type="MeshInstance" parent="."]
transform = Transform( 1.3, 0, 0, 0, 1.66, 0, 0, 0, 1, 0, 0, 0 )
mesh = SubResource( 2 )