Zelaron Gaming Forum

Zelaron Gaming Forum (http://zelaron.com/forum/index.php)
-   General Discussion (http://zelaron.com/forum/forumdisplay.php?f=182)
-   -   Action Script (http://zelaron.com/forum/showthread.php?t=50880)

Asamin 2012-04-24 07:37 PM

Action Script
 
I'm making a basic physics engine for Action Script 3 for my final project in a class, anyone have experience with AS3 in case I get stuck a bit?

Chruser 2012-04-26 01:14 AM

I wrote a few games in AS2 around 8 years ago. I probably don't remember that much of it, but perhaps I'll somehow be able to assist, anyway.

What physical laws are you going to model?

Asamin 2012-04-26 07:39 AM

Well so far I have gravity working. It also will collide with walls and react accordingly (bounces off at the correct angle and velocity decreases according to friction). I'm going to introduce multiple balls next and then figure out how to make them collide and react with each other.

Chruser 2012-04-28 05:08 AM

Circle-circle collisions are easy to detect; just check if the distance between the centers of two circles is less than the sum of their radiuses. Actually, while not computationally optimal, you can do a regular bounding box hit test (Object1.hitTestObject(Object2)) between two arbitrary objects. If the bounding box hit test detects a collision, do a pixel hit test on the two objects to determine if they really collided.

(There are various ways to optimize the latter, like transforming the bounding boxes to different shapes, or spacing vertices along the edges of objects.)

Furthermore, classical momentum is probably a good enough starting point to model the consequences of collisions. For instance, elastic collisions applied separately to the x and y components of velocity (for each object involved in the collision) looks pretty impressive.

Edit: Drag is simple enough to implement for spheres moving through a fluid (such as air), too.

Asamin 2012-04-28 08:51 AM

If you gave me some way, I could upload what I have as of now. It's doing pretty good. I have drag, friction, and correct bouncing. One thing I've been thinking about, which I would figure is hard, would be having a shape with corners bounce correctly, I have no idea how to start with that. I assume I'd start with a square but I have no idea how to do that.

WetWired 2012-04-28 02:07 PM

I'd assume you need to do torque calculations.

!King_Amazon! 2012-04-28 07:00 PM

http://en.wikipedia.org/wiki/Moment_of_inertia

Asamin 2012-04-28 07:04 PM

Quote:

Originally Posted by WetWired (Post 697224)
I'd assume you need to do torque calculations.

I've honestly never learned any equations for torque. I'm gonna show my professor my project on Tuesday and see what he thinks. He thought it would take me the full two weeks to get half as far as I've gotten so I'm doing pretty good.

WetWired 2012-04-29 02:05 PM

So then you've never taken physics?

Asamin 2012-04-29 02:28 PM

I took it in high school but we didn't cover torque. At least not that I remember. It was a while ago. I'm still a first year collage student, I'm taking physics next year.


All times are GMT -6. The time now is 04:04 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.