Skip to content

Commit

Permalink
Merge pull request #39 from DOGamedev5/main
Browse files Browse the repository at this point in the history
adding room3 and audioManager system
  • Loading branch information
DOGamedev5 authored Dec 22, 2023
2 parents a677a78 + 685323e commit 6bea144
Show file tree
Hide file tree
Showing 22 changed files with 264 additions and 98 deletions.
47 changes: 47 additions & 0 deletions audio/audioSystem/audioSystem.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
extends Node

onready var musics := {
"temple in ruins" : preload("res://audio/musics/templeInRuins.mp3")
}
onready var sfxs := {

}


onready var musicPlayer := $musicPlayer

var currentMusic : String

func playMusic(music : String):
if music == currentMusic:
return

if musicPlayer.playing:
stop()

_setMusic(music)

func _setMusic(music : String):
musicPlayer.stream = musics[music]
currentMusic = music
musicPlayer.playing = true

func stop():
musicPlayer.playing = false

func playSFX(SFX : String, positional := false, position = Vector2.ZERO, distance = .0, maskArea = 0):
var newSfx
if positional:
newSfx = AudioStreamPlayer2D.new()
newSfx.position = position
newSfx.max_distance = distance
newSfx.area_mask = maskArea
else:
newSfx = AudioStreamPlayer.new()

newSfx.stream = sfxs[SFX]
newSfx.set_bus("SFX")
newSfx.connect("finished", newSfx, "queue_free")

get_tree().current_scene.add_child(newSfx)
newSfx.play()
38 changes: 38 additions & 0 deletions audio/audioSystem/audioSystem.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://audio/audioSystem/audioSystem.gd" type="Script" id=1]

[sub_resource type="Animation" id=1]
length = 0.001
tracks/0/type = "bezier"
tracks/0/path = NodePath("musicPlayer:volume_db")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( 0, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0 )
}

[sub_resource type="Animation" id=2]
resource_name = "fade-in"
tracks/0/type = "bezier"
tracks/0/path = NodePath("musicPlayer:volume_db")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( 0, -0.25, 0, 0.3, -79.25, -100, -0.3, 30.75, 0.25, 0 ),
"times": PoolRealArray( 0, 0.6 )
}

[node name="Audio" type="Node"]
script = ExtResource( 1 )

[node name="musicPlayer" type="AudioStreamPlayer" parent="."]

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 1 )
anims/fade-in = SubResource( 2 )
16 changes: 16 additions & 0 deletions audio/default_bus_layout.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gd_resource type="AudioBusLayout" format=2]

[resource]
bus/0/volume_db = -12.1201
bus/1/name = "music"
bus/1/solo = false
bus/1/mute = false
bus/1/bypass_fx = false
bus/1/volume_db = 0.0
bus/1/send = "Master"
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"
File renamed without changes.
15 changes: 15 additions & 0 deletions audio/musics/templeInRuins.mp3.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[remap]

importer="mp3"
type="AudioStreamMP3"
path="res://.import/templeInRuins.mp3-9f8c17b60e483fa8ca2894963b564134.mp3str"

[deps]

source_file="res://audio/musics/templeInRuins.mp3"
dest_files=[ "res://.import/templeInRuins.mp3-9f8c17b60e483fa8ca2894963b564134.mp3str" ]

[params]

loop=true
loop_offset=0
File renamed without changes.
24 changes: 13 additions & 11 deletions entities/player/powerStates/normal/playerNormal.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,20 @@ func onWall():
return false

func setFlipConfig():
if not stunned:
for ray in onWallRayCast:
if stunned:
return

if Input.get_axis("ui_left", "ui_right"):
for ray in onWallRayCast:
ray.cast_to.x = 20 * Input.get_axis("ui_left", "ui_right")


attackComponents[0].position.x = 24 *(1 - 2 * int(fliped))
attackComponents[1].position.x = 36 *(1 - 2 * int(fliped))

$speedEffect.position.x = 20 * (1 - 2 * int(fliped))
$speedEffect.flip_h = fliped

sprite.flip_h = fliped

attackComponents[0].position.x = 24 *(1 - 2 * int(fliped))
attackComponents[1].position.x = 36 *(1 - 2 * int(fliped))

$speedEffect.position.x = 20 * (1 - 2 * int(fliped))
$speedEffect.flip_h = fliped

sprite.flip_h = fliped

func setAttackSpeed():
if running:
Expand Down
2 changes: 1 addition & 1 deletion entities/player/powerStates/normal/playerNormal.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[ext_resource path="res://entities/player/powerStates/normal/sprites/lodrofoAttack.pxo" type="Texture" id=19]
[ext_resource path="res://entities/classes/attackComponent/attackComponent.gd" type="Script" id=20]
[ext_resource path="res://entities/player/sprites/top_speedEffect.pxo" type="Texture" id=21]
[ext_resource path="res://gameplay/effect1.pxo" type="Texture" id=22]
[ext_resource path="res://gameplay/effects/effect1.pxo" type="Texture" id=22]
[ext_resource path="res://entities/classes/hitboxComponent/hitboxComponent.gd" type="Script" id=23]

[sub_resource type="AtlasTexture" id=2]
Expand Down
10 changes: 6 additions & 4 deletions entities/player/powerStates/normal/scripts/WALL.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends State
var currentState

func enter(lastState):

if not parent.floorDetect.is_colliding() or ["TOP_SPEED", "ATTACK"].has(lastState):
parent.playback.travel("SPLAT")
parent.stunned = true
Expand All @@ -20,11 +21,12 @@ func process_state():
return "FALL"


if parent.floorDetect.is_colliding() and not parent.onWall():
if Input.get_axis("ui_left", "ui_right") == 0 :
if parent.floorDetect.is_colliding():
if Input.get_axis("ui_left", "ui_right") == 0:
return "IDLE"

return "RUN"

elif not parent.onWall():
return "RUN"

elif parent.can_jump and Input.is_action_pressed("ui_jump"):
return "JUMP"
Expand Down
13 changes: 0 additions & 13 deletions gameplay/effect1.pxo.import

This file was deleted.

File renamed without changes.
13 changes: 13 additions & 0 deletions gameplay/effects/effect1.pxo.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[remap]

importer="com.technohacker.pixelorama"
type="StreamTexture"
path="res://.import/effect1.pxo-e14b83f33bc5af2dbff6a39023222ec2.stex"

[deps]

source_file="res://gameplay/effects/effect1.pxo"
dest_files=[ "res://.import/effect1.pxo-e14b83f33bc5af2dbff6a39023222ec2.stex" ]

[params]

4 changes: 0 additions & 4 deletions musics/default_bus_layout.tres

This file was deleted.

15 changes: 0 additions & 15 deletions musics/templeInRuins.mp3.import

This file was deleted.

3 changes: 2 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ config/icon="res://icon.png"

[audio]

default_bus_layout="res://musics/default_bus_layout.tres"
default_bus_layout="res://audio/default_bus_layout.tres"

[autoload]

Global="*res://gameplay/global.gd"
IntegerResolutionHandler="*res://addons/integer_resolution_handler/integer_resolution_handler.gd"
AudioManager="*res://audio/audioSystem/audioSystem.tscn"

[display]

Expand Down
6 changes: 3 additions & 3 deletions worlds/classes/ChangeRoom/ChangeRoom.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ onready var parent = get_parent()

func _ready():

set_collision_mask_bit(11, true)
set_collision_mask_bit(1, false)
set_collision_layer_bit(1, false)
set_collision_layer_bit(10, true)
set_collision_mask_bit(0, false)
set_collision_layer_bit(0, false)

if roomID != 0:
room = "res://worlds/{world}/rooms/room{room}.tscn".format({"world" : world, "room" : roomID})
Expand Down
1 change: 1 addition & 0 deletions worlds/classes/levelClass/levelClass.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var player
signal changeRoom(room, warpID)

func _ready():
AudioManager.playMusic("temple in ruins")
connect("changeRoom", self, "loadRoom")
player = load("res://entities/player/powerStates/normal/playerNormal.tscn").instance()
add_child(player)
Expand Down
1 change: 1 addition & 0 deletions worlds/classes/roomClass/roomClass.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export var limitsMax := Vector2(10000000, 10000000)
signal changeRoom(room, warpID)

func _ready():

connect("changeRoom", get_parent(), "loadRoom")
get_parent().setCameraLimits(limitsMin, limitsMax)

Expand Down
9 changes: 2 additions & 7 deletions worlds/gamesArt/level1.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=2]

[ext_resource path="res://worlds/classes/levelClass/levelClass.gd" type="Script" id=1]
[ext_resource path="res://musics/templeInRuins.mp3" type="AudioStream" id=2]

[node name="level1" type="Node2D"]
script = ExtResource( 1 )
firstRoom = "res://debugRoom.tscn"
firstRoom = "res://worlds/gamesArt/rooms/room1.tscn"

[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
scroll_offset = Vector2( 0, -600 )
Expand All @@ -20,7 +19,3 @@ margin_top = -392.0
margin_right = 1888.0
margin_bottom = 508.0
color = Color( 0.282353, 0.247059, 0.239216, 1 )

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 2 )
autoplay = true
33 changes: 31 additions & 2 deletions worlds/gamesArt/rooms/room1.tscn

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions worlds/gamesArt/rooms/room2.tscn

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions worlds/gamesArt/rooms/room3.tscn

Large diffs are not rendered by default.

0 comments on commit 6bea144

Please sign in to comment.