c++ bullets

hey guys i am rather stupid with c++ so bare with me. i am a game developer learning c++.
anyway back to the point.
i am having issues creating bullets with vectors and matricies and make them move in were the appropriate direction of the tank's barrel node, the node is classified as node01 and vice vversa for player 2 except with a B at the end of node01. anyway i am having issues getting the bullet to move as it will only stay in its current position and trail with the tank. any idea's?


Bullet cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  #include "Bullet.h"
#include "Mat3.h"
#include "Vec2.h"
#include "Game.h"

Bullet::Bullet( Vec2 bulletPosition, float bulletDirection ) : Node()
{
	m_speed			= 100.0f;

	m_bulletTexture	= new Texture("./Images/bullet.png");
	m_bullet		= new StaticSprite( m_bulletTexture, Vec2( 15, 15 ) );

	AddChild(m_bullet);



}

Bullet::~Bullet()
{
	delete m_bullet;
	delete m_bulletTexture;

}

void Bullet::Update( float deltaTime )
{
	Mat3 transform;
	transform.CreateTranslation( 0, 100 * deltaTime );

	GetWorldTransform() = transform * GetWorldTransform();

	m_bullet->Update(deltaTime);

	Transform().Translate(Transform().GetRightRot()*m_speed*deltaTime , Transform().GetUpRot()*m_speed*deltaTime ); // heres the issue kids
}

void Bullet::Draw( SpriteBatch *sb )
{
	m_bullet->Draw(sb);

}



Game update code for the bullets themselves
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
	if((glfwGetKey(GetpWindow(), GLFW_KEY_SPACE ) ) &&  m_shootCooldown < 0.0f)	
		{
			Mat3 m_point = m_node1->GetWorldTransform();

			Bullet *b = new Bullet( m_point.GetTranslation(), m_point.GetUpRot() );
			Vec2 pos = (m_node1->GetWorldTransform().GetTranslation());
			b->Transform().Translate(pos.X,pos.Y );

			Shoot( b );
		}

	}
	for (std::list<Bullet *>::iterator it = m_bullets.begin(); it != m_bullets.end(); it++)
		{
			Bullet *pBulet = *it; 
			pBulet->Update(m_deltaTime);
			
			
		}





Game draw code for the bullets themselves
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 

	
		std::cout << "BEGIN LOOPING" << std::endl;
		for (std::list<Bullet *>::iterator it = m_bullets.begin(); it != m_bullets.end(); it++)
		{
			Bullet *pBulet = *it; 
			pBulet->Draw(m_spriteBatch);
			
			
		}
		std::cout << "END LOOPING" << std::endl;
		m_spriteBatch->End();
	}



any help would be greatly appreciated guys. i could upload the entire source code if you wish if this sounds rather confusing for some



Topic archived. No new replies allowed.