Changed sound behaviour. Working on interaction map.

This commit is contained in:
Jonathan Herrewijnen 2022-10-11 19:21:46 +02:00
parent 22b3c5a53f
commit 6529ed8b65
9 changed files with 17 additions and 47 deletions

View File

@ -1,9 +1,16 @@
extends Node2D
#Global functions for the game, like speech bubbles
#Global functions for the game, like speech bubbles and sounds
func RenderSpeech(load_on, text):
var speech = preload("res://MiscScenes/Speech.tscn").instance()
speech.bubble_text = text
speech.set_position(Vector2(0,-40))
load_on.add_child(speech)
func SoundOnInteraction(load_on, sound_name):
var audio = preload("res://MiscScenes/Sound.tscn").instance()
var format_string = "res://Sounds/%s.wav"
var actual_string = format_string % sound_name
var Sound = load(actual_string)
audio.stream = Sound
load_on.add_child(audio)

View File

@ -4,8 +4,8 @@ const GRAVITY = 0.0
const WALK_SPEED = 200
const interaction_circle_size = 150
onready var background_map = get_node("/root/base_scene/background")
onready var player = get_node("/root/base_scene/Player")
onready var cell_size = background_map._get_cell_size()
onready var player = get_node("/root/base_scene/Player")
onready var interaction_map = get_node("/root/base_scene/interaction_map")
onready var player_interaction = get_node("/root/base_scene/player_interaction")
@ -48,6 +48,7 @@ func InteractWithCell():
print("plant cell mouse line 1: ", interaction_map.get_cell(12, 36))
print('plant_cell_mouse=',plant_cell_mouse,' | plant_cell_character=', plant_cell_character,' | background_cell=', background_cell,' | interaction_cell=',interaction_cell)
GlobalGameFunctions.SoundOnInteraction(self, "standard")
if plant_cell_mouse > 0 and plant_cell_mouse % 2 == 0:
Global.AddInventoryItem(plant_cell_mouse/2, 1)
@ -71,12 +72,5 @@ func AnimationOnInteraction(Item):
var itemimage = TextureRect.new()
var item = null
func SoundOnInteraction(x):
var format_string = "res://Sounds/%s.wav"
var actual_string = format_string % x
var Sound = load(actual_string)
$AudioStreamPlayer.stream = Sound
$AudioStreamPlayer.play()
func _ready():
Global.player_inventory_items = Database.GetInventoryItems().duplicate()

View File

@ -1,16 +1,4 @@
extends Button
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
pass

View File

@ -3,9 +3,6 @@ extends TileMap
onready var player = get_node("/root/base_scene/Player")
onready var camera = get_node("/root/base_scene/Camera2D")
func _ready():
pass
func _get_cell_size():
return cell_size

View File

@ -2,7 +2,6 @@
[ext_resource path="res://pictures/arrow_down.png" type="Texture" id=1]
[sub_resource type="GradientTexture" id=1]
[node name="Control" type="Control"]

4
MiscScenes/Sound.tscn Normal file
View File

@ -0,0 +1,4 @@
[gd_scene format=2]
[node name="Sound" type="AudioStreamPlayer"]
autoplay = true

View File

@ -3,7 +3,6 @@
[ext_resource path="res://pictures/gui/dialogue/SpeachBubbleBoarder.png" type="Texture" id=1]
[ext_resource path="res://MiscCodes/Speech.gd" type="Script" id=2]
[node name="Speech" type="Node2D"]
script = ExtResource( 2 )

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=2]
[gd_scene load_steps=19 format=2]
[ext_resource path="res://pictures/gui/player_interaction.tres" type="TileSet" id=1]
[ext_resource path="res://MiscCodes/background_script.gd" type="Script" id=2]
@ -16,7 +16,6 @@
[ext_resource path="res://pictures/gui/buttons/crafting_alchemy.png" type="Texture" id=14]
[ext_resource path="res://pictures/surroundings/bomen/boom_stand3.png" type="Texture" id=15]
[ext_resource path="res://pictures/gui/buttons/quick_item_button.png" type="Texture" id=16]
[ext_resource path="res://Sounds/night-chip.ogg" type="AudioStream" id=17]
[sub_resource type="CapsuleShape2D" id=1]
radius = 20.0
@ -192,10 +191,6 @@ z_index = 11
shape = SubResource( 2 )
action = "map_interaction"
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="Player"]
pause_mode = 2
stream = ExtResource( 17 )
[node name="Tween" type="Tween" parent="."]
[connection signal="released" from="Camera2D/Interactive/GameButtons/Inventory" to="background" method="_on_Inventory_released"]
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/MoveDown" to="Player" method="_on_TouchScreenButton_pressed"]

View File

@ -1,16 +1,6 @@
extends Node2D
func load_scene(map_data):
#$background.tile_set = load("base_tilemap/tilesets/background_ts.tres")
#$vegetation.tile_set = load("res://river_intersection_home2.tscn::1")
# for x in range(map_data.width):
# for y in range(map_data.height):
# $background.set_cell(x, y, map_data.background_map[x][y])
# $vegetation.set_cell(x, y, -1)
# $interaction_map.set_cell(x, y, -1)
# $player_interaction.set_cell(x, y, -1)
var scene = load(map_data+".tscn")
print("MAP NAME ",map_data+".tscn")
var map = scene.instance()
@ -19,6 +9,3 @@ func load_scene(map_data):
func _ready():
self.add_child(load_scene("res://Maps/river_intersection"))
# var scene = load("res://Maps/river_intersection.tscn")
# var map = scene.instance()
# self.add_child(map)