Hi all
Here's a local gravity plugin, in case you need one. Injects all entities with dormant attraction capability, activated by setting mass property.
Demo and usage information here.
Git sources here.
Any questions let me know.
Cheers
A.
Nicely done. A plugin like this opens up a lot of possibilities for games. Don't forget to post it over at
POIJS. ;)
1 decade ago
by paulh
WOW! Your amasing, will get into this tomorrow, and give you some feedback! looks awesome!
This is really useful, thanks.
Thanks guys. And Graphikos, done and awaiting your review. :)
Yea right.. I already had it approved. ;) Thanks for the contribution!
1 decade ago
by paulh
Hey andre, this i brilliant, will it work on ios?
@paulh
Yep, unless Apple dropped the ball on multiplications and divisions in the past week. :)
EDIT
The demo itself may not, though, given that it custom-draws the spheres; not sure dom ported canvas beginPath and arc commands to iosimpact. If not, just use textures instead and all should be shiny.
1 decade ago
by paulh
Yea i just had a little look and i think our right with the begin paths .. awesome stuff in so little code!
It's nature that's awesome. ;)
1 decade ago
by paulh
Hey Alexandre
Just going through the plugin, can i ask some questions, ive learned a lot from that code, and hoping to improve a little more:
this.generate(32,2); //tis relates to num of planets,suns
generate: function(numPlanets, numSuns) // Why the words in brackets, how does that work?
if (this.localGravity.mass) // if it has a mass?
gravitateWith: function(other) // what is the other here and why?
Hope you dont mind me asking!
generate: function(numPlanets, numSuns) // Why the words in brackets, how does that work?
numPlanets and numSuns are named arguments that the function, generate, needs to do its job, namely that of creating n0 planets and n1 suns.
if (this.localGravity.mass) // if it has a mass?
Yes. The plugin's mass property is null by default: if(some possibly null property) will return true if the property is not null. This default was chosen so that no entity would be affected by gravity unless you specifically set its mass prop to some number. Just explaining this however, I realize that 0 would be a better default. I'm revising the plugin right now, in fact, and will add this change to the next update.
gravitateWith: function(other) // what is the other here and why?
Every gravitationally-enabled entity is pulled by its (in-range) neighbours. So of course, if A pulls B, B will, before the next ig.game.draw, pull A.
v2 of the plugin is on the way. I had to modify it so that it would prove more useful for a prototype I am working on. The new version will let you specify, as impact does with collisions, what entity types (A, B, BOTH, or NONE) an entity can be attracted to/repelled by.
More news apace.
1 decade ago
by paulh
WOW, thanks for the reply ... really helpful in understanding the excelent work!
i was wandering if there woudl be a way to make the planets rectangular also or a zone so if a vertical zone was placed in the centre and 6 entities were placed vertically on either side of the screen they would ocilate in a straight line to make two interacting moving lines.
You've just given me a slight buzz. :) Not sure what you mean. Can you explain some more?
1 decade ago
by paulh
[IMG]
http://i45.tinypic.com/34gvzfq.png [/IMG]
Red box indicates zone/ sun.
red dots indicate planets
Black lines indicate screen edge (4 screens shown)
That's way clearer, but, unfortunately no: your sketches indicate the need for something quite different from local, point-centric attractors.
What if there were 2 such rectangular zones applying pull at the same time? How would you envisage the results?
1 decade ago
by paulh
Wouldn't be allowed in level design :-)
But no big deal, its firly easy to do with just some set velocities and zone triggers...
Also dont want to detract form the awesomeness of this!
Thanks for the kind words. :)
Thanks. Not yet satisfied with it: Euler drift makes the simulation unusable for the game I am working on. Am reworking the plugin now; update in a few days.
1 decade ago
by paulh
and we all get to learn a new word too :-)
and we all get to learn a new word too :-)
few?
Great plugin. Thanks for sharing.
Hi folks, per request by a fellow impacter, I've just updated the
gravity plugin, adding a drawnTo property that lets you specify what entity types (A, B, BOTH, NONE) "this" can be attracted to.
Page 1 of 1
« first
« previous
next ›
last »