shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] Script Boas Festas


From: Julio C. Neves
Subject: Re: [shell-script] Script Boas Festas
Date: Mon, 10 Dec 2007 17:56:42 -0200

Fala Reinaldo,
o que eu fiz estava estático, vc melhorou piscando as bolas, aproveiteia a
sua idéia e fiz outra versão, onde tenho sempre 25 bolas acesas, isto é, a
26a. rodada, apago a bola que liguei na rodada 1.

Pessoal, se não conhecer um cmd, procure-o na caixa que tem no canto
superior esquerdo do Papo de Botequim. Tentem entender e proponham melhorias
como o Reinaldo fez.

$ cat natal.sh
#!/bin/bash
# Versão 2.0
trap 'tput reset; exit' 2
clear
tput civis
lin=2
col=$(($(tput cols) / 2))
c=$((col-1))
tput setaf 2; tput bold
                 # Montando a Árvore
for ((i=1; i<20; i+=2))
{
    tput cup $lin $col
    for ((j=1; j<=i; j++))
    {
        echo -n \*
    }
    let lin++
    let col--
}
tput sgr0; tput setaf 3
for ((i=1; i<=2; i++))
{
    tput cup $((lin++)) $c
    echo '|||'
}
tput setaf 1; tput bold
tput cup $lin $((c - 4)); echo BOAS FESTAS
let c++
k=1
                   # Pendurando as bolas (da árvore, claro!)
while true; do
    for ((i=1; i<=25; i++))
    {
                   # Apagando a bola que foi ligada há 25 rodadas atras
       [ $k -gt 1 ] && {
            tput setaf 2; tput bold
            tput cup ${linha[$[k-1]$i]} ${coluna[$[k-1]$i]}; echo \*
            tput setaf 1; tput bold
            unset linha[$[k-1]$i]; unset coluna[$[k-1]$i]  # Mantenha limpo
o vetor
            }
        li=$((RANDOM % 9 + 3))
        ini=$((c-li+2))
        fim=$((c+li+2))
        co=$((RANDOM % (li-2) * 2 + 1 + ini))
        tput cup $li $co
        echo o
        linha[$k$i]=$li
        coluna[$k$i]=$co
        sleep 0.2
    }
done
-- 
Abraços,
Julio
Feliz Natal
:wq


Em 10/12/07, Reinaldo Carvalho <address@hidden> escreveu:
>
>   --- noel.sh 2007-12-10 14:29:13.000000000 -0300
> +++ noel.sh.old 2007-12-10 14:30:55.000000000 -0300
> @@ -1,7 +1,4 @@
> #!/bin/bash
> -
> -trap 'reset; exit' 2
> -while true; do
> clear
> lin=2
> col=$(($(tput cols) / 2))
> @@ -35,6 +32,4 @@
> tput cup $li $co
> echo o
> }
> -tput cup $((lin+2)) 0; tput civis; sleep 0.4; tput sgr0
> -done
> -
> +tput cup $((lin+2)) 0; tput civis; read -sn1; tput sgr0
>
> #!/bin/bash
>
> trap 'reset; exit' 2
> while true; do
> clear
> lin=2
> col=$(($(tput cols) / 2))
> c=$((col-1))
> tput setaf 2; tput bold
> for ((i=1; i<20; i+=2))
> {
> tput cup $lin $col
> for ((j=1; j<=i; j++))
> {
> echo -n \*
> }
> let lin++
> let col--
> }
> tput sgr0; tput setaf 3
> for ((i=1; i<=2; i++))
> {
> tput cup $((lin++)) $c
> echo '|||'
> }
> tput cup $lin $((c - 4)); echo BOAS FESTAS
> let c++
> tput setaf 1; tput bold
> for ((i=1; i<=15; i++))
> {
> li=$((RANDOM % 9 + 3))
> ini=$((c-li+2))
> fim=$((c+li+2))
> co=$((RANDOM % (li-2) * 2 + 1 + ini))
> tput cup $li $co
> echo o
> }
> tput cup $((lin+2)) 0; tput civis; sleep 0.4; tput sgr0
> done
>
> --
> Reinaldo Carvalho
>  
>


[As partes desta mensagem que não continham texto foram removidas]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]