FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonbirds/fase.py at simples · pythonprobr/pythonbirds · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
pythonprobr
/
pythonbirds
Public
Notifications
You must be signed in to change notification settings
Fork
2k
Star
312
Code
Issues
3
Pull requests
3
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonbirds
/
fase.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
107 lines (74 loc) · 2.6 KB
Breadcrumbs
pythonbirds
/
fase.py
Copy path
File metadata and controls
107 lines (74 loc) · 2.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
from
itertools
import
chain
from
atores
import
ATIVO
VITORIA
=
'VITORIA'
DERROTA
=
'DERROTA'
EM_ANDAMENTO
=
'EM_ANDAMENTO'
class
Ponto
():
def
__init__
(
self
,
x
,
y
,
caracter
):
self
.
caracter
=
caracter
self
.
x
=
round
(
x
)
self
.
y
=
round
(
y
)
def
__eq__
(
self
,
other
):
return
self
.
x
==
other
.
x
and
self
.
y
==
other
.
y
and
self
.
caracter
==
other
.
caracter
def
__hash__
(
self
):
return
hash
(
self
.
x
)
^
hash
(
self
.
y
)
def
__repr__
(
self
,
*
args
,
**
kwargs
):
return
"Ponto(%s,%s,'%s')"
%
(
self
.
x
,
self
.
y
,
self
.
caracter
)
class
Fase
():
def
__init__
(
self
,
intervalo_de_colisao
=
1
):
"""
Método que inicializa uma fase.
:param intervalo_de_colisao:
"""
self
.
intervalo_de_colisao
=
intervalo_de_colisao
self
.
_passaros
=
[]
self
.
_porcos
=
[]
self
.
_obstaculos
=
[]
def
adicionar_obstaculo
(
self
,
*
obstaculos
):
"""
Adiciona obstáculos em uma fase
:param obstaculos:
"""
pass
def
adicionar_porco
(
self
,
*
porcos
):
"""
Adiciona porcos em uma fase
:param porcos:
"""
pass
def
adicionar_passaro
(
self
,
*
passaros
):
"""
Adiciona pássaros em uma fase
:param passaros:
"""
pass
def
status
(
self
):
"""
Método que indica com mensagem o status do jogo
Se o jogo está em andamento (ainda tem porco ativo e pássaro ativo), retorna essa mensagem.
Se o jogo acabou com derrota (ainda existe porco ativo), retorna essa mensagem
Se o jogo acabou com vitória (não existe porco ativo), retorna essa mensagem
:return:
"""
return
EM_ANDAMENTO
def
lancar
(
self
,
angulo
,
tempo
):
"""
Método que executa lógica de lançamento.
Deve escolher o primeiro pássaro não lançado da lista e chamar seu método lançar
Se não houver esse tipo de pássaro, não deve fazer nada
:param angulo: ângulo de lançamento
:param tempo: Tempo de lançamento
"""
pass
def
calcular_pontos
(
self
,
tempo
):
"""
Lógica que retorna os pontos a serem exibidos na tela.
Cada ator deve ser transformado em um Ponto.
:param tempo: tempo para o qual devem ser calculados os pontos
:return: objeto do tipo Ponto
"""
pontos
=
[
self
.
_transformar_em_ponto
(
a
)
for
a
in
self
.
_passaros
+
self
.
_obstaculos
+
self
.
_porcos
]
return
pontos
def
_transformar_em_ponto
(
self
,
ator
):
return
Ponto
(
ator
.
x
,
ator
.
y
,
ator
.
caracter
())
Back
|
FazBrowse Home
|
New Git URL