1
2
Oct 8 2011, 6:37 am
In response to ANiChowy
|
|
These are vectors, just inlined.
|
In response to Zaoshi
|
|
I didn't even read the code, I just figured that you wouldn't be using them. Woops
|
In response to ANiChowy
|
|
To make it look like vectors we'd need to create vector, matrix, multiplication, transformation etc. Half of numbers would be 0 either 1 which can easily be optimized. That's why it's easier to do like this (possibly even easier to understand after a little research).
|
In response to Zaoshi
|
|
SUCCESS! Thank you very much! :3
|
In response to Zaoshi
|
|
I guess. But when you move up to more complex things happening at once I think it becomes a lot simpler to manage. It seems like he's making some sort of space game with gravity being simulated here, and I'm not really sure if gravity between...say...6 different bodies would be easy here or not. It might be, but I can see him using dedicated vector functions in different situations as well.
|
In response to ANiChowy
|
|
Nonono I'm not going that much in-depth. In fact I'm pretty much ignoring the REAL effects of gravity all together. I'm aiming for semi-complex which results in planets orbiting suns, and suns essentially orbiting the center of the map.
|
In response to ANiChowy
|
|
According to Newton's law ( http://en.wikipedia.org/wiki/ Newton%27s_law_of_universal_gravitation ) all objects in the universe are affected by gravity towards each other. Basically even your mouse pulls Sun to itself.
That's O(n^2) calculation and I really doubt he needs that. |
In response to Zaoshi
|
|
I know that. But you only need to calculate gravity that is significant as opposed to all gravity.
Regardless, he said he didn't need to, so whatever. |
In response to ANiChowy
|
|
But you can't know it's significant unless you calculate it 0.o
Of course you could use view() to get nearest objects. However very far object with very huge mass can still have equal effect if it's heavy enough. |
In response to Zaoshi
|
|
Any object massive enough to induce significant gravity after n distance should be classed and handled differently...for example, the center of the screen would be something handled differently in his case.
|
In response to Zaoshi
|
|
How would I go about making objects (a; AKA a planet) closer to the orbit origin (b; AKA the sun), orbit faster than those further away? Right now everything orbits in perfect alignment which is just awkward.
|
In response to Stevenw9
|
|
Nevermind, I figured it out.
orbit(C,O,1/get_dist(C,O),get_dist(C,O)*32) |
In response to ANiChowy
|
|
Someone should make a simulation library based on all this, if only to hand a huge improvement to space games that like to simulate things properly. Plus, pixel movement based systems need more documentation in general if you ask me.
|
1
2