• Advertisement
Sign in to follow this  

creating Enemy Bots

This topic is 1735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am a software developer but have recently learning to develop game, I know how to move a char in an applet animate it and even create bots

(basic stuff) but i fail to understand how to bring in bots randomly (like cars appearing in a racing game). All beginners tutorials I look into are about animation or keyboard/mouse interface. What and where should I look into... 

  

Share this post


Link to post
Share on other sites
Advertisement

It's tough to say without knowing a little bit more about how things are structured, but my first thought would be to do something like this:

 

Set a variable that represents the odds a bot should appear in a given game frame, let's say it should be 0.1%, so:

 

BOT_SPAWN_CHANCE = 1

 

Then, somewhere in your main game loop, just run pick a random number between 0 and 999, let's call it "r", and spawn a bot if r is less than the spawn chance:

 

if ( r < BOT_SPAWN_CHANCE )

  spawn_bot()

 

This is a pretty basic way of doing it but maybe it will work for you. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement