00:00
00:00
Newgrounds Background Image Theme

Coppock just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As:enemy's Random Attack

1,224 Views | 9 Replies
New Topic Respond to this Topic

As:enemy's Random Attack 2005-11-09 02:22:25


Enemy random attack.
As i was looking through as:main the other day trying to think of something to do, i noticed that knowbody had made an enemy's random attack script. so i thought to myself "i know how to do that" so i started typing and came up with this.
Here is the script, it is self explanatory.
onClipEvent(load){
speed=6} //sets the movement speed
onClipEvent (enterFrame) {
if (this._currentframe==1 || this._currentframe==2 && this.hitTest(_root.player)) {// if the current frame is 1 or 2 and its hitting the player
this.gotoAndPlay(random(3)+4); //this goes to and plays a random frame between 4-6
}
if (_currentframe == 4 && !this.hitTest(_root.player)) { //if the current frame is 4 and its not hitting player
this.gotoAndPlay(1); //this goes to and plays 1
}
if (_currentframe == 5 && !this.hitTest(_root.player)) { //if the current frame is 5 and its not hitting player
this.gotoAndPlay(1);//this goes to and plays 1
}
if (_currentframe == 6 && !this.hitTest(_root.player)) {//if the current frame is 6 and its not hitting player
this.gotoAndPlay(1); //this goes to and plays 1
}
if (_root.player._x>this._x) { // if players _x is aboves this's _x
this._x += speed; //_x increases by speed
this.gotoAndStop(2); // this goes to second frame..modify for your movie
_xscale=-100 //xscale is -100 or backwards
}
if (_root.player._x<this._x) { //same as above just the other way around
this._x -= speed;
_xscale=+100
this.gotoAndStop(2);
}
}
*NOTE* don’t forget to change the variables according to your games.
The only things that you need are: a main character with the name of "player" the frames of it attacking as 4,5 and 6 (these can be changed in the script) and thats about it. if you are having any troubles then post a question or add me on msn; e-mail in my profile.
im sure there are other ways but this is the way that i use. post feedback and any questions.


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

BBS Signature

Response to As:enemy's Random Attack 2005-11-09 03:09:44


needs more explanation

Response to As:enemy's Random Attack 2005-11-09 03:19:03


At 11/9/05 03:09 AM, shazwoogle wrote: needs more explanation

what more explanation do you need? there are comments that explain every line


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

BBS Signature

Response to As:enemy's Random Attack 2005-11-09 08:57:30


At 11/9/05 03:19 AM, Flash_kid wrote:

there are comments that explain every line

there may be comments, but you didnt explain how theory and practice come together to create this. you might have done better to include a pseudo-code. i understand this, but AS: Main threads are meant to be a place to send n00bs who ask questions that can be answered with a thread; this will not help a n00b. they will walk away more confused than they began.


BBS Signature

Response to As:enemy's Random Attack 2005-11-09 09:16:40


I understand what he means. It should have:
Necessary AS knowledge
-blah
-blah blah
-blah
Introduction'
Blah blah blah
blah
Explanations'
Blah...
Code
onblahenterframe = function(blah)


BBS Signature

Response to As:enemy's Random Attack 2005-11-09 15:17:29


At 11/9/05 08:57 AM, authorblues wrote: there may be comments, but you didnt explain how theory and practice come together to create this. you might have done better to include a pseudo-code.

wats a pseudo-code

i understand this, but AS: Main threads are meant to be a place to send n00bs who ask questions that can be answered with a thread;

this does answer questions asked my noobs because i asked my friend who doesnt know shit about AS and he now understands how to make random attacks.

this will not help a n00b. they will walk away more confused than they began.

already proven in the last line.


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

BBS Signature

Response to As:enemy's Random Attack 2005-11-09 15:27:16


Pseudo-code is the most basic form of programming explanation that can be applied to any language. Example-

if(x==4)z=6;
else z=5;

Pseudo-code:

If x equals 4, assign six to z.
Otherwise, assign five to z


BBS Signature

Response to As:enemy's Random Attack 2005-11-09 15:48:57


aaah, i see. thats pretty basic, but it probably could be useful


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

BBS Signature

Response to As:enemy's Random Attack 2005-11-09 15:51:35


Right.. pseudocoding an if statement is almost pointless, but doing it for something like this is good because it gives inexperienced people something to grab onto, instead of just dumping code on them. Comments may help some, but that still doesn't mean they have any idea how the code in question is working


BBS Signature

Response to As:enemy's Random Attack 2006-02-09 20:00:34


it is kind of helpful, but even so, like said before, more explanation may be in consideration.

I'll admit, im not amazing at AS, so i guess i call for all those other noobs :P