From 5d7d7c0822d59a3058f4fc7e058122e10ce29d15 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Mon, 30 May 2022 11:23:47 +0300 Subject: [PATCH] Cleaned up positional sound. --- SpaceCadetPinball/Sound.cpp | 1 + SpaceCadetPinball/TBall.h | 2 +- SpaceCadetPinball/TCollisionComponent.cpp | 1 + SpaceCadetPinball/TCollisionComponent.h | 2 +- SpaceCadetPinball/TPinballComponent.cpp | 12 +++++++----- SpaceCadetPinball/TPinballComponent.h | 6 ++++-- SpaceCadetPinball/TSound.h | 1 - SpaceCadetPinball/options.cpp | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/SpaceCadetPinball/Sound.cpp b/SpaceCadetPinball/Sound.cpp index 4e5f317..1ef4e87 100644 --- a/SpaceCadetPinball/Sound.cpp +++ b/SpaceCadetPinball/Sound.cpp @@ -1,6 +1,7 @@ #include "options.h" #include "pch.h" #include "Sound.h" +#include "maths.h" int Sound::num_channels; bool Sound::enabled_flag = false; diff --git a/SpaceCadetPinball/TBall.h b/SpaceCadetPinball/TBall.h index b451dd2..2d58424 100644 --- a/SpaceCadetPinball/TBall.h +++ b/SpaceCadetPinball/TBall.h @@ -13,7 +13,7 @@ public : void not_again(TEdgeSegment* edge); bool already_hit(TEdgeSegment* edge); int Message(int code, float value) override; - vector2 get_coordinates(); + vector2 get_coordinates() override; static void throw_ball(TBall* ball, vector3* direction, float angleMult, float speedMult1, float speedMult2); diff --git a/SpaceCadetPinball/TCollisionComponent.cpp b/SpaceCadetPinball/TCollisionComponent.cpp index a779c29..d713867 100644 --- a/SpaceCadetPinball/TCollisionComponent.cpp +++ b/SpaceCadetPinball/TCollisionComponent.cpp @@ -4,6 +4,7 @@ #include "maths.h" #include "TEdgeSegment.h" #include "TPinballTable.h" +#include "TBall.h" TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, bool createWall) : diff --git a/SpaceCadetPinball/TCollisionComponent.h b/SpaceCadetPinball/TCollisionComponent.h index ff58403..e0d727c 100644 --- a/SpaceCadetPinball/TCollisionComponent.h +++ b/SpaceCadetPinball/TCollisionComponent.h @@ -1,9 +1,9 @@ #pragma once #include "TPinballComponent.h" -#include "TBall.h" struct vector2; class TEdgeSegment; +class TBall; class TCollisionComponent : public TPinballComponent { diff --git a/SpaceCadetPinball/TPinballComponent.cpp b/SpaceCadetPinball/TPinballComponent.cpp index a899ce5..88d27a6 100644 --- a/SpaceCadetPinball/TPinballComponent.cpp +++ b/SpaceCadetPinball/TPinballComponent.cpp @@ -17,8 +17,8 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool ListZMap = nullptr; GroupName = nullptr; Control = nullptr; - Coordinates.X = -1.0f; - Coordinates.Y = -1.0f; + VisualPosNormX= -1.0f; + VisualPosNormY = -1.0f; if (table) table->ComponentList.push_back(this); if (groupIndex >= 0) @@ -71,8 +71,10 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool rootBmp->XPosition - table->XOffset, rootBmp->YPosition - table->YOffset, &bmp1Rect); - Coordinates.X = (bmp1Rect.XPosition + (bmp1Rect.Width / 2.0f)) / PinballTable->Width; - Coordinates.Y = (bmp1Rect.YPosition + (bmp1Rect.Height / 2.0f)) / PinballTable->Height; + + auto& rect = RenderSprite->BmpRect; + VisualPosNormX = (rect.XPosition + (rect.Width / 2.0f)) / PinballTable->Width; + VisualPosNormY = (rect.YPosition + (rect.Height / 2.0f)) / PinballTable->Height; } } GroupIndex = groupIndex; @@ -118,5 +120,5 @@ int TPinballComponent::get_scoring(int index) vector2 TPinballComponent::get_coordinates() { - return this->Coordinates; + return {VisualPosNormX, VisualPosNormY}; } diff --git a/SpaceCadetPinball/TPinballComponent.h b/SpaceCadetPinball/TPinballComponent.h index 3d32fcf..c68d41c 100644 --- a/SpaceCadetPinball/TPinballComponent.h +++ b/SpaceCadetPinball/TPinballComponent.h @@ -1,10 +1,10 @@ #pragma once -#include "maths.h" struct zmap_header_type; struct gdrv_bitmap8; struct render_sprite_type_struct; struct component_control; +struct vector2; class TPinballTable; enum class message_code @@ -36,5 +36,7 @@ public: TPinballTable* PinballTable; std::vector* ListBitmap; std::vector* ListZMap; - vector2 Coordinates; +private: + float VisualPosNormX; + float VisualPosNormY; }; diff --git a/SpaceCadetPinball/TSound.h b/SpaceCadetPinball/TSound.h index 5abd837..fa39a1d 100644 --- a/SpaceCadetPinball/TSound.h +++ b/SpaceCadetPinball/TSound.h @@ -6,7 +6,6 @@ class TSound : { public: TSound(TPinballTable* table, int groupIndex); - float Play(); float Play(TPinballComponent *soundSource, const char* info); int SoundIndex; diff --git a/SpaceCadetPinball/options.cpp b/SpaceCadetPinball/options.cpp index 5969312..0c9b3de 100644 --- a/SpaceCadetPinball/options.cpp +++ b/SpaceCadetPinball/options.cpp @@ -102,7 +102,7 @@ void options::InitPrimary() Options.HybridSleep = get_int("HybridSleep", false); Options.Prefer3DPBGameData = get_int("Prefer 3DPB Game Data", false); Options.IntegerScaling = get_int("Integer Scaling", false); - Options.SoundStereo = get_int("Stereo Sound Effects", true); + Options.SoundStereo = get_int("Stereo Sound Effects", false); Options.SoundVolume = Clamp(get_int("Sound Volume", DefVolume), MinVolume, MaxVolume); Options.MusicVolume = Clamp(get_int("Music Volume", DefVolume), MinVolume, MaxVolume); Options.DebugOverlay = get_int("Debug Overlay", false);