Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post Posted: September 21st, 2017, 9:58 am 
 

Joined: September 21st, 2017, 9:55 am
Posts: 2
Hello i did everything correctly and the reticle moves only UPWARDS AND RIGHT SIDE
Its not moving Left and Down side...help me..
Code:
void Game::UpdateModel()
{
   if (wnd.kbd.KeyIsPressed(VK_RIGHT))
   {
      if (inhibitRight)
      {

      }
      else
      {
         vx = vx + 1;
         inhibitRight = true;
      }
   }
   if (wnd.kbd.KeyIsPressed(VK_LEFT))
   {
      if (inhibitLeft)
      {

      }
      else
      {
         vx = vx - 1;
         inhibitLeft = true;
      }
   }
   
   if (wnd.kbd.KeyIsPressed(VK_UP))
   {
      if (inhibitUp)
      {

      }
      else
      {
         vy = vy - 1;
         inhibitUp = true;
      }
   }

   if (wnd.kbd.KeyIsPressed(VK_LEFT))
   {
      if (inhibitLeft)
      {

      }
      else
      {
         vy = vy + 1;
         inhibitLeft = true;
      }
   }

   x = x + vx;
   y = y + vy;
   shapeischanged = (wnd.kbd.KeyIsPressed(VK_SHIFT));
}

   


Top 
 Profile  
Reply with quote  
 Post Posted: September 21st, 2017, 10:26 am 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 499
Location: Idiot from northern Europe
You're doing if (wnd.kbd.KeyIsPressed(VK_LEFT)) twice bro

Change second one to VK_UP

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: September 21st, 2017, 10:46 am 
 

Joined: September 21st, 2017, 9:55 am
Posts: 2
Yumtard wrote:
You're doing if (wnd.kbd.KeyIsPressed(VK_LEFT)) twice bro

Change second one to VK_UP

Thanks but its still not increasing its speed everytime i press a key..


Top 
 Profile  
Reply with quote  
 Post Posted: September 21st, 2017, 2:19 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 499
Location: Idiot from northern Europe
well you never mentioned that was a problem..

You're forgetting to set your inhibits to false.


Code:
 if (wnd.kbd.KeyIsPressed(VK_UP))
   {
      if (inhibitUp)
      {

      }
      else
      {
         vy = vy - 1;
         inhibitUp = true;
      }
   }



You're setting it to true, but it never becomes false again so you wont change the velocity next time you hit the button.

Instead you need to write

Code:
 if (wnd.kbd.KeyIsPressed(VK_UP))
   {
      if (inhibitUp)
      {

      }
      else
      {
         vy = vy - 1;
         inhibitUp = true;
      }
   }
   else
   {
      inhibitUp = false;
   }

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: September 21st, 2017, 2:28 pm 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3494
Location: Japan
Truth.

_________________
Chili


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 5 posts ] 

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: