I want to make a faked physics engine in As2 like Sonic or Fancy Pants. So far all I got is gravity, when you hit the floor you stop going down, move left and right, and when you hit a steep enough slope you can't go up it.

But what I am currently trying to do is make it so the player can go through loops, or go up upside-down ramps, like this: [url=http://i39.tinypic.com/2uti2d4.jpg]

Any help would be appreciated!

I want to make a faked physics engine in As2 like Sonic or Fancy Pants. So far all I got is gravity, when you hit the floor you stop going down, move left and right, and when you hit a steep enough slope you can't go up it.\r\n\r\nBut what I am currently trying to do is make it so the player can go through loops, or go up upside-down ramps, like this: [url=http://i39.tinypic.com/2uti2d4.jpg]\r\n\r\nAny help would be appreciated!

I recommend you give this article a look, just to get the basic idea for all your loopy goodness.

I recommend you give [url=http://info.sonicretro.org/SPG:Solid_Tiles]this article[/url] a look, just to get the basic idea for all your loopy goodness.

@KentyBK That article is just talking about Sonic's "amazingness". And who knows if it's talking about As2, As3, or javascript.

Uhhhh no. It explains how the game's engine works, including how the game handles slopes and curved surfaces. It's written in pseudocode so that you can adapt it to whatever language you want. It seemed appropriate given that you want to make an engine "like" those games.

I'm not going to post ready-made code, because that's your job.

[quote]@KentyBK That article is just talking about Sonic's "amazingness". And who knows if it's talking about As2, As3, or javascript.[/quote]\r\n\r\nUhhhh no. It explains how the game's engine works, including how the game handles slopes and curved surfaces. It's written in pseudocode so that you can adapt it to whatever language you want. It seemed appropriate given that you want to make an engine "like" those games.\r\n\r\nI'm not going to post ready-made code, because that's [b]your[/b] job.

I looked through the link you gave me, it helped a lot.

So far I got my player to go halfway up the loop, but then because of using "_y -= gravity" to make it so he hits the ground, it makes the player shoot up to the top of the ground. So, I replaced that with: "_y -= Math.sin(_rotation * Math.PI / 180) * gravity;" into a "while" statement. But now whenever the player hits the ground, Flash Player freezes. I have encountered this problem A LOT of times,
and am getting pretty tired of it ruining every fix i come up with. (I tried an "if" statement too, froze Flash Player also).

Will "_y -= Math.sin(_rotation * Math.PI / 180) * gravity;" even work? And if so how can I fix this "while" statement problem?

Sorry, was just really frustrated.\r\n\r\nI looked through the link you gave me, it helped a lot.\r\n\r\nSo far I got my player to go halfway up the loop, but then because of using "_y -= gravity" to make it so he hits the ground, it makes the player shoot up to the top of the ground. So, I replaced that with: "_y -= Math.sin(_rotation * Math.PI / 180) * gravity;" into a "while" statement. But now whenever the player hits the ground, Flash Player freezes. I have encountered this problem A LOT of times,\r\n and am getting pretty tired of it ruining every fix i come up with. (I tried an "if" statement too, froze Flash Player also).\r\n\r\nWill "_y -= Math.sin(_rotation * Math.PI / 180) * gravity;" even work? And if so how can I fix this "while" statement problem?

I'm not sure what the exact calculation would be but you can look at this\r\n\r\nspeed = 5;\r\ngravity = 2;\r\nangle = MC._rotation;\r\n\r\ndx = Math.[b]cos[/b](angle*Math.PI/180);\r\ndy = Math.[b]sin[/b](angle*Math.PI/180);\r\n\r\n\r\nMC.onEnterFrame = function() \r\n{\r\n this.dy += gravity;\r\n this._x += this.dx*speed;\r\n this._y += this.dy*speed;\r\n}

Well, I still have the problem of Flash Player freezing when using my gravity var with math in a while or if statement. I used math.cos and math.sin in other if statements, but for some reason it's freezing in just this one... The only code I used in my while statement was this:

And I tried to do so with an if statement too. But it still froze. Tried googling it, could only find as3 results. But then when I just use

Grav = 0;
_y -= gravity;

No freezing, but halfway up the loop the player shoots up.

So I'm pretty sure _y -= Math.sin(_rotation * Math.PI / 180) * gravity; will work, all I need is a fix for flash freezing when I put it In a while statement.

If you need more of my code to help figure out the problem, just let me know.

Ps: if this helps at all, it's not timeline code, it's code inside of a symbol.

Well, I still have the problem of Flash Player freezing when using my gravity var with math in a while or if statement. I used math.cos and math.sin in other if statements, but for some reason it's freezing in just this one... The only code I used in my while statement was this:\r\n\r\n_y -= Math.sin(_rotation * Math.PI / 180) * gravity;\r\nGrav = 0;\r\n\r\nAnd I tried to do so with an if statement too. But it still froze. Tried googling it, could only find as3 results. But then when I just use \r\n\r\nGrav = 0;\r\n_y -= gravity;\r\n\r\nNo freezing, but halfway up the loop the player shoots up.\r\n\r\nSo I'm pretty sure _y -= Math.sin(_rotation * Math.PI / 180) * gravity; will work, all I need is a fix for flash freezing when I put it In a while statement.\r\n\r\nIf you need more of my code to help figure out the problem, just let me know.\r\n\r\nPs: if this helps at all, it's not timeline code, it's code inside of a symbol.