Skip to content

Commit cfb73d4

Browse files
committed
reduced lag of sound_fx
1 parent cd5fd16 commit cfb73d4

File tree

6 files changed

+12
-3
lines changed

6 files changed

+12
-3
lines changed

Game/XMultiply.exe

0 Bytes
Binary file not shown.

Game/XMultiply.zip

-24 MB
Binary file not shown.

ModuleAudio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ bool ModuleAudio::Init()
3434

3535
else {
3636

37-
int init = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096); // frequency, Uint16 format, channel, chunksize
38-
37+
//int init = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096); // frequency, Uint16 format, channel, chunksize
38+
int init = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 1024); //Reduces buffer and lag of the sound_fx
3939
if (init == -1)
4040
{
4141
LOG("Could not initialize Mixer lib. Mix_Init: %s", Mix_GetError());

ModuleInput.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ update_status ModuleInput::PreUpdate()
5555
if(keyboard[SDL_SCANCODE_ESCAPE])
5656
return update_status::UPDATE_STOP;
5757

58+
SDL_PumpEvents();
59+
while (SDL_PollEvent(&Events))
60+
{
61+
if (Events.type == SDL_QUIT) {
62+
return update_status::UPDATE_STOP;
63+
}
64+
}
65+
5866
return update_status::UPDATE_CONTINUE;
5967
}
6068

ModuleInput.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ModuleInput : public Module
3131

3232
public:
3333
KEY_STATE keyboard[MAX_KEYS];
34+
SDL_Event Events;
3435
};
3536

3637
#endif // __ModuleInput_H__

ModuleWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool ModuleWindow::Init()
4343
if(WIN_FULLSCREEN_DESKTOP == true)
4444
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
4545

46-
window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
46+
window = SDL_CreateWindow("XMultiply - v0.3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
4747

4848
if(window == NULL)
4949
{

0 commit comments

Comments
 (0)