Add better sound effects and some server code

This commit is contained in:
Hamcha 2019-07-03 22:15:12 +02:00
parent 91e55a1709
commit 19d27b7515
Signed by: hamcha
GPG Key ID: A40413D21021EAEE
20 changed files with 247 additions and 66 deletions

View File

@ -8,4 +8,4 @@ Some assets come from fellow MLP fans and artists:
The following Sound effects from Freesound were used:
- [**long wispy woosh1.wav** by newagesoup](https://freesound.org/people/newagesoup/sounds/377830/)
- [**rise-crash.wav** by soneproject](https://freesound.org/people/soneproject/sounds/334522/) (CC0, what a champ)

View File

@ -11,4 +11,4 @@ static func get_card(cardid: String, cbObj: Object, cbFn: String):
cbObj.call(cbFn, HTTPRequest.RESULT_SUCCESS, 200, [], buf)
return
# Otherwise, fetch it and cache it
Remote.fetch(Remote.IMGURL + cardid + ".webp", cbObj, cbFn)
Remote.fetch(Remote.ImageURL + cardid + ".webp", cbObj, cbFn)

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# MLPCARDGAME
Work in progress name, work in progress game
# License
Code is ISC, Assets "depends", some stuff is taken from FreeSound and DeviantArt so your best bet is to just praise the copyright gods.

View File

@ -7,8 +7,8 @@
[sub_resource type="ShaderMaterial" id=1]
resource_local_to_scene = true
shader = ExtResource( 2 )
shader_param/effect_color = Color( 0.0117647, 0.768627, 1, 0 )
shader_param/effect_width = 0.1
shader_param/effect_color = Color( 0.0117647, 0.768627, 1, 1 )
shader_param/effect_width = 0.05
shader_param/effect_offset = 0.0
[sub_resource type="Animation" id=2]

View File

@ -1,10 +1,10 @@
extends Node
const HOST = "https://mcg.zyg.ovh/"
const IMGURL = HOST + "images/cards/"
const Host = "http://192.168.22.23/"
const ImageURL = Host + "images/cards/"
func res_file_name(url: String) -> String:
return "user://" + url.trim_prefix(HOST).replace("/","_")
return "user://" + url.trim_prefix(Host).replace("/","_")
func fetch(url: String, cbObj: Object, cbFn: String):
# Check for cached resource
@ -22,10 +22,10 @@ func fetch(url: String, cbObj: Object, cbFn: String):
# On other platforms (such as Android), we *need* to!
req.use_threads = !OS.has_feature("HTML5")
add_child(req)
req.connect("request_completed", self, "_request_completed", [url, cbObj, cbFn])
req.connect("request_completed", self, "_fetch_completed", [url, cbObj, cbFn])
req.request(url)
func _request_completed(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray, url: String, cbObj: Object, cbFn: String):
func _fetch_completed(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray, url: String, cbObj: Object, cbFn: String):
# Cache result for later
if result == HTTPRequest.RESULT_SUCCESS:
# Get file name by trimming the host

18
Scenes/Global/Server.gd Normal file
View File

@ -0,0 +1,18 @@
extends Node
const RoomListAPI = Remote.Host + "api/v1/lobby/room/list"
func get_rooms(cbObj: Object, cbFn: String):
var req := HTTPRequest.new()
req.use_threads = !OS.has_feature("HTML5")
add_child(req)
req.connect("request_completed", self, "_get_completed", [cbObj, cbFn])
req.request(RoomListAPI)
func _get_completed(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray, cbObj: Object, cbFn: String):
# Cache result for later
if result != HTTPRequest.RESULT_SUCCESS:
cbObj.call(cbFn, result, body)
var obj = parse_json(body.get_string_from_utf8())
# Call callback
cbObj.call(cbFn, OK, obj)

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/Global/Server.gd" type="Script" id=1]
[node name="Server" type="Node"]
script = ExtResource( 1 )

View File

@ -9,10 +9,10 @@ var RoomItem := preload("res://Scenes/Lobby/RoomEntry.tscn")
func _ready():
# Load bgm
BGM.load_music("lobby")
emit_signal("loaded")
Server.get_rooms(self, "_room_list")
add_room("test", "Unnamed room")
$ChooseNameDialog.popup_centered()
func add_room(id: String, name: String):
var item := RoomItem.instance()
@ -20,5 +20,14 @@ func add_room(id: String, name: String):
item.connect("clicked", self, "_room_clicked", [id])
roomList.add_child(item)
func _room_list(result, obj):
if result != OK:
# Handle error
breakpoint
print(obj)
func _room_clicked(id: String):
print(id)
print(id)
func _create_room():
$CreateRoomDialog.popup_centered_ratio(0.75)

View File

@ -1,7 +1,15 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Scenes/Lobby.gd" type="Script" id=1]
[ext_resource path="res://MLPAssets/Background/menubg.webp" type="Texture" id=2]
[ext_resource path="res://UIAssets/Fonts/Catamaran.tres" type="DynamicFont" id=3]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Light.ttf" type="DynamicFontData" id=4]
[sub_resource type="DynamicFont" id=1]
size = 20
use_mipmaps = true
use_filter = true
font_data = ExtResource( 4 )
[node name="Lobby" type="Control"]
anchor_right = 1.0
@ -31,3 +39,52 @@ margin_right = 1220.0
margin_bottom = 400.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="NewRoom" type="Button" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -130.0
margin_top = 60.0
margin_right = -30.0
margin_bottom = 90.0
text = "Create room"
[node name="CreateRoomDialog" type="PopupDialog" parent="."]
margin_left = 317.0
margin_top = 178.0
margin_right = 983.0
margin_bottom = 587.0
[node name="ChooseNameDialog" type="PopupDialog" parent="."]
visible = true
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_right = 400.0
margin_bottom = 200.0
rect_min_size = Vector2( 400, 200 )
popup_exclusive = true
[node name="Label" type="Label" parent="ChooseNameDialog"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 394.0
margin_bottom = 13.0
rect_scale = Vector2( 0.5, 0.5 )
custom_fonts/font = ExtResource( 3 )
text = "Choose a name"
align = 1
valign = 1
[node name="LineEdit" type="LineEdit" parent="ChooseNameDialog"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 90.825
margin_top = 100.0
margin_right = -90.0
margin_bottom = -60.0
custom_fonts/font = SubResource( 1 )
align = 1
placeholder_text = "Player name"
[connection signal="pressed" from="NewRoom" to="." method="_create_room"]

View File

@ -10,5 +10,5 @@ func _ready():
func _process(delta):
timeout -= delta
if timeout <= 0:
Loader.load_scene("res://Scenes/Lobby.tscn")
Loader.load_scene("res://Scenes/TitleIntro.tscn")
set_process(false)

9
Scenes/TitleScreen.gd Normal file
View File

@ -0,0 +1,9 @@
extends Control
signal loaded()
func _ready():
emit_signal("loaded")
func _anim_finished(anim_name):
pass

View File

@ -1,13 +1,17 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://UIAssets/mane6start.png" type="Texture" id=1]
[ext_resource path="res://UIAssets/Sounds/low_woosh.wav" type="AudioStream" id=2]
[ext_resource path="res://Scenes/TitleScreen.gd" type="Script" id=1]
[ext_resource path="res://UIAssets/mane6start.png" type="Texture" id=2]
[ext_resource path="res://UIAssets/Sounds/Swoosh.wav" type="AudioStream" id=3]
[ext_resource path="res://UIAssets/Sounds/TWRise.wav" type="AudioStream" id=4]
[ext_resource path="res://UIAssets/Effects/FlashCenter.shader" type="Shader" id=5]
[sub_resource type="Animation" id=1]
resource_name = "FadeIn"
length = 3.5
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("TS:position")
tracks/0/path = NodePath("Intro/TS:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
@ -19,7 +23,7 @@ tracks/0/keys = {
"values": [ Vector2( 655.393, 702.101 ), Vector2( 655.393, 702.101 ), Vector2( 656.979, 500 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("TS:modulate")
tracks/1/path = NodePath("Intro/TS:modulate")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/imported = false
@ -31,31 +35,31 @@ tracks/1/keys = {
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("PP:position")
tracks/2/path = NodePath("Intro/PP:position")
tracks/2/interp = 2
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.9, 1.2 ),
"times": PoolRealArray( 0, 0.85, 1.15 ),
"transitions": PoolRealArray( 1, 0.5, 1 ),
"update": 0,
"values": [ Vector2( 599.236, 504.842 ), Vector2( 599.236, 504.842 ), Vector2( 319.982, 603.216 ) ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("PP:modulate")
tracks/3/path = NodePath("Intro/PP:modulate")
tracks/3/interp = 2
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0, 0.9, 1.2 ),
"times": PoolRealArray( 0, 0.85, 1.15 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/4/type = "value"
tracks/4/path = NodePath("FS:position")
tracks/4/path = NodePath("Intro/FS:position")
tracks/4/interp = 2
tracks/4/loop_wrap = true
tracks/4/imported = false
@ -67,7 +71,7 @@ tracks/4/keys = {
"values": [ Vector2( 559.227, 368.769 ), Vector2( 559.227, 368.769 ), Vector2( 299.012, 292.608 ) ]
}
tracks/5/type = "value"
tracks/5/path = NodePath("FS:modulate")
tracks/5/path = NodePath("Intro/FS:modulate")
tracks/5/interp = 2
tracks/5/loop_wrap = true
tracks/5/imported = false
@ -79,79 +83,79 @@ tracks/5/keys = {
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/6/type = "value"
tracks/6/path = NodePath("RD:position")
tracks/6/path = NodePath("Intro/RD:position")
tracks/6/interp = 2
tracks/6/loop_wrap = true
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/keys = {
"times": PoolRealArray( 0, 0.7, 1 ),
"times": PoolRealArray( 0, 0.65, 0.95 ),
"transitions": PoolRealArray( 1, 0.5, 1 ),
"update": 0,
"values": [ Vector2( 630.323, 392.166 ), Vector2( 630.323, 392.166 ), Vector2( 630.323, 247.779 ) ]
}
tracks/7/type = "value"
tracks/7/path = NodePath("RD:modulate")
tracks/7/path = NodePath("Intro/RD:modulate")
tracks/7/interp = 2
tracks/7/loop_wrap = true
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/keys = {
"times": PoolRealArray( 0, 0.7, 1 ),
"times": PoolRealArray( 0, 0.65, 0.95 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/8/type = "value"
tracks/8/path = NodePath("AJ:position")
tracks/8/path = NodePath("Intro/AJ:position")
tracks/8/interp = 2
tracks/8/loop_wrap = true
tracks/8/imported = false
tracks/8/enabled = true
tracks/8/keys = {
"times": PoolRealArray( 0, 1.2, 1.5 ),
"times": PoolRealArray( 0, 1.1, 1.4 ),
"transitions": PoolRealArray( 1, 0.5, 1 ),
"update": 0,
"values": [ Vector2( 767.327, 325.855 ), Vector2( 767.327, 325.855 ), Vector2( 1008.5, 278.254 ) ]
}
tracks/9/type = "value"
tracks/9/path = NodePath("AJ:modulate")
tracks/9/path = NodePath("Intro/AJ:modulate")
tracks/9/interp = 2
tracks/9/loop_wrap = true
tracks/9/imported = false
tracks/9/enabled = true
tracks/9/keys = {
"times": PoolRealArray( 0, 1.2, 1.5 ),
"times": PoolRealArray( 0, 1.1, 1.4 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/10/type = "value"
tracks/10/path = NodePath("RR:position")
tracks/10/path = NodePath("Intro/RR:position")
tracks/10/interp = 2
tracks/10/loop_wrap = true
tracks/10/imported = false
tracks/10/enabled = true
tracks/10/keys = {
"times": PoolRealArray( 0, 0.5, 0.8 ),
"times": PoolRealArray( 0, 0.45, 0.75 ),
"transitions": PoolRealArray( 1, 0.5, 1 ),
"update": 0,
"values": [ Vector2( 744.717, 476.045 ), Vector2( 744.717, 476.045 ), Vector2( 1008.5, 598.14 ) ]
}
tracks/11/type = "value"
tracks/11/path = NodePath("RR:modulate")
tracks/11/path = NodePath("Intro/RR:modulate")
tracks/11/interp = 2
tracks/11/loop_wrap = true
tracks/11/imported = false
tracks/11/enabled = true
tracks/11/keys = {
"times": PoolRealArray( 0, 0.5, 0.8 ),
"times": PoolRealArray( 0, 0.45, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/12/type = "audio"
tracks/12/path = NodePath("Channel1")
tracks/12/path = NodePath("Intro/Channel1")
tracks/12/interp = 1
tracks/12/loop_wrap = true
tracks/12/imported = false
@ -160,20 +164,20 @@ tracks/12/keys = {
"clips": [ {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 2 )
"stream": ExtResource( 3 )
}, {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 2 )
"stream": ExtResource( 3 )
}, {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 2 )
"stream": ExtResource( 3 )
} ],
"times": PoolRealArray( 0.2, 0.7, 1.1 )
"times": PoolRealArray( 0.35, 0.7, 1.15 )
}
tracks/13/type = "audio"
tracks/13/path = NodePath("Channel2")
tracks/13/path = NodePath("Intro/Channel2")
tracks/13/interp = 1
tracks/13/loop_wrap = true
tracks/13/imported = false
@ -182,14 +186,34 @@ tracks/13/keys = {
"clips": [ {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 2 )
"stream": ExtResource( 3 )
}, {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 2 )
"stream": ExtResource( 3 )
}, {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 4 )
} ],
"times": PoolRealArray( 0.4, 0.9 )
"times": PoolRealArray( 0.5, 0.9, 1.3 )
}
tracks/14/type = "value"
tracks/14/path = NodePath("Intro/ColorRect:material:shader_param/effect_strength")
tracks/14/interp = 2
tracks/14/loop_wrap = true
tracks/14/imported = false
tracks/14/enabled = true
tracks/14/keys = {
"times": PoolRealArray( 0, 2.55, 3.2 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ 0.0, 0.0, 1.0 ]
}
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 5 )
shader_param/effect_strength = 1.0
[node name="TitleScreen" type="Control"]
anchor_left = 0.5
@ -200,55 +224,67 @@ margin_left = -640.0
margin_top = -400.0
margin_right = 640.0
margin_bottom = 400.0
script = ExtResource( 1 )
[node name="RD" type="Sprite" parent="."]
[node name="Intro" type="Node" parent="."]
[node name="RD" type="Sprite" parent="Intro"]
position = Vector2( 630.323, 247.779 )
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 1 )
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 3.0625, -0.241745, 357.39, 576.697 )
[node name="FS" type="Sprite" parent="."]
[node name="FS" type="Sprite" parent="Intro"]
position = Vector2( 299.012, 292.608 )
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 1 )
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 850.711, 1.36916, 538.217, 391.606 )
[node name="AJ" type="Sprite" parent="."]
[node name="AJ" type="Sprite" parent="Intro"]
position = Vector2( 1008.5, 278.254 )
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 1 )
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( -7.22717, 592.3, 422.556, 379.131 )
[node name="RR" type="Sprite" parent="."]
[node name="RR" type="Sprite" parent="Intro"]
position = Vector2( 1008.5, 598.14 )
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 1 )
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 362.65, -8.27631, 466.841, 383.89 )
[node name="PP" type="Sprite" parent="."]
[node name="PP" type="Sprite" parent="Intro"]
position = Vector2( 319.982, 603.216 )
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 1 )
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 846.772, 430.27, 542.718, 340.81 )
[node name="TS" type="Sprite" parent="."]
[node name="TS" type="Sprite" parent="Intro"]
position = Vector2( 656.979, 500 )
scale = Vector2( 0.8, 0.8 )
texture = ExtResource( 1 )
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 429.027, 395.82, 401.907, 578.254 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
[node name="AnimationPlayer" type="AnimationPlayer" parent="Intro"]
root_node = NodePath("../..")
autoplay = "FadeIn"
anims/FadeIn = SubResource( 1 )
[node name="Channel1" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 2 )
[node name="Channel1" type="AudioStreamPlayer2D" parent="Intro"]
stream = ExtResource( 3 )
bus = "SFX"
[node name="Channel2" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 2 )
[node name="Channel2" type="AudioStreamPlayer2D" parent="Intro"]
stream = ExtResource( 4 )
bus = "SFX"
[node name="ColorRect" type="ColorRect" parent="Intro"]
material = SubResource( 2 )
anchor_right = 1.0
anchor_bottom = 1.0
[connection signal="animation_finished" from="Intro/AnimationPlayer" to="." method="_anim_finished"]

View File

@ -0,0 +1,11 @@
shader_type canvas_item;
render_mode blend_mix,unshaded;
uniform float effect_strength : hint_range(0, 1) = 0.1;
void fragment() {
vec2 uv = UV;
vec2 center = vec2(0.5);
COLOR.a *= effect_strength*2.-distance(UV, center);
}

BIN
UIAssets/Sounds/Swoosh.wav Normal file

Binary file not shown.

View File

@ -2,12 +2,12 @@
importer="wav"
type="AudioStreamSample"
path="res://.import/low_woosh.wav-f25971f094bce7f745ac9ca56d1a164c.sample"
path="res://.import/Swoosh.wav-f0d8871e17ba61534f20190bd6013cca.sample"
[deps]
source_file="res://UIAssets/Sounds/low_woosh.wav"
dest_files=[ "res://.import/low_woosh.wav-f25971f094bce7f745ac9ca56d1a164c.sample" ]
source_file="res://UIAssets/Sounds/Swoosh.wav"
dest_files=[ "res://.import/Swoosh.wav-f0d8871e17ba61534f20190bd6013cca.sample" ]
[params]

BIN
UIAssets/Sounds/TWRise.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/TWRise.wav-71f8bce81e740bdb96c78634a54b0dbf.sample"
[deps]
source_file="res://UIAssets/Sounds/TWRise.wav"
dest_files=[ "res://.import/TWRise.wav-71f8bce81e740bdb96c78634a54b0dbf.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

Binary file not shown.

View File

@ -15,3 +15,9 @@ bus/1/volume_db = -8.5
bus/1/send = "Master"
bus/1/effect/0/effect = SubResource( 1 )
bus/1/effect/0/enabled = true
bus/2/name = "SFX"
bus/2/solo = false
bus/2/mute = false
bus/2/bypass_fx = false
bus/2/volume_db = 0.0
bus/2/send = "Master"

View File

@ -64,6 +64,7 @@ Remote="*res://Scenes/Global/Remote.tscn"
Loader="*res://Scenes/Global/Loader.tscn"
BGM="*res://Scenes/BGMusic.tscn"
Mods="*res://Scenes/Global/Mods.tscn"
Server="*res://Scenes/Global/Server.tscn"
[debug]