Cleaned up positional sound.

This commit is contained in:
Muzychenko Andrey 2022-05-30 11:23:47 +03:00
parent a4c6165094
commit 5d7d7c0822
8 changed files with 16 additions and 11 deletions

View file

@ -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;

View file

@ -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);

View file

@ -4,6 +4,7 @@
#include "maths.h"
#include "TEdgeSegment.h"
#include "TPinballTable.h"
#include "TBall.h"
TCollisionComponent::TCollisionComponent(TPinballTable* table, int groupIndex, bool createWall) :

View file

@ -1,9 +1,9 @@
#pragma once
#include "TPinballComponent.h"
#include "TBall.h"
struct vector2;
class TEdgeSegment;
class TBall;
class TCollisionComponent : public TPinballComponent
{

View file

@ -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};
}

View file

@ -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<gdrv_bitmap8*>* ListBitmap;
std::vector<zmap_header_type*>* ListZMap;
vector2 Coordinates;
private:
float VisualPosNormX;
float VisualPosNormY;
};

View file

@ -6,7 +6,6 @@ class TSound :
{
public:
TSound(TPinballTable* table, int groupIndex);
float Play();
float Play(TPinballComponent *soundSource, const char* info);
int SoundIndex;

View file

@ -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);