Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#Actualdakeeper1995

Posted 05 October 2012 - 07:34 AM

Hey guys, first post here.

I have a slight problem with my camera right now. When I press the right or left keys (A/D), the screen jumps in that direction(by a lot more then just the key press), movement goes as planned, and when the key is released the screen jumps back to where it would've been. Here's the relevant pieces of code:

The message loop:
while( msg.message != WM_QUIT )
			{
			   if ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
				{
					 if (msg.message==WM_KEYDOWN) OnKeyDown(msg.wParam);
					 else if (msg.message==WM_KEYUP) OnKeyUp(msg.wParam);
					 else{
						 TranslateMessage( &msg );
						 DispatchMessage( &msg );
					  }
				 }
			  
				 else Render();
			  }

void OnKeyDown(WPARAM key){
	 switch (key){
		  case 0x41:
				 ak=TRUE;
				 break;
		   case 0x53:
				 sk=TRUE;
				 break;
		  case 0x44:
				  dk=TRUE;
				  break;
		  case 0x57:
				  wk=TRUE;
				   break;
		   default:
					break;
	 }
}
void OnKeyUp(WPARAM key){
   switch (key){
	   case 0x41:
			  ak=FALSE;
			  break;
	   case 0x53:
			   sk=FALSE;
			   break;
	   case 0x44:
				dk=FALSE;
				 break;
	   case 0x57:
				wk=FALSE;
			   break;
		default:
				break;
   }

}

if (ak==TRUE) EyePt-=sideVector;
if (sk==TRUE) EyePt-=CurrentView
if (dk==TRUE) EyePt+=sideVector;
if(wk==TRUE) EyePt+=CurrentView;

I'm working on implementing a camera class, but right now I'm very confused as to why my camera jumps whenever the A/D buttons are pressed. SOrry for the messy coding.

#4dakeeper1995

Posted 05 October 2012 - 07:33 AM

Hey guys, first post here.

I have a slight problem with my camera right now. When I press the right or left keys (A/D), the screen jumps in that direction(by a lot more then just the key press), movement goes as planned, and when the key is released the screen jumps back to where it would've been. Here's the relevant pieces of code:

The message loop:
while( msg.message != WM_QUIT )
			{
			   if ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
				{
					 if (msg.message==WM_KEYDOWN) OnKeyDown(msg.wParam);
					 else if (msg.message==WM_KEYUP) OnKeyUp(msg.wParam);
					 else{
						 TranslateMessage( &msg );
						 DispatchMessage( &msg );
					  }
				 }
			  
				 else Render();
			  }

void OnKeyDown(WPARAM key){
	 switch (key){
		  case 0x41:
				 ak=TRUE;
				 break;
		   case 0x53:
				 sk=TRUE;
				 break;
		  case 0x44:
				  dk=TRUE;
				  break;
		  case 0x57:
				  wk=TRUE;
				   break;
		   default:
					break;
	 }
}
void OnKeyUp(WPARAM key){
   switch (key){
	   case 0x41:
			  ak=FALSE;
			  break;
	   case 0x53:
			   sk=FALSE;
			   break;
	   case 0x44:
				dk=FALSE;
				 break;
	   case 0x57:
				wk=FALSE;
			   break;
		default:
				break;
   }

}

if (ak==TRUE) EyePt-=sideVector;
if (sk==TRUE) EyePt-=CurrentView
if (dk==TRUE) EyePt+=sideVector;
if(wk==TRUE) EyePt+=CurrentView;

I'm working on implementing a camera class, but right now I'm very confused as to why my camera jumps whenever the A/D buttons are pressed. SOrry for the messy coding.

#3dakeeper1995

Posted 05 October 2012 - 07:32 AM

Hey guys, first post here.

I have a slight problem with my camera right now. When I press the right or left keys (A/D), the screen jumps in that direction, movement goes as planned, and when the key is released the screen jumps back. Here's the relevant pieces of code:

The message loop:
while( msg.message != WM_QUIT )
			{
			   if ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
				{
                     if (msg.message==WM_KEYDOWN) OnKeyDown(msg.wParam);
                     else if (msg.message==WM_KEYUP) OnKeyUp(msg.wParam);
                     else{
                         TranslateMessage( &msg );
                         DispatchMessage( &msg );
                      }
                 }
			  
                 else Render();
              }

void OnKeyDown(WPARAM key){
     switch (key){
          case 0x41:
                 ak=TRUE;
                 break;
           case 0x53:
                 sk=TRUE;
                 break;
          case 0x44:
                  dk=TRUE;
                  break;
          case 0x57:
                  wk=TRUE;
                   break;
           default:
                    break;
     }
}
void OnKeyUp(WPARAM key){
   switch (key){
       case 0x41:
              ak=FALSE;
              break;
       case 0x53:
               sk=FALSE;
               break;
       case 0x44:
                dk=FALSE;
                 break;
       case 0x57:
                wk=FALSE;
               break;
        default:
                break;
   }

}

if (ak==TRUE) EyePt-=sideVector;
if (sk==TRUE) EyePt-=CurrentView
if (dk==TRUE) EyePt+=sideVector;
if(wk==TRUE) EyePt+=CurrentView;

I'm working on implementing a camera class, but right now I'm very confused as to why my camera jumps whenever the A/D buttons are pressed. SOrry for the messy coding.

#2dakeeper1995

Posted 05 October 2012 - 07:27 AM

Hey guys, first post here.

I have a slight problem with my camera right now. When I press the right or left keys (A/D), the screen jumps in that direction, movement goes as planned, and when the key is released the screen jumps back. Here's the relevant pieces of code:

The message loop:
while( msg.message != WM_QUIT )
			{
			   if ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
				{
     if (msg.message==WM_KEYDOWN) OnKeyDown(msg.wParam);
	 else if (msg.message==WM_KEYUP) OnKeyUp(msg.wParam);
	 else{
					TranslateMessage( &msg );
					DispatchMessage( &msg );
	 }
				}
			  
					else Render();
			}

void OnKeyDown(WPARAM key){
switch (key){
case 0x41:
  ak=TRUE;
  break;
case 0x53:
  sk=TRUE;
  break;
case 0x44:
  dk=TRUE;
  break;
case 0x57:
  wk=TRUE;
  break;
case 0x1B:
  Cleanup();
  PostQuitMessage( 0 );
default:
  break;
}
}
void OnKeyUp(WPARAM key){
switch (key){
case 0x41:
  ak=FALSE;
  break;
case 0x53:
  sk=FALSE;
  break;
case 0x44:
  dk=FALSE;
  break;
case 0x57:
  wk=FALSE;
  break;
default:
  break;
}

}if (ak==TRUE){
  EyePt-=sideVector;
}
if (sk==TRUE){
  EyePt-=CurrentView;
}
if (dk==TRUE){
  EyePt+=sideVector;
}
if(wk==TRUE){
  EyePt+=CurrentView;
}

I'm working on implementing a camera class, but right now I'm very confused as to why my camera jumps whenever the A/D buttons are pressed. SOrry for the messy coding.

#1dakeeper1995

Posted 05 October 2012 - 07:25 AM

Hey guys, first post here.

I have a slight problem with my camera right now. When I press the right or left arrow keys, the screen jumps in that direction, movement goes as planned, and when the key is released the screen jumps back. Here's the relevant pieces of code:

The message loop:
while( msg.message != WM_QUIT )
		    {
			   if ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
			    {
	 if (msg.message==WM_KEYDOWN) OnKeyDown(msg.wParam);
	 else if (msg.message==WM_KEYUP) OnKeyUp(msg.wParam);
	 else{
				    TranslateMessage( &msg );
				    DispatchMessage( &msg );
	 }
			    }
			   
				    else Render();
		    }

void OnKeyDown(WPARAM key){
switch (key){
case 0x41:
  ak=TRUE;
  break;
case 0x53:
  sk=TRUE;
  break;
case 0x44:
  dk=TRUE;
  break;
case 0x57:
  wk=TRUE;
  break;
case 0x1B:
  Cleanup();
  PostQuitMessage( 0 );
default:
  break;
}
}
void OnKeyUp(WPARAM key){
switch (key){
case 0x41:
  ak=FALSE;
  break;
case 0x53:
  sk=FALSE;
  break;
case 0x44:
  dk=FALSE;
  break;
case 0x57:
  wk=FALSE;
  break;
default:
  break;
}

}if (ak==TRUE){
  EyePt-=sideVector;
}
if (sk==TRUE){
  EyePt-=CurrentView;
}
if (dk==TRUE){
  EyePt+=sideVector;
}
if(wk==TRUE){
  EyePt+=CurrentView;
}

I'm working on implementing a camera class, but right now I'm very confused as to why my camera jumps whenever the A/D buttons are pressed.

PARTNERS