Jump to content

  • Log In with Google      Sign In   
  • Create Account


creating Enemy Bots


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 F-117   Members   -  Reputation: 105

Like
0Likes
Like

Posted 23 April 2013 - 08:32 AM

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

  



Sponsor:

#2 matrisking   Members   -  Reputation: 282

Like
0Likes
Like

Posted 23 April 2013 - 02:18 PM

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. 






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS