Atom Smash simulation
Atom Smash simulation
EDIT: All of the source mentioned in this post is available for download here: http://frontpage.execulink.com/coder/fr ... /atoms.asp
I was looking around for a module in my old qb code and I found this instead:
Blocks (made of simulated bonded atoms) are dropped from some height and smash against the ground and each other.
I made it about 6 years ago in QB. It's one of several that I did trying to simulate things like jello and dominos. Anyway, I only had to change a few lines to get it to compile and run in freebasic. (it could not have been easier).
There are some constants at the top of the program that can be tweaked to give different effects. Since the simulation is not based on any real physics, numbers don't have any real world meaning: so you will just have to play with the values. And I'm sorry if it's too fast for newer computers, there's no timing code. Maybe you can add a sleep or something in the main loop.
Download Source :atom_smash.bas 10k
I now go back to my search for what I was really looking for.
I was looking around for a module in my old qb code and I found this instead:
Blocks (made of simulated bonded atoms) are dropped from some height and smash against the ground and each other.
I made it about 6 years ago in QB. It's one of several that I did trying to simulate things like jello and dominos. Anyway, I only had to change a few lines to get it to compile and run in freebasic. (it could not have been easier).
There are some constants at the top of the program that can be tweaked to give different effects. Since the simulation is not based on any real physics, numbers don't have any real world meaning: so you will just have to play with the values. And I'm sorry if it's too fast for newer computers, there's no timing code. Maybe you can add a sleep or something in the main loop.
Download Source :atom_smash.bas 10k
I now go back to my search for what I was really looking for.
Last edited by coderJeff on Mar 27, 2006 22:17, edited 1 time in total.
-
- Posts: 5494
- Joined: Sep 12, 2005 20:06
- Location: California
Hmmm, looking at the code, looks like I put something like that in there. (Must have been thinking the same thing as you) Press uppercase "A" and it will give one of the atoms a jerk upward. Look in the code around line 129 where it has CASE "A" Maybe you could add some of your own CASE statements in there and play around with it.
-
- Posts: 5494
- Joined: Sep 12, 2005 20:06
- Location: California
Brilliant!
I see the makings of a 2D Stickman Ragdoll System!!!
http://mambazo.langfordtavern.com/zips/ ... _lines.bas
Who's up for the challenge! :P
I see the makings of a 2D Stickman Ragdoll System!!!
http://mambazo.langfordtavern.com/zips/ ... _lines.bas
Who's up for the challenge! :P
-
- Posts: 5494
- Joined: Sep 12, 2005 20:06
- Location: California
2D stickmen ... Cool idea! Maybe a good way to get out aggressiveness by tossing them and squashing them with heavy virtual bricks. (Oh, nooo! who will help Mr. Bill? SPLAT!)
Some of the global constants could be coded in to the "Bonds" type so that things like body joints could have different properties from things like legs and arms. So that when dismemberment occurs, it's more likely to occur at a joint.
Here's an idea. Create a program that takes a color bitmap and converts it to an atom lattice structure, different colors could indicate different properties.
I added some of mambazo's code bits to add color to the atoms. Also, press "ESC" to exit, "R" to restart, SPACE to add random velocities.
I added a function to create a triangular shaped block, and I also re-read though my code and made a comment about how the program is supposed to work.
Link is as before: atom_smash.bas 12 k
Some of the global constants could be coded in to the "Bonds" type so that things like body joints could have different properties from things like legs and arms. So that when dismemberment occurs, it's more likely to occur at a joint.
Here's an idea. Create a program that takes a color bitmap and converts it to an atom lattice structure, different colors could indicate different properties.
I added some of mambazo's code bits to add color to the atoms. Also, press "ESC" to exit, "R" to restart, SPACE to add random velocities.
I added a function to create a triangular shaped block, and I also re-read though my code and made a comment about how the program is supposed to work.
Link is as before: atom_smash.bas 12 k
Code: Select all
'' This particle system is not based on any real world model but
'' it does have some theory. The math is simplified by having
'' all "atoms" of the same size and mass. (There is no mass in
'' any of the calculations) Also, certain physical effects are
'' simulated using factors and conditions to change the state of
'' the system.
''
'' The solid bodies are made up of "atoms".
''
'' * Atoms have a spacing and a size (ATOMSPACE, ATOMSIZE)
'' * Atoms are affected by gravity (XGRAVITY, YGRAVITY)
'' * Atoms can bounce off the sides and bottom of the screen
'' and when they do, lose some momentum due to the
'' collision (BOUNDDECAY)
'' * Atoms have a max speed (MAXSPEED) to limit values and
'' make the simulation work better.
''
'' "Bonds" represent the relationship between two atoms.
'' When a bond is first created a distance between two atoms
'' is set to indicate how far the two atoms should be from
'' each other. Too far or too close and the system will move
'' the atoms closer or further apart. Let's call this the
'' balanced distance.
''
'' * The rate at which two atoms return to the balanced
'' distance is affected by stiffness (STIFFNESS).
'' * If two atoms are moving away from each other and the
'' instantaneous velocity is high enough the bond is
'' broken. (BREAKTHRESHOLD)
'' * If the magnitude of the relative velocity between two
'' atoms is high enough (DEFORMTHRESHOLD) the bond can be
'' deformed. The amount of deformation is controlled
'' by a factor. (FDEFORM)
Oh, I know what you're talking about now: http://jet.ro/dismount/
Not sure how it would work in 2D though ...
Not sure how it would work in 2D though ...
OK, here's another version that can load a from a bitmap.
ragdoll_smash.bas 14 k
ragdoll.bmp 4 k
WARNING: Some may find this program offensive and may not be suitable for younger audiences.
ragdoll_smash.bas 14 k
ragdoll.bmp 4 k
WARNING: Some may find this program offensive and may not be suitable for younger audiences.