Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: AS help plz

(139 views • 9 replies)

This topic is 1 page long.

<< < > >>
Questioning

micky315

Reply To Post Reply & Quote

Posted at: 4/22/08 08:01 PM

micky315 DARK LEVEL 09

Sign-Up: 08/02/07

Posts: 217

can someone help make the arm on a stickman follow the mouse and shoot like in stickman sam

BBS Signature

PyroflameProductions NEUTRAL LEVEL 09

Sign-Up: 08/04/07

Posts: 1,956

No one is going to make yours games for you... But, we will lead you in the right direction.

AS: Arrays
AS: Intervals
AS: Collisions
AS: Following/Shooting at Mouse
AS: Platformer

Free .fla's are currently down.

BBS Signature

None

gankro

Reply To Post Reply & Quote

Posted at: 4/22/08 09:37 PM

gankro EVIL LEVEL 11

Sign-Up: 09/16/06

Posts: 1,136

At 4/22/08 08:57 PM, PyroflameProductions wrote: No one is going to make yours games for you... But, we will lead you in the right direction.

AS: Arrays
AS: Intervals
AS: Collisions
AS: Following/Shooting at Mouse
AS: Platformer

... arrays? that doesn't seem necessary... eventually useful... but pretty useless to what he's doing...

My Coding Portfolio (updated frequently)
If you stay in bed for long enough it will be socially acceptable to go to bed again

BBS Signature

PyroflameProductions NEUTRAL LEVEL 09

Sign-Up: 08/04/07

Posts: 1,956

At 4/22/08 09:37 PM, gankro wrote:
At 4/22/08 08:57 PM, PyroflameProductions wrote: No one is going to make yours games for you... But, we will lead you in the right direction.

AS: Arrays
AS: Intervals
AS: Collisions
AS: Following/Shooting at Mouse
AS: Platformer
... arrays? that doesn't seem necessary... eventually useful... but pretty useless to what he's doing...

Actually It's quite useful. He can use an array to store his guns, bullet types, ammo, and more trust me. It may not be at his level of actionscripting yet, but it will be very useful to him in the future for making a game like "Stickman Sam".

Free .fla's are currently down.

BBS Signature

None

DrkFox

Reply To Post Reply & Quote

Posted at: 4/22/08 09:43 PM

DrkFox EVIL LEVEL 08

Sign-Up: 01/03/08

Posts: 283

You achieve that effect by using Math.atan2
There are some tutorials on it on newgrounds so look for it. I would suggest AS:Main


None

Snubby

Reply To Post Reply & Quote

Posted at: 4/22/08 10:12 PM

Snubby FAB LEVEL 20

Sign-Up: 12/04/04

Posts: 3,141

At 4/22/08 09:37 PM, gankro wrote: ... arrays? that doesn't seem necessary... eventually useful... but pretty useless to what he's doing...

you need an array to keep track of all the bullets on the screen genious


None

gankro

Reply To Post Reply & Quote

Posted at: 4/22/08 10:16 PM

gankro EVIL LEVEL 11

Sign-Up: 09/16/06

Posts: 1,136

At 4/22/08 10:12 PM, Snubby wrote:
At 4/22/08 09:37 PM, gankro wrote: ... arrays? that doesn't seem necessary... eventually useful... but pretty useless to what he's doing...
you need an array to keep track of all the bullets on the screen genious

says who? bullets only stay on screen for a couple moments, certainly not worth logging... please explain an advantage because I'm sure you have a really good point but I can't see it... not even being sarcastic, do elaborate.

My Coding Portfolio (updated frequently)
If you stay in bed for long enough it will be socially acceptable to go to bed again

BBS Signature

None

Kart-Man

Reply To Post Reply & Quote

Posted at: 4/22/08 10:48 PM

Kart-Man NEUTRAL LEVEL 23

Sign-Up: 01/07/07

Posts: 3,172

At 4/22/08 10:16 PM, gankro wrote:
At 4/22/08 10:12 PM, Snubby wrote:
At 4/22/08 09:37 PM, gankro wrote: ... arrays? that doesn't seem necessary... eventually useful... but pretty useless to what he's doing...
you need an array to keep track of all the bullets on the screen genious
says who? bullets only stay on screen for a couple moments, certainly not worth logging... please explain an advantage because I'm sure you have a really good point but I can't see it... not even being sarcastic, do elaborate.

They're quite worth logging. If you push all of the bullet instance names into an array when they appear, and splice them off the array when you remove them off-screen, then you don't have to check extra loops when you hitTest using a for loop. All you can do is just check how many are in the array (you know, arrayName.length), instead of having a ballpark estimate of how many bullets you want to check. This reduces lag (maybe with a small number of bullets onscreen at a time, it's not particularly noticeable, but when you have dozens or hundreds, you'll probably see a difference).

Code Ex:
Non-Array:

 for (i = 0; i < 50; i++) { 

Array:

 for (i = 0; i < arrayName.length; i ++) {

I probably made a typo somewhere in there (typed quickly), but I think you get the gist of it. So, arrays aren't really necessary, but it makes things easier to view when you're checking your code (just trace the array), and it's faster in the long run.


None

gankro

Reply To Post Reply & Quote

Posted at: 4/22/08 10:55 PM

gankro EVIL LEVEL 11

Sign-Up: 09/16/06

Posts: 1,136

At 4/22/08 10:48 PM, Kart-Man wrote:
They're quite worth logging. If you push all of the bullet instance names into an array when they appear, and splice them off the array when you remove them off-screen, then you don't have to check extra loops when you hitTest using a for loop. All you can do is just check how many are in the array (you know, arrayName.length), instead of having a ballpark estimate of how many bullets you want to check. This reduces lag (maybe with a small number of bullets onscreen at a time, it's not particularly noticeable, but when you have dozens or hundreds, you'll probably see a difference).

Code Ex:
Non-Array:

for (i = 0; i < 50; i++) {

Array:

for (i = 0; i < arrayName.length; i ++) {

I probably made a typo somewhere in there (typed quickly), but I think you get the gist of it. So, arrays aren't really necessary, but it makes things easier to view when you're checking your code (just trace the array), and it's faster in the long run.

i just use a minimum variable to get a precise number i.e.

if(!"mc"+mini){
mini++
}
for(a=mini;a<spawned;a++){

works just as well, maybe better since you're not splicing an array up all the time.

My Coding Portfolio (updated frequently)
If you stay in bed for long enough it will be socially acceptable to go to bed again

BBS Signature

None

GuyWithHisComp

Reply To Post Reply & Quote

Posted at: 4/23/08 09:20 AM

GuyWithHisComp LIGHT LEVEL 23

Sign-Up: 11/10/05

Posts: 4,029

At 4/22/08 10:55 PM, gankro wrote: if(!"mc"+mini){

Obviously that line wouldn't work though. It will always return false because the boolean value of a string is always true as long as it is defined and has a length of more than 0.

And if we're talking about speed it's good to store the array length in a separate variable because otherwise flash has to look up the length each iteration.

var l:Number = arr.length;
for(var i:Number = 0; i < l; i += 1)

Alternatively, you can just store i as the array length and then decrease i each iteration instead of increase.

for(var i:Number = arr.length-1; i >= 0; i -= 1)
BBS Signature

All times are Eastern Daylight Time (GMT -4) | Current Time: 12:27 AM

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