Page 1 of 1

Episode 4.3 messed UP PLEASE HELP

Posted: September 21st, 2017, 9:58 am
by SkyBlizard
Hello i did everything correctly and the reticle moves only UPWARDS AND RIGHT SIDE
Its not moving Left and Down side...help me..

Code: Select all

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));
}

	

Re: Episode 4.3 messed UP PLEASE HELP

Posted: September 21st, 2017, 10:26 am
by Yumtard
You're doing if (wnd.kbd.KeyIsPressed(VK_LEFT)) twice bro

Change second one to VK_UP

Re: Episode 4.3 messed UP PLEASE HELP

Posted: September 21st, 2017, 10:46 am
by SkyBlizard
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..

Re: Episode 4.3 messed UP PLEASE HELP

Posted: September 21st, 2017, 2:19 pm
by Yumtard
well you never mentioned that was a problem..

You're forgetting to set your inhibits to false.

Code: Select all

 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: Select all

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

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

Re: Episode 4.3 messed UP PLEASE HELP

Posted: September 21st, 2017, 2:28 pm
by chili
Truth.