PDA

View Full Version : What's a better way to handle grounds with AS3



shazzmoe
July 30th, 2008, 03:02 PM
I had no problem doing this in AS2 when I tried creating grounds in a sidescroller shooter game, but with AS3 the only way i can figure it out seems inefficient (though it does work). I'm trying to simplify the following code to make less copy and paste work for myself because I'll end up having many more platforms for the player to jump from.

...
if (!jumping && (!player_mc.hitTestObject(background_mc.ground_mc1 ) || !player_mc.hitTestObject(background_mc.plat_mc1)|| !player_mc.hitTestObject(background_mc.plat_mc2) || !player_mc.hitTestObject(background_mc.ground_mc2) )) {
jumping= true;
jump = 0;
}

if (falling && (player_mc.hitTestObject(background_mc.ground_mc1) || player_mc.hitTestObject(background_mc.plat_mc1) || player_mc.hitTestObject(background_mc.plat_mc2) || player_mc.hitTestObject(background_mc.ground_mc2)) ) {
jump = 20;
jumping = false;
falling = false;
}
...

as you can see i'm just checking every MC within my background_mc for collision. Ideally I would like to have one check here for collision, but if i were to run the same check on just background_mc the player is counted as colliding even when in open space because of how flash draws its boxes around the movie clips. Does anyone have any suggestions for how i should approach this? It's not to big of a deal right now but when i decide to place my walls into the game it will become a major pain.

shazzmoe
July 30th, 2008, 03:08 PM
now that i think about it, if someone knows how or could direct me to a post about handling slopes for a player to run up in AS3 i think that would resolve the same problem. Just a thought, i could be wrong.

Lou
July 30th, 2008, 07:10 PM
I've always made my platformers tick by registering the player to a grid or matrix, and checking him against another matrix that contained data for the scenery or monsters. You should check out tonyPA's tile tutorials, they are awesome for small platformers.

http://www.tonypa.pri.ee/tbw/start.html

rahul_7star
August 4th, 2008, 01:59 AM
now that i think about it, if someone knows how or could direct me to a post about handling slopes for a player to run up in AS3 i think that would resolve the same problem. Just a thought, i could be wrong.

see this might help...

shazzmoe
August 4th, 2008, 04:42 PM
thank you guys so much, its seems pretty simple and i have the basics of it working after looking at these for 10mins.

substance
August 8th, 2008, 01:21 AM
see this might help...

Unfortunately that is a pretty bad example. This method doesnt fix problems with characters going through the floor or even mention slope rotation.


I've always made my platformers tick by registering the player to a grid or matrix, and checking him against another matrix that contained data for the scenery or monsters. You should check out tonyPA's tile tutorials, they are awesome for small platformers.

http://www.tonypa.pri.ee/tbw/start.html

This example is better but only works with grid/tile-based scrollers and the ground has to be an exact 45 degree angle.

I'm working on a method that resolves all issues and works with any bitmap image (as a background). I'll be making a post about it very soon but you can see what I have so far here:

http://teamimpulse9.com/Platformer/Platformer.html

In the meantime, I'd suggest checking out this tutorial :

http://www.worldfaction.com/forums/viewtopic.php?f=18&t=178

rahul_7star
August 8th, 2008, 05:20 AM
http://www.worldfaction.com/forums/viewtopic.php?f=18&t=178 deals with AS2 la.

in As2 its easy to code..but in as3 a bit tricky ..i knw few bugs are there but that can be resolved.

this work fine with as2 see this.
http://www.kirupa.com/forum/showthread.php?p=2310737#post2310737

and i am waiting eagerly for your AS3 code...


Unfortunately that is a pretty bad example. This method doesnt fix problems with characters going through the floor or even mention slope rotation.



This example is better but only works with grid/tile-based scrollers and the ground has to be an exact 45 degree angle.

I'm working on a method that resolves all issues and works with any bitmap image (as a background). I'll be making a post about it very soon but you can see what I have so far here:

http://teamimpulse9.com/Platformer/Platformer.html

In the meantime, I'd suggest checking out this tutorial :

http://www.worldfaction.com/forums/viewtopic.php?f=18&t=178