Skip to content

Commit

Permalink
reduced lag of sound_fx
Browse files Browse the repository at this point in the history
  • Loading branch information
knela96 committed Apr 9, 2018
1 parent cd5fd16 commit cfb73d4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
Binary file modified Game/XMultiply.exe
Binary file not shown.
Binary file modified Game/XMultiply.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions ModuleAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ bool ModuleAudio::Init()

else {

int init = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096); // frequency, Uint16 format, channel, chunksize

//int init = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096); // frequency, Uint16 format, channel, chunksize
int init = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 1024); //Reduces buffer and lag of the sound_fx
if (init == -1)
{
LOG("Could not initialize Mixer lib. Mix_Init: %s", Mix_GetError());
Expand Down
8 changes: 8 additions & 0 deletions ModuleInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ update_status ModuleInput::PreUpdate()
if(keyboard[SDL_SCANCODE_ESCAPE])
return update_status::UPDATE_STOP;

SDL_PumpEvents();
while (SDL_PollEvent(&Events))
{
if (Events.type == SDL_QUIT) {
return update_status::UPDATE_STOP;
}
}

return update_status::UPDATE_CONTINUE;
}

Expand Down
1 change: 1 addition & 0 deletions ModuleInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ModuleInput : public Module

public:
KEY_STATE keyboard[MAX_KEYS];
SDL_Event Events;
};

#endif // __ModuleInput_H__
2 changes: 1 addition & 1 deletion ModuleWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool ModuleWindow::Init()
if(WIN_FULLSCREEN_DESKTOP == true)
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;

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

if(window == NULL)
{
Expand Down

0 comments on commit cfb73d4

Please sign in to comment.