Jogo de Programação!!!

Started by DavidSalgueiro, March 23, 2006, 10:50:33 PM

Previous topic - Next topic

KTachyon

Em COW:

oom moO oom MOO MOo mOo MoO moO moo mOo OOM
Atenção: ISTO FUNCIONA!
My Q4 estimate: Macs: 5.89M; iPods: 4.19M; iPhones: 30.0M; iPads: 18.05M; Revenue: 37.00B; EPS: 9.50
AAPL Q3 result: Macs: 4.02M; iPods: 6.80M; iPhones: 26.0M; iPads: 17.04M; Revenue: 35.02B; EPS: 9.32

Teotónio Ricardo

QuoteEm COW:

oom moO oom MOO MOo mOo MoO moO moo mOo OOM
Atenção: ISTO FUNCIONA!

Tás a gosar ou existe mesmo a linguagem de programação \\"Baca\\"?

KTachyon

My Q4 estimate: Macs: 5.89M; iPods: 4.19M; iPhones: 30.0M; iPads: 18.05M; Revenue: 37.00B; EPS: 9.50
AAPL Q3 result: Macs: 4.02M; iPods: 6.80M; iPhones: 26.0M; iPads: 17.04M; Revenue: 35.02B; EPS: 9.32

Teotónio Ricardo

QuoteYup:

http://www.bigzaphod.org/cow/

Bem, isso mesmo para quem não tem nada que fazer!

lol

KTachyon

My Q4 estimate: Macs: 5.89M; iPods: 4.19M; iPhones: 30.0M; iPads: 18.05M; Revenue: 37.00B; EPS: 9.50
AAPL Q3 result: Macs: 4.02M; iPods: 6.80M; iPhones: 26.0M; iPads: 17.04M; Revenue: 35.02B; EPS: 9.32

KTachyon

Bem... brainfuck até é fácil...

,>,[-<+>].
O verdadeiro brainfuck é a whitespace... não me meto com essa linguagem... pretendo manter o meu cerebro funcional durante mais uns kuantos anos.
My Q4 estimate: Macs: 5.89M; iPods: 4.19M; iPhones: 30.0M; iPads: 18.05M; Revenue: 37.00B; EPS: 9.50
AAPL Q3 result: Macs: 4.02M; iPods: 6.80M; iPhones: 26.0M; iPads: 17.04M; Revenue: 35.02B; EPS: 9.32


nDray

whitespace eÃ,´ mais interessante.............................


Let\'s communicate one byte at a time :)

Undertaker

Lindo, só falta em assembly.... (tou a brincar)...

KTachyon

Já kuase me eskecia desse... ainda bem k m lembrás-t

Kdo tiver tempo coloco aki o código para Assembly MIPS.
My Q4 estimate: Macs: 5.89M; iPods: 4.19M; iPhones: 30.0M; iPads: 18.05M; Revenue: 37.00B; EPS: 9.50
AAPL Q3 result: Macs: 4.02M; iPods: 6.80M; iPhones: 26.0M; iPads: 17.04M; Revenue: 35.02B; EPS: 9.32

lycosman

Grande! Mesmo grande!

DarkBASIC


10:

cls : sync on : sync rate 30 : randomize rnd(200)



set display mode 640, 480, 32

ink rgb(255, 255, 255), 0



hide mouse

set text font "system"

set text size 100

center text 320, 130, "|  PONG   "

center text 580, 340, ".   |"

line 200, 220, 440, 220

set text size 20

line 320, 0, 320, 480

center text 320, 230, "Made by lycosman_"

center text 320, 275, "Controlos:"

line 240, 290, 400, 290

text 200, 300, "Setas cima/baixo:  Movimento"

text 200, 315, "Click direito:   Terminar"

text 200, 330, "Botão\\'S\\': Resultados"

center text 320, 360, "Pressione qualquer tecla para continuar..."

center text 320, 400, "Pressione Esc para sair."

set text font "arial"

set text size 12

center text 320, 460, "v1.03"

suspend for key:cls

set text font "system"

if inkey$()="s" then gosub scores



40:

cls

set text size 30

center text 320, 150, "MENU PRINCIPAL"

line 240, 190, 400, 190

set text size 20

text 240, 210, "Pressione \\'S\\' para ver a classificação"

text 240, 225, "Pressione \\'G\\' para começar"

text 240, 240, "Pressione \\'W\\' paravoltar ao ecrã de arranque"

text 240, 255, "Pressione \\'Q\\' a qualquer altura para sair"

set cursor 315, 300

input ans$

if ans$ = "s" then gosub scores

if ans$ = "g" then goto 30

if ans$ = "q" then goto 10

if ans$ <> "s" and ans$ < "g" and ans$ <> "q"

   cls : goto 40

endif



30:

y = rnd(480):x=rnd(640)

something=2:something2=4

ink rgb(255, 255, 255), 0

rx = 2:ry = 2

player1_score = 0

player2_score = 0

20:

cls

input "Escolha a dificuldade (fácil, médio, difícil, impossível:)", diff$

if diff$ = "fácil" then ai_diff = 3

if diff$ = "médio" then ai_diff = 4

if diff$ = "difícil" then ai_diff = 5

if diff$ = "impossível" then ai_diff = 7

if diff$ <> "fácil" and diff$ <> "médio" and diff$ <> "difícil" and diff$ <> "impossível"

   print "Tem de escolher uma dificuldade! Não inclua"

   print "maiusculas ou espaços."

   wait 3000 : cls : goto 20

endif



do : cls



   set text size 30

   set cursor 300, 10

   print player1_score

   set cursor 335, 10

   print player2_score

   box x-10, y-10, x, y







   if x > 620

 if y >= y3 and y <= (y3+5)

ry = 7

something = 1

something2 = 3

 endif

 if y >= (y3 + 5) and y <= (y3 + 20)

ry = 5

something = 1

 endif

 if y >= (y3 + 20) and y <= (y3 + 40)

something = 1

 endif

 if y >= (y3 + 40) and y <= (y3 + 55)

ry = 5

something = 1

 endif

 if y >= (y3 + 55) and y <= (y3 + 70)

ry = 7

something = 1

something2 = 4

 endif

 if y < y3 or y > (y3 + 60)

x = x + 10

player1_score = player1_score + 1

y = rnd(240):x=rnd(320):rx = 4:ry = 4

wait 500

 endif

   endif

   if x < 20

 if y >= y2 and y <= (y2+5)

ry = 7

something = 2

something2 = 3

 endif

 if y >= (y2 + 5) and y <= (y2 + 20)

ry = 5

something = 2

 endif

 if y >= (y2 + 20) and y <= (y2 + 40)

something = 2

 endif

 if y >= (y2 + 40) and y <= (y2 + 55)

ry = 5

something = 2

 endif

 if y >= (y2 + 55) and y <= (y2 + 70)

ry = 7

something = 2

something2 = 4

 endif

 if y < y2 or y > (y2 + 60)

x = x - 10

player2_score = player2_score + 1

y = rnd(240)+240:x=rnd(320)+320:rx = 4:ry = 4

wait 500

 endif

   endif

   if y > 480 then something2 = 3

   if y < 10 then something2 = 4









   if something = 1 then x = x - rx

   if something = 2 then x = x + rx

   if something2 = 3 then y = y - ry

   if something2 = 4 then y = y + ry





   box 0, y2, 10, y2+50

   box 620, y3, 630, y3+50

   line 320, 0, 320, 480

   if upkey()=1

 y2 = y2 - 5

 if y2 < 15 then y2 = 15

   endif

   if downkey()=1

 y2 = y2 + 5

 if y2 > 415 then y2 = 415

   endif

   if y < (y3 + 25)

 y3 = y3 - ai_diff

 if y3 < 15 then y3 = 15

   endif

   if y > (y3 + 25)

 y3 = y3 + ai_diff

 if y3 > 415 then y3 = 415

   endif





   if mouseclick()=2

 if diff$ = "fácil"

if hscore < player1_score then hscore = player1_score

 endif

 if diff$ = "médio"

if hscorem < player1_score then hscorem = player1_score

 endif

 if diff$ = "difícil"

if hscoreh < player1_score then hscoreh = player1_score

 endif

 if diff$ = "impossível"

if hscorei < player1_score then hscorei = player1_score

 endif

 goto 10

   endif

   if inkey$() = "s"

 if diff$ = "fácil"

if hscore < player1_score then hscore = player1_score

 endif

 if diff$ = "médio"

if hscorem < player1_score then hscorem = player1_score

 endif

 if diff$ = "difícil"

if hscoreh < player1_score then hscoreh = player1_score

 endif

 if diff$ = "impossível"

if hscorei < player1_score then hscorei = player1_score

 endif

 gosub scores

   endif



   if player1_score = 10 or player2_score = 10

 set text size 60

 if player1_score = 10

cls

center text 320, 200, "GANHOU!"

if diff$ = "fácil"

if hscore < player1_score then hscore = player1_score

endif

if diff$ = "médio"

if hscorem < player1_score then hscorem = player1_score

endif

if diff$ = "difícil"

if hscoreh < player1_score then hscoreh = player1_score

endif

if diff$ = "impossível"

if hscorei < player1_score then hscorei = player1_score

endif

wait 3500: goto 10

 endif

 if player2_score = 10

cls

center text 320, 200, "PERDEU!"

if diff$ = "fácil"

if hscore < player1_score then hscore = player1_score

endif

if diff$ = "médio"

if hscorem < player1_score then hscorem = player1_score

endif

if diff$ = "difícil"

if hscoreh < player1_score then hscoreh = player1_score

endif

if diff$ = "impossível"

if hscorei < player1_score then hscorei = player1_score

endif

wait 3500: goto 10

 endif

   endif



sync : loop



scores:

   cls

   set text size 30

   center text 320, 150, "RESULTADOS"

   line 240, 190, 400, 190

   set text size 20

   set cursor 240, 210

   print "Classificações:  Fácil  ", hscore

   set cursor 240, 225

   print "   Médio ", hscorem

   set cursor 240, 240

   print "   Difícil   ", hscoreh

   set cursor 240, 255

   print "   impossível ", hscorei

   set cursor 210, 380

   print "Pressione qualquer tecla...":wait 1000

   suspend for key:cls

   goto 10

return

É um jogo do tipo PONG, sem som e com algumas lacunas... Se quizerem o EXE para verem como é digam...

EDIT: assim está mais bonito...
Hooray for chainsaws :3


DavidSalgueiro

Conection Refused!!!

KTachyon

Quoteimport java.awt.*;
import java.applet.*;

public class PingPong extends Applet implements Runnable {

    int d = 20, x_init, y_init, x, y, bool = 0, velocidade;
    Thread kicker = null;
   
    public void init () {
        /* Posição inicial aleatória (mas dentro dos limites do Applet)
        (x_init, y_init) */
        x_init = (int) (Math.random() * getWidth());
        y_init = (int) (Math.random() * getHeight());
       
       
        // Direcção inicial aleatória (vector (x,y) inicial)
        x = (int)((Math.random() * 10 + 1) * Math.pow(-1, (int)(Math.random()*2)));
        y = (int)((Math.random() * 10 + 1) * Math.pow(-1, (int)(Math.random()*2)));
       
        /***************************
        (Math.random() * 10 + 1)
       
        Dá um numero aleatório de 1 a 10
               
       
        Math.pow(-1, (int)(Math.random()*2))
       
        Dá o valor 1 ou -1, tornando o y ou o x negativo ou positivo para que a
        direcção inicial possa ser qualquer uma num angulo de 360 graus.
        ***************************/
       
       
        velocidade = (int) (Math.random() * 20 + 1);
        /* A velocidade é o tempo de sleep do Thread, logo quanto maior for mais
        lenta é a bola.
        A velocidade máxima é 50.*/
    }
   

    public void paint (Graphics g) {
       
        if (bool == 0) {
            g.setColor(Color.white);
            g.fillOval(x_init, y_init, d, d);
        }
        else {
            g.setColor(Color.blue);
            g.fillOval(x_init, y_init, d, d);
        }
    }
   
    public void run() {
        while (true) {
       
            bool = 0;
            repaint();
           
            x_init += x;
            y_init += y;
           
            if (x_init >= getWidth() - d) {
                x_init = (getWidth() - d);
                x *= -1;
            }
            if (x_init <= 0) {
                x_init = 0;
                x *= -1;
            }
            if (y_init >= getHeight() - d) {
                y_init = (getHeight() - d);
                y *= -1;
            }
            if (y_init <= 0) {
                y_init = 0;
                y *= -1;
            }
           
            bool = 1;
            repaint();
           
            try {
                Thread.sleep(velocidade);
            }
            catch (Exception e) {
            }
        }
    }
   
    public void start() {
        if (kicker == null) {
            kicker = new Thread(this);
            kicker.start();
        }
    }
}

Basicamente é um programa k faz uma bola andar numa direcção a uma velocidade aleatória k quando embate nas paredes desvia-se para outra direcção.
My Q4 estimate: Macs: 5.89M; iPods: 4.19M; iPhones: 30.0M; iPads: 18.05M; Revenue: 37.00B; EPS: 9.50
AAPL Q3 result: Macs: 4.02M; iPods: 6.80M; iPhones: 26.0M; iPads: 17.04M; Revenue: 35.02B; EPS: 9.32

southafrikanse

Isto é JAVA?

Bolas.....

Estou mesmo verde quanto a esta linguagem. E eu que tenho uma disciplina destas na faculdade e não consigo perceber como se fazem os exercicios... e já tenho um projecto da disciplina para fazer e já prevejo longas serões a trabalhar nele....

Eu pelo menos estou a seguir Electrónica e é muito mais bonito do que estas palavras. Só mesmo para quem gosta.... nem sei porque tenho isto no curso.

Mas pelos vistos sei que se tiver dúvidas no projecto já sei onde encontrar os malucos da programação.  Vão me ajudar não vão?

Alguém conhece um jogo de cartas chamado Jogo do 21?
Blog Pessoal | Tugatrónica | Fórum Webtuga
"Knowledge is knowing that a tomato is a fruit, but Wisdom is knowing not to put it in a fruit salad."


southafrikanse

Quote.Up

Eu escrevi o post há praticamente um ano cenouras :wink:
Blog Pessoal | Tugatrónica | Fórum Webtuga
"Knowledge is knowing that a tomato is a fruit, but Wisdom is knowing not to put it in a fruit salad."

scotty

FORTRAN

    program soma_webtuga
    implicit none
    real num1,num2,soma
    soma=0.0
    num1=0
    num2=0
    print *,\\'Escreva o primeiro numero \\'
    read *, num1
    print *,\\'Escreva o segundo numero \\'
    read *, num2
    soma=num1+num2
    print *,\\' RESULTADO\\',soma
    stop
    end


Não sei nada de fortran, só andei a ler o suficiente para contribuir para o jogo lol, é interesante ver as diferenças de linguagem lol.

Teotónio Ricardo

É parecido com pascal... lol

eLson

tão vão criar um jogo é? :roll:

rda

este é o meu primeiro post neste forum, e nada melhor para começar do que programação!!

Haskell:

soma :: Int -> Int -> Int
soma x y = x+y

---------------------------------------------------------------------------------------------------
para kem não conhece:
 - linguagem porreira não é?