Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- menu * {
- Pendulum:/pendulum.init
- }
- alias pendulum.init {
- .timerPend off
- if (!$window(@Pendulum)) { window -ep @Pendulum }
- else { drawrect -rf @Pendulum $rgb(255,255,255) 1 0 0 $window(@Pendulum).w $window(@Pendulum).h }
- %pendulum.radius = $$1
- %pendulum.angle = $calc($$2 * ($pi / 180))
- %pendulum.rate = $iif($3,$3,62)
- %pendulum.tick = $ticks
- %pendulum.momentum = 0
- %pendulum.x = $calc(0 $iif($2 > 0,+,-) $sin($2).deg * $1))
- %pendulum.y = $calc(0 $iif($2 > 0,+,-) $cos($2).deg * $1))
- .timerPend 0 0 pendulum.animate
- }
- alias pendulum.animate {
- var %x $window(@Pendulum).w / 2
- var %y $window(@Pendulum).h / 2
- var %distance $ticks - %pendulum.tick
- var %FPS 1 / %pendulum.rate
- %pendulum.tick = $ticks
- $iif(%pendulum.x > 0,dec,inc) %pendulum.momentum $calc((%fps * 9) * ($abs(%pendulum.x) / ($abs(%pendulum.y) + $abs(%pendulum.x))))
- inc %pendulum.angle $calc(%pendulum.momentum / %pendulum.radius)
- %pendulum.x = $sin(%pendulum.angle) * %pendulum.radius
- %pendulum.y = $cos(%pendulum.angle) * %pendulum.radius
- drawrect -nrf @Pendulum $rgb(255,255,255) 1 0 0 $window(@Pendulum).w $window(@Pendulum).h
- drawtext -nr @Pendulum $rgb(255,0,0) 10 $calc($window(@Pendulum).h - 100) Angular Momentum: %pendulum.momentum
- drawtext -nr @Pendulum $rgb(255,0,0) 10 $calc($window(@Pendulum).h - 90) Angular Momentum Ratio: $calc($abs(%pendulum.x) / ($abs(%pendulum.y) + $abs(%pendulum.x)))
- drawtext -nr @Pendulum $rgb(15,175,30) 10 $calc($window(@Pendulum).h - 150) FPS: $int($calc(1000 / %distance))
- drawtext -nr @Pendulum $rgb(15,175,30) 10 $calc($window(@Pendulum).h - 140) Emulation speed: $left($calc(%fps * (1000 / %distance) + 0.00001),7) $+ X
- drawline -nr @Pendulum $rgb(255,0,0) 2 %x %y $calc(%pendulum.x + %x) $calc(%pendulum.y + %y)
- drawdot -nref @Pendulum 0 4 $calc(%x + 2) $calc(%y + 2)
- var %n $sqrt(%pendulum.radius)
- drawdot -nref @Pendulum $rgb(0,0,255) %n $calc(%pendulum.x + %x + 4) $calc(%pendulum.y + %y + 4)
- drawdot @Pendulum
- }
- on 1:input:@Pendulum: {
- if ($1 == start) {
- pendulum.init $2-
- }
- if ($1 == stop) {
- pendulum.init
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement