Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlucena authored Jan 30, 2017
1 parent 1dfe120 commit 285f01b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 35 deletions.
77 changes: 42 additions & 35 deletions potigol/CataEstrela.poti
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use "jerimum"

# Tipos
tipo Jogador
x, y: Real
imagem = Imagem("Nave.bmp")
var x, y: Real
imagem = Imagem("Nave.png")
var placar = 0
var vel_x, vel_y = 0.0
var angulo = 0.0

desenhe()
imagem.desenhe(x, y, 3, angulo)
imagem.desenhe_centralizado(x, y, 3, angulo)
fim

girar_direita()
Expand All @@ -28,100 +28,107 @@ tipo Jogador
mover()
x := x + vel_x
y := y + vel_y
x := x mod jogo.largura
y := y mod logo.altura

x := (jogo.largura + x) mod jogo.largura
y := (jogo.altura + y) mod jogo.altura
vel_x := vel_x * 0.95
vel_y := vel_y * 0.95
fim

cata_estrelas(estrelas: Lista[Estrela])
catado = estrelas.selecione(estrela => Jogo.distancia(x, y, estrela.x, estrela.y) >= 35)
catar_estrelas(estrelas: Lista[Estrela])
catado = estrelas.selecione(
estrela => Jogo.distância(x, y, estrela.x, estrela.y) >= 35
)
n = estrelas.tamanho - catado.tamanho
placar := placar + n * 10
catado
fim
fim

tipo Estrela
cor: Cor
x = aleatório(jogo.largura)
y = aleatório(jogo.altura)
cor = Cor(aleatório(40, 256), aleatório(40, 256), aleatório(40, 256))
imagens = Imagem.fatie("Estrela.png", 25, 25)

desenhe()
imagem = imagens[Relogio.milisegundos div 100 mod imagens.tamanho + 1]
imagem.desenhe(x - imagem.largura / 2, y - imagem.altura / 2, 1, 0, color)
img = imagens[Relogio.milisegundos div 100 mod imagens.tamanho + 1]
img.desenhe_centralizado(x, y, 1, 0)
fim
fim

imagem_fundo = Imagem("/textures/Space.png")
imagem_fundo = Imagem("Space.png")
nave = Jogador(40, 40)
var estado = "INICIO"
var tempo := 0.0
fonte = Fonte(16)

var estrelas = Lista(1,Estrela(Cor.BRANCO))

var estrelas = Lista[Estrela]()
para i de 1 até 10 faça
estrelas = Estrela(aleatorio(620), aleatorio(460)) :: estrelas
estrelas := Estrela(Cor.BRANCO) :: estrelas
fim

desenhe()
imagem_fundo.desenhe(0, 0, 0)
escolha estado
caso "INICIO" => desenhe_inicio
caso "JOGANDO" => desenhe_jogando
caso "FIM" => desenhe_fim
caso _ => desenhe_fim
fim
fim

atualize()
escolha estado
caso "INICIO" => atualize_inicio
caso "JOGANDO" => atualize_jogando
caso _ =>
caso _ => atualize_fim
fim
fim

# Estado: inicio do jogo
atualize_inicio()
se teclado.TECLA_I então estado := "JOGANDO" fim
se Teclado.TECLA_I então estado := "JOGANDO" fim
fim

draw_inicio()
desenhe_inicio()
msg = "PRESSIONE [I] PARA COMEÇAR"
fonte.desenhe_centralizado(msg, largura / 2, height / 2, 3, Cor.AMARELO)
end
fonte.desenhe_centralizado(msg, jogo.largura / 2, jogo.altura / 2, 3, Cor.AMARELO)
fim

# Estado: JOGANDO
atualize_jogando()
# eventos
se Teclado.TECLA_PARA_DIREITA então jogador.girar_direita fim
se Teclado.TECLA_PARA_ESQUERDA então jogador.girar_esquerda fim
se Teclado.TECLA_PARA_CIMA então jogador.acelerar fim
se Teclado.TECLA_PARA_DIREITA então nave.girar_direita fim
se Teclado.TECLA_PARA_ESQUERDA então nave.girar_esquerda fim
se Teclado.TECLA_PARA_CIMA então nave.acelerar fim
# inserir novas estrelas estrelas se necessario
se aleatório(100) < 4 e estrelas.tamanho < 25 então estrelas := Estrela() :: estrelas fim
se aleatório(100) < 4 e estrelas.tamanho < 25 então
estrelas := Estrela(Cor.BRANCO) :: estrelas
fim

estrelas := jogador.cata_estrelas(estrelas) # catar estrelas
jogador.mover # atualizar a posicao do jogador
estrelas := nave.catar_estrelas(estrelas) # catar estrelas
nave.mover # atualizar a posicao do jogador
tempo := tempo + 1.0/60.0 # incrementar o tempo
se tempo.inteiro >= 30 então estado := "FIM" fim # terminar o jogo depois de 30 segundos
fim

desenhe_jogando()
jogador.desenhe
nave.desenhe
para estrela em estrelas faça
estrela.desenhe
fim
fonte.desenhe("Placar: {jogador.placar}", 10, 10, 3, Cor.AMARELO)
fonte.desenhe("Tempo: {tempo.inteiro}s", 10, 30, 3, Cor.AMARELO)
fonte.desenhe("Placar: {nave.placar}", 10, 20, 3, Cor.AMARELO)
fonte.desenhe("Tempo: {tempo.inteiro}s", 10, 40, 3, Cor.AMARELO)
fim

# Estado: fim do jogo
draw_fim()
msg = "FIM DE JOGO, VOCE FEZ {jogador.placar} PONTOS"
fonte.desenhe_centralizado(msg, meio/2, altura/2, 3, Cor.AMARELO)
desenhe_fim()
msg = "FIM DE JOGO, VOCE FEZ {nave.placar} PONTOS"
fonte.desenhe_centralizado(msg, jogo.largura/2, jogo.altura/2, 3, Cor.AMARELO)
fim

# Jogo
jogo = Jogo("Cata Estrelas", 640, 480, atualize, desenhe)
jogo.iniciar
atualize_fim()
fim

# Jogo
jogo.iniciar("Cata Estrelas", 640, 480, atualize, desenhe)
Binary file added potigol/Estrela.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added potigol/Nave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added potigol/Space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added potigol/potigol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 285f01b

Please sign in to comment.