diff options
-rw-r--r-- | glpong3d.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -64,7 +64,6 @@ void GLPong_Init() { temp = IMG_Load("ball.png");
SDL_WM_SetIcon(temp, NULL);
SDL_FreeSurface(temp);
- SDL_ShowCursor(SDL_DISABLE);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
@@ -150,7 +149,15 @@ void GLPong_HandleEvents() { key = SDL_GetKeyState(NULL);
SDL_GetMouseState(&x, &y);
GLPong.Mouse.x = ((float) x / GLPong.w) * 3.3f - 1.65f;
+ if (GLPong.Mouse.x <= -1.5 + (GLPong.Front.w / 2))
+ GLPong.Mouse.x = -1.5 + (GLPong.Front.w / 2);
+ else if (GLPong.Mouse.x >= 1.5 - (GLPong.Front.w / 2))
+ GLPong.Mouse.x = 1.5 - (GLPong.Front.w / 2);
GLPong.Mouse.y = ((float) y / GLPong.h) * 2.5f - 1.25f;
+ if (GLPong.Mouse.y <= -1.0 + (GLPong.Front.h / 2))
+ GLPong.Mouse.y = -1.0 + (GLPong.Front.h / 2);
+ else if (GLPong.Mouse.y >= 1.0 - (GLPong.Front.h / 2))
+ GLPong.Mouse.y = 1.0 - (GLPong.Front.h / 2);
printf("SDL x,y: %d,%d; OpenGL x,y: %f,%f\n", x, y, GLPong.Mouse.x, GLPong.Mouse.y);
}
|