Planetary physics simulator and FlashDevelop

2014-01-05 14:39:37 by Pahgawk

I've been working mostly in Javascript for the past little while, and over the winter break, I thought maybe I'd take the time to look at Flash again. Although I think Javascript is the future of front-end web programming, I still just really like Actionscript as a language. All the problems I felt AS2 had were resolved with AS3. It's really just a pleasure to work with a lot of the time, and since I wanted a fun little project to do, I decided to forget about futureproofing the code for a bit and I just wanted to have fun making something.

So, I made OrbitalMechanics: a planetary physics simulator written in Actionscript 3. Click to start adding new masses (first click sets position, second sets mass, third sets velocity.)

Basically, it is an application of various parts of the Grade 12 physics curriculum. Gravitational force is calculated using the formula F = (G * m_1 * m_2)/(d^2), where G is the arbitrary number 100, masses are in arbitrrary units where mass = 1 is comparable to a small asteroid, and distance is measured in Flash units. When two bodies collide (when the distance between them is less than the sum of their radii), they are replaced with a single body with their combined mass. The resulting body’s velocity is found assuming it is a perfectly inelastic collision using the formula m_1 * v_1 + m_2 * v_2 = (m_1 + m_2) * v’.

I decided to make this in FlashDevelop, an open-source Flash/Flex IDE. Flash Professional feels to me to be a little weird to work with, having become used to IDEs for other platforms, so I wanted to use something a little more similar to a traditional development environment. I could have used Adobe's Flash Builder, but I decided to try the free an open-source alternative, and I actually quite like it. Once I got it up and running, I actually had no complaints with it. It has all the useful code writing features that Flash Pro does, plus some, while also being more reliable (have you ever found that code completion in Flash just stops happening for seemingly random intervals? Doesn't happen in FlashDevelop.) 

I didn't fully escape Flash Pro, though. I opened up Flash at the beginning and created the little menu you see in the bottom left of the screen and added it to the library. Once that was done, I exported a SWC from Flash and added that to FlashDevelop's library and I was good to go. Basically, I was fully satisfied with my FlashDevelop experience and if you like using editors more similar in style to Visual Studio or Code::Blocks or Brackets or something like that, FlashDevelop is free and a great option.

So that's that. Hopefully it's kind of fun to play with. You can find the source on GitHub if you feel like taking a look at it.


As far as other updates go, I'm still not planning on doing any more animations for a bit. I've got all my university applications in and I'm waiting to hear back from a few still, but that's basically settled. Right now I'm just trying to get through school and deal with other personal problems and hope the depression medication kicks in a bit eventually. Everything will probably be ok soon enough though.




You must be logged in to comment on this post.


2014-01-05 14:45:52

FD's code completion does poop out sometimes, but only in specific circumstances.

Pahgawk responds:

Right. Overall I've found it to be pretty stable though. I'm impressed anyway.


2014-01-06 03:36:51

You should get ready for actionscript 4.0 because people find it hard to use actionscript 3.0

(Updated ) Pahgawk responds:

I guess so. Admittedly, the one thing that I miss about AS2 is being able to use Key.isDown() in an onEnterFrame function, which means you have to lay down some extra groundwork if you're making an AS3 game.


2014-01-06 14:32:43

I'm not sure if I understood all of this post or none of it. All I know for sure is that there is a disturbing lack of bad jokes in the NATA chatroom at the moment in dire need of your expertise.

(Updated ) Pahgawk responds:

haha well one day I will maybe return. I will try, anyway. things have been weird and busy