The Partridge Family were neither partridges nor a family. Discuss.
-
SkyBlizard
- Posts: 2
- Joined: September 21st, 2017, 9:55 am
Post
by SkyBlizard » September 21st, 2017, 9:58 am
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));
}
-
Yumtard
- Posts: 575
- Joined: January 19th, 2017, 10:28 pm
- Location: Idiot from northern Europe
Post
by Yumtard » September 21st, 2017, 10:26 am
You're doing if (wnd.kbd.KeyIsPressed(VK_LEFT)) twice bro
Change second one to VK_UP
-
SkyBlizard
- Posts: 2
- Joined: September 21st, 2017, 9:55 am
Post
by SkyBlizard » September 21st, 2017, 10:46 am
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..
-
Yumtard
- Posts: 575
- Joined: January 19th, 2017, 10:28 pm
- Location: Idiot from northern Europe
Post
by Yumtard » September 21st, 2017, 2:19 pm
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;
}
-
chili
- Site Admin
- Posts: 3948
- Joined: December 31st, 2011, 4:53 pm
- Location: Japan
-
Contact:
Post
by chili » September 21st, 2017, 2:28 pm
Truth.
Chili