Tkinter有什么跳过功能?

时间:2014-04-23 07:30:12

标签: tkinter

嘿伙计们我正在做一个大学项目,但我不知道为什么tkinter没有显示我的功能。这是我的代码:

from tkinter import *
import os
import threading
from threading import Thread
#global Music_Flag
#Music_Flag=False,print('Ready')
#global Score
Game=Tk()
Game.title('Space Invaders')
Game.geometry('400x400')#Tamaño de prueba
Game.configure(background="#000000")
Game.resizable(0,0)
Game.focus_force()
Game_can=Canvas(Game, width=400, height=400, bg="#000000")
Game_can.place(x=0,y=0)
Game_can.update()
Game.focus_force()

def loadimage(name):
    path=os.path.join('Images',name)
    image=PhotoImage(file=path)
    return image

Lives=3#Cantidad de vidas para jugar
Score=0#Puntuación
AxisX=170#Variable de movimiento
Hey=360
shot=loadimage('shot.gif')

Highscore=open(r'C:\Users\juanpablo\Dropbox\U\Semestre I\Introducción-Taller a la programación\SuperPalmadas!\Proyecto 1 Space Invaders\Text\Highscores.txt','w')

ship=loadimage("ship.gif")
Game_can.create_image(AxisX,372,image=ship,anchor=NW, tag='Ship')

invade=loadimage('alien.gif')
x=15
y=15

def level(x,y):
    Game_can.create_image(x,y, image=invade,tag='invader')
    if x<=300:
        print('shit')
        Game_can.move(invader,3,0)
        Game_can.update()
        print('here')
        return level(x+20,y)
        #print('level1.2')
    if x==300:
        return level(x,y+20)

def keypress(event):
    global AxisX
    global Score
    global Hey
    if AxisX>0:
        if event.keysym=='Left':
            AxisX-=2
            Game_can.move('Ship', -2,0)
    if AxisX<366:
        if event.keysym=='Right':
            AxisX+=2
            Game_can.move('Ship',2,0)
    if event.keysym=='space':
        global shot
        Game_can.create_image(AxisX+17, 365, image=shot, tag='Shot')
        def moveshot():
                global Hey
                if Hey<=0:
                    Game_can.delete('Shot')
                    Hey=360
                elif Hey>0:
                    Hey-=2
                    hey=Game_can.move('Shot', 0,-2)
                    Game_can.after(3)
                    print('shot')
                    return moveshot()

        shoot=Thread(target=moveshot,args=())
        shoot.daemon=True
        shoot.start()

Game_can.bind('<Key-Left>', keypress)
Game_can.bind('<Key-Right>', keypress)
Game_can.bind('<Key-space>', keypress)
Game_can.focus_set()


Game.mainloop()

问题出在level()函数中。我有一些印刷品,但它甚至没有显示它们。不是图像或打印。

0 个答案:

没有答案