## [Help] damage function

Discuss how to have fun with Algodoo, how to create games, and entertaining scenes.

### [Help] damage function

Hi everybody.. umm this question is a littlebit difficult,
i want to do a function that when polygon hit another polygon, the damage will reduce due to velocity and weight.
i need it to Wrestling game that i did..
this what i have now in the oncollide-
Code: Select all
`(e)=>{    scene.my.blue > 0 ? {scene.my.blue := (scene.my.blue - (2 + 2 * math.sin(sim.time * 2)))} : {        e.this.density := 60;        e.this.color := [0, 0, 0, 1];        scene.my.blue := 0    }}`

this is my scene-
Rating:
Filesize: 0.57 MB
Ratings: 2

i want to replace the "math.sin" function with much better function.
*I tried this
Code: Select all
`(e)=>{    x := (readable(owner)).vel(0);    y := (readable(owner)).vel(1);    {x < 0} ? {x := x * (-1)} : {};    {y < 0} ? {y := y * (-1)} : {};    {scene.my.green > 0} ? {scene.my.green := scene.my.green - (x * y)} : {density := 0}}`

(But i dont know why, i think x / y, dont change there direction, because when object goes left, x is -x and then -x*y
result= -(x*y) but i change it!
Code: Select all
`{x < 0} ? {x := x * (-1)} : {};`

and then health increase instead of decrease)
I cant take Speed and thatz it??
Hope you understand my problem..
plz if anyone can write this function for me it will be nice. (sorry for my bad english)
daniel1296

Posts: 15
Joined: Fri Dec 30, 2011 9:31 pm