Difference between revisions of "Ball Friction"
From ASSS Wiki
m (oops, fixed mistake when I was tidying up the code) |
m (fixed another code tidying typo (good job no one has seems to have seen this yet)) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
fireball() | fireball() | ||
{ | { | ||
− | ball. | + | ball.frictiontimer = 1000000; |
} | } | ||
Line 8: | Line 8: | ||
updateball() | updateball() | ||
{ | { | ||
− | if (ball.xspeed | + | if (ball.xspeed || ball.yspeed) |
{ | { | ||
− | int workfriction = ball. | + | int workfriction = ball.frictiontimer / 1000; |
ball.xspeed = ball.xspeed * workfriction / 1000; | ball.xspeed = ball.xspeed * workfriction / 1000; | ||
ball.yspeed = ball.yspeed * workfriction / 1000; | ball.yspeed = ball.yspeed * workfriction / 1000; | ||
− | ball. | + | ball.frictiontimer -= cfg_friction; |
− | if (ball. | + | if (ball.frictiontimer < 0) |
− | ball. | + | ball.frictiontimer = 0; |
} | } | ||
} | } | ||
</pre> | </pre> | ||
+ | |||
+ | [[Category:Game Intricacies]] |
Latest revision as of 08:17, 10 March 2008
fireball() { ball.frictiontimer = 1000000; } // call this per tick updateball() { if (ball.xspeed || ball.yspeed) { int workfriction = ball.frictiontimer / 1000; ball.xspeed = ball.xspeed * workfriction / 1000; ball.yspeed = ball.yspeed * workfriction / 1000; ball.frictiontimer -= cfg_friction; if (ball.frictiontimer < 0) ball.frictiontimer = 0; } }