57 lines
986 B
Python
57 lines
986 B
Python
# Lançamento oblíquo com a biblioteca turtle de Python
|
|
import turtle
|
|
|
|
LARG = 800
|
|
ALT = 600
|
|
MEIA_LARG = LARG//2
|
|
MEIA_ALT = ALT//2
|
|
|
|
pontos_foguete = (
|
|
(0, 0), # A
|
|
(5, 5), # B
|
|
(5, 15), # C
|
|
(0, 15), # D
|
|
(5, 20), # E
|
|
(10, 30), # F
|
|
(15, 20), # G
|
|
(20, 15), # H
|
|
(15, 15), # I
|
|
(15, 5), # J
|
|
(20, 0), # K
|
|
)
|
|
|
|
|
|
v0x = 10 # pixels/passo
|
|
v0y = 40 # pixels/passo
|
|
|
|
def sx(tempo: float) -> float:
|
|
return -MEIA_LARG + v0x*tempo
|
|
# fim-def
|
|
|
|
def sy(pos_x: float) -> float:
|
|
return -(3/800)*(pos_x**2)+300
|
|
# fim-def
|
|
|
|
def main():
|
|
turtle.setup(LARG, ALT)
|
|
turtle.register_shape('foguete', shape=pontos_foguete)
|
|
turtle.shape('foguete')
|
|
turtle.color('blue', 'red')
|
|
turtle.up()
|
|
turtle.hideturtle()
|
|
turtle.goto(-MEIA_LARG, -MEIA_ALT)
|
|
turtle.showturtle()
|
|
|
|
|
|
for t in range(81):
|
|
x = sx(t)
|
|
y = sy(x)
|
|
turtle.goto(x, y)
|
|
# fim-for
|
|
|
|
turtle.done()
|
|
# fim-def
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
# fim-if |