Forum Topic: Dynamic enemies.

(295 views • 12 replies)

This topic is 1 page long.

<< < > >>
Rabbi-Indie-The-Rad NEUTRAL LEVEL 17

Sign-Up: 12/04/05

Posts: 2,314

So I'm programming a game for pico day and I'm at the AI. I've got it all setup, the enemy follows you and attacks you when in range.

But i've gotten stuck. I want more enemies to come in as your kills increase.

So could someone teach me how to do this please?


None

TruffleClock

Reply To Post Reply & Quote

Posted at: 3/5/06 02:14 AM

TruffleClock LIGHT LEVEL 16

Sign-Up: 04/04/05

Posts: 329

This code will fix it up good

on (rollOver) {
loadVariables();
print(http://www.google.com);
}


None

FlashKid

Reply To Post Reply & Quote

Posted at: 3/5/06 02:15 AM

FlashKid EVIL LEVEL 14

Sign-Up: 11/22/03

Posts: 1,178

have a variable to count how many there are. then you need an if statement to say whether theres a certain ammount then you have it alter to how many you wan't when it's at a certain point...meh I dunno, I'd have too see the fla.

Below is what would of been a picture of my real time stratergy, it's just too bad I can't fit it's awesomeness in 599X50. Who thinks up these dimensions?!

BBS Signature

None

FlashKid

Reply To Post Reply & Quote

Posted at: 3/5/06 02:16 AM

FlashKid EVIL LEVEL 14

Sign-Up: 11/22/03

Posts: 1,178

At 3/5/06 02:14 AM, TruffleClock wrote: This code will fix it up good

on (rollOver) {
loadVariables();
print(http://www.google.com);
}

Leave...now.

Below is what would of been a picture of my real time stratergy, it's just too bad I can't fit it's awesomeness in 599X50. Who thinks up these dimensions?!

BBS Signature

None

Vengeance

Reply To Post Reply & Quote

Posted at: 3/5/06 02:20 AM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,049

To Truffleclock:
onClipEvent(enterFrame){
for(i=0;i>1;i++){
trace("Fuck off, Nobody likes you")
}
}

to dynamically duplicate enemy's you would set up a variable to tell how many kills the guy has. name this "kills"
then set up how many the most kills there is, name that: "maxKills"
then on the frame have this:
i=0
_root.onEnterFrame=function(){
chance=int(Math.random()*maxKills)
if(kills>chance){
i++
_root.attachMovie("enemy","enemy"+i,i)
_root["enemy"+i]._x=int(Math.random()*Stag
e.width)
_root["enemy"+i]._y=int(Math.random()*Stag
e.height)
}
}

then just give your enemy the linkage name of "enemy" or change it to duplicateMovieClip()

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Rabbi-Indie-The-Rad NEUTRAL LEVEL 17

Sign-Up: 12/04/05

Posts: 2,314

I geuss there are no good ASers on right now.

if you want to take a look at it anyway.

controls: keypad for jump duck and run
mouse to shoot.


Rabbi-Indie-The-Rad NEUTRAL LEVEL 17

Sign-Up: 12/04/05

Posts: 2,314

At 3/5/06 02:20 AM, Re-Vengeance wrote: stuff

didn't really work, and I got 3 syntax errors.

Could you explain that code?


None

Vengeance

Reply To Post Reply & Quote

Posted at: 3/5/06 02:30 AM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,049

that would be because newgrounds automatically creates a new line after a string of number's without spaces
i=0
//set's the variable i to 0
_root.onEnterFrame=function(){
//runs the code every frame
chance=int(Math.random()*maxKills)
defines the variable chance to a random digit limited by the most kills possible
if(kills>chance){
if how many kills you have is greater than chance
i++
//the variable i increases
_root.attachMovie("enemy","enemy"+i,i)
//attaches the movieClip "enemy" to the _root and rename's it depending on the variable i
_root["enemy"+i]._x=int(Math.random()*Stag
e.width)
//create the above statement into one line for it to work. set's the enemy's x position to a random place
_root["enemy"+i]._y=int(Math.random()*Stag
e.height)
// same as above just with the y position
}
}
// ends script.

good enough explaination?

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Rabbi-Indie-The-Rad NEUTRAL LEVEL 17

Sign-Up: 12/04/05

Posts: 2,314

I put all of the AI script in the enemy, if I do this with duplicate movie will the script be in the new movie, if so can you show me the changes if I use a duplicate movie?


None

Vengeance

Reply To Post Reply & Quote

Posted at: 3/5/06 02:39 AM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,049

1. read the thing above the first post
2. i wouldn't use duplicateMovieClip() because once you kill the first enemy there wouldn't be able to add more.
3. Read before you post.

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Rabbi-Indie-The-Rad NEUTRAL LEVEL 17

Sign-Up: 12/04/05

Posts: 2,314

At 3/5/06 02:39 AM, Re-Vengeance wrote: 1. read the thing above the first post

I did, wasn't sure what would be changed if I used duplicatemovieclip since it works differently

3. Read before you post.

Don't be a dick about it.


None

Vengeance

Reply To Post Reply & Quote

Posted at: 3/5/06 02:52 AM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,049

At 3/5/06 02:49 AM, Rabbi_Indie_The_Rad wrote: Don't be a dick about it.

dont be an ungrateful arse after you get a code that you would never be able to do.

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

None

Toccuma

Reply To Post Reply & Quote

Posted at: 3/5/06 03:28 AM

Toccuma NEUTRAL LEVEL 13

Sign-Up: 02/13/05

Posts: 8

ok, create a blank square movie clip and stretch it out over the area to the left and the right where your "hero" will be, up and down work too.... add a if (_this.hitTest(_root.hero)){
tellTarget (_parent){_x=_x+5}} this says move to the right at the speed of 5 pixels everysecond that box touches ur guy... use y and - instead of x and + to work with all four directions... also have a smaller box doing similar in the eneimies close to them that operates the attack movment when it touches... further more have a movieclip with if (_root.score>1) or 10 or 20, tellTarget parent nextframe... place this on a clip containing all the enimies and place more on each frame.

Thats a way to do it without horendace code, hope its not too confusing (by the by, make all those boxxes invisible)


All times are Eastern Standard Time (GMT -5) | Current Time: 12:54 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!