00:00
00:00
Newgrounds Background Image Theme

TheADHX 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've made a jumping engine for all.

48,480 Views | 365 Replies
New Topic Respond to this Topic

Response to I've made a jumping engine for all. 2004-08-14 10:50:34


wow, about time someone posted something as usefull as that,

thank a lot ay.

Response to I've made a jumping engine for all. 2004-08-15 07:24:04


At 8/13/04 03:50 PM, PunkerFish wrote: Mmm...quick question.

How would I go about scrolling with no instance names?

Wow! I can't believe this topic is still alive. I went to Saint Croix for a week (which is why no one could reach me), and thought it would die off.

Anyway, to answer you question, yes, I do have code for an instance-nameless sidescroller. This, obviously, works in tune with the jumping engine (you need to put it in with the engine to make it work). It's slightly complex, but here goes:

First, make a LONG, VERTICAL box on the right. Put it off screen (there is a variation to this, which I will explain later). Then, add this code:

-------------------------------------------------------------

onClipEvent (enterFrame) {
x++;
if (hitTest(_root.circle)) {
_global.moveX = 1;
x=0;
}
if (x==5 && _global.moveX==1) {
_global.moveX=0;
}
}

-------------------------------------------------------------

Do the same thing on the left, except add this code:

-------------------------------------------------------------

onClipEvent (enterFrame) {
x++;
if (hitTest(_root.circle)) {
_global.moveX = -1;
x=0;
}
if (x==5 && _global.moveX==-1) {
_global.moveX=0;
}
}

-------------------------------------------------------------

Then, put this in EVERY CLIP . I CANNOT EMPHASIS HOW IMPORTANT PUTTING IT IN EVERY CLIP IS (other then the vertical boxes. Don't put it in them. Also, don't put it in things that you don't want to scroll, such as the wall blocking off the end of the level).


onClipEvent (enterFrame) {
if (_global.moveX>0) {
_x -= _root.circle.speed;
}
if (_global.moveX<0) {
_x += _root.circle.speed;
}
}

And there ya go! It sidescrolls. This code hasn't been extensively tested like the jumping engine has, so an error or two may occur. If that does happen, e-mail me at Rystic_Force@hotmail.com, or IM me (IMing preferred; we usually get more work done that way).

VARIATION

An alternitive, which I do recommend, is putting the vertical boxes in the center, on the sides of but not touching the player. This gives the feel of an old side scroller, such as Mario, but requires the player to stand in the center (which is why I didn't post it originally. Flexability). Frankly, if I were to make a game (maybe one day), I would use this version.

-Rystic

Response to I've made a jumping engine for all. 2004-08-15 07:29:57


At 8/14/04 06:04 AM, Rhysswift wrote: cool look what i made www.flashweapons.tk -- its in movies section

Hmmm... Go inside the stick movieclip and move every frame's stick figure up about 2 notches... That should fix it...

Also, mention it's my jumping engine. I do like to be credited :)

Response to I've made a jumping engine for all. 2004-08-15 12:02:07


At 7/24/04 04:02 PM, liquid-fyre wrote: Could you guys plz tell me how to work this. i m a huge n00b
[IMG]http://img49.exs.cx/img49/5799/LF.jpg[/IMG]

It shows!.. in your grounds gold profile click: "BBS Sigiature Pic" and upload your signiature through there..

u will need to make it 60px high by 400px wide though..

Response to I've made a jumping engine for all. 2004-09-16 23:15:11


amazing, i will soon make a side scroller! and hopefully it will pass!

Response to I've made a jumping engine for all. 2004-09-19 18:42:22


UPDATE:

Alright, there was a small bug with the side scrolling engine that allowed the user to move through blocks via the scroll. To fix this bug, replace:

onClipEvent (enterFrame) {
if (_global.moveX>0) {
_x -= _root.circle.speed;
}
if (_global.moveX<0) {
_x += _root.circle.speed;
}
}

with

onClipEvent(enterFrame) {
if (_global.moveX<>0 && _root.circle.yMax>yMin && _root.circle.jump==0) {
if (hitTest(_root.circle) && _root.circle.xmax>_x) {
_root.circle._x -= _root.circle.speed*2;
}
if (hitTest(_root.circle) && _root.circle.xmin>_x) {
_root.circle._x += _root.circle.speed*2;
}
}
if (_global.moveX>0) {
_x -= _root.circle.speed;
}
if (_global.moveX<0) {
_x += _root.circle.speed;
}
}

Anyway, that's the update. If you find any more bugs, please report them at Rystic_Force@hotmail.com. Please send me any .fla's with the bugs. Thank you.

Response to I've made a jumping engine for all. 2004-09-19 18:54:24


Arrrgg... Nevermind... that code doesn't seem to work... I need more time to fix this bug. I'll update later this week.

Response to I've made a jumping engine for all. 2004-10-18 20:48:09


At 7/23/04 10:31 PM, Rystic wrote: I've just made a new jumping engine. And, unlike all other jumping engines in this forum, this one doesn't have "_root.ground "in it.

Is there a way where it could be altered so if it jumps from a high ledge and hits a low edge it wont go through?

Response to I've made a jumping engine for all. 2004-10-19 09:40:17


At 10/18/04 08:48 PM, ChtFreak64 wrote:
Is there a way where it could be altered so if it jumps from a high ledge and hits a low edge it wont go through?

Sorry, I might have confused you. I am talking about your first jumping code, not the side scroller. ^_^

Response to I've made a jumping engine for all. 2004-10-22 18:56:12


At 10/19/04 09:40 AM, ChtFreak64 wrote:
At 10/18/04 08:48 PM, ChtFreak64 wrote:
Is there a way where it could be altered so if it jumps from a high ledge and hits a low edge it wont go through?
Sorry, I might have confused you. I am talking about your first jumping code, not the side scroller. ^_^

It shouldn't go through....

Response to I've made a jumping engine for all. 2004-10-22 22:31:21


At 9/19/04 06:54 PM, Rystic wrote: Arrrgg... Nevermind... that code doesn't seem to work... I need more time to fix this bug. I'll update later this week.

I reviewed the script.
It doesn't look like the background was changed at all.
(Unless I missed something)

But hell, I'll try my hand at scripting one.
I'll post it if it works.

Response to I've made a jumping engine for all. 2004-10-22 23:38:00


I just thought though, having one instance name with _root.ground, and then having all the blocks in there, and having one script on the character would be much more beginner friendly. Hmmmm...

Just my outlook, still a great thing to have.

Response to I've made a jumping engine for all. 2004-10-23 21:12:21


At 10/22/04 11:41 PM, Swirling_Venom wrote: Whoah talk about bumping and old thread, well none the less, great engine.

This thread isn't that old, anyways, I had a question. Could you make this into an .fla document?


.

BBS Signature

Response to I've made a jumping engine for all. 2004-10-25 16:21:07


At 10/22/04 11:38 PM, -Geoff- wrote: I just thought though, having one instance name with _root.ground, and then having all the blocks in there, and having one script on the character would be much more beginner friendly. Hmmmm...

Just my outlook, still a great thing to have.

Wouldn't work. Because of the "blue border thingie" in flash, a single clip named ground would function as one block. That is to say that each block wouldn't act individually, but rather as a whole, thus pushing out the character even if they're not touching anything.

Response to I've made a jumping engine for all. 2004-10-25 16:23:48


At 10/22/04 10:31 PM, Rabid_Badger wrote:
At 9/19/04 06:54 PM, Rystic wrote: Arrrgg... Nevermind... that code doesn't seem to work... I need more time to fix this bug. I'll update later this week.
I reviewed the script.
It doesn't look like the background was changed at all.
(Unless I missed something)

But hell, I'll try my hand at scripting one.
I'll post it if it works.

There was an error that I fixed, but I never posted. I put it in the JumpDis.fla, but I'll post the WORKING code here:

Put all this code in each block (replacing all the old code):


onClipEvent (load) {
activated = false;
down = false;
}
onClipEvent (enterFrame) {
if (_global.moveX<>0 && _root.circle.yMax>yMin && _root.circle.jump==0) {
if (hitTest(_root.circle) && _root.circle.xmax>_x) {
_root.circle._x -= _root.circle.speed*2;
}
if (hitTest(_root.circle) && _root.circle.xmin>_x) {
_root.circle._x += _root.circle.speed*2;
}
}
if (_global.moveX>0) {
_x -= _root.circle.speed;
}
if (_global.moveX<0) {
_x += _root.circle.speed;
}
}
onClipEvent (enterFrame) {
xmin = getBounds(_root).xMin;
xmax = getBounds(_root).xMax;
ymin = getBounds(_root).yMin;
ymax = getBounds(_root).yMax;
if (_root.circle.xMax>xMin && _root.circle.xMin<xMax && _root.circle.yMax<yMin) {
if (_root.circle.yMax-_root.circle.jump*2>yMin) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
}
if (Math.round(_root.circle.yMax)>Math.round(yMin)) {
if (hitTest(_root.circle) && _root.circle.xmax<xmin) {
_root.circle._x -= _root.circle.speed;
}
if (hitTest(_root.circle) && _root.circle.xmin>xmax) {
_root.circle._x += _root.circle.speed;
}
if (hitTest(_root.circle) && _root.circle.ymin>ymax && _root.circle.jump>-1) {
_root.circle.jump = -1*(_root.circle.jump);
}
}
if (activated == true && not hitTest(_root.circle) && _root.circle.jump == undefined) {
_root.circle.jump = 0;
activated = false;
}
if (hitTest(_root.circle) && _root.circle.ymax>ymin && _root.circle.jump<>undefined && _root.circle._y<_y) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
if (_root.circle.ymax-_root.circle.jump>ymin && _root.circle.xMin<xMax && _root.circle.xMax>xMin && _root.circle.jump<>undefined && _root.circle._y<_y) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
}

To those who don't know, there was an error regarding the side scoller. If the scroller touched the edge of a block, and the player touched the scroller, then the player went through the block. This code fixes that.

Response to I've made a jumping engine for all. 2004-10-25 16:25:35


At 10/25/04 04:21 PM, Rystic wrote:
Wouldn't work. Because of the "blue border thingie" in flash, a single clip named ground would function as one block. That is to say that each block wouldn't act individually, but rather as a whole, thus pushing out the character even if they're not touching anything.

Sure it would, you just need to set shapeflag to true. The link in my sig is proof of it. The only real problem is the fact that it can only detect a hitTest between a point and a shape, not two shapes. However that's still better than the normal way.

Response to I've made a jumping engine for all. 2004-10-25 16:27:06


At 10/23/04 09:12 PM, Lord_Of_Ketchup wrote:
At 10/22/04 11:41 PM, Swirling_Venom wrote: Whoah talk about bumping and old thread, well none the less, great engine.
This thread isn't that old, anyways, I had a question. Could you make this into an .fla document?

It is. IM me through MSN messenger and I'll e-mail you the .fla. My e-mail account is Rystic_Force@hotmail.com

Also, be warned, there is another bug in the engine that's pretty minor. It involves a player being able to jump through a block (from the bottom) that's too close to another. I've put a test of the error in my JumpDis.fla, so anyone who wants to try debugging it can (I've been busy of late.)

Response to I've made a jumping engine for all. 2004-10-25 16:29:30


At 10/25/04 04:25 PM, -Geoff- wrote:
At 10/25/04 04:21 PM, Rystic wrote:
Sure it would, you just need to set shapeflag to true. The link in my sig is proof of it. The only real problem is the fact that it can only detect a hitTest between a point and a shape, not two shapes. However that's still better than the normal way.

Which version of flash are you using, MX or MX 2004?

Response to I've made a jumping engine for all. 2004-10-25 16:33:13


At 10/25/04 04:29 PM, Rystic wrote:
At 10/25/04 04:25 PM, -Geoff- wrote:
Which version of flash are you using, MX or MX 2004?

I've tried it on both, and it works.

Response to I've made a jumping engine for all. 2004-10-25 16:45:23


At 10/25/04 04:33 PM, -Geoff- wrote:
At 10/25/04 04:29 PM, Rystic wrote:
At 10/25/04 04:25 PM, -Geoff- wrote:
Which version of flash are you using, MX or MX 2004?
I've tried it on both, and it works.

Sorry for the delay. I reached my quota, and needed to get my other account. I forgot it's password, though, so I did some guessing...

Anyway....

You made another version with the shapeflag method? Well, then post it. The link in your sig isn't working for me.

And, for anyone who doesn't know, the shapeflag method is basically:

hitTest (_root.blala.coordinate, _root.blala.coordinate, true) {
etc...
}

The "true" meaning to relate to the object, not the bounds, to sum up very, very quickly.

Response to I've made a jumping engine for all. 2004-10-25 17:00:14


At 10/25/04 04:33 PM, -Geoff- wrote:
At 10/25/04 04:29 PM, Rystic wrote:
At 10/25/04 04:25 PM, -Geoff- wrote:
Which version of flash are you using, MX or MX 2004?
I've tried it on both, and it works.

Sorry, I couldn't post cause' of the quota. Read above. That's me.(FrogbagLock)

Response to I've made a jumping engine for all. 2004-10-25 17:17:08


Whoops, sorry about the wait, had some computer problems.
Here it is.

Directions: Attach this script to your main player movieclip, then make a movie clip with the instance name "ground" *without the quotes* and put all your blocks and platforms in that.

As of now it supports platforms, and walls. I'll probably add terrain and
jumping down from a platform in a few minutes, and I'll be sure to post the code.

*Note*: Ignore the gotoAndStops, as I put them in my version.

onClipEvent (load) {
this.swapDepths(10000);
vel = -16;
jumping = false;
down = false;
_root._quality = "BEST";
}
onClipEvent (enterFrame) {
rsx = _x+_width/2;
lsx = _x-_width/2;
dsy = _y+_height/2;
kl = Key.isDown(Key.LEFT);
kr = Key.isDown(Key.RIGHT);
ks = Key.isDown(Key.SPACE);
if (ks && !down && !jumping) {
jumping = true;
}
if (jumping) {
if (_root.ground.hitTest(_x, dsy+vel, true) && vel>=0) {
for (x=vel; x>0; x--) {
if (!_root.ground.hitTest(_x, dsy+x, true)) {
_y += x;
break;
}
}
jumping = false;
vel = -16;
}
if (jumping) {
_y += vel;
vel++;
if (vel>16) {
vel = 16;
}
}
}
if (kl) {
if (!jumping) {
gotoAndStop(2);
}
_xscale = -100;
if (!_root.ground.hitTest(lsx-5, _y+_height/3, true)) {
_x -= 5;
} else {
for (i=5; i>0; i--) {
if (!_root.ground.hitTest(lsx-i, _y+_height/3, true)) {
_x -= i;
break;
}
}
}
}
if (kr) {
if (!jumping) {
gotoAndStop(2);
}
_xscale = 100;
if (!_root.ground.hitTest(rsx+5, _y+_height/3, true)) {
_x += 5;
} else {
for (i=5; i>0; i--) {
if (!_root.ground.hitTest(rsx+i, _y+_height/3, true)) {
_x += i;
break;
}
}
}
}
if (!kr && !kl) {
gotoAndStop(1);
}
if (!_root.ground.hitTest(_x, dsy+2, true) && !jumping) {
jumping = true;
vel = 0;
}
if (jumping) {
if (vel<0) {
gotoAndStop(3);
} else {
gotoAndStop(4);
}
}
}

Response to I've made a jumping engine for all. 2004-10-25 17:24:05


I'm seeing a fews bugs in this (e.g. falling through blocks near the edges, being able to jump through bocks from the bottom, not actually touching the blocks). Can you e-mail me a .fla file with this code?

Response to I've made a jumping engine for all. 2004-10-25 17:26:18


Well there's obviously a few bugs. But you're meant to be able to jump through from underneath, most platformers allow that *except for ? blocks on mario*.

And that platforming thing I'll fix right now, and email.

Response to I've made a jumping engine for all. 2004-10-25 17:30:19


At 10/25/04 05:26 PM, -Geoff- wrote: Well there's obviously a few bugs. But you're meant to be able to jump through from underneath, most platformers allow that *except for ? blocks on mario*.

And that platforming thing I'll fix right now, and email.

I need a file in MX, not MX 2004. It keeps saying "Unexpected File Format".

Response to I've made a jumping engine for all. 2004-10-25 17:36:55


Whoops sorry. New fla mailed.

Response to I've made a jumping engine for all. 2004-10-25 17:37:05


At 10/25/04 05:26 PM, -Geoff- wrote: Well there's obviously a few bugs. But you're meant to be able to jump through from underneath, most platformers allow that *except for ? blocks on mario*.

And that platforming thing I'll fix right now, and email.

One problem with doing it this way is that this jump engine can't handle small blocks clumped together (as in just randomly throwing shapes together with the square tool). The getBounds jump engine can handle small blocks.

None the less, it's a good engine for people new to flash.

Response to I've made a jumping engine for all. 2004-10-25 17:41:32


I don't really see that problem, but I guess that's just with the graphics on my end. Oh well, no use criticising the different methods, as both have their pros and cons. I was just bored one night and started coding and an hour later I got what you see.

Response to I've made a jumping engine for all. 2004-10-25 17:43:33


At 10/25/04 05:41 PM, -Geoff- wrote: I don't really see that problem, but I guess that's just with the graphics on my end. Oh well, no use criticising the different methods, as both have their pros and cons. I was just bored one night and started coding and an hour later I got what you see.

Yea, they're both useful. Yours can scale up circles and triangles, and mine can detect smaller blocks. These are both really good aspects of our engines.

Response to I've made a jumping engine for all. 2004-12-06 13:59:32


I dunno if you fixed this or not, but when I'm scrolling I go through a platform if it's standing vertically. How can I fix this?