The Daily Click ::. Downloads ::. Miscellaneous ::. 2D box physics engine kinda of have a problem wth
 

2D box physics engine kinda of have a problem wth
Author: QuaziGNRLnose Submitted: 16th August, 2008 Favourites:0
Genre: Miscellaneous Downloads: 156
Rated:


Edited By QuaziGNRLnose on 8/16/2008

This is basically a 2D box which can bounce and will always land on one of its flat faces, it incorporates acceleration and some fastloop stuff, but thats where i have a problem, since im using fastloops i cant have more than 1 object, or else itll start acting all weird, is there a way i can fix this???, also i dont think ive incorporated wall bounces yet, and i dont know how i can make it use fastloops without making it do act strange, help would be appreciated? right click on the box to launch it around and left click to repos it on mouse, the object controls are in the layout, play with them, any bounciness lower than 10 creates an object which increases in Y speed as it bounces (glitchy) also id like to know if there would be a way for me to make this slip off edges, without using detectors? since i cant handle detectors on a per object basis. mmf2 makes it really hard for me to makes this work well, BECUASE IT ROUNDS ALL MY NUMBERS TO THE NEAREST UNIT, i hate using *1000 to make my sim more accurate. anyone is free to edit and improve this thing, ive switched to construct after my mmf demo ran out, i have another demo on my laptop tho, pending to be installed. im kinda of a noob, and i dont know what flags do

ps: sorry about strange resolution size just change it if its 2 big.

Review This Download



 


http://download259.mediafire.com/b9ngytijxjug/avdfhhfbhha/physics+blok.mfa (87.92 kkb )



Posted by QuaziGNRLnose 16th August, 2008

that image is basically all it is lol
 
Posted by Foo Fighter 16th August, 2008

well, kinda nice. hope you get the help you need
 
Posted by Pixelthief 16th August, 2008

ok I can't run MMF2 files, but judging by your descript, what you need is to apply your "Block physics" to multiple copies of the block object; ie if there are more than 1 block, you want them ALL to have individual physics, instead of just the newest copy of it.

The problem is that MMF will only apply some functions to the NEWEST copy of an object, ignoring the other ones; this may mess up your detectors and such- if you set an "Always: set detector position to "Box" (0,0)", it will put all your detectors at a single box.

The way to get around this is to check each box one at a time, inside of a fast loop. You need to use flags and references to know which box is active at a single time, apply all your physics code, and then set its flag off and restart the loop, choosing a new one.

The easiest way to achieve this effect is a very simple set up I use in every single one of my games:


*Always

=Set Box Flag 0 off
=Set Box Flag 1 off
=Start loop "Physics" (#Box Objects) Number of Times

*On loop Physics
+Box Flag 0 is off
+Pick a Box at random
=Set Box Flag 0 on
=Set Box Flag 1 on

*On loop Physics
+Box Flag 1 is on
=insert your code in these events

*On loop Physics
+Box Flag 1 is on
=Set Box Flag 1 off


it might be difficult to comprehend, but once it does this will let you check unlimited copies of an object with just one copy of the code; you can use a single detector for every single object in your game, and have physics for all of them.
 
Posted by Pixelthief 16th August, 2008

Or if you can open it, try looking at this ungodly piece of overblown coding:
http://www.create-games.com/download.asp?id=7298

If you look carefully at the code in the physics loops, it uses the exact method I just described in several places. This allows me to apply my physics engine on every single object.
 
Posted by Dr. James MD 16th August, 2008

That's good and all, but it doesn't support collisions with other boxes and it breaks completely if you have more than 1 box.
 
Posted by QuaziGNRLnose 16th August, 2008

yea, thats my problem.






@poopoothief





well it currently doesn't have detectors, because if it did i would be unable to define which detectors are being used by which boxes, which would get a kinda mashed up result, i currently only support ground collisions and im trying to do this by finding the normal of the ground surface (via a defined value) which then defines values of the box based on which faces a true box would land on. like if i had a flat normal (0 degrees) my box would try to land on all multiples of of 90 which it would then using some simple greater and less than events would find which face would be the easiest to fall and how to fall on it whilst its on the ground. it would roll down any normal greater or = than 45.i understand your flag thingy but wouldnt everything go all blocky that way, since your only updating one box per loop the more boxes you have the more lag between processing each one there would be.also is there some1 who could make it an exe for me? itd be much appreciated and im sorry about the extreme mess of code it uses, the whole apple qualifier is for a the same SAMPLE crate and explain to me what falgs and loop index does, i still have no idea







MMF is real annoying sometimes, it wont let me use any point values in positions and angles, which really limits my control over the objects, i can scale their values and the divide when inputed but strange things happen that way, blocky movements. thats the main reason im using construct now, numbers can be point values and their calculated to the millionth i think. no more blocky angle control.

oh yah? does loop physics replace my already existing loop?
Comment edited by QuaziGNRLnose on 8/16/2008
 
Posted by Pixelthief 16th August, 2008

sadly scaling the values is the only way to get precision like that, having a x & y position stored multiplied by 1000 and loaded when needed. Angles are usually precise enough with 360 degrees afaik.
 
Posted by Bibin 10th November, 2008

"MMF is real annoying sometimes, it wont let me use any point values in positions and angles, which really limits my control over the objects, i can scale their values and the divide when inputed but strange things happen that way, blocky movements. thats the main reason im using construct now, numbers can be point values and their calculated to the millionth i think. no more blocky angle control."

There is a way of forcing the use of point values; the method is rather stupid but you must multiply the equation by 1.0. Oddly this enables point values.
 

 



Author

Favourite



Advertisement

Worth A Click