Forum Topic: I've made a jumping engine for all.

(29,525 views • 373 replies)

This topic is 13 pages long. [ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 91113 ]

<< < > >>
None

LordSyth

Reply To Post Reply & Quote

Posted at: 8/13/04 05:27 PM

LordSyth EVIL LEVEL 07

Sign-Up: 07/17/04

Posts: 290

At 7/26/04 09:50 AM, Rabid_Badger wrote: Damn.
I forgot to state that it has "Z" set to attack.
(if you want to change this, you can do so by finding the ASCII Key Value of the key you want to have attack, and replace the 90 in: if(Key.isDown(90) with the appropriate key value.

it says this with your code

**Warning** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: The file 'toplevel.as', which is required for typechecking ActionScript 2.0, could not be found. Please make sure the directory '$(LocalData)/Classes' is listed in the global classpath of the ActionScript Preferences.
stop

**Warning** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: The file 'toplevel.as', which is required for typechecking ActionScript 2.0, could not be found. Please make sure the directory '$(LocalData)/Classes' is listed in the global classpath of the ActionScript Preferences.
onClipEvent (enterFrame) {

Total ActionScript Errors: 2 Reported Errors: 2


None

LordSyth

Reply To Post Reply & Quote

Posted at: 8/13/04 08:53 PM

LordSyth EVIL LEVEL 07

Sign-Up: 07/17/04

Posts: 290

fixed that know this is screwed help

onClipEvent(enterFrame){
if (Key.isDown(65)) {
if(_root.moving=="right") {
if(_root.moving_2=="left")
_root.circle.gotoAndStop(7)
} else {
_root.circle.gotoAndStop(8)
}
}
if(_root.moving=="left") {
_root.circle.gotoAndStop(8)
}

}


None

Rhysswift

Reply To Post Reply & Quote

Posted at: 8/14/04 06:04 AM

Rhysswift NEUTRAL LEVEL 05

Sign-Up: 06/04/04

Posts: 46

cool look what i made www.flashweapons.tk -- its in movies section


None

powerman50001

Reply To Post Reply & Quote

Posted at: 8/14/04 10:50 AM

powerman50001 NEUTRAL LEVEL 03

Sign-Up: 08/07/04

Posts: 57

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

thank a lot ay.


None

Rystic

Reply To Post Reply & Quote

Posted at: 8/15/04 07:24 AM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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


None

Rystic

Reply To Post Reply & Quote

Posted at: 8/15/04 07:29 AM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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 :)


None

binaryflow

Reply To Post Reply & Quote

Posted at: 8/15/04 12:02 PM

binaryflow LIGHT LEVEL 08

Sign-Up: 07/23/03

Posts: 660

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..


None

rmthegreat88

Reply To Post Reply & Quote

Posted at: 9/16/04 11:15 PM

rmthegreat88 LIGHT LEVEL 10

Sign-Up: 04/17/04

Posts: 1,314

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


Shouting

Rystic

Reply To Post Reply & Quote

Posted at: 9/19/04 06:42 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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.


None

Rystic

Reply To Post Reply & Quote

Posted at: 9/19/04 06:54 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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


None

64

Reply To Post Reply & Quote

Posted at: 10/18/04 08:48 PM

64 DARK LEVEL 18

Sign-Up: 02/16/04

Posts: 3,868

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?

BBS Signature

None

64

Reply To Post Reply & Quote

Posted at: 10/19/04 09:40 AM

64 DARK LEVEL 18

Sign-Up: 02/16/04

Posts: 3,868

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. ^_^

BBS Signature

None

Rystic

Reply To Post Reply & Quote

Posted at: 10/22/04 06:56 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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....


None

Diki

Reply To Post Reply & Quote

Posted at: 10/22/04 10:31 PM

Diki NEUTRAL LEVEL 13

Sign-Up: 01/31/04

Posts: 927

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.


None

GeoffCLogan

Reply To Post Reply & Quote

Posted at: 10/22/04 11:38 PM

GeoffCLogan LIGHT LEVEL 11

Sign-Up: 04/25/04

Posts: 4,424

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.


None

Swirling-Venom

Reply To Post Reply & Quote

Posted at: 10/22/04 11:41 PM

Swirling-Venom LIGHT LEVEL 14

Sign-Up: 06/07/04

Posts: 3,775

Whoah talk about bumping and old thread, well none the less, great engine.


None

LordOfKetchup

Reply To Post Reply & Quote

Posted at: 10/23/04 09:12 PM

LordOfKetchup FAB LEVEL 17

Sign-Up: 05/10/04

Posts: 1,063

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

None

Rystic

Reply To Post Reply & Quote

Posted at: 10/25/04 04:21 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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.


None

Rystic

Reply To Post Reply & Quote

Posted at: 10/25/04 04:23 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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.


None

GeoffCLogan

Reply To Post Reply & Quote

Posted at: 10/25/04 04:25 PM

GeoffCLogan LIGHT LEVEL 11

Sign-Up: 04/25/04

Posts: 4,424

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.


None

Rystic

Reply To Post Reply & Quote

Posted at: 10/25/04 04:27 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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.)


None

Rystic

Reply To Post Reply & Quote

Posted at: 10/25/04 04:29 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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?


None

GeoffCLogan

Reply To Post Reply & Quote

Posted at: 10/25/04 04:33 PM

GeoffCLogan LIGHT LEVEL 11

Sign-Up: 04/25/04

Posts: 4,424

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.


None

FrogbagLock

Reply To Post Reply & Quote

Posted at: 10/25/04 04:45 PM

FrogbagLock EVIL LEVEL 13

Sign-Up: 07/10/02

Posts: 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.


None

Rystic

Reply To Post Reply & Quote

Posted at: 10/25/04 05:00 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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)


None

GeoffCLogan

Reply To Post Reply & Quote

Posted at: 10/25/04 05:17 PM

GeoffCLogan LIGHT LEVEL 11

Sign-Up: 04/25/04

Posts: 4,424

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);
}
}
}


None

Rystic

Reply To Post Reply & Quote

Posted at: 10/25/04 05:24 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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?


None

GeoffCLogan

Reply To Post Reply & Quote

Posted at: 10/25/04 05:26 PM

GeoffCLogan LIGHT LEVEL 11

Sign-Up: 04/25/04

Posts: 4,424

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.


None

Rystic

Reply To Post Reply & Quote

Posted at: 10/25/04 05:30 PM

Rystic LIGHT LEVEL 50

Sign-Up: 03/09/02

Posts: 956

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".


None

GeoffCLogan

Reply To Post Reply & Quote

Posted at: 10/25/04 05:36 PM

GeoffCLogan LIGHT LEVEL 11

Sign-Up: 04/25/04

Posts: 4,424

Whoops sorry. New fla mailed.


All times are Eastern Standard Time (GMT -5) | Current Time: 09:13 PM

<< Back

This topic is 13 pages long. [ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 91113 ]

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