From a5d8b148782f401357349684954afe670ca45dd6 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 4 Aug 2006 21:37:18 +0000 Subject: Paddle can no longer move out of bounds git-svn-id: svn://mattst88.com/svn/glpong3d/trunk@9 4dd1920e-271a-0410-bca0-81b404a81564 --- glpong3d.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3