Page 1 of 1
how to create the stochastic enemy ?
Posted: Sat Oct 15, 2005 12:03 pm
by jarful
hi! friends!!
how can i create the enemy in a random way?
just like fighter plane in the game ,fly to you.
which function should i use ?
i am newbie please help me.
thank you!!
Posted: Sat Oct 15, 2005 3:24 pm
by jarful
i know this question is very easy.
but i dont know how to start.
which function to use?
Posted: Sat Oct 15, 2005 4:13 pm
by BlackNinjaGames
You just need to wait for the correct audience.
What are you trying to do? Create a plane then have it fly to you?
Posted: Sat Oct 15, 2005 11:20 pm
by Guest
how can i create the enemy in a random way?
If I read your question correctly, you're not going to make it happen with a single "built in" function. It's going to be a collection of functions and procedures. And there are going to be many ways of doing it, depending on what you're trying to achieve.
I would suggest you read the Irrlicht docs and study the examples more...
Posted: Sun Oct 16, 2005 1:44 am
by jarful
hi thank you!!
i love this forum.
i am chinese,so my meaning express in a difficult way
i use (gettimer()->gettime()%50) ,but when this condition happen then create a lot of plane and they not random.
i want to find a condition,when it happen the plane will be create.
the condition will happen in a random way.
i dont know if i have say my question expressly
thank you for your help!!
Posted: Sun Oct 16, 2005 5:46 am
by bitplane
you want to use rand to get a random number.
here's one way of doing it...
Code: Select all
#include <stdlib.h> // include rand
// first you set the 'seed'
// each seed gives a different sequence of numbers
// setting it to the timer makes it seem more random
srand(getTimer()->getTime());
// we need to control the frequency of the check
if (one_second_has_passed)
{
// rand() gives a random number
if (rand() % 100 < 5) // 5% chance
{
// new enemy every (100/5=)20 seconds on average
}
}
Posted: Sun Oct 16, 2005 6:08 am
by jarful
oh i see
thank you for your help!!
i will try it!!