Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 5th Jul 2004 04:35
can someone give me a bit of code that makes the enemy shoot me ive done the est i just need him to shoot me so the bullet comes out of him and goes for a while then he shoots again pls thanks

i used to be indecisive but now ime not so sure
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 5th Jul 2004 15:21 Edited at: 5th Jul 2004 15:25
irish,
What you want is a function that handles fireing bullets with a bullet time.

The way you do it is;
1. Determine if the enemy should be shooting the player or not ( usually done with a simple distance check ) If true, continue;
2. Point the enemy at the player
3. Position a bullet ( the bullet would have been created before-hand out of a plain or cube ) at the end of the enemy's gun
4. Give the bullet a Bullet Life. This is what determins how long the bullet is "alive" for.
5. Set the bullet's moving flag to 1 ( just set a variable enemfire = 1 or something to that effect )
6. Each loop, check to see if the bullet is moving. If so, then move it a bit using the Move Object command.
7. Bullet life = Bullet life - 1
8. If the bullet life reaches zero, then the bullet has gone as far as it can go. Destroy ( or reposition ) the bullet, set it's moving flag to 0. Go to 10. Else, go to 9.
9. If Bullet collides with Player, player loses life, bullet life = zero, moving flag = 0. Else go to 6.
10. Repeat

Hopefully that helps some... But, I will not write the code for you, the best way to learn is to write it yourself, and if it doesn't do what you want it to do then post it up here and ask why it's not working.

Jess.

[EDIT] If you have lots of enemies at one time, it would be best if you set up an array to hold all the values, it would be much easier to code, and to handle withing loops


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Axelman
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 5th Jul 2004 18:27 Edited at: 5th Jul 2004 18:28
i think to make multiple enemies you would use a for next loop, like this:

for x = 1 to 10 ` or however many enemies you want
load object "Enemy.x",x
position object x RND(500),RND(500),RND(500)
next x


Then you would do all the stuff that jess said, but i'm not gonna write it either.

Anyways,
Cya Later,
Axelman.

P.S
When did you become a mod jess?

CURRENT PROJECT: Enemy At The Gates

Login to post a reply

Server time is: 2025-05-24 22:24:44
Your offset time is: 2025-05-24 22:24:44