# Why is my bullet disappearing after I release the shoot button?

I'm making a game using DirectXTK for my university project. When I press space bullet moves forward like I wanted, but when I let go it stops my bullet from moving. How do I keep the bullet moving when space was pressed?

void update
{
//shooting
if (kb.Space)
Shoot(true);
else
Shoot(false);
}
void Render()
{
if (draw)
{
for (int i = 0; i < 10; i++)
{
m_projectile[i]->Draw(m_bullet[i], m_view, m_proj, Colors::Red);
}
}
}
bool shoot(bool test)
{
shoot = test;
draw = true;

//bool isShot = false;
if (!shoot)
{
for (int i = 0; i < 10; i++)
{
m_bullet[i] = Matrix::CreateRotationY(m_ship._42) * m_ship;
}
}
else
{
m_bullet[0] = Matrix::CreateTranslation(-Vector3::Forward *float(1))*Matrix::CreateRotationY(0.f) * m_bullet[0];
//m_bullet *= Matrix::CreateTranslation(-Vector3::Forward);
}

return draw;
}

• It sounds like the code to move the bullet is in a function tied to the press-and-hold of the space-bar. Perhaps consider moving this code so that it runs after the space-bar is pressed rather than held down...? – Neil Hibbert Mar 16 '16 at 12:07

• Okay, I got that working, but only on one bullet. with using unique_ptr how do I create a new object? i cant get the examples from the internet to work – Przemek Hendel Mar 16 '16 at 16:55