Aleks11

Balls

Aug 20th, 2011
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.32 KB | None | 0 0
  1. alias ball {
  2.   window -apd +e @pic 50 50 518 540
  3.   set %pos[0].x 200.0 | set %pos[0].y 200.0
  4.   set %dp[0].x 0.7 | set %dp[0].y 0.5
  5.   set %pos[1].x 400.0 | set %pos[1].y 400.0
  6.   set %dp[1].x -0.7 | set %dp[1].y -0.4
  7.   set %rad 20
  8.   var %max 0
  9.   while (1) {
  10.     dll WhileFix.dll WhileFix .
  11.     var %t $ticks
  12.     drawrect -fn @pic 0 1 0 0 500 500
  13.     move 0
  14.     move 1
  15.     drawdot -n @pic 1 %rad %pos[0].x %pos[0].y
  16.     drawdot -n @pic 1 %rad %pos[1].x %pos[1].y
  17.     if ($calc((%pos[0].x - %pos[1].x)*(%pos[0].x - %pos[1].x)+(%pos[0].y - %pos[1].y)*(%pos[0].y - %pos[1].y)) $&
  18.       <= $calc(4 * %rad * %rad)) {
  19.       var %vx = $calc(%pos[1].x - %pos[0].x),%vy = $calc(%pos[1].y - %pos[0].y)
  20.       var %len $dist(%vx,%vy,0,0)
  21.       if (len > 0) {
  22.         var %vx $calc(%vx / %len)
  23.         var %vy $calc(%vy / %len)
  24.       }
  25.       push 0 $calc(-0.2 * %vx) $calc(-0.2 * %vy)
  26.       push 1 $calc(0.2 * %vx) $calc(0.2 * %vy)
  27.       var %rvx = $calc(%dp[0].x - %dp[1].x),%rvy = $calc(%dp[0].y - %dp[1].y)
  28.       var %exv $calc(%rvx * %vx + %rvy * %vy)
  29.       if (%exv > 0) {
  30.         bs %dp[0].x $calc(%dp[0].x + %vx * 0.2 * %exv)
  31.         bs %dp[0].y $calc(%dp[0].y + %vy * 0.2 * %exv)
  32.         bs %dp[1].x $calc(%dp[1].x - %vx * 0.2 * %exv)
  33.         bs %dp[1].y $calc(%dp[1].y - %vy * 0.2 * %exv)
  34.       }
  35.     }
  36.     drawdot @pic
  37.     var %t $calc($ticks - %t)
  38.     if (%t > %max) { var %max %t | echo -a %max }
  39.   }
  40. }
  41. alias dist return $sqrt($calc(( $1 - $3) * ( $1 - $3)) - (( $2 - $4) * ( $2 - $4)))
  42. alias move {
  43.   var %px = $+(pos[,$1,].x),%py = $+(pos[,$1,].y)
  44.   var %dx = $+(dp[,$1,].x),%dy = $+(dp[,$1,].y)
  45.   bs %px $calc($bg(%px) + $bg(%dx))
  46.   bs %py $calc($bg(%py) + $bg(%dy))
  47.   if ($calc($bg(%py) - %rad) <= 0.0 && $bg(%dy) <= 0.0) bs %dy $calc($bg(%dy) * -1)
  48.   if ($calc($bg(%py) + %rad) >= 500.0 && $bg(%dy) >= 0.0) bs %dy $calc($bg(%dy) * -1)
  49.   if ($calc($bg(%px) - %rad) <= 0.0 && $bg(%dx) <= 0.0) bs %dx $calc($bg(%dx) * -1)
  50.   if ($calc($bg(%px) + %rad) >= 500.0 && $bg(%dx) >= 0.0) bs %dx $calc($bg(%dx) * -1)
  51. }
  52. alias push {
  53.   bs $+(pos[, $1 ,].x) $calc($bg($+(pos[, $1 ,].x)) + $2 )
  54.   bs $+(pos[, $1 ,].y) $calc($bg($+(pos[, $1 ,].y)) + $3 )
  55.   bs $+(dp[, $1 ,].x) $calc($bg($+(dp[, $1 ,].x)) + $2 )
  56.   bs $+(dp[, $1 ,].y) $calc($bg($+(dp[, $1 ,].y)) + $3 )
  57. }
  58. alias bg return % [ $+ [ $1- ] ]
  59. alias bs set % [ $+ [ $1 ] ] $2
Advertisement
Add Comment
Please, Sign In to add comment