<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Prezado Rodrigo e demais da lista<br>
      <br>
      obrigado por se manifestar.<br>
      eu guardei o código qdo apareceu na lista e procurando<br>
      meus arquivos antigos eu o achei!<br>
      <br>
      Penso que vc deveria era criar um pacote ou colocar na lista
      internacional<br>
      <br>
      pq é muito legal o joguinho feito num programa de estatística...<br>
      tem alguns no pacote 'fun', mas esse é bem melhor do que estão lá.<br>
      Certamente faria sucesso.<br>
      <br>
      <br>
      cleber<br>
      <br>
      <br>
      <br>
      <br>
      Em 02/10/2015 08:35, Rodrigo Coster escreveu:<br>
    </div>
    <blockquote
cite="mid:CAKU4wouptM8Omvzq+om5t9YvZS0drdqtKBLo9LGPpLz7sVSfAA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>Cleber,<br>
            <br>
          </div>
          Fui quem fiz o jogo. E tu desinterrou esse e-mail hein, é do
          final de 2010!<br>
          <br>
          <br>
        </div>
        []'s<br>
        <div>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">On Thu, Oct 1, 2015 at 10:07 PM,
              Leonardo Ferreira Fontenelle <span dir="ltr"><<a
                  moz-do-not-send="true"
                  href="mailto:leonardof@leonardof.med.br"
                  target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:leonardof@leonardof.med.br">leonardof@leonardof.med.br</a></a>></span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">Algora
                é tarde, mas deixo a dica mesmo assim. Procuro salvar
                trecho<br>
                assim com um comentário indicando o URL da fonte.<br>
                <span><font color="#888888"><br>
                    --<br>
                    Leonardo Ferreira Fontenelle<br>
                    <a moz-do-not-send="true"
                      href="http://lattes.cnpq.br/9234772336296638"
                      rel="noreferrer" target="_blank">http://lattes.cnpq.br/9234772336296638</a><br>
                  </font></span>
                <div>
                  <div><br>
                    Em Qui 1 out. 2015, às 21:51, Cleber N.Borges
                    escreveu:<br>
                    > olá a todos,<br>
                    ><br>
                    > um bom tempo atrás, alguém postou um código
                    (segue abaixo)<br>
                    ><br>
                    > Alguém sabe o autor? (pq queria dar o devido
                    crédito ao autor)<br>
                    ><br>
                    > Obrigado<br>
                    ><br>
                    > Cleber<br>
                    > #===============================<br>
                    ><br>
                    ><br>
                    ><br>
                    > tank <- function(x) {<br>
                    >   desenha <- function(ang1,ang2,t) {<br>
                    >    ang1 <- ang1<br>
                    >    ang2 <- ang2<br>
                    >    par(mar=rep(0,4),xaxs='i',yaxs='i')<br>
                    >   
                    plot(seq(0,t,by=0.01),mapa,type='n',ylim=c(0,t))<br>
                    >    xplot <- seq(0,t,by=0.01)<br>
                    >   
                    polygon(c(xplot,t,0),c(mapa,t,t),col='slategray1')<br>
                    >
segments(p1,y1,sin(ang1/180*pi)*(t/30)+p1,cos(ang1/180*pi)*(t/30)+y1,lwd=2)<br>
                    >
segments(p2,y2,-sin(ang2/180*pi)*(t/30)+p2,cos(ang2/180*pi)*(t/30)+y2,lwd=2)<br>
                    >    points(p1,y1,pch=16,cex=3,col=4)<br>
                    >    points(p2,y2,pch=16,cex=3,col=2)<br>
                    >   
                    polygon(c(xplot,t,0),c(mapa,0,0),col="green1")<br>
                    >
legend('topleft',paste(formatC(c('Angulo:','Força:','Vida:')),formatC(c(ang1,f1,v1),digits=2,width=7,format='f')),bty='n')<br>
                    >
legend('topright',paste(formatC(c('Angulo:','Força:','Vida:')),formatC(c(ang2,f2,v2),digits=2,width=7,format='f')),bty='n')<br>
                    >    text(t/2,t-.5,paste('Distância:
                    ',round(t1,2)))<br>
                    >    if (v2 < 0) { text(10,10,'Você ganhou!
                    \\o/',cex=3) ; stop('Fim de<br>
                    > jogo') }<br>
                    >    if (v1 < 0) { text(10,10,'Você perdeu!
                    <o>',cex=3) ; stop('Fim de<br>
                    > jogo') }<br>
                    >   }<br>
                    >   atira <- function(p,ang,forc,t,...) {<br>
                    >    ang1 <- (ifelse(p ==
                    2,ang-90,90-ang))/180*pi<br>
                    >    x <- ifelse(p == 1,p1,p2)<br>
                    >    a <- -(tan(ang1)/forc) ^2*(t1/20)<br>
                    >    b <- (tan(ang1)-2*a*x)<br>
                    >    c <- -(a*x^2 + b*x)<br>
                    >    x <- if (p == 1) seq(p1,t,.01) else
                    seq(p2,.01,-.01)<br>
                    >    yt <- a * x^2 + b*x + c + ifelse(p ==
                    1,y1,y2)<br>
                    >    y <- rep(NA,length(yt))<br>
                    >    if (sum(yt < mapa[x*100]) > 1) {
                    y[1:(which(yt < mapa[x*100])[2])] <-<br>
                    > yt[1:(which(yt < mapa[x*100])[2])] }<br>
                    >    else { y <- yt }<br>
                    >    check <- ifelse(p ==
                    1,(p2-p1-.39)*100,(p2-p1-.39)*100)<br>
                    >    if (!<a moz-do-not-send="true"
                      href="http://is.na" rel="noreferrer"
                      target="_blank">is.na</a>(y[check])) {<br>
                    >     pi <- if (p == 1) p2 else p1<br>
                    >     pi <- pi + c(.39,-.39)<br>
                    >     alv <- a * pi^2 + b*pi + c + ifelse(p ==
                    1,y1-y2,y2-y1)<br>
                    >     if (any(alv < 0) && any(alv >
                    0)) {<br>
                    >      pi <- if (p == 1) p2 else p1<br>
                    >      d <- dnorm((a * pi^2 + b*pi + c +
                    ifelse(p == 1,y1-y2,y2-y1))*10)<br>
                    >      if (p == 1) { v2 <<- v2-d*100 }<br>
                    >      if (p == 2) { v1 <<- v1-d*100 }<br>
                    >     }<br>
                    >    }<br>
                    >    lines(x,y,lty=2,...)<br>
                    >    return(invisible(cbind(x,y)))<br>
                    >   }<br>
                    >   tecla <- function(bot) {<br>
                    >    if (bot %in% c('Left','Right')) { ang1
                    <<- min(max(ang1 + ifelse(bot<br>
                    > == 'Left',-.25,+.25),0),90) }<br>
                    >    if (bot %in% c('Up','Down')) { f1 <<-
                    max(f1 + ifelse(bot ==<br>
                    > 'Up',.05,-.05),0) }<br>
                    >    if (bot == ' ') { atira(1,ang1,f1,t,col=1) ;
                    Sys.sleep(1) ;<br>
                    > desenha(ang1,ang2,t) ; joga() }<br>
                    >    desenha(ang1,ang2,t)<br>
                    >    return()<br>
                    >   }<br>
                    >   joga <- function() {<br>
                    >    if (n == 1) {<br>
                    >     m <- mapa[(p1*100+1):(p2*100-1)]<br>
                    >     a2 <-
                    atan((m-y1)/seq(.01,p2-p1-.01,.01))<br>
                    >     a1 <-
                    atan((m-y2)/seq(p2-p1-.01,.01,-.01))<br>
                    >     ang2 <<-
                    max(min(70-max(a1,a2)*180/pi,70),20)<br>
                    >     f2 <<- (p2-p1)*t1/70<br>
                    >    }<br>
                    >    else {<br>
                    >     f2 <<- f2t<br>
                    >    }<br>
                    >    desenha(ang1,ang2,t)<br>
                    >    o <- atira(2,ang2,f2,t)<br>
                    >    fv <<- rbind(fv,c(f2,ifelse(<a
                      moz-do-not-send="true" href="http://is.na"
                      rel="noreferrer" target="_blank">is.na</a>(o[(nrow(o)
                    - p1*100),2]),1,2)))<br>
                    >    if ((any(fv[,2] == 1)) &&
                    (any(fv[,2] == 2))) {<br>
                    >     f2t <<- mean(c(max(fv[fv[,2] ==
                    1,1]),min(fv[fv[,2] == 2,1])))<br>
                    >    }<br>
                    >    else {<br>
                    >     if (<a moz-do-not-send="true"
                      href="http://is.na" rel="noreferrer"
                      target="_blank">is.na</a>(o[(nrow(o) -
                    p1*100),2])) {<br>
                    >      f2t <<- f2*1.20*(t1/80+1)<br>
                    >      ln <<- n<br>
                    >     }<br>
                    >     else {<br>
                    >      f2t <<- f2*.8<br>
                    >     }<br>
                    >    }<br>
                    >    f3t <<- f2t<br>
                    >    Sys.sleep(1)<br>
                    >    desenha(ang1,ang2,t)<br>
                    >    n <<- n+1<br>
                    >   }<br>
                    >   ln <<- vector()<br>
                    >   f2t <- 0<br>
                    >   fv <- vector()<br>
                    >   f1 <- 2<br>
                    >   f2 <- 2<br>
                    >   v1 <- 100<br>
                    >   v2 <- 100<br>
                    >   ang1 <- 45<br>
                    >   ang2 <- 45<br>
                    >   t1 <- round(runif(1,5,20),2)<br>
                    >   t <- 20<br>
                    >   p1 <- round(runif(1,.05,.2)*t,2)<br>
                    >   p2 <- round(runif(1,.80,.95)*t,2)<br>
                    >   mapa <-<br>
                    >
filter(cumsum(sample(c(.25,.1,0,-.1,-.25),t*100+7,rep=T,prob=c(1,5,20,5,1))),rep(1,7)/7)<br>
                    >   mapa <- mapa[!<a moz-do-not-send="true"
                      href="http://is.na" rel="noreferrer"
                      target="_blank">is.na</a>(mapa)]<br>
                    >   mapa <- mapa - min(mapa) + .1<br>
                    >   mapa[mapa > 5] <- 5<br>
                    >   mapa[seq(p1*100-49,p1*100+49)] <-
                    mean(mapa[seq(p1*100-49,p1*100+49)])<br>
                    >   mapa[seq(p2*100-49,p2*100+49)] <-
                    mean(mapa[seq(p2*100-49,p2*100+49)])<br>
                    >   y1 <- mapa[p1*100]<br>
                    >   y2 <- mapa[p2*100]<br>
                    >   desenha(ang1,ang2,t)<br>
                    >   n <- 1<br>
                    >   getGraphicsEvent('Tanks',onKeybd=tecla)<br>
                    >   atira(1,ang1,2,t,col=1)<br>
                    >   atira(2,ang2,2,t,col=4)<br>
                    > }<br>
                    > tank()<br>
                    ><br>
                    > # Direcionais (esquerda e direita) movem e
                    espaço atira.<br>
                    ><br>
                  </div>
                </div>
              </blockquote>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
        <tr>
                <td style='border:none;padding:0px 15px 0px 8px'>
                        <a href="https://www.avast.com/antivirus">
                                <img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
                        </a>
                </td>
                <td>
                        <p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
                                Este email foi escaneado pelo Avast antivírus.
                                <br><a href="https://www.avast.com/antivirus">www.avast.com</a>
                        </p>
                </td>
        </tr>
</table>
<br />
</body>
</html>