Created
May 1, 2017 00:16
Teste de colisão
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#testa colisão em um eixo e retorna verdadeiro ou falso | |
def test_colli(a, b, c, d): | |
if (a >= c and a <= d) or (b >= c and b <= d): | |
return True | |
return False | |
#posição x e y do canto esquerdo do retangulo | |
posX = input () | |
posY = input () | |
#posição x e y do canto direito do retângulo | |
larguraX = input () | |
larguraY = input () | |
#posição x e y do canto esquerdo do outro retangulo | |
pos2X = input () | |
pos2Y = input () | |
#posição x e y do canto direito do outro retangulo | |
largura2X = input () | |
largura2Y = input () | |
#testa a colisão nos dois eixos | |
colX = test_colli(posX, larguraX, pos2X, largura2X) | |
colY = test_colli(posY, larguraY, pos2Y, largura2Y) | |
#caso colida nos dois eixos, o resultado será 1 ("verdadeiro") | |
if colX and colY: | |
print (1) | |
else: | |
print (0) |
felipemfp
commented
May 1, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment