summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2006-08-04 21:37:18 +0000
committerMatt Turner <mattst88@gmail.com>2006-08-04 21:37:18 +0000
commita5d8b148782f401357349684954afe670ca45dd6 (patch)
treee195c7acff45ff5dbd2385ba51aa32482093ecf1
parent4dad8cc6605fc7e01386ae2a0bb4dc061b64fd5f (diff)
Paddle can no longer move out of bounds
git-svn-id: svn://mattst88.com/svn/glpong3d/trunk@9 4dd1920e-271a-0410-bca0-81b404a81564
-rw-r--r--glpong3d.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/glpong3d.c b/glpong3d.c
index 9fb1d42..26d09d9 100644
--- a/glpong3d.c
+++ b/glpong3d.c
@@ -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);
}