A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 39

Thread: teach me platfrom game physics

  1. #1
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175

    teach me platfrom game physics

    i hope i posted this in the right place, i'm new here.

    well the title says it all really. i'm looking for a teacher, so i can learn how to make great platform engines and or games.

    what i wish to learn:
    all of this will be in as3 by the way. and i learned tile based levels in both as3 and as2 so we will be making this example from that tile based level system. just because it will be easier.

    first off the basics; gravity, moving left and right. then going more complicated so slopes being introduced. then get slightly more complicated and make accelerated movement. then things get slightly more hard when jumping is introduced and it would be the kind of jumping were you can set the max height but you can actually let go of the jump button while jumping and if it hasn't reached max height yet it begins to fall until it hits ground.

    also even know that all i wish to learn it would involve understanding those variables that people use sometimes in there examples like wind resistance and friction while moving and also there is one called velocity sometimes. i've got confused by all of them many times. so if at all possible you could help teach me that to that would be awesome.

    Interested?
    well if your interested in wanting to teach me this, please email me at scorpafied@gmail.com

    i'm alot more active on my email account so i will reply quicker if you email me. thats why i provided it.

    well thanks in advance.

  2. #2
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    so can anyone help me out?

  3. #3
    Zombie Coder EvilKris's Avatar
    Join Date
    Jun 2006
    Location
    Fukuoka, Japan.
    Posts
    796
    I'll save some anticipation and tell you now- no one's going to e-mail you. You'll just have to google what you're looking for, and you'll find plenty of tutorials online.
    This isn't the place where programmers teach people everything from scratch, but if you do have any specific code-related problems, please feel free to ask.

  4. #4
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    there are no tutorials. hence why i'm here.

    basic platformer stuff there are tutorials. but as soon as you want to start making slopes, movement on different shaped surfaces. and you know the general physics behind stuff like that. so yeah basic movement in platformers is as far as it goes.

    so you see what i mean hopefully. if not i'll sum it up for you. there are heaps of tutorials on basics of platformers, which is what you mean't i'm sure. but as soon as you want actual physics (meaning movement on different shaped surfaces, and physics involved with that. meaning going down a hillo would increase speed ect...) theres nothing anywere. if there was but, it would be great but still to complex to understand just by looking at thhe code so i would need someone to help me to understand it.

    hence why i've asked this question. i'm hyere becuase all other actionscript forums said if i had hope of getting help with this propblem this would be my best place to go.

  5. #5
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    you'll want to deal mostly with circle - line intersection for collision handling.

    http://ozviz.wasp.uwa.edu.au/~pbourk...ry/sphereline/
    http://mathworld.wolfram.com/Circle-...ersection.html

    for collision resolution

    http://www.metanetsoftware.com/technique/tutorialA.html

    download the source files and have a good look.
    lather yourself up with soap - soap arcade

  6. #6
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    ohh thanks. they helped. now the only issue is understanding the fla that put all that math into practise. i'm, going threw the code now. but i'm only intermediate level in actionscript. not great at math i've only ever used the basic math functions like math.floor .ceil and .random

    so yeah will do my best to understand this stuff i've been given.

    thanks for the assitance, so far

  7. #7
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    838
    They aren't AS3 specific, but Tonypa's tutorials seem to be all you need. It wouldn't be difficult to update the code to AS3.

    Tile Based Collision: http://www.tonypa.pri.ee/tbw/

    Vector Based Collison: http://www.tonypa.pri.ee/vectors/index.html

  8. #8
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    it bascially comes down to projection and intersection. Projecting vectors (or points) onto geometry (lines), detecting intersection between projection point and object point, projecting object velocity onto geometry, setting new projected velocity to object.

    It all sounds simple on paper, but yeah, learning this stuff will take some time. I'm by no means a maths guru, in fact quite the opposite. Just over the years i've needed to use this stuff more and more.

    some advice: start with just getting collision to register, finding collision depth and collision normal (the direction the collision point is from center point of object), once you know this stuff you can easily apply the velocity resolution.

    Also, start off with brute force, don't worry about making the algorithm nice and fancy fast, concentrate on getting the result first.

    point on a line: http://ozviz.wasp.uwa.edu.au/~pbourk...try/pointline/
    lather yourself up with soap - soap arcade

  9. #9
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    Son of Bryce:
    i've never like tonypa his examples were based from outsideofsociety.com and i always thoughjt they were harder to understand then there ones.

    i'm not sure if that was just for tile-based levels or if it was for all his work. i'll look at the examples later when i get home. because i can't access them on the pc i'm on right now. (i'm at work and they filter there internet so people can't view games and stuff. his website is classified as a game, lol.)

    but yeah will view them later. thanks didn't even think to look at his stuff.

    mr_malee:
    yeah everytime i look at math my head says "ahhhh! what are you doing to me." and just runs off somewere. lol so i find it hard to learn how to actually do alot of this stuff. however it dopesn't stop me from trying and usually failing. :P

  10. #10
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    You don't have to resort to physics to replicate slopes etc.

    http://blog.gamingyourway.com/PermaL...e86ca7e89.aspx

    But if you do want to go that way, look into box2D, I'm sure there are a handful of tuts on how to make a platform game using it.

    Squize.

  11. #11
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    Squize:
    well i have no idea what that guy is ranting on about. slopes, arrays, angles, tile based maps.
    its almost like he tried to throw a bunch of stuff into a few paragraphs just to make it sound natural, lol. couldn't have done a better job if i say so myself.

    but anyway, i can't even do normal sloped collisions on my own. and believe me when i say i've tried going threw tutorials on them for help. but they never do. this is alot of the reason i'm here, asking for a teacher. because to do this, you need to use advance stuff to make it work or stuff i clearly struggle using.

    so yeah i'm hoping something helps. or someone manages to teach it to me...

    Everyone:
    i looked over that fla files code again and i've manage to have no luck understanding it. its past my knowledge of flash programming. so if anyone could go over it and explain in detail all the lines of code, so i can understand it easier; that would be great.

    thanks in advance!

  12. #12
    Isometric Engine AS3
    Join Date
    Apr 2009
    Location
    France
    Posts
    18

    Smile Isometric Engine

    Hi,
    I ve made an 2D Isometric Multilevel Engine thanks to Tonypa's tutorials. They explain the basics. You can use my source code if you want to develop your game it will avoid you a lot of headhache.
    Links below:
    - http://angelstreetv2.free.fr/as3/IsoEngine_AS3.swf
    - http://code.google.com/p/2d-isometric-engine/

  13. #13
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    thank you, i really appreicate the code. but i'm making a platformer. so your code wouldn't help me.

    plus if i were to take it, i would be stealing. nothing more, i wish to learn not steal. i know learning is seeming like an impossible task but i'd rather my try and keep failing method. it gets my know were but hopefully in the end after failing so many times i'll be able to do all this no problems.

    thats the goal anyway.

  14. #14
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    forget all the source files. Have you got a point projected onto a line?

    that should be your first task
    lather yourself up with soap - soap arcade

  15. #15
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    i tried bu didn't understand it. so i kept trying, and failed even more. so i left it alone.

  16. #16
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    following this page: http://ozviz.wasp.uwa.edu.au/~pbourk...try/pointline/

    here is a simple script which find the intersection of a point and line.

    Code:
    //setup our objects
    
    var line:Object = { sx:100, sy:100, ex:400, ey:260 };
    var point:Object = { x:0, y:0 };
    
    function onMain(event:Event):void {
    	
    	point.x = mouseX;
    	point.y = mouseY;
    	
    	//get the lines components (P2 - P1)
    	
    	var lineSizeX:Number = line.ex - line.sx;
    	var lineSizeY:Number = line.ey - line.sy;
    	
    	//get the components between point and line start (P3 - P1)
    	
    	var linePointDistX:Number = point.x - line.sx;
    	var linePointDistY:Number = point.y - line.sy;
    	
    	//find the dot product of the above components
    	
    	var dotProduct:Number = linePointDistX * lineSizeX + linePointDistY * lineSizeY;
    	
    	//find the unit vector, this is the time at which the point intersects with the line
    	//if the point intersects with the line this will be 0 to 1.
    	
    	var u:Number = dotProduct / (lineSizeX * lineSizeX + lineSizeY * lineSizeY);
    	
    	//cap the unit vector so it doesn't extend past the lines extents
    	
    	u = Math.max(0, Math.min(1, u));
    	
    	//find the intersection point on the line using the unit sized vector
    	
    	var intersectionX:Number = line.sx + u * lineSizeX;
    	var intersectionY:Number = line.sy + u * lineSizeY;
    	
    	//draw some graphics so we can visually see this
    	
    	graphics.clear();
    	graphics.lineStyle(1, 0xFF0000);
    	graphics.moveTo(line.sx, line.sy);
    	graphics.lineTo(line.ex, line.ey);
    	
    	graphics.lineStyle(1, 0x000FF);
    	graphics.drawCircle(point.x, point.y, 2);
    	
    	graphics.lineStyle(0.3, 0x00FF00);
    	graphics.moveTo(point.x, point.y);
    	graphics.lineTo(intersectionX, intersectionY);
    	
    	graphics.lineStyle(1, 0x00FF00);
    	graphics.drawCircle(intersectionX, intersectionY, 2);
    }
    
    addEventListener(Event.ENTER_FRAME, onMain);
    AS3, copy and paste into a new fla.

    two things you might not know about that were used

    http://en.wikipedia.org/wiki/Dot_product
    http://en.wikipedia.org/wiki/Unit_vector

    the dot product is a very useful operation and helps us to know information about vectors in relation to other vectors.
    Last edited by mr_malee; 09-01-2009 at 08:31 PM.
    lather yourself up with soap - soap arcade

  17. #17
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    think you can comment that any better?

    its just i can't seem to understand the code that well. its just your current comments are going by a common mistake when helping. they phrase things in a way that people of there own skill level would understand.

    common mistake, but would be good if you could recomment

    thanks for the help. if i can understand this stuff i'm sure everything else would be easier to understand.

  18. #18
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    how about you tell us exactly what you know. I'm guessing you know AS3 since you mentioned you wanted the game created in AS3. What about the comments doesn't make sense?

    please don't say all of it
    lather yourself up with soap - soap arcade

  19. #19
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    x-death, please stop looking at code as it is, and try to understand the logic behind it..... every programmer has his own way of implementing things, so it's pretty futile if you try to grasp the implementation without understanding the logic!

    I don't understand how much your "intermediate" knoledge of actionscript is so, forget slope and create a basic platformer where you can move left,right, and jump without going through the ground! Next up build simple walls...if you can do this much on your own, show it here, and then I will tell you how to add slopes to this!


    And Mr.Malee, since circle-line is going over his head, I think you should start explaining from moving up predefined slopes(point-point check), instead of irregular slopes!
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  20. #20
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    it wil take a few days to make. but it wasn't just slopes i wanted to make. i wanted it to be what ever angle to slope is. and possibly even circular shaped ground also.

    but yes i suppose it is wrong of me to expect help, without giving first. i was asking for a little to much; so i will come back in a few days and post up the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center