00:00
00:00
Newgrounds Background Image Theme

Blozeoff 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

1,820 Views | 18 Replies
New Topic Respond to this Topic

Foss: Car engine 2005-11-07 13:14:06


i just made a pretty simple car engine to all of u,
which is pretty easy to use or edit,
just change the variables to make
the car movement just as you want!
I know there has beeen make a topic like this before,
but that was by a n00b who stole the code from another site.
I was going to make a building hittest code too,
i will maybe add that later!
so here's the code!

onClipEvent (load) {
//variables u may change
acceleration = 2;
speed = 0;
rotation = 0;
forwardRotation = 15;
reverseRotation = -7;
maxSpeed = 16;
minSpeed = -8;
brake = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation += rotation;
} else if (Key.isDown(Key.LEFT)) {
_rotation -= rotation;
}
if (Key.isDown(Key.UP)) {
if (speed<maxSpeed) {
speed += acceleration;
} else {
speed = maxSpeed;
}
if (rotation<forwardRotation) {
rotation++;
}
} else if (speed>0) {
speed--;
if (rotation>0) {
rotation--;
}
}
if (Key.isDown(Key.DOWN)) {
if (speed>0) {
speed -= brake;
} else if (speed>minSpeed) {
speed--;
}
if (rotation>reverseRotation) {
rotation--;
}
} else if (speed<0) {
speed++;
if (rotation<0) {
rotation++;
}
}
if (_rotation>180) {
_y += (speed*Math.cos(Math.PI/180*_rotation));
_x -= (speed*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y -= (speed*Math.cos(Math.PI/180*_rotation));
_x += (speed*Math.sin(Math.PI/180*_rotation));
}
}

so have fun! :)

Response to Foss: Car engine 2005-11-07 13:16:41


*sigh*

This has been done many times before, someone has even done a car engine, albeit badly.


Sup, bitches :)

BBS Signature

Response to Foss: Car engine 2005-11-07 13:17:38


this has been done sooo many times if your gona do it, try adding somthing new to the script, like say , when you turn black lines come from the tires like in gta and then people will like it

Response to Foss: Car engine 2005-11-07 13:18:20


At 11/7/05 01:16 PM, -liam- wrote: *sigh*

This has been done many times before, someone has even done a car engine, albeit badly.

that was the guy i was talking about!
he didnt even know AS, just stle the code from a site!
and my code is super editable!! :D

<3

Response to Foss: Car engine 2005-11-07 13:43:47


At 11/7/05 01:17 PM, -reelbigcheese- wrote: this has been done sooo many times if your gona do it, try adding somthing new to the script, like say , when you turn black lines come from the tires like in gta and then people will like it

yeh that was acctually a good idea! i think i will make that! :)

Response to Foss: Car engine 2005-11-07 13:50:10


At 11/7/05 01:17 PM, -reelbigcheese- wrote: this has been done sooo many times if your gona do it, try adding somthing new to the script, like say , when you turn black lines come from the tires like in gta and then people will like it

Exactly, and using API too.. goddamn it.

Anyway, I just saw a video of the helicopter in GTA:LCS, it's awesome! I just saw the snow too and it's cool, I love the internet. In other news, Google Web Accelerator is absolutly amazing, It really works (very well).


Sup, bitches :)

BBS Signature

Response to Foss: Car engine 2005-11-07 14:34:39


ok i made the black thing after the car!
put this in the main frame:
createEmptyMovieClip("myDrawing1", 2);
myDrawing1.lineStyle(2, 0x000000, 30);
createEmptyMovieClip("myDrawing2", 1);
myDrawing2.lineStyle(2, 0x333333, 30);
onEnterFrame = function () {
myDrawing1.moveTo(_root.car._x+11, _root.car._y+11);
myDrawing2.moveTo(_root.car._x-11, _root.car._y-11);
_root.car.onEnterFrame = function() {
if (_root.car.speed>15) {
if (_root.car.braking) {
myDrawing1.lineTo(_root.car._x+11, _root.car._y+11);
myDrawing2.lineTo(_root.car._x-11, _root.car._y-11);
}
if (_root.car.turn) {
myDrawing1.lineTo(_root.car._x+11, _root.car._y+11);
myDrawing2.lineTo(_root.car._x-11, _root.car._y-11);
}
}
};
};

then put this code in the movieclip car! (instance name: car)
here:

onClipEvent (load) {
acceleration = 2;
speed = 0;
rotation = 0;
forwardRotation = 26;
reverseRotation = -7;
maxSpeed = 20;
minSpeed = -8;
brake = 3;
slading = 10;
braking = false;
turn = false;
}
onClipEvent (enterFrame) {
this.swapDepths(2);
if (Key.isDown(Key.RIGHT)) {
_rotation += rotation;
if (rotation == forwardRotation+reverseRotation) {
turn = true;
}
} else if (Key.isDown(Key.LEFT)) {
_rotation -= rotation;
if (rotation == forwardRotation+reverseRotation) {
turn = true;
}
} else {
turn = false;
}
if (Key.isDown(Key.UP)) {
if (speed<maxSpeed) {
if (rotation<forwardRotation) {
rotation++;
}
speed += acceleration;
} else {
speed = maxSpeed;
if (rotation<forwardRotation) {
rotation++;
} else if (rotation>+reverseRotation) {
rotation = forwardRotation-slading;
}
}
} else if (speed>0) {
speed--;
if (rotation>0) {
rotation--;
}
}
if (Key.isDown(Key.DOWN)) {
if (speed>minSpeed) {
braking = true;
}
if (speed>0) {
speed -= brake;
} else if (speed>minSpeed) {
speed--;
}
if (rotation>reverseRotation) {
rotation--;
}
} else if (speed<0) {
speed++;
if (rotation<0) {
rotation++;
}
} else {
braking = false;
}
if (_rotation>180) {
_y += (speed*Math.cos(Math.PI/180*_rotation));
_x -= (speed*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y -= (speed*Math.cos(Math.PI/180*_rotation));
_x += (speed*Math.sin(Math.PI/180*_rotation));
}
}

there u go! :)

Response to Foss: Car engine 2005-11-07 14:36:33


this is what it looks like, if u were wondering:

http://img129.images..age=carengine5hq.swf

Response to Foss: Car engine 2005-11-07 15:18:49


At 11/7/05 02:36 PM, Creeepy wrote: this is what it looks like, if u were wondering:

http://img129.images..age=carengine5hq.swf

Pretty nice, but you should make the lines bigger, and more alpha, as you can see the points the lines join.


BBS Signature

Response to Foss: Car engine 2005-11-07 15:27:57


Response to Foss: Car engine 2005-11-07 15:28:21


At 11/7/05 03:18 PM, DNentertainment wrote:
At 11/7/05 02:36 PM, Creeepy wrote: this is what it looks like, if u were wondering:

http://img129.images..age=carengine5hq.swf


Pretty nice, but you should make the lines bigger, and more alpha, as you can see the points the lines join.

thanx yeh the lines were a bit small! gonna fix it!

Response to Foss: Car engine 2005-11-07 15:30:56


Response to Foss: Car engine 2005-11-07 15:42:02


one you let go of up/down, even though the car still moves, you cant turn it using left and right <- your god commands you to fix this

Response to Foss: Car engine 2005-11-07 15:45:40


does any1 knows a game like GTA1|2 on flash? i tried searching on newgrounds and the "best" i found was BOOM BOOM town or something like that..
can anyone make a decent car game like GTA?

Response to Foss: Car engine 2005-11-07 15:49:52


Well, i posted my source. It has the basics for a car and pedestrians fleeing if you drive too fast.
The car even has a health status.
Adding a guy that can shoot is not too hard, since there are several tutorials on this forum and on other websites.

Put the pieces together ;-)

Response to Foss: Car engine 2005-11-07 15:57:46


At 11/7/05 01:16 PM, -liam- wrote: *sigh*

This has been done many times before, someone has even done a car engine, albeit badly.

lol and stolen


- Matt, Rustyarcade.com

Response to Foss: Car engine 2005-11-07 16:42:03


At 11/7/05 03:45 PM, Hadar1989 wrote: does any1 knows a game like GTA1|2 on flash? i tried searching on newgrounds and the "best" i found was BOOM BOOM town or something like that..
can anyone make a decent car game like GTA?

Not on newgrounds but I have seen one. It used to be on the synj forum. It was reallly well made it even had the 3d buildings from GTA 1 and 2. Very impressive, but alas the synj forum was deleted becasue some asshole hacked it.

Response to Foss: Car engine 2005-12-13 14:14:16


i like the one i made. it has wheels that turn. i had it on my memory stick, but that got stolen, so at the mo i'm making a new and better one, and if i finish it i might submit it.

Response to Foss: Car engine 2006-03-27 14:30:12


At 11/7/05 01:14 PM, -Creepy- wrote: code

is there a way of making another variable so it travels longer when you let go of forward, it bugs me when it stops almost straight away when you let go of forward