inf-kswo/Animation/Animation_ship.py
2025-01-20 19:41:45 +01:00

102 lines
1.5 KiB
Python
Executable File

from turtle import*
import time
import math
speed_boat = 0.01
def ship():
clear()
fd(130)
lt(50)
fd(50)
lt(130)
fd(90)
rt(90)
fd(150)
rt(154)
fd(math.sqrt(16900 + 4900))
rt(116)
fd(65)
lt(90)
fd(18)
rt(90)
fd(102)
lt(130)
fd(49)
lt(50)
update()
def ship_2():
clear()
fd(130)
lt(50)
fd(50)
lt(130)
fd(240)
rt(130)
def speed_more():
global speed_boat
speed_boat += 0.5
def goleft():
lt(1)
bk(1)
def goright():
rt(1)
bk(1)
def speed_less():
global speed_boat
speed_boat -= 0.5
def speed_stop():
global speed_boat
speed_boat = -1.35
def speed_exelerate_fast():
global speed_boat
speed_boat += 2
def speed_reduce_fast():
global speed_boat
speed_boat -= 2
def reset_system():
global speed_boat
speed_boat = 0.01
home()
pu()
setpos(-350,-50)
pd()
tracer(0)
ht()
reset_system()
while True:
fd(speed_boat)
ship()
time.sleep(0.01)
onkeypress(reset_system, "Escape")
onkeypress(speed_exelerate_fast, "w")
onkeypress(speed_reduce_fast, "s")
onkeypress(speed_stop, "space")
onkeypress(speed_more, "Up")
onkeypress(goright, "Right")
onkeypress(goleft, "Left")
onkeypress(speed_less, "Down")
listen()