I am kinda new in game programming, but I've got a semestral work to make a game, so I decided to do a clone of Geometry Wars. Despite that the game is really simple (in principle), I have ran into a problem I can not solve. I use SDL, OpenGL in C (vanilla C, so no C++/C# and stuff, only procedural ANSI (I think ANSI) C). When I get input from joystick, it is fine in the console (if I flush it to the output, it will make immediate action) but when I draw a simple dot (it shouldn't be that time consuming to draw a dot on screen) it have a slight to severe input lag (up to 3 sec.). But that's only the first part of my problem, because it not only renders slow, the movement is totally different from that I make with joystick. Here is the code:
void pollInput()
{
SDL_JoystickUpdate ();
SDL_PollEvent(&event);
double XYValue;
if ( ( event.jaxis.value < -3200 ) || (event.jaxis.value > 3200 ) )
{
if( event.jaxis.axis == 0)
{
XYValue = event.jaxis.value / 2500.0;
XYValue = floor(XYValue);
player.playerX += (XYValue);
printf("X: %.0lf\n", XYValue);
}
if( event.jaxis.axis == 1)
{
XYValue = event.jaxis.value / 2500.0;
XYValue = floor(XYValue);
player.playerY += (-XYValue);
printf("Y: %.0lf\n", XYValue);
}
}
}
I am really stuck here. And another question came to my mind, is it a good idea to add the input from joystick to the XY coords of the player? Shouldn't I make it like acceleration? If yes, would you kindly write a pseudocode for that? Thank you for your replies guys!