Jump to content

  • Log In with Google      Sign In   
  • Create Account


TheResolute

Member Since 08 Feb 2012
Offline Last Active Mar 08 2013 12:24 PM
-----

Posts I've Made

In Topic: Constant buffer not working

10 February 2013 - 09:24 PM

Thank you for your help, I realized that I never called PSSetConstantBuffers(), so I fixed that and now everything is fine


In Topic: Why is it faster to develop in certain languages over others?

13 September 2012 - 10:34 PM

Thank you for these clarifications so far, and I would like to note that I asked this exact question on Stack Overflow and watched it be mocked and closed within minutes. Kudos to the GameDev.net community!

In Topic: Enemy shooting

30 August 2012 - 02:49 PM

Won't work.

So you have 30 enemies. Let us say I have killed the 2nd, 4th, 6th one. So 27 enemies left.

the rand() seeder will only give me a number from 0-27.
Meaning, if I get the number 0, 4, 6 those enemies will try to shoot but they are dead..
Also means the last 3 enemies will never be able to shoot a bullet.

You must have misread the code or I made a mistake, but it is not accessing the array using the random number as an index, it is iterating through the array and every time an enemy is alive, it decrements its counter and if the counter is zero, meaning that this enemy is the nth living one, it will then have it shoot

In Topic: Enemy shooting

30 August 2012 - 02:18 PM

EngineProgrammer provided a nice solution

Something far more simple would be to:
keep track of how many enemies are alive (variable initialized with number of enemies and decremented each time one dies);
using the same process he described to do this at certain intervals: generate a random number using the number of living enemies as your cap, and iterate through your enemies array, skipping dead ones, while decrementing the random number, and have the enemy shoot when your random number is 0
Hope that makes sense Posted Image

Some pseudo code could help:
int totalEnemies = 30;
int livingEnemies = totalEnemies;
Enemy[30] enemies;

// in code region dealing with enemy death
livingEnemies--;
//

// on iterval for enemy to shoot
if(livingEnemies > 0)
{
	 int randNum = Math.Rand(0, livingEnemies);  // generates a random integer between bounds, lower exclusive, upper inclusive
	 for(int i = 0; i < totalEnemies; i++)
	 {
		  if(enemies[i].isAlive)
		  {
			   randNum--;
			   if(randNum == 0)
			   {
					// Enemy shoots
			   }
		  }
	 }
}
//

In Topic: XNA Frame animation problem

29 August 2012 - 11:46 AM

Please include some more detail about your problem to be clear

However, I will attempt to help at this point based on what I think is happening
If your sprite normally moves around by player input or AI or something like that, all you would have to do is: add a isPlayingAnimation variable to your code an relate it to your sprite somehow; add a statement to the code that begins an animation to set that variable to true; and include a condition in its movement code that checks whether it is playing an animation, and doesn't execute movement if it is

Another thing that occurred to me is that your is constantly on an animation loop, and you want to stop it during a certain part of that animation; in that case, you would add a counter to its movement code that increments every frame, is reset when the animation restarts, and then a condition to the code that prevents movement when the counter is in a certain range

Hopefully you will find at least some of that helpful

PARTNERS