Added game functions and bubble speech
This commit is contained in:
parent
8f3e13e532
commit
cc8c7ba477
BIN
GameScenes/speech_bubble/SpeachBubbleBoarder.png
Normal file
BIN
GameScenes/speech_bubble/SpeachBubbleBoarder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 159 B |
34
GameScenes/speech_bubble/SpeachBubbleBoarder.png.import
Normal file
34
GameScenes/speech_bubble/SpeachBubbleBoarder.png.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/SpeachBubbleBoarder.png-0786cb6596266c43c2897b48768509b4.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://GameScenes/speech_bubble/SpeachBubbleBoarder.png"
|
||||||
|
dest_files=[ "res://.import/SpeachBubbleBoarder.png-0786cb6596266c43c2897b48768509b4.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
44
GameScenes/speech_bubble/Speech.gd
Normal file
44
GameScenes/speech_bubble/Speech.gd
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#Thanks to: https://github.com/trolog/GodotanimatedSpeedbubble
|
||||||
|
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
var bubble_text = "this is just a test"
|
||||||
|
var can_shrink = true
|
||||||
|
var bubble_text_length = 0
|
||||||
|
var bubble_text_index = 0
|
||||||
|
var current_text = ""
|
||||||
|
|
||||||
|
onready var lbltext = get_node("VBoxContainer/Label")
|
||||||
|
onready var ninerect = get_node("VBoxContainer/Label/NinePatchRect")
|
||||||
|
onready var timer = get_node("Timer")
|
||||||
|
|
||||||
|
var do_close = false
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
bubble_text_length = bubble_text.length()
|
||||||
|
timer.start(1)
|
||||||
|
|
||||||
|
func _on_Timer_timeout():
|
||||||
|
if(!do_close):
|
||||||
|
current_text += bubble_text[bubble_text_index]
|
||||||
|
lbltext.text = current_text
|
||||||
|
|
||||||
|
if(bubble_text_index < bubble_text_length -1):
|
||||||
|
timer.start(0.04)
|
||||||
|
bubble_text_index += 1
|
||||||
|
else:
|
||||||
|
if(!do_close):
|
||||||
|
do_close = true
|
||||||
|
timer.start(1)
|
||||||
|
else:
|
||||||
|
if(bubble_text_length > 0):
|
||||||
|
current_text.erase(bubble_text_length -1,1)
|
||||||
|
lbltext.text = current_text
|
||||||
|
bubble_text_length -= 1
|
||||||
|
if(can_shrink):
|
||||||
|
ninerect.rect_size -= Vector2(6,0)
|
||||||
|
ninerect.rect_position += Vector2(3,0)
|
||||||
|
|
||||||
|
timer.start(0.04)
|
||||||
|
else:
|
||||||
|
queue_free()
|
47
GameScenes/speech_bubble/Speech.tscn
Normal file
47
GameScenes/speech_bubble/Speech.tscn
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://GameScenes/speech_bubble/SpeachBubbleBoarder.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://GameScenes/speech_bubble/Speech.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="Speech" type="Node2D"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||||
|
margin_bottom = 14.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="NinePatchRect" type="NinePatchRect" parent="VBoxContainer/Label"]
|
||||||
|
show_behind_parent = true
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_left = -17.8063
|
||||||
|
margin_top = -3.31948
|
||||||
|
margin_right = 18.1937
|
||||||
|
margin_bottom = 3.68052
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
patch_margin_left = 18
|
||||||
|
patch_margin_top = 11
|
||||||
|
patch_margin_right = 18
|
||||||
|
patch_margin_bottom = 10
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
one_shot = true
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
9
Global_Game.gd
Normal file
9
Global_Game.gd
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
#Global functions for the game, like speech bubbles
|
||||||
|
|
||||||
|
func RenderSpeech(load_on, text):
|
||||||
|
var speech = preload("res://GameScenes/speech_bubble/Speech.tscn").instance()
|
||||||
|
speech.bubble_text = text
|
||||||
|
speech.set_position(Vector2(0,-40))
|
||||||
|
load_on.add_child(speech)
|
@ -55,6 +55,10 @@ func InteractWithCell():
|
|||||||
Global.AddInventoryItem(plant_cell_character/2, 1)
|
Global.AddInventoryItem(plant_cell_character/2, 1)
|
||||||
plants_map.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), (plant_cell_character-1))
|
plants_map.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), (plant_cell_character-1))
|
||||||
AnimationOnInteraction(1)
|
AnimationOnInteraction(1)
|
||||||
|
else:
|
||||||
|
#space is now a test function
|
||||||
|
GlobalGameFunctions.RenderSpeech(self, "joe")
|
||||||
|
pass
|
||||||
|
|
||||||
func _interaction_process():
|
func _interaction_process():
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ func _on_Btn_PlayGame_pressed():
|
|||||||
var game = load("res://base_tilemap/base_tilemap.tscn").instance()
|
var game = load("res://base_tilemap/base_tilemap.tscn").instance()
|
||||||
game.load_scene(game_data)
|
game.load_scene(game_data)
|
||||||
|
|
||||||
|
#save this scene to global scenes
|
||||||
|
Global.AddScene(self, "menu", false)
|
||||||
|
|
||||||
#set this scene as main
|
#set this scene as main
|
||||||
Global.mainscene = "startmap1"
|
Global.mainscene = "startmap1"
|
||||||
Global.AddScene(game, "startmap1", true)
|
Global.AddScene(game, "startmap1", true)
|
||||||
|
@ -17,6 +17,9 @@ func _unhandled_input(event):
|
|||||||
if(pl_tile != -1):
|
if(pl_tile != -1):
|
||||||
set_cellv(pl_pos_tile, -1)
|
set_cellv(pl_pos_tile, -1)
|
||||||
|
|
||||||
|
func _on_Settings_pressed():
|
||||||
|
Global.GoToScene("menu")
|
||||||
|
|
||||||
func _on_Inventory_pressed():
|
func _on_Inventory_pressed():
|
||||||
var inventory_screen = preload("res://MiscScenes/Inventory.tscn").instance()
|
var inventory_screen = preload("res://MiscScenes/Inventory.tscn").instance()
|
||||||
Global.AddScene(inventory_screen, "inventory_screen", true)
|
Global.AddScene(inventory_screen, "inventory_screen", true)
|
||||||
|
@ -90,6 +90,7 @@ rotation = -3.14158
|
|||||||
scale = Vector2( 1.22003, 1.11562 )
|
scale = Vector2( 1.22003, 1.11562 )
|
||||||
z_index = 13
|
z_index = 13
|
||||||
normal = ExtResource( 11 )
|
normal = ExtResource( 11 )
|
||||||
|
action = "settings_button"
|
||||||
|
|
||||||
[node name="Map" type="TouchScreenButton" parent="Camera2D/Interactive/GameButtons"]
|
[node name="Map" type="TouchScreenButton" parent="Camera2D/Interactive/GameButtons"]
|
||||||
position = Vector2( 88.136, 1376.12 )
|
position = Vector2( 88.136, 1376.12 )
|
||||||
|
@ -29,6 +29,7 @@ config/icon="res://pictures/gui/buttons/delete_ringofraces.png"
|
|||||||
Global="*res://Global.gd"
|
Global="*res://Global.gd"
|
||||||
Database="*res://Storage/Database.gd"
|
Database="*res://Storage/Database.gd"
|
||||||
GlobalStructures="*res://Global_structures.gd"
|
GlobalStructures="*res://Global_structures.gd"
|
||||||
|
GlobalGameFunctions="*res://Global_Game.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user