Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from math import *
- import time
- root = Tk()
- canv = Canvas(root, height = 500, width = 500, bg = "light blue")
- canv.pack()
- canv.create_line(300, 500, 300, 400, fill = 'orange', width = 5, tag = 'du')
- def u_down(event):
- global angle,v
- angle += 0.05
- vx = v * cos(angle)
- vy = v * sin(angle)
- canv.delete('snr')
- canv.create_line(5,495,10*vx,495+10*vy,width=2,arrow=LAST,tag='snr')
- def u_up(event):
- global angle,v
- angle -= 0.05
- vx = v * cos(angle)
- vy = v * sin(angle)
- canv.delete('snr')
- canv.create_line(5,495,10*vx,495+10*vy,width=2,arrow=LAST,tag='snr')
- def u_right(event):
- global v
- v += 0.5
- vx = v * cos(angle)
- vy = v * sin(angle)
- canv.delete('snr')
- canv.create_line(5,495,10*vx,495+10*vy,width=2,arrow=LAST,tag='snr')
- def u_left(event):
- global v
- v -= 0.5
- vx = v * cos(angle)
- vy = v * sin(angle)
- canv.delete('snr')
- canv.create_line(5,495,10*vx,495+10*vy,width=2,arrow=LAST,tag='snr')
- def shot(event):
- global angle,x,y,v
- sx = x
- sy = y
- vx = v * cos(angle)
- vy = v * sin(angle)
- for i in range(100):
- sx += vx
- sy += vy
- vy += 0.3
- canv.delete('lo')
- canv.create_oval(sx,sy,sx+10,sy-10,fill = "blue",tag='lo')
- time.sleep(0.1)
- canv.update()
- if sx>=300 and sx<=300+vx and sy>=400-vy and sy<=500+vy:
- s = -1.1
- for i in range(10):
- s += 0.1
- canv.delete('du')
- canv.create_line(300, 500, 300+100*s**2, 400+100*(1-s**2), fill = 'orange', width = 5, tag = 'du')
- time.sleep(0.1)
- canvas.update()
- canv.create_text(300,300, text = 'ура', font = 'Arial')
- root.bind("<Up>",u_up)
- root.bind("<Down>",u_down)
- root.bind("<Left>",u_left)
- root.bind("<Right>",u_right)
- root.bind("<space>",shot)
- angle = -1
- angle1 = str(-1*((180/pi)*angle))
- v = 5
- vx = v * cos(angle)
- vy = v * sin(angle)
- canv.create_line(5,495,10*vx,495+10*vy,width=2,arrow=LAST,tag='s1')
- x, y = 0, 500
- bullet = canv.create_oval(x+10,y,x,y-10,fill = "blue",tag='s2')
- canv.create_text(35, 40, text = str(v), font = 'Arial')
- canv.create_text(20, 40, text = 'V = ', font = 'Arial')
- canv.create_text(100, 60, text = str(angle1), font = 'Arial')
- canv.create_text(20, 60, text = 'a = ', font = 'Arial')
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement