• Create Account

### #ActualFantasyVII

Posted 29 October 2012 - 08:49 AM

Not sure what you did to solve this, but what I would do is have the ShootAt function only called at the time of shooting and the details of what it should shoot at stored in a bullet class. Then just loop over all bullets and call an update function where each one is heading towards its stored off target.

I just can't get my mind around it. Starting to hate this project because of this.

Yeah, that was my idea... but that was too easy of a solution so I wanted to clarify. Looks like it is taken care of.

(I forgot to ask my usual first question... "did you trace your code?")

the problem is I can't use the ShootAt function only when I shoot because I need to keep track of where is the enemy position. So I need to call it every update. The solution I found was to create a bullet list for each enemy and when the enemy is in rage let that list only shoot at him. the problem is that its very messy and looks very bad. I need another solution but I don't know what.

		List<Bullet> Bullets1;
List<Bullet> Bullets2;
List<Bullet> Bullets3;
List<Bullet> Bullets4;
List<Bullet> Bullets5;
List<Bullet> Bullets6;
List<Bullet> Bullets7;
List<Bullet> Bullets8;
List<Bullet> Bullets9;
List<Bullet> Bullets10;


And I do this 10 times which is very very wrong and bad and messy.
if(enemyManager.enemy.Count > 0)
{
if (IsInRange(enemyManager, 0))
{
Time = (float)gameTime.TotalGameTime.TotalMilliseconds;
deltaTime = Time - LastTime;
if (deltaTime > (1000 / AttackSpeed))
{
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].Initialize(graphics);
for (int i = 0; i < Bullets1.Count; i++)
LastTime = Time;
}
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].SetBulletPosition(Position);
}
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].ShootAt(gameTime, enemyManager.enemy[0].Position, Bullets1[i].GetPosition() + Bullets1[i].GetVelocity());

for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].Update();
}


### #2FantasyVII

Posted 29 October 2012 - 08:46 AM

Not sure what you did to solve this, but what I would do is have the ShootAt function only called at the time of shooting and the details of what it should shoot at stored in a bullet class. Then just loop over all bullets and call an update function where each one is heading towards its stored off target.

Yeah, that was my idea... but that was too easy of a solution so I wanted to clarify. Looks like it is taken care of.

(I forgot to ask my usual first question... "did you trace your code?")

the problem is I can't use the ShootAt function only when I shoot because I need to keep track of where is the enemy position. So I need to call it every update. The solution I found was to create a bullet list for each enemy and when the enemy is in rage let that list only shoot at him. the problem is that its very messy and looks very bad. I need another solution but I don't know what.

		List<Bullet> Bullets1;
List<Bullet> Bullets2;
List<Bullet> Bullets3;
List<Bullet> Bullets4;
List<Bullet> Bullets5;
List<Bullet> Bullets6;
List<Bullet> Bullets7;
List<Bullet> Bullets8;
List<Bullet> Bullets9;
List<Bullet> Bullets10;


And I do this 10 times which is very very wrong and bad and messy.
if(enemyManager.enemy.Count > 0)
{
if (IsInRange(enemyManager, 0))
{
Time = (float)gameTime.TotalGameTime.TotalMilliseconds;
deltaTime = Time - LastTime;
if (deltaTime > (1000 / AttackSpeed))
{
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].Initialize(graphics);
for (int i = 0; i < Bullets1.Count; i++)
LastTime = Time;
}
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].SetBulletPosition(Position);
}
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].ShootAt(gameTime, enemyManager.enemy[0].Position, Bullets1[i].GetPosition() + Bullets1[i].GetVelocity());

for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].Update();
}


### #1FantasyVII

Posted 29 October 2012 - 08:46 AM

Not sure what you did to solve this, but what I would do is have the ShootAt function only called at the time of shooting and the details of what it should shoot at stored in a bullet class. Then just loop over all bullets and call an update function where each one is heading towards its stored off target.

Yeah, that was my idea... but that was too easy of a solution so I wanted to clarify. Looks like it is taken care of.

(I forgot to ask my usual first question... "did you trace your code?")

the problem is I can't use the ShootAt function only when I shoot because I need to keep track of where is the enemy position. The solution I found was to create a bullet list for each enemy and when the enemy is in rage let that list only shoot at him. the problem is that its very messy and looks very bad. I need another solution but I don't know what.

        List<Bullet> Bullets1;
List<Bullet> Bullets2;
List<Bullet> Bullets3;
List<Bullet> Bullets4;
List<Bullet> Bullets5;
List<Bullet> Bullets6;
List<Bullet> Bullets7;
List<Bullet> Bullets8;
List<Bullet> Bullets9;
List<Bullet> Bullets10;


And I do this 10 times which is very very wrong and bad and messy.
if(enemyManager.enemy.Count > 0)
{
if (IsInRange(enemyManager, 0))
{
Time = (float)gameTime.TotalGameTime.TotalMilliseconds;
deltaTime = Time - LastTime;
if (deltaTime > (1000 / AttackSpeed))
{
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].Initialize(graphics);
for (int i = 0; i < Bullets1.Count; i++)
LastTime = Time;
}
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].SetBulletPosition(Position);
}
for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].ShootAt(gameTime, enemyManager.enemy[0].Position, Bullets1[i].GetPosition() + Bullets1[i].GetVelocity());

for (int i = 0; i < Bullets1.Count; i++)
Bullets1[i].Update();
}


PARTNERS