Skip to content

Commit

Permalink
targeting can be controlled with right mouse button
Browse files Browse the repository at this point in the history
  • Loading branch information
theZiz committed Apr 27, 2017
1 parent 701a08c commit ed1257f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
5 changes: 1 addition & 4 deletions ToDo
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
* Mouse support
* In game ;)
* left button moves hare (arrow left and right replacement)
* right button sets shooting direction (arrow up and down replacement)

38 changes: 33 additions & 5 deletions hase.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,17 +1179,45 @@ int calc(Uint32 steps)
{
if (player[active_player]->activeHare)
{
weapon_button[1].pressed = 1;
mx -= screen->w/2;
my -= screen->h/2;
weapon_button[1].pressed = 1;
Sint32 rot = -(player[active_player]->activeHare->cam_rotation + rotation);
int nx = spCos(rot) * mx - spSin(rot) * my >> SP_ACCURACY;
//int ny = spSin(rot) * mx + spCos(rot) * my >> SP_ACCURACY;
if (nx < 0)
spGetInput()->axis[0] = -1;
if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT))
{
if (nx < 0)
spGetInput()->axis[1] = -1;
else
if (nx > 0)
spGetInput()->axis[1] = +1;
/*Sint32 ox = -spSin(
player[active_player]->activeHare->cam_rotation+
player[active_player]->activeHare->w_direction-SP_PI/2
);
Sint32 oy = spCos(
player[active_player]->activeHare->cam_rotation+
player[active_player]->activeHare->w_direction-SP_PI/2
) ;
Sint32 nx = spMul(ox,spCos(rotation))-spMul(oy,spSin(rotation));
Sint32 ny = spMul(ox,spSin(rotation))+spMul(oy,spCos(rotation));
Sint32 l = spSqrt(mx*mx+my*my<<SP_HALF_ACCURACY)<<SP_HALF_ACCURACY/2;
if (l)
{
mx = spDiv(mx << SP_ACCURACY,l);
my = spDiv(my << SP_ACCURACY,l);
}
printf("%.3f %.3f - %.3f %.3f - %.3f\n",spFixedToFloat(nx),spFixedToFloat(ny),spFixedToFloat(mx),spFixedToFloat(my),spFixedToFloat(l));*/
}
else
if (nx > 0)
spGetInput()->axis[0] = +1;
{
if (nx < 0)
spGetInput()->axis[0] = -1;
else
if (nx > 0)
spGetInput()->axis[0] = +1;
}
}
}
}
Expand Down

0 comments on commit ed1257f

Please sign in to comment.