00:00
00:00
Newgrounds Background Image Theme

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

Foss: Car engine for all

1,670 Views | 13 Replies
New Topic

Foss: Car engine for all 2005-10-28 22:46:07


FOSS: Main

I made a simple car engine for everyone to use. Why? Why did I make this for eveyone? Because I love everyone (except....maybe Wesley Snipes).

Anyway. With this code you can make things like this:
Car thing

Ok, so heres the script:

onClipEvent (enterFrame) {
// right
if (Key.isDown(Key.RIGHT)) {
_rotation = _rotation+move;
}
// left
if (Key.isDown(Key.LEFT)) {
_rotation = _rotation-move;
}
// up
if (Key.isDown(Key.UP)) {
if (move<8) {
move++;
}
} else if (move>0) {
move--;
}
// down
if (Key.isDown(Key.DOWN)) {
if (move>-10) {
move--;
}
} else if (move<0) {
move++;
}
// _x & _y position
if (_rotation>180) {
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}
}

Put this script into a movie clip, and WHAM!! you have a car-ish thing. Also throw some hitTest's in it and you can do more than just.....drive it around.

Theres really not much I can explain, you'll understand it if you know basic / intermediate maths. Which can be found here:
Maths basic
Maths intermediate

Well, there ya go. Have fun.

Also, Note: I would recommend 24 fps, in case you don't know how to edit the speed and what not.


2b r not2b lawl

BBS Signature

Response to Foss: Car engine for all 2005-10-28 22:50:33


Boo, looks like you took it off a website, you didn't even define move, so it cant work


wtfbbqhax

Response to Foss: Car engine for all 2005-10-28 22:53:08


At 10/28/05 10:50 PM, fwe wrote: Boo, looks like you took it off a website, you didn't even define move, so it cant work

try it.
I Dare you to try it.
watch it work.

And no I didnt take it off of a website.


2b r not2b lawl

BBS Signature

Response to Foss: Car engine for all 2005-10-29 02:20:40


come on, doesnt anyone like my car engine?

Its easy, nice, simple, and can be built upon


2b r not2b lawl

BBS Signature

Response to Foss: Car engine for all 2005-10-29 02:55:23


there are a few ways you could optimize it to make it run faster (although on its own it wont matter) and if you didnt steal it, then learn how to use += -= they are useful things

Response to Foss: Car engine for all 2005-10-29 02:57:17


its alright thought that is a pretty easy engine to make though but still good job

Response to Foss: Car engine for all 2005-10-29 03:22:16


At 10/29/05 02:57 AM, keifer_kbn wrote: its alright thought that is a pretty easy engine to make though but still good job

The point of it was that it was easy. I made it like that so people who don't understand it (even though I don't condemn the n00b copy paste games) can use it with ease. Because I love everyone <3 (cept wesley snipes)


2b r not2b lawl

BBS Signature

Response to Foss: Car engine for all 2005-10-29 03:24:32


At 10/29/05 02:55 AM, dELta_Luca wrote: there are a few ways you could optimize it to make it run faster (although on its own it wont matter) and if you didnt steal it, then learn how to use += -= they are useful things

I know how to use em. I just made it this way because its prettier <3

mr. action script god *bows down*

2b r not2b lawl

BBS Signature

Response to Foss: Car engine for all 2005-10-29 08:18:58


u havent defined the variable move!
i tested the script now and it wont work!

Response to Foss: Car engine for all 2005-10-29 08:21:43


i can try it out...

Response to Foss: Car engine for all 2005-10-29 08:28:57


At 10/28/05 10:53 PM, Katow-Jo wrote:
At 10/28/05 10:50 PM, fwe wrote: Boo, looks like you took it off a website, you didn't even define move, so it cant work
try it.

Okay I did

I Dare you to try it.

Yes did

watch it work.

Oh wait cant do that because it doesnt. You have to declare move before this will ever work (you clearly have no idea what youre doing)


And no I didnt take it off of a website.

Very bad code; wouldnt suprise me if it was stolen


- Matt, Rustyarcade.com

Response to Foss: Car engine for all 2005-10-29 08:30:56


sorry man it wont work ... i dont know why
check the script out again and find if there is
something wrong

Response to Foss: Car engine for all 2005-10-29 08:33:49


At 10/29/05 08:30 AM, H4wk wrote: sorry man it wont work ... i dont know why

Thats because you dont know AS : P

check the script out again and find if there is
something wrong

Ummm at least 4 of us have pointed out its because he never declared the variable move (thats what happens when you copy code)


- Matt, Rustyarcade.com

Response to Foss: Car engine for all 2005-10-29 08:46:22


LOL!
LOL!!!
LOL!!!!!!

Don't try to claim credit for others' work.


- - Flash - Music - Images - -

BBS Signature