Forum Topic: Is this good coding?

(313 views • 21 replies)

This topic is 1 page long.

<< < > >>
None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/14/06 04:49 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

Well Im just learning trig and some flash and I was just wondering how well I did on this code... Is there any changes I should make?

This code is a simple gun turret that shoots bullets and when they hit the wall they expand and disapear.

var speed:Number = 10;
var depth:Number = 0;
var nose:Number = 50;

_root.onMouseMove = function() {
updateAfterEvent();
var xdiff:Number = _root._xmouse-spaceShip._x;
var ydiff:Number = _root._ymouse-spaceShip._y;
var angle:Number = Math.atan2(ydiff, xdiff);
angle = angle*180/Math.PI;
spaceShip._rotation = angle;
};
_root.onMouseDown = function() {
var angle:Number = spaceShip._rotation;
angle = angle*Math.PI/180;
++depth;
var name:String = "projectile"+depth;
var clip:MovieClip = _root.attachMovie("projectile", name, depth);
clip._x = spaceShip._x+nose*Math.cos(angle);
clip._y = spaceShip._y+nose*Math.sin(angle);
clip.xmov = speed*Math.cos(angle);
clip.ymov = speed*Math.sin(angle);
clip.ticker=0;
clip.explode=false;
clip.onEnterFrame = function() {
if (this.explode){
this.ticker+=4;
this._xscale=100+ (2*this.ticker);
this._yscale=100+(2*this.ticker);
this._alpha=200-(this.ticker);
if (this._alpha<1){
this.removeMovieClip();
}
}

if (this._x>700){
this.explode=true;
this.xmov = -this.xmov;
this._y += this.ymov;
}
if (this._x<0){
this.explode=true;
this.xmov = -this.xmov;
this._y += this.ymov;
}
if (this._y>400){
this.explode=true;
this._x+= this.xmov;
this.ymov =-this.ymov;
}
if (this._y<0){
this.explode=true;
this._x+= this.xmov;
this.ymov =-this.ymov;
}
this._x += this.xmov;
this._y += this.ymov;
};
};


None

Old-Style-Clock

Reply To Post Reply & Quote

Posted at: 7/14/06 04:55 AM

Old-Style-Clock LIGHT LEVEL 17

Sign-Up: 05/28/04

Posts: 2,683

meh i wish i could tell ya but i suck at AS


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/14/06 04:58 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

Heh xD

Well I love your sig by the way!


None

Cecemel

Reply To Post Reply & Quote

Posted at: 7/14/06 05:00 AM

Cecemel DARK LEVEL 16

Sign-Up: 08/19/05

Posts: 1,070

At 7/14/06 04:49 AM, BaffledLad wrote: Blah

Guess it's good enough, not very complicated but it's good

<3


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/14/06 05:01 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

What should I add to it?
Anything?


None

Cecemel

Reply To Post Reply & Quote

Posted at: 7/14/06 05:11 AM

Cecemel DARK LEVEL 16

Sign-Up: 08/19/05

Posts: 1,070

i have no idea

<3


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/14/06 05:16 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

At 7/14/06 05:11 AM, Cecemel wrote: i have no idea

Okay :)

Thanks for your help!


None

GameSQUID

Reply To Post Reply & Quote

Posted at: 7/14/06 05:50 AM

GameSQUID NEUTRAL LEVEL 02

Sign-Up: 07/13/05

Posts: 95

It's not that bad, but not good either. Try to look into classes and object oriented programming and you'll be fine.


Happy

TastyLamp

Reply To Post Reply & Quote

Posted at: 7/14/06 05:56 AM

TastyLamp LIGHT LEVEL 11

Sign-Up: 07/13/06

Posts: 224

If it does the job, 'S good.
XD


None

zoy

Reply To Post Reply & Quote

Posted at: 7/14/06 05:57 AM

zoy EVIL LEVEL 09

Sign-Up: 05/17/04

Posts: 1,393

At 7/14/06 04:55 AM, Old_Style_Clock wrote: meh i wish i could tell ya but i suck at AS

then why fucking post?

BBS Signature

None

artville

Reply To Post Reply & Quote

Posted at: 7/14/06 07:40 AM

artville EVIL LEVEL 13

Sign-Up: 10/28/05

Posts: 1,808

Post an example so we can see how the coding turned out then..

Too lazy to open up flash..

None

GameSQUID

Reply To Post Reply & Quote

Posted at: 7/14/06 08:14 AM

GameSQUID NEUTRAL LEVEL 02

Sign-Up: 07/13/05

Posts: 95

At 7/14/06 05:56 AM, TastyLamp wrote: If it does the job, 'S good.
XD

That's not true at all. Some code might do the job, but it might do it very inefficiently, it might be a bitch to add stuff to later, or even to understand later, ... Writing good code is not just writing code that works.


None

dragonjet

Reply To Post Reply & Quote

Posted at: 7/14/06 09:27 AM

dragonjet LIGHT LEVEL 20

Sign-Up: 12/02/05

Posts: 557

and this is....? oh a code...
AS and I are good friends but you are starting to break our relationship....
not very complicated but significant...

ive seen this code before but... you just changed and added some things...
you're a flash beginner right?
oh and there are hundreds of AS codes in this BBS forum....
check them out here...

AS: Main


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/15/06 03:03 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

LOL the reason you have seen that code is because Im learning from a book... And its not the same code! And well Ill get a example up soon if possible


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/15/06 03:05 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

At 7/14/06 09:27 AM, dragonjet wrote: and this is....? oh a code...
AS and I are good friends but you are starting to break our relationship....
not very complicated but significant...

ive seen this code before but... you just changed and added some things...
you're a flash beginner right?
oh and there are hundreds of AS codes in this BBS forum....
check them out here...

AS: Main

No I really don't consider myself a begginner... I mean I guess I might be compared to some people but if I put my mind to it I could make alot of the games on newgrounds..

Sorry to double post by the way >.>


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/15/06 04:11 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

http://img147.images..e=turretthingct7.swf

BAM^^^^

The image shack has differnt boundries then flash so... The bouncing shit will look funny... But everything else should be fine!

Sorry for the poor graphics didn't think they were really needed.


None

shazwoogle

Reply To Post Reply & Quote

Posted at: 7/15/06 04:16 AM

shazwoogle NEUTRAL LEVEL 10

Sign-Up: 09/27/04

Posts: 2,661

At 7/15/06 04:11 AM, BaffledLad wrote: Sorry for the poor graphics didn't think they were really needed.

for an engine, graphics arnt needed :D
but other whies it looks awsome :D what FPS are you running at?


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/15/06 04:18 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

At 7/15/06 04:16 AM, shazwoogle wrote:
At 7/15/06 04:11 AM, BaffledLad wrote: Sorry for the poor graphics didn't think they were really needed.
for an engine, graphics arnt needed :D
but other whies it looks awsome :D what FPS are you running at?

30 fps


None

flashmenow-kthx

Reply To Post Reply & Quote

Posted at: 7/15/06 04:19 AM

flashmenow-kthx NEUTRAL LEVEL 05

Sign-Up: 04/17/06

Posts: 491

while i haven't the patience to read all that, i can only deduce that you spent a long time figuring it out and are now proud of yourself, and you get an A for effort in my book


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/15/06 04:21 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

At 7/15/06 04:19 AM, flashmenow_kthx wrote: while i haven't the patience to read all that, i can only deduce that you spent a long time figuring it out and are now proud of yourself, and you get an A for effort in my book

Rofl just look at the imageshack link.


None

shazwoogle

Reply To Post Reply & Quote

Posted at: 7/15/06 04:22 AM

shazwoogle NEUTRAL LEVEL 10

Sign-Up: 09/27/04

Posts: 2,661

At 7/15/06 04:18 AM, BaffledLad wrote: 30 fps

K, run it at 35fps its the best for games!


None

BaffledLad

Reply To Post Reply & Quote

Posted at: 7/15/06 04:26 AM

BaffledLad NEUTRAL LEVEL 01

Sign-Up: 06/21/06

Posts: 16

At 7/15/06 04:22 AM, shazwoogle wrote:
At 7/15/06 04:18 AM, BaffledLad wrote: 30 fps
K, run it at 35fps its the best for games!

Okay will do! Any other suggestions from anyone?


All times are Eastern Standard Time (GMT -5) | Current Time: 08: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!