All pastes #513001 Raw Edit

Untitled

public text v1 · immutable
#513001 ·published 2007-05-27 02:14 UTC
rendered paste body
on *:close:@darting:{
  unset %y
  unset %d
  unset %mouse.x
  unset %mouse.y
  unset %f
  unset %gameplayed
  unset %x
}
alias draw {
  clear @darting
  set %y $r(100,400)
  set %d $r(200,500)
  /drawdot -h @darting 4 175 %d %y %d %y
  /drawdot -h @darting 7 150 %d %y %d %y
  /drawdot -h @darting 6 125 %d %y %d %y
  /drawdot -h @darting 9 100 %d %y %d %y
  /drawdot -h @darting 4 75 %d %y %d %y
  /drawdot -h @darting 7 75 %d %y %d %y
  /drawdot -h @darting 7 75 %d %y %d %y
  /drawdot -h @darting 6 50 %d %y %d %y
  /drawdot -h @darting 9 25 %d %y %d %y
  /drawdot -h @darting 4 5 %d %y %d %y
  /drawtext -h @darting 4 20 20 topscore: %top
}
menu * {
  Darts:{   
    window -pk0 +fxtn @Darting
    /draw
  }
}
menu @darting { 
  sclick:{
    if (%gameplayed) {
      /draw
      unset %gameplayed
    }
    else {
      set %mouse.x $mouse.x
      set %mouse.y $mouse.y
      /throw
    }
  }
}
alias throw {
  if ( $dialog(throw) ) {
    dialog -v throw throw
  }
  else {
    dialog -mv throw throw
  }
}
alias fly {
  dialog -x throw throw
  set %mouse.x $calc(%mouse.x $iif(- !isin %f,+ %f,%f) )
  set %mouse.y $calc(%mouse.y * $calc(%x / 100))
  /drawdot -h @darting 12 3 %mouse.x %mouse.y %mouse.x %mouse.y
  set %score $calc($remove($calc(%d - %mouse.x),-) + $remove($calc(%y - %mouse.y),-))
  set %gameplayed yes
  unset %f
  /drawtext -h @darting 20 50 50 To play again Click in the Window
  /drawtext -h @darting 4 20 30 Score: %score
  if ($round(%top) < $round(%score)) || (!%top) {
    set %top %score
  }
}
dialog Throw {
  title "Throwing the dart"
  size -1 -1 135 59
  option dbu
  text "Left-Right", 2, 7 20 25 8
  text "Move it a bit to the left the arrow flys a bit more to the left, move it a bit to the right the arrow flys a bit more to the right.", 3, 4 36 121 21
  button "Throw", 1, 43 5 37 10
  edit "", 4, 91 20 18 10, read
  button "<", 5, 38 19 12 10
  button "<<", 6, 50 19 12 10
  button ">>", 7, 62 19 12 10
  button ">", 8, 74 19 12 10
}
on *:dialog:throw:init:0:{
  did -a throw 4 0
}
on *:dialog:throw:sclick:5:{
  dec %f
  did -ra throw 4 %f
}
on *:dialog:throw:sclick:6:{
  dec %f 5
  did -ra throw 4 %f
}
on *:dialog:throw:sclick:7:{
  inc %f 5
  did -ra throw 4 %f
}
on *:dialog:throw:sclick:8:{
  inc %f
  did -ra throw 4 %f
}
on *:dialog:throw:sclick:1:{
  /window -p @Power -1 -1 50 100
  /drawdot -rh @power $rgb(225,150,0) 500 0 1
  set %x 150
  .timerthrow -m 0 50 /power
}
alias power {
  if ($window(@power)) {
    if (%x <= 20) {
      set %x 20
      inc %x 130
      /drawdot -rh @power $rgb(225,%x,0) 500 0 1
    }
    else { dec %x
      /drawdot -rh @power $rgb(225,%x,0) 500 0 1
    }
  }
  else { .timerthrow off
  }
}
menu @power {
  sclick:{ .timerthrow off
    clear @power
    window -c @power
    /fly
  }
}