def main(): plan1 = "200 200 400 400" plan2 = "0 250 600 300" plan3 = "" plan4 = "" plan5 = "" janela = tkinter.Tk() canvas_altura = 720 canvas_largura = 1280 tela = tkinter.Canvas(janela, bg='white', width=canvas_largura, height=canvas_altura) #~ quad = tela.create_rectangle(20,20,150,160,width=2,fill="red") pl1 = TP.cria_plano(plan1) pl2 = TP.cria_plano(plan2) quad1 = tela.create_rectangle(pl1, width=1, fill="red") quad2 = tela.create_rectangle(pl2, width=1, fill="blue") pl_sob = TP.sobreposicao_planos(pl1, pl2) if None != pl_sob: tela.create_rectangle(pl_sob, width=1, fill="purple") tela.pack() #~ for i in range(100): #~ #~ tela.move(quad1,5,5) #~ tela.update() #~ time.sleep(.1) janela.mainloop() return 0
def quebratijolos(matriz,bola,tela,vet): tijolo = [] for col in range (len(matriz)): for lin in range (len(matriz[col])): posbola = tela.bbox(bola) tijolo = tela.bbox(matriz[col][lin]) if posbola != None and tijolo != None: sobreposto = TP.sobreposicao_planos(posbola,tijolo) if tijolo != None and sobreposto != None: vet = TB.dir_bola(vet,sobreposto,posbola) tela.delete(matriz[col][lin]) matriz[col][lin]=[0,0,0,0] return vet
def quebratijolos(matriz, bola, tela, vet): tijolo = [] for col in range(len(matriz)): for lin in range(len(matriz[col])): posbola = tela.bbox(bola) tijolo = tela.bbox(matriz[col][lin]) if posbola != None and tijolo != None: sobreposto = TP.sobreposicao_planos(posbola, tijolo) if tijolo != None and sobreposto != None: vet = TB.dir_bola(vet, sobreposto, posbola) tela.delete(matriz[col][lin]) matriz[col][lin] = [0, 0, 0, 0] return vet
def barras_laterais(barras,boll,vet,tela): for elem in range(len(barras)): posbola = tela.bbox(boll) sobreposto = TP.sobreposicao_planos(posbola,barras[elem]) if sobreposto != None: vet = TB.dir_bola(vet,sobreposto,posbola) return vet #### #~ def movecomando(janela,comando): #~ ws = janela.winfo_screenwidth() #~ hs = janela.winfo_screenheight() #~ x = janela.winfo_pointerxy()[0] #~ print(x, ws,hs) #~ input() janela.move(comando,x)
def barras_laterais(barras, boll, vet, tela): for elem in range(len(barras)): posbola = tela.bbox(boll) sobreposto = TP.sobreposicao_planos(posbola, barras[elem]) if sobreposto != None: vet = TB.dir_bola(vet, sobreposto, posbola) return vet #### # ~ def movecomando(janela,comando): # ~ ws = janela.winfo_screenwidth() # ~ hs = janela.winfo_screenheight() # ~ x = janela.winfo_pointerxy()[0] # ~ print(x, ws,hs) # ~ input() janela.move(comando, x)
def main(): ############## tkinter criando janelas janela = tkinter.Tk() # canvas_altura = 600 # canvas_largura = 600 # tela = tkinter.Canvas(janela, bg='white', width=canvas_largura, height=canvas_altura) # ############### ######## paredes plano1= TP.cria_plano("200 200 400 400") plano2= TP.cria_plano("150 350 300 450") plano3= TP.cria_plano("300 150 450 300") plano4= TP.cria_plano("300 250 350 500") tela.create_rectangle(plano1,width=0,fill="red") tela.create_rectangle(plano2,width=1,fill="blue") #~ tela.create_rectangle(plano3,width=1,fill="green") #~ tela.create_rectangle(plano4,width=1,fill="lightblue") dif1=TP.sobreposicao_planos(plano1,plano2) print(dif1[0]-plano2[0],dif1[1]-plano2[1],dif1[2]-plano2[2],dif1[3]-plano2[3]) #~ dif2=TP.sobreposicao_planos(plano1,plano3) #~ print(dif2[0]-plano3[0],dif2[1]-plano3[1],dif2[2]-plano3[2],dif2[3]-plano3[3]) #~ dif3=TP.sobreposicao_planos(plano1,plano4) #~ print(dif3[0]-plano4[0],dif3[1]-plano4[1],dif3[2]-plano4[2],dif3[3]-plano4[3]) ######## paredes tela.pack() janela.mainloop() # #################### return 0
def main(): ############## tkinter criando janelas janela = tkinter.Tk() # canvas_altura = 600 # canvas_largura = 600 # tela = tkinter.Canvas(janela, bg='white', width=canvas_largura, height=canvas_altura) # ############### ######## paredes plano1 = TP.cria_plano("200 200 400 400") plano2 = TP.cria_plano("150 350 300 450") plano3 = TP.cria_plano("300 150 450 300") plano4 = TP.cria_plano("300 250 350 500") tela.create_rectangle(plano1, width=0, fill="red") tela.create_rectangle(plano2, width=1, fill="blue") #~ tela.create_rectangle(plano3,width=1,fill="green") #~ tela.create_rectangle(plano4,width=1,fill="lightblue") dif1 = TP.sobreposicao_planos(plano1, plano2) print(dif1[0] - plano2[0], dif1[1] - plano2[1], dif1[2] - plano2[2], dif1[3] - plano2[3]) #~ dif2=TP.sobreposicao_planos(plano1,plano3) #~ print(dif2[0]-plano3[0],dif2[1]-plano3[1],dif2[2]-plano3[2],dif2[3]-plano3[3]) #~ dif3=TP.sobreposicao_planos(plano1,plano4) #~ print(dif3[0]-plano4[0],dif3[1]-plano4[1],dif3[2]-plano4[2],dif3[3]-plano4[3]) ######## paredes tela.pack() janela.mainloop() # #################### return 0
def main(): ############## tkinter criando janelas janela = tkinter.Tk() # canvas_altura = 600 # canvas_largura = 600 # tela = tkinter.Canvas(janela, bg='white', width=canvas_largura, height=canvas_altura) # ############### ######## paredes plano1= TP.cria_plano("0 0 600 2") plano2= TP.cria_plano("0 0 2 600") plano3= TP.cria_plano("598 0 600 600") plano4= TP.cria_plano("0 598 600 600") plano_A= TP.cria_plano("200 200 202 600") plano_B= TP.cria_plano("300 300 600 302") tela.create_rectangle(plano_B,width=0,fill="red") tela.create_rectangle(plano_A,width=0,fill="red") tela.create_rectangle(plano1,width=0,fill="red") tela.create_rectangle(plano2,width=0,fill="red") tela.create_rectangle(plano3,width=0,fill="red") tela.create_rectangle(plano4,width=0,fill="red") ######## paredes # bola bola = TB.cria_bola(50,10,100) boll = tela.create_oval(bola,width=0,fill="red") # bola tela.pack() ## fisica da bola barra= None vet = "SE" barras=[plano1,plano2,plano3,plano4,plano_A,plano_B] while 1: for elem in barras: if TP.sobreposicao_planos(bola,elem) != None: barra = TP.direcao_parede(elem) vet = TB.vet_bola(vet,barra) print(vet,barra) TB.move_bola(bola,vet) boll = tela.create_oval(bola,width=2,fill="red") tela.update() time.sleep(.01) #~ if TB.vet_bola(vet,barra) == "NO": #~ tela.move(boll,-1,-1) #~ tela.update() #~ time.sleep(.01) #~ if TB.vet_bola(vet,barra) == "SE": #~ tela.move(boll,1,1) #~ tela.update() #~ time.sleep(.01) #~ if TB.vet_bola(vet,barra) == "SO": #~ tela.move(boll,-1,1) #~ tela.update() #~ time.sleep(.01) ## fisica da bola ################### escrevendo janela com tkinter # janela.mainloop() # #################### return 0