Window shaking

This commit is contained in:
Mathew Velasquez 2016-10-29 22:21:43 -04:00
parent 01b4e7e2a0
commit 50d64ea060
2 changed files with 21 additions and 2 deletions

View file

@ -3,6 +3,9 @@
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
#include "eventthread.h"
#include <SDL.h>
RB_METHOD(oneshotSetYesNo)
{
@ -48,6 +51,21 @@ RB_METHOD(oneshotAllowExit)
return Qnil;
}
RB_METHOD(oneshotShake)
{
RB_UNUSED_PARAM;
int absx, absy;
SDL_GetWindowPosition(shState->rtData().window, &absx, &absy);
srand(time(NULL));
for (int i = 0; i < 60; ++i) {
int max = 60 - i;
int x = rand() % (max * 2) - max;
int y = rand() % (max * 2) - max;
SDL_SetWindowPosition(shState->rtData().window, absx + x, absy + y);
}
return Qnil;
}
void oneshotBindingInit()
{
VALUE module = rb_define_module("Oneshot");
@ -69,4 +87,5 @@ void oneshotBindingInit()
_rb_define_module_function(module, "reset_obscured", oneshotResetObscured);
_rb_define_module_function(module, "obscured_cleared?", oneshotObscuredCleared);
_rb_define_module_function(module, "allow_exit", oneshotAllowExit);
_rb_define_module_function(module, "shake", oneshotShake);
}

View file

@ -13,7 +13,7 @@ static void start()
ipc.open("oneshot-pipe", Pipe::Write);
// Create process
#ifdef _WIN32
#if defined _WIN32
WCHAR path[MAX_PATH];
WCHAR gameFolder[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, shState->config().gameFolder.c_str(), -1, gameFolder, MAX_PATH);
@ -28,7 +28,7 @@ static void start()
CreateProcessW(path, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
delete [] args;
#else
#ifdef linux
#if defined __linux
char path[PATH_MAX];
ssize_t len = readlink("/proc/self/exe", path, PATH_MAX);
if (len == -1)