[x]

deviantART

 

Physics test 1 by ~Supa-Monky:iconSupa-Monky:


©2006-2009 ~Supa-Monky
Details
Submitted: September 21, 2006
File Size: 8.1 KB
Image Size: 7.8 KB
Resolution: 275×186
Comments: 32
Favourites & Collections: 18 [who?]

Views
Total: 1,997
Today: 0

Downloads
Total: 48
Today: 0

Embed


Thumb

Artist's Comments

Test of multiple collisions against particles
[x]

Devious Comments

love 0 0 joy 0 0 wow 0 0 mad 0 0 sad 0 0 fear 0 0 neutral 0 0

Comments


damn that's cool..mindif i ask how you went about coding it?
Well for starters i like to test basic collision between the particles useing hitTest then after that you need to get the x and y distance

xd = particle._x - circle._x
yd = particle._y - circle._y

after that you can get the distance and direction

distance = Math.sqrt(xd*xd+yd*yd)
direction = -Math.atan2(xd,yd)/(Math.PI/180)

then you ask if the distance is less then the radius of the circle (if circle on circle collision use both radius's combined)
if the distance is less or equal (<=) then we go

particle._x = circle._x+(Math.cos((direction+90)*(Math.PI/180))*radius
particle._y = circle._y+(Math.sin((direction+90)*(Math.PI/180))*radius

the code above makes it so the particle cant pass through the circle, so it sets its position relitive to its direction

then you have to set new velocities to the particles
(i useually have to stuff around for a while to get what i want because i dont learn physics at school yet :[ )

for this i made the particles y velocity just bounce

yv = -yv*0.5+2 // y velocity = -y velocity * bounce + weight

and i tryed to make some of the y vecocity transfer into x velocity

xv = (Math.cos(dir+90)*yv)*0.5

if you need more help just ask, i know alot of formulas :P
wow...lol..that's a long reply

thanks :D
very nice.

good work.

--
Stalk me

[This is the Panic Office, section nine-seventeen may have been hit. Activate the following procedure.]
This very very cool...If I knew how to use this code *I saw your formula and I don't know...pretty advanced stuff for me personally* but if I could do it...i would use this effect to have the cursor as a movie clip of Pegasus and turn the blocks into droppings and have the circles as frowning heads...I apologize for that visual but my small mind thinks like that :P again nice coding on that ...works perfectly

--
:star:FLAnimate:star:

Midlife Crisis On Infinite Earths
You do know that im gonna have to make that now :D
YOU NEED TO!!!! oh man that would rock...I am telling you!

--
:star:FLAnimate:star:

Midlife Crisis On Infinite Earths

Site Map