mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2023-12-30 21:52:56 +00:00
Tweaked ball mouse control cheat.
This commit is contained in:
parent
69ecce88df
commit
5947727f80
@ -201,11 +201,13 @@ void pb::replay_level(int demoMode)
|
||||
MainTable->Message(1014, static_cast<float>(options::Options.Players));
|
||||
}
|
||||
|
||||
void pb::ballset(int x, int y)
|
||||
void pb::ballset(float dx, float dy)
|
||||
{
|
||||
// dx and dy are normalized to window, ideally in [-1, 1]
|
||||
static constexpr float sensitivity = 7000;
|
||||
TBall* ball = MainTable->BallList.at(0);
|
||||
ball->Acceleration.X = x * 30.0f;
|
||||
ball->Acceleration.Y = y * 30.0f;
|
||||
ball->Acceleration.X = dx * sensitivity;
|
||||
ball->Acceleration.Y = dy * sensitivity;
|
||||
ball->Speed = maths::normalize_2d(&ball->Acceleration);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
static void mode_change(int mode);
|
||||
static void toggle_demo();
|
||||
static void replay_level(int demoMode);
|
||||
static void ballset(int x, int y);
|
||||
static void ballset(float dx, float dy);
|
||||
static void frame(float dtMilliSec);
|
||||
static void timed_frame(float timeNow, float timeDelta, bool drawBalls);
|
||||
static void window_size(int* width, int* height);
|
||||
|
@ -212,10 +212,18 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||
{
|
||||
if (mouse_down)
|
||||
{
|
||||
int x, y;
|
||||
int x, y, w, h;
|
||||
SDL_GetMouseState(&x, &y);
|
||||
pb::ballset(last_mouse_x - x, y - last_mouse_y);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
float dx = (last_mouse_x - x) / static_cast<float>(w);
|
||||
float dy = (y - last_mouse_y) / static_cast<float>(h);
|
||||
pb::ballset(dx, dy);
|
||||
|
||||
SDL_WarpMouseInWindow(window, last_mouse_x, last_mouse_y);
|
||||
|
||||
// Mouse warp does not work over remote desktop or in some VMs
|
||||
//last_mouse_x = x;
|
||||
//last_mouse_y = y;
|
||||
}
|
||||
if (!single_step)
|
||||
{
|
||||
@ -560,7 +568,6 @@ int winmain::event_handler(const SDL_Event* event)
|
||||
if (mouse_down)
|
||||
{
|
||||
mouse_down = 0;
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
SDL_SetWindowGrab(MainWindow, SDL_FALSE);
|
||||
}
|
||||
switch (event->type)
|
||||
@ -665,7 +672,6 @@ int winmain::event_handler(const SDL_Event* event)
|
||||
mouse_down = 1;
|
||||
last_mouse_x = event->button.x;
|
||||
last_mouse_y = event->button.y;
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_SetWindowGrab(MainWindow, SDL_TRUE);
|
||||
}
|
||||
else
|
||||
@ -689,7 +695,6 @@ int winmain::event_handler(const SDL_Event* event)
|
||||
if (mouse_down)
|
||||
{
|
||||
mouse_down = 0;
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
SDL_SetWindowGrab(MainWindow, SDL_FALSE);
|
||||
}
|
||||
if (!pb::cheat_mode)
|
||||
|
Loading…
Reference in New Issue
Block a user