00:00
00:00
Newgrounds Background Image Theme

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

I'm working on a gta style engine!

3,100 Views | 33 Replies
New Topic Respond to this Topic

For all of you people who wanted to make a gta game but didn't know the code to make the controls change when the person entered the car, I have started to work on a code for that exact situation. It is not even close to being finished but I have started working on it so I thought I might show you. First off, create the person you will control and convert it to a MC and give it the instance name of "person" without the quotes. Then give him this code:

onClipEvent(load){
speed=0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)&& _root.person.hitTest (_root.car)) {
speed += 1;
}
// This will make the car go backwards
if (Key.isDown(Key.DOWN)&& _root.person.hitTest (_root.car)) {
speed -= 1;
}
//The car will start to slow down after the speed of 25
if (Math.abs(speed)>25) {
speed *= .6;
}
// This will change the angle of the car
if (Key.isDown(Key.LEFT)&& _root.person.hitTest (_root.car)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)&&_root.person.hitTest (_root.car)) {
_rotation += 15;
}
// This will make the car move
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.move.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
on (press) {
startDrag ('');
}
on (release) {
stopDrag ();
}

Note: When I was working on this code, I didn't know how to make it so that if the person is not on the car, he would walk with normal controls so just to test the code, you can drag the person on to the car and then press the buttons to make the car move. Then you can drag the person off the car and press the same buttons and you will see that nothing will happen.

Then make the car MC and give it the instance name of "car" without the quotes. After that, give it these actions:

onClipEvent (load) {
speed=0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)&& _root.person.hitTest (_root.car)) {
speed += 1;
}
if (Key.isDown(Key.DOWN)&& _root.person.hitTest (_root.car)) {
speed -= 1;
}
//The car will start to slow down after the speed of 25
if (Math.abs(speed)>25) {
speed *= .6;
}
// This will change the angle of the car
if (Key.isDown(Key.LEFT)&& _root.person.hitTest (_root.car)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)&& _root.person.hitTest (_root.car)) {
_rotation += 15;
}
// This will make the car move
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.move.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}

Another Note: Another thing I didn't complete was I didn't know how to make it so once the character is on the car, he could get off. So for as of now, you can only drag and drop the person on and off the car.

As you can see, this code is still VERY buggy, and if anyone would like to help me work out the problems I said in the notes, you can look up my contact info in my profile. And the car physics in the code aren't mine, I just used them to test my code and all. So please tell me how this code is in your replys!

Response to I'm working on a gta style engine! 2005-06-27 15:47:59


I guess I should of reworded the title :-(

Response to I'm working on a gta style engine! 2005-06-27 15:50:22


make it so when u push Space,
u make the person inviible and just steers the car instead!

Response to I'm working on a gta style engine! 2005-06-27 15:53:08


At 6/27/05 03:50 PM, Creeepy wrote: make it so when u push Space,
u make the person inviible and just steers the car instead!

Hey, if your a good ASer, you can help me with the script! Oh, and good idea, I can add a

if(Key.isDown(Key.SPACE)) {
_root.person.visible==false;
}
}

Response to I'm working on a gta style engine! 2005-06-27 15:56:02


At 6/27/05 03:53 PM, Dancing-Thunder wrote:
At 6/27/05 03:50 PM, Creeepy wrote: make it so when u push Space,
u make the person inviible and just steers the car instead!
Hey, if your a good ASer, you can help me with the script! Oh, and good idea, I can add a

yes im very good with actionscript, contact me on msn; alexander_tommeraas@msn.com

if(Key.isDown(Key.SPACE)) {
_root.person.visible==false;
}
}

exactly what i meant!

Response to I'm working on a gta style engine! 2005-06-27 16:02:49


At 6/27/05 03:56 PM, Creeepy wrote: yes im very good with actionscript, contact me on msn; alexander_tommeraas@msn.com

Great! I will try to get more people to help too.

Response to I'm working on a gta style engine! 2005-06-27 16:05:38


At 6/27/05 04:02 PM, Dancing-Thunder wrote:
At 6/27/05 03:56 PM, Creeepy wrote: yes im very good with actionscript, contact me on msn; alexander_tommeraas@msn.com
Great! I will try to get more people to help too.

so add me to msn!
(if u got it)
then we can talk!

Response to I'm working on a gta style engine! 2005-06-27 16:14:20


At 6/27/05 04:05 PM, Creeepy wrote: so add me to msn!
(if u got it)
then we can talk!

I got AIM so do you so just look up my AIM.

Response to I'm working on a gta style engine! 2005-06-27 16:26:55


Anyone else wanna' help?

Response to I'm working on a gta style engine! 2005-06-27 16:47:39


Bumpedy bump!

Response to I'm working on a gta style engine! 2005-06-27 16:59:55


All this hard work and nobody cares. Tsk, tsk, tsk.

Response to I'm working on a gta style engine! 2005-06-27 17:02:42


sounds cool
i dont get AS...

Response to I'm working on a gta style engine! 2005-06-27 17:06:39


you must turly understand the lingo. well done, i understand this was hard to do.

Response to I'm working on a gta style engine! 2005-06-27 17:09:13


I find it very interesting, unfortunately I got a C- in programming last time I took a class in it ::chuckles:: And I'm new here so I know nothing about action script yet, but I'm trying to learn. I would love to help you, but unfortunately I just don't have the knowledge as of now :(

-Elizabeth

Response to I'm working on a gta style engine! 2005-06-27 17:09:54


At 6/27/05 05:06 PM, pumpkinlover wrote: you must turly understand the lingo. well done, i understand this was hard to do.

Thanks

Response to I'm working on a gta style engine! 2005-06-27 17:22:01


I've been trying to learn actionscript. well i'm making a crash bandicoot game at the moment, actionsctipt is seriously hard, i don't know how you guys come up with all that amzing crazy code. It's so friggin hard, but freakishjly sexy and delicious. Anyway here's what i've made of my crash bandicoot game so far, it still has many errors but hopefully i'll fix those when i get better with actionscript. Crash bandicoot game so far

Oh and topic starter good luck with the game, i would prefer it if you press something like "a" to enter a car and then it's in a birds eye view, sort of like that stick rpg game. good luck with the game anyway, sounds good!

Response to I'm working on a gta style engine! 2005-06-27 17:25:26


Thanks for the positive reply! Oh, your game looks awesome so far! But what I dont understand, is why are you using mario platfroms?

Response to I'm working on a gta style engine! 2005-06-27 17:27:19


At 6/27/05 05:25 PM, Dancing-Thunder wrote: Thanks for the positive reply! Oh, your game looks awesome so far! But what I dont understand, is why are you using mario platfroms?

Oh it's because i learnt how to make the game from a mario game tutorial. But i'll change those backgrounds another time, right now i have to work on my dragonball movie (preview located in my sig), all my friends have been telling me to finish it so i'll work on the dragonball movie for now and the crash bandicoot game another time.

Response to I'm working on a gta style engine! 2005-06-27 17:40:27


Th3t 1s T3h Gae$t c0d3 3v3r! 1m 2o much b3TT3r!

Response to I'm working on a gta style engine! 2005-06-27 17:46:10


At 6/27/05 05:40 PM, skateer wrote: Th3t 1s T3h Gae$t c0d3 3v3r! 1m 2o much b3TT3r!

I would like to see you try to make a better code!

Response to I'm working on a gta style engine! 2005-06-27 17:51:00


At 6/27/05 05:47 PM, reedo11 wrote: oh and btw: I'd LOVE to help you out! I'll ad you right now!

Thanks! I now have 2 people helping! This engine should come out great!

Response to I'm working on a gta style engine! 2005-06-27 18:00:00


Good bye everyone! If I'm lucky, I will be back on later tonight!

Response to I'm working on a gta style engine! 2005-06-27 18:54:36


Yes! Im back on!

Response to I'm working on a gta style engine! 2005-06-27 19:08:13


At 6/27/05 05:06 PM, pumpkinlover wrote: you must turly understand the lingo. well done, i understand this was hard to do.

AS, doesn't, look , like, lingo , anymore , at , all...

I'm ok with AS, my msn is in my sig

Response to I'm working on a gta style engine! 2005-06-27 19:10:15


Inglor, I always thought you were VERY good with AS. And sorry, I don't have msn.
*starts going nuts about not having msn*

Response to I'm working on a gta style engine! 2005-06-27 19:14:44


I'm pretty good with it, do you have aim?

Response to I'm working on a gta style engine! 2005-06-27 19:30:12


At 6/27/05 07:14 PM, Inglor wrote: I'm pretty good with it, do you have aim?

Check my profile. XD -God, I love that expression!

Response to I'm working on a gta style engine! 2005-06-27 20:30:21


BTW, if you use my engine, you gotta give me credit!

Response to I'm working on a gta style engine! 2005-06-27 20:42:27


At 6/27/05 08:30 PM, Dancing-Thunder wrote: BTW, if you use my engine, you gotta give me credit!

its a copy from flashkit.com!

Response to I'm working on a gta style engine! 2005-06-27 20:47:49


At 6/27/05 08:42 PM, Creeepy wrote: its a copy from flashkit.com!

The car physics part is, but thats not the whole engine. I just used that to test my actual engine. And who says that whoever uses this has to use it for cars, it can be anything!!!!!