alias -l mot return $hget(Kshoot,word)
alias -l life return $hget(KShoot,life)
alias -l level return $hget(Kshoot,level)
alias -l timeout return $hget(Kshoot,timeout)
alias -l u drawline -rn @speed $1 1 $2 $3 $calc($2 +1) $3
alias -l v drawtext -nrc %win 14937070 Tahoma -7 $1-
alias -l w drawdot -r %win $1 5 $2 250
alias speed {
  if (!$window(@speed)) /window -apdhRk0 @Speed 100 100 450 290
  %win = @speed
  hadd -m kShoot life 5 | hadd -m KShoot word $read($+(",$scriptdirKsDB.txt,"))
  drawrect -nfr %win 0 1 0 0 450 300
  var %i = 0, %x = 0, %rouge
  while (%i < 3.1416) {
    %rouge = $int($calc($sin(%i) * 255))
    u %rouge %x 25 | u %rouge %x 225
    inc %x 1 | inc %i 0.007
  }
  var %i = 0, %x = 30, %rouge
  while (%i < 3) {
    %rouge = $int($calc($sin(%i) * 255))
    drawline -rn %win $rgb(%rouge,%rouge,%rouge) 1  400 %x 400 $calc(%x + 1)
    inc %x 1 | inc %i 0.016
  }
  v 340 230 90 12 Lifes : | v 200 230 90 12 Shoot speed : | v 20 10 90 12 Level :
  w 14937070 350 | w 14937070 360 | w 14937070 370 | w 14937070 380 | w 14937070 390
  drawrect -nr %win 16777215 1 424 7 12 13
  v 60 10 90 12 $level | v 100 10 90 12 Next level : | v 240 10 120 12 Words already shoot :
  v 428 8 120 12 ? | v 20 230 90 12 Keyboard Shoot v1 | v 20 245 90 12 by Monark.
  set %xdtext 2 | .timerdtext -m 0 $calc(1000 / ($level * 6)) dtext | drawdot %win

}
alias -l dtext {
  if ($window(@Speed)) {
    set %dtick = $ticks
    if ($calc(%xdtext + $width($mot,Tahoma,-20,1)) < 400) {
      var %win = @speed
      if ($mot != $null) {
        drawrect -nrf %win 0 1 $calc(%xdtext - 3) 110 $width($mot,Tahoma,-20) 50 
        $iif($mot != $null,drawtext -nrc %win 14937070 Tahoma -20 %xdtext 110 $width($ifmatch,Tahoma,-20) 50 $ifmatch)
        drawdot %win | inc %xdtext 3
      }
    }
    elseif ($calc(%xdtext + $width($mot,Tahoma,-20,1)) >= 400) {
      if ($life > 0) {
        .timerdtext off
        drawrect -nrf %win 0 1 $calc(%xdtext - 3) 110 $width($mot,Tahoma,-20) 50 
        drawtext -nrc %win 14937070 Tahoma -22 70 110 450 50 You are too slow!
        drawtext -nrc %win 14937070 Tahoma -8 140 143 450 50 Press ENTER
        w 0 $calc(350 + ((5- $life) * 10)) | hadd KShoot life $calc($life - 1) | hadd Kshoot timeout $ $+ true
      }
      elseif ($life <= 0) { 
        drawrect -nrf %win 0 1 $calc(%xdtext - 3) 110 $width($mot,Tahoma,-20) 50
        drawtext -nrc %win 14937070 Tahoma -22 80 110 450 50 GAME OVER! 
        .timerdtext off
      }
      var %i = 0, %x = 30, %rouge | unset %xdtext
      while (%i < 3) {
        %rouge = $int($calc($sin(%i) * 255))
        drawline -rn %win $rgb(%rouge,%rouge,%rouge) 1  400 %x 400 $calc(%x + 1)
        inc %x 1 | inc %i 0.016
      }
      drawdot @Speed
    }
  }
  if (!$window(@Speed)) { .timerdtext off | unset %xdtext | halt }
}
menu channel,status,menubar {
  KeyBoard Shoot:/speed
}
menu @speed {
  sclick: {
    if ($inrect($mouse.x,$mouse.y,428,7,12,13)) run $scriptdiraide.txt
  }
}
on *:close:@speed:hadd KShoot level 1 | hadd KShoot life 5 | hadd KShoot timeout $ $+ false | hsave KShoot $+(",$scriptdirKshoot.hash,") | unset %nlevel %xdtext
on *:keydown:@speed:*: {
  if ($keychar == $chr(13)) && ($timeout == $true) { 
    drawrect -nrf @speed 0 1 70 100 250 70 | .hadd Kshoot timeout $ $+ false
    drawdot %win | .hadd KShoot word $read($+(",$scriptdirKsDB.txt,")) 
    set %xdtext 2 | .timerdtext -m 0 $calc(1000 / ($level * 6)) dtext | set %dtick = $ticks
  }
  if ($keychar == $left($mot,1)) && ($timeout == $false) { 
    .hadd KShoot word $right($mot,-1) 
    if ($mot) && ($timer(dtext)) {
      drawrect -nrf %win 0 1 $calc(%xdtext - 9) 110 $calc($width($mot $+ $keychar,Tahoma,-20) + 11) 50 
      drawtext -nrc %win 14937070 Tahoma -20 %xdtext 110 $width($mot,Tahoma,-20) 50 $mot
      drawdot %win | inc %xdtext 3
    }
    elseif (!$mot) && (!$timeout) && ($timer(dtext)) {
      drawrect -nrf %win 0 1 $calc(%xdtext - 3) 110 $calc($width($mot $+ $keychar,Tahoma,-20) + 5) 50  
      .hadd KShoot word $read($+(",$scriptdirKsDB.txt,")) 
      set %xdtext 2 | $iif(%nlevel,inc %nlevel,set %nlevel 1)
      drawrect -nrf %win 0 1 320 10 30 10 | drawrect -nrf %win 0 1 180 10 20 10 | drawrect -nrf %win 0 1 60 10 20 10
      v 320 10 20 10 %nlevel | v 180 10 20 10 $iif($level == 1,$calc(10 - %nlevel),$replace($calc(5 - (%nlevel - ($level * 5))),0,5)) | v 60 10 20 10 $level
      v 180 10 20 10 $iif($level == 1,$calc(10 - %nlevel),$replace($calc(5 - (%nlevel - ($level * 5))),0,5))
      v 200 245 70 15 Indisponible! :(
      drawdot %win | .hadd KShoot level $iif(%nlevel <= 5,1,$int($calc(%nlevel / 5)))
      .timerdtext -m 0 $calc(1000 / ($level * 6)) dtext 
      set %dtick = $ticks
    }
  }
}
on *:Start: {
  .hmake Kshoot 100
  if ($exists($+(",$scriptdirKshoot.hash,"))) .hload kshoot $+(",$scriptdirKshoot.hash,")
  if (!$hget(Kshoot,level)) .hadd KShoot level 1
  .hadd KShoot word $read($+(",$scriptdirKsDB.txt,"))
}
on *:load: {
  echo -st Thank you to have download my add-on : KShoot. | echo -st To open it you have several choices :
  echo -st - typing /speed | echo -st - right click on window status, channel
  echo -st - click in the menubar. | echo -s - | echo -st Have fun! Monark!
}
