how to create the stochastic enemy ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jarful

how to create the stochastic enemy ?

Post 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!!
jarful

Post by jarful »

i know this question is very easy.
but i dont know how to start.
which function to use?
BlackNinjaGames
Posts: 31
Joined: Mon Sep 05, 2005 4:47 pm
Contact:

Post 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?
Guest

Post 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...
jarful

Post 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!!
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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
  }
}
jarful

Post by jarful »

oh i see :D

thank you for your help!!

i will try it!!
Post Reply