Esempio n. 1
0
 def solve(self, fileCat, data=False):
     if data == False:
         print('Working on {}.'.format(self.shotlabel))
         print('Getting input parameters...')
         self.param = readinput(fileCat)
         print('Getting experimental data...')
         self.exp = getexp(fileCat)
         print('Creating background plasma...')
         self.brnd = background(self.param, self.exp)
         print('Calculating Ion Orbit Loss...')
         self.tiol = thermaliol(self.brnd)
         print('Calculating neutrals...')
         self.ntrl = neutrals(self.brnd)
         print('Plasma Solved')
     else:
         self.tiol = {}
         print('Working on {} using experimental profiles.'.format(
             self.shotlabel))
         print('Getting input parameters...')
         self.param = readinput(fileCat)
         print('Getting sexy experimental data...')
         self.exp = getexp(fileCat)
         print('Creating background plasma...')
         print "theta points = " + str(self.param.thetapts)
         self.brnd = background(self.param, self.exp, data=data)
         print('Calculating Ion Orbit Loss...')
         self.tiol[1] = thermaliol(self.brnd, 1)
         self.tiol[6] = thermaliol(self.brnd, 6)
         print('Calculating neutrals...')
         self.ntrl = neutrals(self.brnd)
         print('Plasma Solved')
     return
Esempio n. 2
0
    def __init__(self):
        pygame.init()
        pygame.font.init()

        self.font = pygame.font.Font('freesansbold.ttf', 16)
        self.background = background(C.BACKGROUND_POS)
        self.background2 = background(C.BACKGROUND_POS2)
        self.spaceship = spaceship(C.SPACESHIP_START_POS)
        self.group = pygame.sprite.Group(self.background, self.background2,
                                         self.spaceship)
        self.asteroids = pygame.sprite.Group()
        self.score = 0
Esempio n. 3
0
 def __init__(self, mainclass, matser, _winheight, _winwidth):
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = matser
     self.mainclass = mainclass
     self.working = True
     self.comwidth = 210
     self.comheight = 100
     self.clockimg = ImageTk.PhotoImage(
         Image.open("srcimage/emecalling.jpg").resize(
             (int(self.winwidth), int(self.winheight))))
     self.confirmimg = ImageTk.PhotoImage(
         Image.open("srcimage/stopeme.jpg").resize(
             (int(self.comwidth), int(self.comheight))))
     self.emecallpage = tk.Canvas(self.master,
                                  height=self.winheight,
                                  width=self.winwidth)
     self.emecallpage.place(x=0, y=0)
     #背景
     bg = background(self.emecallpage, self.winheight, self.winwidth,
                     "clock")
     #标题
     bg.backgroundcanvas.create_image(0,
                                      0,
                                      anchor="nw",
                                      image=self.clockimg)
     self.combtn = tk.Button(self.emecallpage,
                             image=self.confirmimg,
                             width=self.comwidth,
                             height=self.comheight,
                             command=self.back)
     self.combtn.place(x=(self.winwidth - self.comwidth) / 2,
                       y=self.winheight * 6 / 7)
     _thread.start_new_thread(self.playmusic, ("threadname", 1))
Esempio n. 4
0
 def __init__(self, matser, _winheight, _winwidth):
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = matser
     self.comwidth = 150
     self.comheight = 100
     self.clockimg = ImageTk.PhotoImage(
         Image.open("srcimage/playclock.jpg").resize(
             (int(self.winwidth), int(self.winheight))))
     self.confirmimg = ImageTk.PhotoImage(
         Image.open("srcimage/confirm.jpg").resize(
             (int(self.comwidth), int(self.comheight))))
     self.playclockpage = tk.Canvas(self.master,
                                    bg="pink",
                                    height=self.winheight,
                                    width=self.winwidth)
     self.playclockpage.place(x=0, y=0)
     #背景
     bg = background(self.playclockpage, self.winheight, self.winwidth,
                     "clock")
     #标题
     backbtn(self, self.playclockpage, self.winheight, self.winwidth, 13)
     bg.backgroundcanvas.create_image(0,
                                      0,
                                      anchor="nw",
                                      image=self.clockimg)
     self.combtn = tk.Button(self.playclockpage,
                             image=self.confirmimg,
                             width=self.comwidth,
                             height=self.comheight,
                             command=self.back)
     self.combtn.place(x=(self.winwidth - self.comwidth) / 2, y=750)
     self.playmusic()
Esempio n. 5
0
    def __init__(self,
                 src="uhd",
                 dst=None,
                 repeat=False,
                 reader=True,
                 tag=True,
                 samp_rate=2e6,
                 emulator=None):
        gr.hier_block2.__init__(
            self,
            "decoder",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(0, 0, 0))  # Output signature

        if src == "uhd":
            self._src = usrp_src.usrp_src(samp_rate=samp_rate, dst=dst)
            hi_val = 1.1
        else:
            self._wav = blocks.wavfile_source(src, repeat)
            self._r2c = blocks.float_to_complex(1)
            self._src = blocks.complex_to_mag_squared(1)
            self.connect(self._wav, self._r2c, self._src)
            hi_val = 1.09  # may need to be set to 1.05 depending on antenna setup

        self._back = background.background(reader, tag, emulator)
        self._trans = transition_sink.transition_sink(samp_rate,
                                                      self._back.append,
                                                      hi_val=hi_val)
        self.connect(self._src, self._trans)

        if dst and dst != "uhd" and src == "uhd":
            self._rec = record.record(dst, samp_rate)
            self.connect(self._src, self._rec)
Esempio n. 6
0
 def initBackground(self):
     bgPath = "./img/tile.png"
     tmp = QPixmap(bgPath)
     self.background = background(self, bgPath,
                                  tmp.width() / 2,
                                  tmp.height() / 2, 1 / 3)
     attackParticle.background = self.background
Esempio n. 7
0
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,'01.png',alpha = True)
    mouse = cursor.cursor()
    bgmusic = bgm.bgm("003.mp3")
    running = True
    directorio = os.getcwd()


    #acciones de uso unico
    bgmusic.play(inicio = 2.0)

    #bucle principal
    while running:
        #variables que se comprueban cada bucle


        #lista de los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                running = False

        #actualizacion de objetos en pantalla
        bg.update()
        mouse.update()
        if not(running): bgmusic.stop()
    
        #actualizamos la pantalla
        pygame.display.flip()
        settings.reloj.tick(60)
Esempio n. 8
0
 def __init__(self, mainclass, master, _winheight, _winwidth):
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = master
     self.mainclass = mainclass
     self.imagereadlist = []
     self.topheight = 130  #顶部标题高度
     self.heartpage = tk.Canvas(self.master,
                                bg="pink",
                                width=self.winwidth,
                                height=self.winheight)
     self.heartpage.place(x=0, y=0)
     self.heartpage.configure(highlightthickness=0)
     self.startbtnwidth = 350
     self.working = False
     self.btnimage = ImageTk.PhotoImage(
         Image.open("srcimage/startm.jpg").resize(
             (int(self.startbtnwidth), int(self.startbtnwidth))))
     self.waitingimage = ImageTk.PhotoImage(
         Image.open("srcimage/waiting.jpg").resize(
             (int(self.startbtnwidth), int(self.startbtnwidth))))
     #背景
     bg = background(self.heartpage, self.winheight, self.winwidth, "call")
     #返回按钮
     backbtn(self.heartpage, self.winheight, self.winwidth)
     #标题
     title(self.heartpage, self.winheight, self.winwidth, "心率测量")
     self.startbtn = tk.Button(self.heartpage,
                               image=self.btnimage,
                               width=self.startbtnwidth,
                               height=self.startbtnwidth,
                               command=self.start)
     self.startbtn.place(x=(self.winwidth - self.startbtnwidth) / 2,
                         y=(self.winheight - self.startbtnwidth) / 2)
     bg.showimage()
Esempio n. 9
0
 def __init__(self,master,_winheight,_winwidth):
     self.extensionlist = ['mp4']
     self.videolist = []
     for extension in self.extensionlist:
         file_list = glob.glob('videos/*.' + extension)  #返回一个列表
         for item in file_list:
             self.videolist.append(item[6:])
     self.master = master
     self.master.config(bg='blue')
     self.playing = False #当前是否有视频正在播放
     # 屏幕宽高
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.videowidth = self.winwidth/8
     self.videopadding = self.winwidth/64
     self.topheight = 130 #顶部标题高度
     self.firstimagelist = []
     for n in range(0,len(self.videolist)):
         self.firstimagelist.append(self.getfirstimage(self.videolist[n]))
     # 获取每个视频的第一张图
     # 视频集画框
     self.videocanvas = tk.Canvas(self.master,bg="pink",height=self.winheight,width=self.winwidth)
     self.videocanvas.place(x=0,y=0)
     #背景
     bg = background(self.videocanvas,self.winheight,self.winwidth,"call")
     #返回按钮
     backbtn(self.videocanvas,self.winheight,self.winwidth)
     #标题
     title(self.videocanvas,self.winheight,self.winwidth,"播放视频")
     # 视频缩略图放置
     for n in range(0,len(self.videolist)):
         locals()['self.tempbutton'+str(n)] = tk.Button(self.videocanvas,image=self.firstimagelist[n], width=self.videowidth,height=self.videowidth,command=self.returnfun(n),bd=0)
         locals()['self.tempbutton'+str(n)].place(x=n%7*(self.videowidth+self.videopadding)+self.videopadding,y=int((n+1)/8)*(self.videowidth+self.videopadding)+self.topheight)
     bg.showimage()
Esempio n. 10
0
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,'00.jpg')

    #configuramos boton principal
    boton = button.button(settings.pantalla,posicion=(40,450))
    boton.agregar_img('00.png')
    boton.agregar_img('01.png')
    boton.agregar_img('02.png')
    boton.actual(0)
    
    mouse = cursor.cursor()
    bgmusic = bgm.bgm("001.mp3")
    running = True
    directorio = os.getcwd()

    #acciones de uso unico
    bgmusic.play()

    #bucle principal
    while running:
        #variables que se comprueban cada bucle
            

        #lista que contiene todos los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.MOUSEBUTTONUP:
                if evento.button == 1:
                    if boton.rectangulo.left < mouse.posicion[0] < boton.rectangulo.right and boton.rectangulo.top < mouse.posicion[1] < boton.rectangulo.bottom:
                        s1.main()
                        running = False
                        
                        
            if evento.type == pygame.QUIT:
                running = False


        #opciones de posicion del mouse
        if mouse.posicion[0] > boton.rectangulo.right or \
           mouse.posicion[0] < boton.rectangulo.left or \
           mouse.posicion[1] > boton.rectangulo.bottom or \
           mouse.posicion[1] < boton.rectangulo.top:
            boton.actual(0)
        else:
            if mouse.estado[0]:
                boton.actual(2)
            if not(mouse.estado[0]):
                boton.actual(1)

        #Actualizamos posicion de las cosas
        bg.update()
        boton.update()
        mouse.update()
        if not(running): bgmusic.stop()
        
        #actualizamos la pantalla
        pygame.display.flip()
        settings.reloj.tick(60)                     #60 frames por segundo
Esempio n. 11
0
 def __init__(self, mainclass, matser, _winheight, _winwidth):
     self.mainclass = mainclass
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = matser
     self.calling = False
     self.callpage = tk.Frame(self.master,
                              bg="pink",
                              height=self.winheight,
                              width=self.winwidth)
     self.callpage.place(x=0, y=0)
     #背景
     bg = background(self.callpage, self.winheight, self.winwidth, "call")
     #返回按钮
     backbtn(self.mainclass, self.callpage, self.winheight, self.winwidth,
             5)
     #标题
     title(self.callpage, self.winheight, self.winwidth, "打电话给家人")
     self.childlist = ["firstson", "secondson", "thirdson"]
     self.avatarimagelist = []  #头像放置
     self.avatarlabellist = []
     self.numberlist = ["15060356168", "18792858682", "13024999392"]
     #头像高度
     self.avatarpadding = 60
     self.avatarwidth = (self.winwidth - (len(self.childlist) + 1) *
                         self.avatarpadding) / len(self.childlist)
     self.avatrheight = self.avatarwidth / 0.7
     self.iconwidth = 100
     self.iconpadding = 50
     self.callbtnwidth = 125
     self.callbtnheight = 75
     self.callnumberimg = ImageTk.PhotoImage(
         Image.open("srcimage/callnumber.jpg").resize(
             (int(self.callbtnwidth), int(self.callbtnheight))))
     for n in range(0, len(self.childlist)):
         self.avatarimagelist.append(
             ImageTk.PhotoImage(self.goodimage(self.childlist[n])))
         self.avatarlabellist.append(
             tk.Button(self.callpage,
                       width=self.avatarwidth,
                       height=self.avatrheight,
                       image=self.avatarimagelist[n],
                       command=self.returnfun(n)))
         self.avatarlabellist[n].place(
             x=self.avatarpadding +
             (self.avatarwidth + self.avatarpadding) * n,
             y=200)
     self.callbtn = tk.Button(self.callpage,
                              width=self.callbtnwidth,
                              height=self.callbtnheight,
                              image=self.callnumberimg,
                              command=self.call)
     self.callbtn.place(x=self.winwidth - self.callbtnwidth, y=0)
     bg.showimage()
Esempio n. 12
0
 def init_as_menu(self, rend):
     self.type = "menu"
     self.background = background(rend)
     self.floor = floor(rend)
     self.player = bird(rend)
     self.player.surface.x = 240
     self.title = title(rend)
     self.entities = [self.background, self.floor, self.player, self.title]
     self.index_player = self.entities.index(self.player)
     self.start()
     pass
Esempio n. 13
0
 def __init__(self, mainclass, matser, _winheight, _winwidth):
     self.mainclass = mainclass
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = matser
     self.hearto2page = tk.Frame(self.master,
                                 bg="pink",
                                 height=self.winheight,
                                 width=self.winwidth)
     self.hearto2page.place(x=0, y=0)
     self.heartratescale = [0, 150]  #心跳速度范围
     self.heartratelength = self.heartratescale[1] - self.heartratescale[0]
     self.oxygenscale = [0, 150]  #血氧浓度范围
     self.oxygenlength = self.oxygenscale[1] - self.oxygenscale[0]
     #背景
     bg = background(self.hearto2page, self.winheight, self.winwidth,
                     "call")
     #返回按钮
     backbtn(self.hearto2page, self.winheight, self.winwidth)
     #标题
     self.testbtn = tk.Button(self.hearto2page,
                              bitmap="error",
                              width=100,
                              height=100,
                              command=self.testbtn)
     self.testbtn.place(x=0, y=0)
     title(self.hearto2page, self.winheight, self.winwidth, "健康检测")
     self.paddingl = 200  #水平的间隙
     self.paddingv = 60  #竖直方向的间隙
     self.matwidth = self.winwidth - self.paddingl * 2
     self.matheight = self.winheight - self.paddingv * 2
     self.perx = self.matwidth / 100
     self.pery = self.matheight / 100
     self.matcanvas = tk.Canvas(self.hearto2page,
                                bg="white",
                                width=self.matwidth,
                                height=self.matheight)
     self.matcanvas.place(x=self.paddingl, y=self.paddingv)
     self.opointx = 10 * self.perx
     self.opointy = 90 * self.pery
     self.yheight = 80 * self.pery
     self.xwidth = 80 * self.perx
     self.drawaxis()  #绘制坐标轴
     # 40,130
     # 85,100
     #bg.showimage()
     #self.updatecan()
     plt.ion()
     plt.figure(1)
Esempio n. 14
0
    def updateAndRender(self):
        back_sprites = sprite.Group()
        bkg1, bkg2, bkg3, bkg4  = background(), background2(), background3(), \
                                                    background4()
        back_sprites.add(bkg1, bkg2, bkg3, bkg4)

        screen_sf = upg.display.set_mode()
        while True:
            if (self.scrollBack):
                back_sprites.update()
                back_sprites.draw(screen_sf)
            self.drawText()
            if (self.buttonPress()):
                return cs.state(self.nextState, gv.level)
            upg.display.flip()
Esempio n. 15
0
    def __init__(self, master, _winheight, _winwidth):
        #获取本地图片文件
        self.extensionlist = ['jpg']
        self.imagelist = []
        for extension in self.extensionlist:
            file_list = glob.glob('photos/*.' + extension)  #返回一个列表
            for item in file_list:
                self.imagelist.append(item[7:])

        self.winheight = _winheight
        self.winwidth = _winwidth
        self.photowidth = self.winwidth / 8
        self.photopadding = self.winwidth / 64
        self.master = master
        self.imagereadlist = []
        self.topheight = 130  #顶部标题高度
        #读取图片
        for n in range(0, len(self.imagelist)):
            self.imagereadlist.append(ImageTk.PhotoImage(self.goodimage(n)))
        self.photopage = tk.Canvas(self.master,
                                   bg="pink",
                                   width=self.winwidth,
                                   height=self.winheight)
        self.photopage.place(x=0, y=0)
        self.photopage.configure(highlightthickness=0)
        #背景
        bg = background(self.photopage, self.winheight, self.winwidth, "call")
        #返回按钮
        backbtn(self.photopage, self.winheight, self.winwidth)
        #标题
        title(self.photopage, self.winheight, self.winwidth, "看照片")
        #图片缩略图放置
        for n in range(0, len(self.imagelist)):
            locals()['self.tempbutton' + str(n)] = tk.Button(
                self.photopage,
                image=self.imagereadlist[n],
                width=self.photowidth,
                height=self.photowidth,
                command=self.returnfun(n),
                bd=0)
            locals()['self.tempbutton' + str(n)].place(
                x=n % 7 * (self.photowidth + self.photopadding) +
                self.photopadding,
                y=int((n + 1) / 8) * (self.photowidth + self.photopadding) +
                self.topheight)
        bg.showimage()
Esempio n. 16
0
def line_sum(image,sumflag='c',nbgr=0,width=0,pow=2.,tangent=False,compress=1):
    """
    Sum down 'c'olumns or across 'r'ows
    
    This returns the summed data and background
    """
    if sumflag == 'c':
        data = image.sum(axis=0)
    elif sumflag == 'r':
        data = image.sum(axis=1)
    npts     = len(data)
    data_idx = num.arange(npts,dtype=float)
    #data_err  = data**(0.5)

    ### compute background
    bgr = background(data,nbgr=nbgr,width=width,pow=pow,tangent=tangent,
                     compress=compress)
    
    return (data, data_idx, bgr)
Esempio n. 17
0
 def init_as_game(self, rend):
     if rend is not None:
         self.type = "game"
         self.background = background(rend)
         self.floor = floor(rend)
         self.pipe1_bot = pipe(rend, False)
         self.pipe1_top = pipe(rend, True)
         self.pipe2_bot = pipe(rend, False)
         self.pipe2_top = pipe(rend, True)
         self.pipe1_top.surface.x = 804
         self.pipe1_bot.surface.x = 804
         self.pipe2_top.surface.x = 1130
         self.pipe2_bot.surface.x = 1130
         self.player = bird(rend)
         self.score = score(rend)
         self.entities = [
             self.background, self.pipe1_bot, self.pipe1_top,
             self.pipe2_bot, self.pipe2_top, self.floor, self.player,
             self.score
         ]
         self.index_player = self.entities.index(self.player)
         self.start()
     else:
         self.player.surface.x = 80
         self.player.surface.y = 270
         self.pipe1_top.surface.x = 800
         self.pipe2_top.surface.x = 1130
         self.pipe1_bot.surface.x = 800
         self.pipe2_bot.surface.x = 1130
         self.pipe1_top.surface.y = random.randint(pipeTopLowBound,
                                                   pipeTopHighBound)
         self.pipe1_bot.surface.y = self.pipe1_top.surface.y + pipeOffset
         self.pipe2_top.surface.y = random.randint(pipeTopLowBound,
                                                   pipeTopHighBound)
         self.pipe2_bot.surface.y = self.pipe2_top.surface.y + pipeOffset
         self.background.surface.x = 0
         self.background.surface.y = 0
         self.floor.surface.x = 0
         self.score.count = 0
         self.score.update_textures()
     pass
Esempio n. 18
0
 def __init__(self, matser, _winheight, _winwidth):
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = matser
     self.callpage = tk.Frame(self.master,
                              bg="pink",
                              height=self.winheight,
                              width=self.winwidth)
     self.callpage.place(x=0, y=0)
     #背景
     bg = background(self.callpage, self.winheight, self.winwidth, "call")
     #返回按钮
     backbtn(self.callpage, self.winheight, self.winwidth)
     #标题
     title(self.callpage, self.winheight, self.winwidth, "打电话给家人")
     self.childlist = ["firstson", "secondson", "thirdson"]
     self.avatarimagelist = []  #头像放置
     self.avatarlabellist = []
     #头像高度
     self.avatarpadding = 200
     self.avatarwidth = (self.winwidth - (len(self.childlist) + 1) *
                         self.avatarpadding) / len(self.childlist)
     self.avatrheight = self.avatarwidth / 0.618
     # self.testimage = ImageTk.PhotoImage(Image.open("srcimage/firstson.jpg").resize(
     #     (int(self.avatarwidth), int(self.avatrheight))))
     # self.test = tk.Button(self.callpage,image=self.testimage,width=self.avatarwidth,height=self.avatrheight,command=self.back)
     # self.test.place(x=0,y=0)
     for n in range(0, len(self.childlist)):
         self.avatarimagelist.append(
             ImageTk.PhotoImage(self.goodimage(self.childlist[n])))
         self.avatarlabellist.append(
             tk.Button(self.callpage,
                       width=self.avatarwidth,
                       height=self.avatrheight,
                       image=self.avatarimagelist[n],
                       command=self.back))
         self.avatarlabellist[n].place(
             x=self.avatarpadding +
             (self.avatarwidth + self.avatarpadding) * n,
             y=200)
     bg.showimage()
Esempio n. 19
0
    def __init__(self, src="uhd", dst=None, repeat=False, reader=True, tag=True, samp_rate=2e6, emulator=None):
        gr.hier_block2.__init__(self, "decoder",
                gr.io_signature(0, 0, 0), # Input signature
                gr.io_signature(0, 0, 0)) # Output signature

        if src == "uhd":
            self._src = usrp_src.usrp_src(samp_rate=samp_rate, dst=dst)
            hi_val = 1.1
        else:
            self._wav = blocks.wavfile_source(src, repeat)
            self._r2c = blocks.float_to_complex(1)
            self._src = blocks.complex_to_mag_squared(1)
            self.connect(self._wav, self._r2c, self._src)
            hi_val = 1.09 # may need to be set to 1.05 depending on antenna setup

        self._back = background.background(reader, tag, emulator)    
        self._trans = transition_sink.transition_sink(samp_rate, self._back.append, hi_val=hi_val)
        self._connect(self._src, self._trans)

        if dst and dst != "uhd" and src == "uhd":
            self._rec = record.record(dst, samp_rate)
            self._connect(self._src, self._rec)
Esempio n. 20
0
    def __init__(self, settingspath):
        # intialize and read/create the settings from the specified file path
        self.settings = gamesettings(settingspath)

        # initialize needed pygame modules
        pygame.init()
        pygame.font.init()

        # create screen with values from settings
        if self.settings.gamevalues["Fullscreen"]:
            self.screen = pygame.display.set_mode(
                self.settings.gamevalues["Resolution"], pygame.FULLSCREEN)
        else:
            self.screen = pygame.display.set_mode(
                self.settings.gamevalues["Resolution"])

        self.background = background(self.settings.gamevalues["Resolution"],
                                     (19, 19, 39, 255))

        self.defaultscene = mainmenuscene

        self.currentscene = self.defaultscene

        self.sceneswitcher()
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,"02.png",alpha = True, posicion = settings.screen_center)
    barra = img.img(settings.pantalla,"001.png",posicion=settings.screen_center)

    #control de los textos
    l0 = text.text(settings.pantalla,color = (255,255,255),nombre = "COOPBL.ttf",tamano = settings.text_tamano_1,posicion = (40,405),linea = u"Voz que parece familiar")
    l1 = text.text_anim_01(settings.pantalla,nombre = "ARLRDBD.ttf",tamano = settings.text_tamano_1,velocidad = settings.text_speed_1,color = (255,255,255), posicion = (25,455), linea = u"Marcelo Salas!")
    l2 = text.text_anim_01(settings.pantalla,nombre = "ARLRDBD.ttf",tamano = settings.text_tamano_1,velocidad = settings.text_speed_1,color = (255,255,255), posicion = (25,495), linea = u"Activaste mi carta trampa!")
    l3 = text.text_anim_01(settings.pantalla,nombre = "ARLRDBD.ttf",tamano = settings.text_tamano_1,velocidad = settings.text_speed_1,color = (255,255,255), posicion = (25,535), linea = "")
    lista = [l0,l1,l2,l3]
    parrafo = text.group_text(lista)
    
    #marcelo
    marcelo = sprites.personaje(settings.pantalla,posicion = (-300,450))
    marcelo.add("marcelo.png")
    marcelo.add("marcelo01.png")
    x2 = pygame.transform.scale2x(marcelo.imagenes[0])
    marcelo.imagenes[0] = x2
    x3 = pygame.transform.scale2x(marcelo.imagenes[1])
    marcelo.imagenes[1] = x3
    marcelo.current(1)
    marcelo.anim_01((150,450),180)
    
    #marmota
    marmota = sprites.personaje(settings.pantalla,posicion = (1000,450))
    marmota.add("marmota.png")
    marmota.add("marmota01.png")
    
    bgmusic = bgm.bgm("004.mp3")
    running = True

    #acciones de uso unico
    bgmusic.play()

    #bucle principal
    while running:
        #variables que se comprueban cada bucle
        
        
        #lista de los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.KEYDOWN:
                if evento.key == pygame.K_z:
                    marmota.end_anim_01()
                    marcelo.end_anim_01()
                    if not(parrafo.renderizado):
                        for linea in lista:
                            linea.velocidad = 5000
                    if parrafo.renderizado:
                        parrafo.contador += 1
                        
            if evento.type == pygame.KEYUP:
                if evento.key == pygame.K_z:
                    for linea in lista:
                        linea.velocidad = settings.text_speed_1
                        
                    
            if evento.type == pygame.QUIT:
                running = False
        
        #manejo de textos
        if parrafo.renderizado and parrafo.contador == 2:
            parrafo.void()
            marcelo.anim_01((150,450),180)
            marcelo.current(0)
            marmota.current(1)
            #modificamos los textos
            l0.line(u"Marcelo")
            l1.line(u"No veo ni mierdas, podrías prender la luz?")
            
        if parrafo.renderizado and parrafo.contador == 4:
            parrafo.void()
            marcelo.current(1)
            marmota.current(0)
            #modificamos textos
            l0.line(u"Voz que parece familiar")
            bg = background.background(settings.pantalla,"03.jpg",alpha = False, posicion = settings.screen_center)
            l1.line(u"En este lugar no hay luz, solo hay Divinas Comedias! ")
            
        if parrafo.renderizado and parrafo.contador == 6:
            parrafo.void()
            marcelo.current(0)
            marmota.current(1)
            #modificamos textos
            l0.line(u"Marcelo")
            l1.line(u"Quien eres?")
            
        if parrafo.renderizado and parrafo.contador == 8:
            parrafo.void()
            marmota.anim_01((600,450),320)
            marmota.current(0)
            marcelo.current(1)
            #modificamos textos
            l0.line(u"Jesucristo")
            l1.line(u"Creías que Jesucristo era una buena persona?")
            l2.line(u"Jesucristo es de la Policía de Investigaciones!")
            l3.line(u"Cagaste culiao!")
            
        if parrafo.renderizado and parrafo.contador == 10:
            parrafo.void()
            #modificamos textos
            l0.line(u"Jesucristo")
            l1.line(u"Soy de la PDI! Quedaste arrestado por ")
            l2.line(u"contrabando y compra de transgénicos ")
            l3.line(u"ilegales!")
            
        if parrafo.renderizado and parrafo.contador == 12:
            parrafo.void()
            marcelo.current(0)
            marmota.current(1)
            #modificamos textos
            l0.line(u"Marcelo")
            l1.line(u"NOOOOOOOOOOOOOO ")

        if parrafo.renderizado and parrafo.contador == 14:
            parrafo.void()
            marmota.current(0)
            marcelo.current(1)
            #modificamos textos
            l0.line(u"Jesucristo")
            l1.line(u"Ajkajakjak y el weon se la cree ajajkakjakjk ")
            l2.line(u"Solo te tendí una trampa para transformarte ")
            l3.line(u"en Dante Allighieri ")
            
        if parrafo.renderizado and parrafo.contador == 16:
            parrafo.void()
            marcelo.current(0)
            marmota.current(1)
            #modificamos textos
            l0.line(u"Marcelo")
            l1.line(u"Ah, de pana igual")
            
        if parrafo.renderizado and parrafo.contador == 18:
            parrafo.void()
            marcelo.current(1)
            marmota.current(0)
            #modificamos textos
            l0.line(u"Jesucristo")
            l1.line(u"Si, ser Allighieri es entrete")
            

        #paso a la siguiente pantalla
        if parrafo.contador == 20:
            running = False
            s5.main()
            
        
        #actualizacion de objetos en pantalla
        bg.update()
        marcelo.update()
        marmota.update()
        barra.update()
        parrafo.update()
        if not(running): bgmusic.stop()
    
        #actualizamos la pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Esempio n. 22
0
    def Processing(self):

        self.progress.setRange(0, 100)
        self.progress.setStyleSheet(self.stylesheet_progressbar_busy)

        self.input_video = self.video_path  # Path for video
        self.c = 0.7  # Confidence score for detecting the face of a person

        background_labels, background_probabilities = background(
            self.video_path)
        emotion_labels, emotion_probabilities = Emotion_Detection(
            self.emotion_model_path, self.prototext, self.model,
            self.video_path, self.c)

        rows = []

        if len(emotion_probabilities) == len(background_probabilities):
            for i in range(0, len(emotion_probabilities)):
                rows.append(emotion_probabilities[i] +
                            background_probabilities[i]
                            )  # Concatenating the two lists.

        if rows != []:
            df = pd.DataFrame(rows)
            predictions = list(self.loaded_model.predict(df.values))

            Genres = {0: 'Horror', 1: 'Action', 2: 'Comedy', 3: 'Romantic'}

            predictions = list(map(Genres.get, predictions))
            # print(predictions)
            self.popup_success()

            self.final_predictions = predictions

        else:
            self.popup_error()

        cap = cv2.VideoCapture(self.input_video)
        fps = cap.get(cv2.CAP_PROP_FPS)

        seconds_interval = fps * 10
        limit = 0  # A variable used to wait until seconds_interval is reached

        n = len(predictions)
        k = 0
        total = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
        total1 = 0

        frame_width = int(cap.get(3))
        frame_height = int(cap.get(4))

        size = (frame_width, frame_height)
        result = cv2.VideoWriter(self.output_path,
                                 cv2.VideoWriter_fourcc(*'MJPG'), fps, size)
        # print("Output video path is", self.output_path)
        while True:
            ret, frame = cap.read()

            if not ret:
                break

            limit += 1
            total1 += 1
            if (limit != int(seconds_interval) and k < n):
                font = cv2.FONT_HERSHEY_SIMPLEX
                org = (100, 100)
                fontScale = 3
                color = (255, 0, 0)
                thickness = 2
                # Using cv2.putText() method

                frame = cv2.putText(frame, predictions[k], org, font,
                                    fontScale, color, thickness, cv2.LINE_AA)
                # print("Written")
            if limit == int(seconds_interval):
                k += 1
                limit = 0
            result.write(frame)
        cap.release()
        result.release()
Esempio n. 23
0
def image_bgr(image,lineflag='c',nbgr=3,width=100,pow=2.,tangent=False,
              nline=1,filter=False,compress=1,plot=False):
    """
    Calculate a 2D background for the image.

    Parameters:
    -----------
    * image is the (hopefully clipped) image data

    * lineflag ('c' or 'r') corresponds to to direction which is
      used to generate the background 

    * nbgr = number of end points to use in linear background determination
      (see background.background)
          
    * width should correspond roughly to the actual peak
      width in the lineflag direction. The background should fit
      features that are in general broader than this value
      Note that width = 0 corresponds to no polynomial bgr
      
    * pow is the power of the polynomial used in background determination
      (see background.background)
      
    * tangent is a flag to indicate if local slope of the data should be fitted 
      (see background.background)

    * nline = number of lines to average for each bgr line fit

    * filter (True/False) flag indicates if a spline filter should be applied
      before background subtraction.  (see scipy.ndimage.filters)

    * compress is a factor by which the number of points in each line is
      reduced.  This helps speed up the background fits.  
     
    * plot is a flag to indicate if a 'plot' should be made
    """
    bgr_arr = num.zeros(image.shape)

    # note this works poorly if the filter removes
    # too much intensity.  Use with caution!
    if filter == True:
        #image = ndimage.laplace(image)
        #print 'spline filter'
        image = ndimage.interpolation.spline_filter(image,order=3)

    # fit to rows
    if lineflag=='r':
        if nline > 1:
            ll = int(nline/2.)
            n = image.shape[0]
            line = num.zeros(len(image[0]))
            for j in range(n):
                idx = [k for k in range(j-ll,j+ll+1) if k>=0 and k<n]
                line = line * 0.0
                for k in idx:
                    line = line + image[k]
                line = line/float(len(idx))
                bgr_arr[j,:] = background(line,nbgr=nbgr,width=width,pow=pow,
                                          tangent=tangent,compress=compress)
        else:
            for j in range(image.shape[0]):
                bgr_arr[j,:] = background(image[j],nbgr=nbgr,width=width,pow=pow,
                                          tangent=tangent,compress=compress)

    # fit to cols
    if lineflag=='c':
        if nline > 1:
            ll = int(nline/2.)
            n = image.shape[1]
            line = num.zeros(len(image[:,0]))
            for j in range(n):
                idx = [k for k in range(j-ll,j+ll+1) if k>=0 and k<n]
                line = line * 0.0
                for k in idx:
                    line = line + image[:,k]
                line = line/float(len(idx))
                bgr_arr[:,j] = background(line,nbgr=nbgr,width=width,pow=pow,
                                          tangent=tangent,compress=compress)
        else:
            for j in range(image.shape[1]):
                bgr_arr[:,j] = background(image[:,j],nbgr=nbgr,width=width,pow=pow,
                                          tangent=tangent,compress=compress)
    #show
    if plot:
        
        pyplot.figure(3)
        pyplot.clf()
        pyplot.subplot(3,1,1)
        pyplot.imshow(image)
        pyplot.title("image")
        pyplot.colorbar()

        pyplot.subplot(3,1,2)
        pyplot.imshow(bgr)
        pyplot.title("background")
        pyplot.colorbar()

        pyplot.subplot(3,1,3)
        pyplot.imshow(image-bgr)
        pyplot.title("image - background")
        pyplot.colorbar()

    return bgr_arr
Esempio n. 24
0
import instances
from instances import win
from vars import *
import background
from hover import hover
from background import squares
from pieces import pieces

pygame.init()


run = True
while run:
    pygame.time.delay(30)

    # Quit function
    for event in pygame.event.get():
        if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_F4 and bool(event.mod & pygame.KMOD_ALT)):
            run = False
    background.background()

    for piece in pieces:
        piece.draw()

    hover()

    pygame.display.update()


pygame.quit()
Esempio n. 25
0
def main():

    #creacion de objetos para la pantalla
    bg = background.background(settings.pantalla,
                               "02.png",
                               posicion=settings.screen_center)

    l0 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 50),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l1 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 100),
                           linea=u"Marcelo Salas emprendió su viaje hacia el",
                           velocidad=settings.text_speed_2)
    l2 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 150),
                           linea=u"mar Atlántico, donde se encontraban sus",
                           velocidad=settings.text_speed_2)
    l3 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 200),
                           linea=u"transgénicos.",
                           velocidad=settings.text_speed_2)
    l4 = text.text_anim_01(
        pantalla=settings.pantalla,
        nombre="COOPBL.ttf",
        color=(255, 255, 255),
        tamano=settings.text_tamano_2,
        posicion=(settings.WIDTH / 10 - 20, 250),
        linea=u"                                                          ",
        velocidad=settings.text_speed_2)
    l5 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 300),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    l6 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 350),
                           linea=u"Su viaje duro 30 años y 2 segundos hasta",
                           velocidad=settings.text_speed_2)
    l7 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 400),
                           linea=u"que llegó al tan anhelado mar Atlántico.",
                           velocidad=settings.text_speed_2)
    l8 = text.text_anim_01(
        pantalla=settings.pantalla,
        nombre="COOPBL.ttf",
        color=(255, 255, 255),
        tamano=settings.text_tamano_2,
        posicion=(settings.WIDTH / 10 - 20, 450),
        linea=u"                                                            ",
        velocidad=settings.text_speed_2)
    l9 = text.text_anim_01(pantalla=settings.pantalla,
                           nombre="COOPBL.ttf",
                           color=(255, 255, 255),
                           tamano=settings.text_tamano_2,
                           posicion=(settings.WIDTH / 10 - 20, 500),
                           linea=u"",
                           velocidad=settings.text_speed_2)
    lis = [l0, l1, l2, l3, l4, l5, l6, l7, l8, l9]
    parrafo = text.group_text(lis)

    mouse = cursor.cursor()
    bgmusic = bgm.bgm()

    running = True

    while running:
        #variables que se comprueban cada bucle

        #control de eventos
        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                running = False
                bgmusic.fadeout(1000)

        #manejo de textos
        if parrafo.contador == 1 and parrafo.renderizado == True:

            parrafo.void()

            l2.line(u"Al llegar a este mar, divisó una manzana")
            l3.line(u"gigante que flotaba sobre una ballena que")
            l4.line(u"comía uretras del fósil de un mamut")
            l5.line(u"congelado que data de aproximadamente")
            l6.line(u"30.000 Mickeys.")
            l7.line(
                u"                                                            "
            )

        if parrafo.contador == 2 and parrafo.renderizado == True:

            parrafo.void()

            l1.line(u"Marcelo Salas rápidamente fue navegando")
            l2.line(u"hacia el (Por cierto, Marcelo Salas viaja")
            l3.line(u"por el mar con el cuerpo del Padre Pío) ")
            l4.line(u"hasta que finalmente llegó hasta la manzana. ")
            l5.line(u"                                           ")
            l6.line(u"Pero, al llegar a esta manzana fue  ")
            l7.line(u"teletransportado a un lugar oscuro.")
            l8.line(u"                                                  ")

        #paso a la siguiente pantalla
        if parrafo.contador == 3:
            running = False
            bgmusic.fadeout(1000)
            s4.main()

        #actualizacion de objetos en pantalla
        bg.update()
        parrafo.update()

        #actualizamos pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Esempio n. 26
0
 def __init__(self, mainclass, matser, _winheight, _winwidth):
     self.winheight = _winheight
     self.insetting = False
     self.winwidth = _winwidth
     self.master = matser
     self.mainclass = mainclass
     self.clockpage = tk.Frame(self.master,
                               bg="pink",
                               height=self.winheight,
                               width=self.winwidth)
     self.clockpage.place(x=0, y=0)
     self.mainclass.tasklist = []
     self.f = open("doc/clockplan.txt")
     line = self.f.readline()
     while line:
         if int(line) != 0:
             templist = []
             line = self.f.readline().replace("\n", "")
             line = list(line.split(","))
             line = self.transint(line)
             templist.append(line)
             line = self.f.readline().replace("\n", "")
             if int(line) == 0:
                 line = False
             else:
                 line = True
             templist.append(line)
             line = self.f.readline().replace("\n", "")
             line = list(line.split(","))
             line = self.transint(line)
             templist.append(line)
             self.mainclass.tasklist.append(templist)
             line = self.f.readline()
         else:
             self.mainclass.tasklist.append([int(line)])
             line = self.f.readline()
     self.f.close()
     self.taskstrlist = self.translist(self.mainclass.tasklist)
     self.topheight = 130  #顶部标题高度
     self.ypadding = 10
     self.xpadding = 20
     self.taskheight = (self.winheight - self.topheight -
                        8 * self.ypadding) / 3
     self.taskwidth = (self.winwidth - 6 * self.xpadding) / 2
     self.btnwidth = 30
     self.btnheight = 30
     self.btnpadding = 10
     self.btnlist = []
     self.detelebtnlist = []
     self.canvaslist = []
     self.addimage = ImageTk.PhotoImage(
         Image.open("srcimage/add.jpg").resize(
             (int(self.taskwidth), int(self.taskheight))))
     self.editimage = ImageTk.PhotoImage(
         Image.open("srcimage/edit.jpg").resize(
             (int(self.btnwidth), int(self.btnheight))))
     self.closeimage = ImageTk.PhotoImage(
         Image.open("srcimage/close.jpg").resize(
             (int(self.btnwidth), int(self.btnheight))))
     #背景
     bg = background(self.clockpage, self.winheight, self.winwidth, "call")
     #返回按钮
     backbtn(self.mainclass, self.clockpage, self.winheight, self.winwidth,
             6)
     #标题
     title(self.clockpage, self.winheight, self.winwidth, "定时服药提醒")
     self.refresh()
     bg.showimage()
Esempio n. 27
0
    def __init__(self, mainclass, master, _winheight, _winwidth):

        #获取本地音乐文件
        self.mainclass = mainclass
        self.extensionlist = ['mp3', 'flac']
        self.musiclist = []
        for extension in self.extensionlist:
            file_list = glob.glob('music/*.' + extension)  #返回一个列表
            for item in file_list:
                self.musiclist.append(item[6:])

        #尺寸变量
        self.winheight = _winheight
        self.winwidth = _winwidth
        self.photopadding = self.winwidth / 128
        self.photoleftpadding = 300
        self.photowidth = self.winwidth - self.photopadding * 2 - self.photoleftpadding
        self.photoheight = 40
        self.photomovex = (self.winwidth - self.photowidth) / 2
        self.master = master
        self.musicreadlist = []
        self.topheight = 130  #顶部标题高度
        self.backbtnheight = self.topheight / 2
        self.backbtnwidth = self.backbtnheight
        self.backbtnpadding = self.topheight / 4  #顶部按钮的间距
        self.pausebtnwidth = 30
        self.pausebtnmovey = (self.photoheight - self.pausebtnwidth) / 2
        self.pausebtnmovex = self.photowidth - 30 - self.pausebtnwidth
        self.curid = -1
        self.pausemusicflag = False  #是否有音乐暂停
        self.pausemusicid = -1  #暂停的音乐id
        #读取图片
        self.backimg = ImageTk.PhotoImage(
            Image.open("srcimage/toleft.jpg").resize(
                (int(self.backbtnwidth), int(self.backbtnheight))))
        self.pauseimg = ImageTk.PhotoImage(
            Image.open("srcimage/pause.jpg").resize(
                (int(self.pausebtnwidth), int(self.pausebtnwidth))))
        self.playimg = ImageTk.PhotoImage(
            Image.open("srcimage/play.jpg").resize(
                (int(self.pausebtnwidth), int(self.pausebtnwidth))))
        self.musicpage = tk.Canvas(self.master,
                                   bg="pink",
                                   width=self.winwidth,
                                   height=self.winheight)
        self.musicpage.place(x=0, y=0)
        self.musicpage.configure(highlightthickness=0)
        #背景
        bg = background(self.musicpage, self.winheight, self.winwidth, "call")
        #返回按钮
        backbtn(self.mainclass, self.musicpage, self.winheight, self.winwidth,
                1)
        #标题
        title(self.musicpage, self.winheight, self.winwidth, "播放音乐")
        self.Canvaslist = []
        self.pausebtnlist = []
        #图片缩略图放置
        for n in range(0, len(self.musiclist)):
            self.Canvaslist.append(
                tk.Canvas(self.musicpage,
                          bg="white",
                          width=int(self.photowidth),
                          height=int(self.photoheight)))
            self.Canvaslist[n].place(
                x=self.photomovex,
                y=n * (self.photoheight + self.photopadding) + self.topheight)
            self.Canvaslist[n].create_text(self.photowidth / 2,
                                           self.photoheight / 2,
                                           text=self.resolvestr(
                                               self.musiclist[n])[0],
                                           font=("黑体", 15))
            self.pausebtnlist.append(
                tk.Button(self.Canvaslist[n],
                          image=self.playimg,
                          width=self.pausebtnwidth,
                          height=self.pausebtnwidth,
                          command=self.returnfun(n)))
            self.pausebtnlist[n].place(x=self.pausebtnmovex,
                                       y=self.pausebtnmovey)
        bg.showimage()
Esempio n. 28
0
suw = statusUpdateWorker.StatusUpdateWorker()
buw = brewUpdateWorker.BrewUpdateWorker()
#but = button.button()
print('thd objects done')
suw.runStatusMonitor()
buw.runBrewMonitor()
#but.button_manager()
print('thd ctors done')
print('all threads started...')
print('starting main while loop')

while True:
    if current_state == 'background':
        sqlite_update('device_info', 'current_state', 'background')
        background_return = background(all_settings)
        time.sleep(0.5)
        if background_return == 'waiting':
            current_state = 'waiting'
        elif background_return == 'brewing':
            pb_test = pbc.prebrew_check(mpu)
            if pb_test == 'good':
                current_state = 'brewing'
            else:
                current_state = 'background'
    elif current_state == 'waiting':
        sqlite_update('device_info', 'current_state', 'waiting')
        waiting_return = waiting(all_settings)
        time.sleep(0.5)
        print('waiting return = {}'.format(waiting_return))
        if waiting_return == 'background':
Esempio n. 29
0
def main():

    # here we creat background
    background1 = background.Background(size)
    background2 = background.background(size)

    # here we creat myplane
    my_plane = pygame.sprite.Group()
    myplane1 = myplane.Myplane(size)
    my_plane.add(myplane1)

    # here we creat the enemy planes
    enemies = pygame.sprite.Group()
    enemy3 = pygame.sprite.Group()
    enemy2 = pygame.sprite.Group()
    boss = pygame.sprite.Group()
    e21 = enemy.Enemy2(size)
    e22 = enemy.Enemy2(size)
    e23 = enemy.Enemy2(size)
    e24 = enemy.Enemy2(size)
    e25 = enemy.Enemy2(size)
    boss1 = enemy.Enemy8(size)
    enemy2.add(e21)
    enemy2.add(e22)
    enemy2.add(e23)
    enemy2.add(e24)
    enemy2.add(e25)
    enemies.add(e21)
    enemies.add(e22)
    enemies.add(e23)
    enemies.add(e24)
    enemies.add(e25)
    boss.add(boss1)

    e3 = enemy.Enemy3(size)
    enemy3.add(e3)

    enemy1 = pygame.sprite.Group()
    add_enemy1(enemy1, enemies, 3)

    enemy4 = pygame.sprite.Group()
    add_enemy4(enemy4, enemies, 2)

    enemy5 = pygame.sprite.Group()

    enemy6 = pygame.sprite.Group()

    enemy7 = pygame.sprite.Group()
    add_enemy7(enemy7, enemies, 1)

    # here we creat the bullets
    bullet1 = []
    bullet1_index = 0
    bullet1_number = 80
    for i in range(bullet1_number // 2):
        bullet1.append(
            bullet.Bullet1(
                (myplane1.rect.centerx - 13, myplane1.rect.centery)))
        bullet1.append(
            bullet.Bullet1(
                (myplane1.rect.centerx + 13, myplane1.rect.centery)))

    # here we creat the super bullet
    bullet2 = []
    bullet2_index = 0
    bullet2_number = 80
    for i in range(bullet2_number // 2):
        bullet2.append(
            bullet.Bullet2(
                (myplane1.rect.centerx - 13, myplane1.rect.centery)))
        bullet2.append(
            bullet.Bullet2(
                (myplane1.rect.centerx + 13, myplane1.rect.centery)))

    # here we creat the super bullet
    bullet3 = []
    bullet3_index = 0
    bullet3_number = 40
    for i in range(bullet3_number):
        bullet3.append(
            bullet.Bullet3(
                (myplane1.rect.centerx - 23, myplane1.rect.centery)))

    # here we creat the super bullet
    bullet4 = []
    bullet4_index = 0
    bullet4_number = 40
    for i in range(bullet4_number):
        bullet4.append(
            bullet.Bullet4(
                (myplane1.rect.centerx + 23, myplane1.rect.centery)))

    bullet6 = []
    bullet6_index = 0
    bullet6_number = 5000
    for i in range(bullet6_number // 5):
        bullet6.append(
            bullet.Bullet6((boss1.rect.centerx - 300, boss1.rect.centery)))
        bullet6.append(
            bullet.Bullet6((boss1.rect.centerx - 100, boss1.rect.centery)))
        bullet6.append(
            bullet.Bullet6((boss1.rect.centerx + 100, boss1.rect.centery)))
        bullet6.append(
            bullet.Bullet6((boss1.rect.centerx + 300, boss1.rect.centery)))

    # here we creat the enemy bullet
    bullet5 = bullet.Bullet5(size)
    b5 = pygame.sprite.Group()
    b5.add(bullet5)

    bullet51 = bullet.Bullet6(size)
    b51 = pygame.sprite.Group()
    b51.add(bullet51)

    bullet52 = bullet.Bullet6(size)
    b52 = pygame.sprite.Group()
    b52.add(bullet52)

    bullet53 = bullet.Bullet6(size)
    b53 = pygame.sprite.Group()
    b53.add(bullet53)

    bullet54 = bullet.Bullet6(size)
    b54 = pygame.sprite.Group()
    b54.add(bullet54)

    bullet55 = bullet.Bullet6(size)
    b55 = pygame.sprite.Group()
    b55.add(bullet55)

    # the index of plane when it is destoried
    e1_destroy_index = 0
    e2_destroy_index = 0
    en3_destroy_index = 0
    e4_destroy_index = 0
    e5_destroy_index = 0
    e6_destroy_index = 0
    e7_destroy_index = 0
    myplane1_destroy_index = 0
    boss_destroy_index = 0

    # here we add the score to the game
    score = 0
    score_font = pygame.font.Font("font/font.ttf.ttf", 36)

    #here we set the stop condtion to the game
    paused = False
    pause_nor_image = pygame.image.load("images/22.png").convert_alpha()
    pause_pressed_image = pygame.image.load("images/23.png").convert_alpha()
    resume_nor_image = pygame.image.load("images/21.png").convert_alpha()
    resume_pressed_image = pygame.image.load("images/24.png").convert_alpha()
    paused_rect = pause_nor_image.get_rect()
    paused_rect.left, paused_rect.top = width - paused_rect.width - 10, 10
    paused_image = pause_nor_image

    # here we set the difficulty of the game
    level = 1

    # here we set the bomb skills
    bomb_image = pygame.image.load("images/25.png").convert_alpha()
    bomb_rect = bomb_image.get_rect()
    bomb_font = pygame.font.Font("font/font.ttf.ttf", 48)
    bomb_num = 3

    # here we set record time
    recorded = False

    # here we set the ending picture
    gameover_font = pygame.font.Font("font/font.ttf.ttf", 48)
    again_image = pygame.image.load("images/29.png").convert_alpha()
    again_rect = again_image.get_rect()
    gameover_image = pygame.image.load("images/30.png").convert_alpha()
    gameover_rect = gameover_image.get_rect()

    # here we set the supply
    bullet_supply = supply.Bullet_supply(size)
    bomb_supply = supply.Bomb_supply(size)
    supply_time = USEREVENT
    pygame.time.set_timer(supply_time, 15 * 1000)

    # here we set the timing of super bullet
    super_bullet_time = USEREVENT + 1

    # here we add the timing of myplane's invincibe
    invincible_time = USEREVENT + 2

    # here we set condition of the super bullet
    is_super_bullet = False

    # here we set the lives of my planes
    life_image = pygame.image.load("images/28.png").convert_alpha()
    life_rect = life_image.get_rect()
    life_num = 3

    # here we set the delay to make the picture change smoothly
    delay = 120

    # here we set the state of running to check if we need to end the game
    running = True

    clock = pygame.time.Clock()

    # here we start the game
    while running:
        print(delay)
        for event in pygame.event.get():

            # here we quit the game and exit the system
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

            elif event.type == MOUSEBUTTONDOWN:
                if event.button == 1 and paused_rect.collidepoint(event.pos):
                    paused = not paused
                    if paused:
                        pygame.time.set_timer(supply_time, 0)
                    else:
                        pygame.time.set_timer(supply_time, 15 * 1000)

            elif event.type == MOUSEMOTION:
                if paused_rect.collidepoint(event.pos):
                    if paused:
                        paused_image = resume_pressed_image
                    else:
                        paused_image = pause_pressed_image
                else:
                    if paused:
                        paused_image = resume_nor_image
                    else:
                        paused_image = pause_nor_image

        # here we set the function of the bomb
            elif event.type == KEYDOWN:
                if event.key == K_SPACE:
                    if bomb_num:
                        bomb_num -= 1
                        for each in enemies:
                            if each.rect.bottom > 0:
                                each.active = False
                        if level == 7:
                            boss1.energy -= 100
                            if boss1.energy < 0:
                                boss1.active = False

        # here we set the supply type
            elif event.type == supply_time:
                if choice([True, False]):
                    bomb_supply.reset()
                else:
                    bullet_supply.reset()

            elif event.type == super_bullet_time:
                is_super_bullet = False
                pygame.time.set_timer(super_bullet_time, 0)

            elif event.type == invincible_time:
                myplane1.invincible = False
                pygame.time.set_timer(invincible_time, 0)

        # here we change the levels
        if level == 1 and score > 100:
            level = 2

            # add more enemy planes to increase the difficulty level
            add_enemy1(enemy1, enemies, 1)
            add_enemy4(enemy4, enemies, 1)

            # increase the speed of the small enemy plane
            inc_speed(enemy1, 1)

        elif level == 2 and score > 300:
            level = 3

            # add more enemy planes to increase the difficulty level
            add_enemy1(enemy1, enemies, 1)
            add_enemy4(enemy4, enemies, 1)
            add_enemy5(enemy5, enemies, 1)
            add_enemy6(enemy6, enemies, 1)

            # increase the speed of the small enemy plane
            inc_speed(enemy1, 1)

        elif level == 3 and score > 800:
            level = 4

            # add more enemy planes to increase the difficulty level
            add_enemy1(enemy1, enemies, 1)
            add_enemy5(enemy5, enemies, 1)
            add_enemy6(enemy6, enemies, 1)

            # increase the speed of the small enemy plane

        elif level == 4 and score > 1500:
            level = 5

            # add more enemy planes to increase the difficulty level
            add_enemy1(enemy1, enemies, 1)
            add_enemy4(enemy4, enemies, 1)

            # increase the speed of the small enemy plane
            inc_speed(enemy4, 1)

        elif level == 5 and score > 2500:
            level = 6

            # add more enemy planes to increase the difficulty level
            add_enemy1(enemy1, enemies, 2)
            add_enemy4(enemy4, enemies, 1)
            add_enemy5(enemy5, enemies, 1)
            add_enemy6(enemy6, enemies, 1)

            # increase the speed of the small enemy plane
            inc_speed(enemy1, 1)

        elif level == 6 and score > 4000:
            score = 4000
            level = 7

            # delete all the enemy planes
            e3.active = False
            e3.reset()
            for each in enemies:
                each.active = False
                each.reset()
            boss1.active = True

        if score == 4000:
            score += 100
            delay = 120
        # here we draw the background picture
        if background1.active:
            background1.move()
            screen.blit(background1.image, background1.rect)

        if background2.active:
            background2.move()
            screen.blit(background2.image, background2.rect)

        if life_num and not paused:
            # here we check the keyboard of user
            key_pressed = pygame.key.get_pressed()
            if key_pressed[K_w]:
                myplane1.moveUp()
            if key_pressed[K_s]:
                myplane1.moveDown()
            if key_pressed[K_a]:
                myplane1.moveLeft()
            if key_pressed[K_d]:
                myplane1.moveRight()

            # here we draw the bomb and indicate if the player get it
            if bomb_supply.active:
                bomb_supply.move()
                screen.blit(bomb_supply.image, bomb_supply.rect)
                if pygame.sprite.collide_mask(bomb_supply, myplane1):
                    if bomb_num < 3:
                        bomb_num += 1
                    bomb_supply.active = False

            # here we draw the bullet supply and indicate if the player get it
            if bullet_supply.active:
                bullet_supply.move()
                screen.blit(bullet_supply.image, bullet_supply.rect)
                if pygame.sprite.collide_mask(bullet_supply, myplane1):
                    # creat and shoot the super bullet
                    is_super_bullet = True
                    pygame.time.set_timer(super_bullet_time, 8 * 1000)
                    bullet_supply.active = False

            # here we check that if the user's plane is touched by the enemies and their bullets
            enemies_down = pygame.sprite.spritecollide(
                myplane1, enemies, False, pygame.sprite.collide_mask)
            enemy3_down = pygame.sprite.spritecollide(
                myplane1, enemy3, False, pygame.sprite.collide_mask)
            enemy2_down = pygame.sprite.spritecollide(
                myplane1, enemy2, False, pygame.sprite.collide_mask)
            b5_down = pygame.sprite.spritecollide(myplane1, b5, False,
                                                  pygame.sprite.collide_mask)
            b51_down = pygame.sprite.spritecollide(myplane1, b51, False,
                                                   pygame.sprite.collide_mask)
            b52_down = pygame.sprite.spritecollide(myplane1, b52, False,
                                                   pygame.sprite.collide_mask)
            b53_down = pygame.sprite.spritecollide(myplane1, b53, False,
                                                   pygame.sprite.collide_mask)
            b54_down = pygame.sprite.spritecollide(myplane1, b54, False,
                                                   pygame.sprite.collide_mask)
            b55_down = pygame.sprite.spritecollide(myplane1, b55, False,
                                                   pygame.sprite.collide_mask)
            if enemies_down and not myplane1.invincible:
                myplane1.invincible = True
                pygame.time.set_timer(invincible_time, 1 * 1000)
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                for e in enemies_down:
                    e.active = False
            if enemy3_down and not myplane1.invincible:
                myplane1.invincible = True
                pygame.time.set_timer(invincible_time, 1 * 1000)
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                e3.active = False
            if enemy2_down and not myplane1.invincible:
                myplane1.invincible = True
                pygame.time.set_timer(invincible_time, 1 * 1000)
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                for m in enemy2_down:
                    m.active = False
            if b5_down and not myplane1.invincible:
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                bullet5.active = False
                bullet5.reset((e3.rect.centerx, e3.rect.bottom))
            if b51_down and not myplane1.invincible:
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                bullet51.active = False
                bullet51.reset((e21.rect.centerx, e21.rect.bottom))
            if b52_down and not myplane1.invincible:
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                bullet52.active = False
                bullet52.reset((e22.rect.centerx, e22.rect.bottom))
            if b53_down and not myplane1.invincible:
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                bullet53.active = False
                bullet53.reset((e23.rect.centerx, e23.rect.bottom))
            if b54_down and not myplane1.invincible:
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                bullet54.active = False
                bullet54.reset((e24.rect.centerx, e24.rect.bottom))
            if b55_down and not myplane1.invincible:
                myplane1.energy -= 1
                if myplane1.energy == 0:
                    myplane1.active = False
                bullet55.active = False
                bullet55.reset((e25.rect.centerx, e25.rect.bottom))

            # here we draw the user's plane
            if myplane1.active:
                screen.blit(myplane1.image, myplane1.rect)
                # here we draw the total blood of my plane
                pygame.draw.line(screen, BLACK, \
                                 (myplane1.rect.left, myplane1.rect.bottom + 5),\
                                 (myplane1.rect.right, myplane1.rect.bottom + 5),\
                                 2)
                # when the energy is bigger than 20%, it will be green. else, it will be red
                energy_remain1 = myplane1.energy / myplane.Myplane.energy
                if energy_remain1 > 0.5:
                    energy_color = GREEN
                else:
                    energy_color = RED
                pygame.draw.line(screen, energy_color,\
                                 (myplane1.rect.left, myplane1.rect.bottom + 5),\
                                 (myplane1.rect.left + myplane1.rect.width * energy_remain1,\
                                 myplane1.rect.bottom + 5), 2)

            else:
                if not (delay % 3):
                    # here we draw the destory pictures of the plane
                    screen.blit(
                        myplane1.destroy_images[myplane1_destroy_index],
                        myplane1.rect)
                    myplane1_destroy_index = (myplane1_destroy_index + 1) % 4
                    if myplane1_destroy_index == 0:
                        life_num -= 1
                        myplane1.reset()
                        pygame.time.set_timer(invincible_time, 3 * 1000)

            # here we check the condition of the enemy3
            if boss1.active:
                boss1.move()
                screen.blit(boss1.image, boss1.rect)
                # here we draw the total blood of the enemy plane
                pygame.draw.line(screen, BLACK, \
                                 (boss1.rect.left, boss1.rect.bottom - 50),\
                                 (boss1.rect.right, boss1.rect.bottom - 50),\
                                 2)
                # when the energy is bigger than 20%, it will be green. else, it will be red
                energy_remain2 = boss1.energy / enemy.Enemy8.energy
                if energy_remain2 > 0.30:
                    energy_color = GREEN
                else:
                    energy_color = RED
                pygame.draw.line(screen, energy_color,\
                                 (boss1.rect.left, boss1.rect.bottom - 50),\
                                 (boss1.rect.left + boss1.rect.width * energy_remain2,\
                                 boss1.rect.bottom - 50), 2)
            else:
                if level == 7:
                    if not (delay % 3):
                        # here we draw the destory pictures of the plane
                        screen.blit(boss1.destroy_images[boss_destroy_index],
                                    boss1.rect)
                        boss_destroy_index = (boss_destroy_index + 1) % 4
                        if boss_destroy_index == 0:
                            score += 10000
                            life_num -= life_num
                            boss1.reset()

            # here we draw the enemy bullet
            if bullet5.active:
                screen.blit(bullet5.image, bullet5.rect)
                bullet5.move()
                if bullet5.rect.centerx > myplane1.rect.centerx and bullet5.rect.top < myplane1.rect.top:
                    bullet5.rect.left -= 2
                if bullet5.rect.centerx < myplane1.rect.centerx and bullet5.rect.top < myplane1.rect.top:
                    bullet5.rect.left += 2
            else:
                if not level == 7:
                    if e3.rect.top > 0 and e3.rect.top < 800:
                        bullet5.reset((e3.rect.centerx, e3.rect.bottom))

            if bullet51.active:
                screen.blit(bullet51.image, bullet51.rect)
                bullet51.move()
            else:
                if not level == 7:
                    if e21.rect.top > 0 and e21.rect.top < 800:
                        bullet51.reset((e21.rect.centerx, e21.rect.bottom))

            if bullet52.active:
                screen.blit(bullet52.image, bullet52.rect)
                bullet52.move()
            else:
                if not level == 7:
                    if e22.rect.top > 0 and e22.rect.top < 800:
                        bullet52.reset((e22.rect.centerx, e22.rect.bottom))

            if bullet53.active:
                screen.blit(bullet53.image, bullet53.rect)
                bullet53.move()
            else:
                if not level == 7:
                    if e23.rect.top > 0 and e23.rect.top < 800:
                        bullet53.reset((e23.rect.centerx, e23.rect.bottom))

            if bullet54.active:
                screen.blit(bullet54.image, bullet54.rect)
                bullet54.move()
            else:
                if not level == 7:
                    if e24.rect.top > 0 and e24.rect.top < 800:
                        bullet54.reset((e24.rect.centerx, e24.rect.bottom))

            if bullet55.active:
                screen.blit(bullet55.image, bullet55.rect)
                bullet55.move()
            else:
                if not level == 7:
                    if e25.rect.top > 0 and e25.rect.top < 800:
                        bullet55.reset((e25.rect.centerx, e25.rect.bottom))

            # here we shot the bullets
            if not (delay % 10):
                if is_super_bullet:
                    bullets = bullet2
                    bullets[bullet2_index].reset(
                        (myplane1.rect.centerx - 13, myplane1.rect.centery))
                    bullets[bullet2_index + 1].reset(
                        (myplane1.rect.centerx + 13, myplane1.rect.centery))
                    bullet3[bullet3_index].reset(
                        (myplane1.rect.centerx + 23, myplane1.rect.centery))
                    bullet4[bullet4_index].reset(
                        (myplane1.rect.centerx - 23, myplane1.rect.centery))
                    bullet2_index = (bullet2_index + 2) % bullet2_number
                    bullet3_index = (bullet3_index + 1) % bullet3_number
                    bullet4_index = (bullet4_index + 1) % bullet4_number
                else:
                    bullets = bullet1
                    bullets[bullet1_index].reset(
                        (myplane1.rect.centerx - 13, myplane1.rect.centery))
                    bullets[bullet1_index + 1].reset(
                        (myplane1.rect.centerx + 13, myplane1.rect.centery))
                    bullet1_index = (bullet1_index + 2) % bullet1_number

            # here we draw the boss bullet
            if boss1.active:
                if not (delay % 40):
                    bossbullets = bullet6
                    bossbullets[bullet6_index].reset(
                        (boss1.rect.centerx - 300, boss1.rect.centery))
                    bossbullets[bullet6_index + 1].reset(
                        (boss1.rect.centerx - 100, boss1.rect.centery))
                    bossbullets[bullet6_index + 2].reset(
                        (boss1.rect.centerx + 100, boss1.rect.centery))
                    bossbullets[bullet6_index + 3].reset(
                        (boss1.rect.centerx + 300, boss1.rect.centery))
                    bullet6_index = (bullet6_index + 4) % bullet6_number

            # here we check if the bullet collides witg the plane
            if level == 7 and boss1.active:
                for v in bossbullets:
                    if v.active:
                        if energy_remain2 >= 0.9:
                            v.move()
                        if energy_remain2 >= 0.8 and energy_remain2 < 0.9:
                            v.move()
                            v.move1()
                        if energy_remain2 >= 0.7 and energy_remain2 < 0.8:
                            v.move()
                            v.move3()
                        if energy_remain2 >= 0.6 and energy_remain2 < 0.7:
                            v.move()
                            v.move2()
                        if energy_remain2 >= 0.5 and energy_remain2 < 0.6:
                            v.move()
                            v.move3()
                        if energy_remain2 >= 0.4 and energy_remain2 < 0.5:
                            v.move()
                            v.rect.top += 1
                            v.move1()
                        if energy_remain2 >= 0.3 and energy_remain2 < 0.4:
                            v.move()
                            v.rect.top += 2
                            v.move2()
                        if energy_remain2 >= 0.2 and energy_remain2 < 0.3:
                            v.move()
                        if energy_remain2 < 0.2:
                            v.move()
                            if v.rect.centerx > myplane1.rect.centerx and v.rect.top < myplane1.rect.top:
                                v.rect.left -= 2
                            if v.rect.centerx < myplane1.rect.centerx and v.rect.top < myplane1.rect.top:
                                v.rect.left += 2

                        screen.blit(v.image, v.rect)
                        bossbullet_down = pygame.sprite.spritecollide(
                            v, my_plane, False, pygame.sprite.collide_mask)
                        if bossbullet_down and not myplane1.invincible:
                            myplane1.energy -= 1
                            if myplane1.energy == 0:
                                myplane1.active = False
                            v.active = False

            # here we check if the bullet collides with the enemy plane
            for b in bullets:
                if b.active:
                    b.move()
                    screen.blit(b.image, b.rect)
                    enemy_hit = pygame.sprite.spritecollide(
                        b, enemies, False, pygame.sprite.collide_mask)
                    enemy3_hit = pygame.sprite.spritecollide(
                        b, enemy3, False, pygame.sprite.collide_mask)
                    enemy2_hit = pygame.sprite.spritecollide(
                        b, enemy2, False, pygame.sprite.collide_mask)
                    boss_hit = pygame.sprite.spritecollide(
                        b, boss, False, pygame.sprite.collide_mask)
                    if enemy_hit:
                        b.active = False
                        for e in enemy_hit:
                            # here we check which type of planes is attacked
                            if e in enemy2:
                                e.energy -= 1
                                if e.energy == 0:
                                    e.active = False
                            else:
                                e.active = False
                    if enemy3_hit:
                        b.active = False
                        # here we check which type of planes is attacked
                        e3.energy -= 1
                        if e3.energy == 0:
                            e3.active = False
                    if enemy2_hit:
                        b.active = False
                        for z in enemy2_hit:
                            z.energy -= 1
                            if z.energy == 0:
                                z.active = False
                    if boss_hit:
                        b.active = False
                        boss1.energy -= 1
                        if boss1.energy == 0:
                            boss1.active = False
                            level == 8

            for x in bullet3:
                if x.active:
                    x.move1()
                    x.move()
                    screen.blit(x.image, x.rect)
                    enemy_hit = pygame.sprite.spritecollide(
                        x, enemies, False, pygame.sprite.collide_mask)
                    enemy3_hit = pygame.sprite.spritecollide(
                        x, enemy3, False, pygame.sprite.collide_mask)
                    enemy2_hit = pygame.sprite.spritecollide(
                        x, enemy2, False, pygame.sprite.collide_mask)
                    boss_hit = pygame.sprite.spritecollide(
                        x, boss, False, pygame.sprite.collide_mask)
                    if enemy_hit:
                        x.active = False
                        for e in enemy_hit:
                            # here we check which type of planes is attacked
                            if e in enemy2:
                                e.energy -= 1
                                if e.energy == 0:
                                    e.active = False
                            else:
                                e.active = False
                    if enemy3_hit:
                        x.active = False
                        # here we check which type of planes is attacked
                        e3.energy -= 1
                        if e3.energy == 0:
                            e3.active = False
                    if enemy2_hit:
                        x.active = False
                        for z in enemy2_hit:
                            z.energy -= 1
                            if z.energy == 0:
                                z.active = False
                    if boss_hit:
                        x.active = False
                        boss1.energy -= 1
                        if boss1.energy == 0:
                            boss1.active = False
                            level == 8

            for y in bullet4:
                if y.active:
                    y.move1()
                    y.move()
                    screen.blit(y.image, y.rect)
                    enemy_hit = pygame.sprite.spritecollide(
                        y, enemies, False, pygame.sprite.collide_mask)
                    enemy3_hit = pygame.sprite.spritecollide(
                        y, enemy3, False, pygame.sprite.collide_mask)
                    enemy2_hit = pygame.sprite.spritecollide(
                        y, enemy2, False, pygame.sprite.collide_mask)
                    boss_hit = pygame.sprite.spritecollide(
                        y, boss, False, pygame.sprite.collide_mask)
                    if enemy_hit:
                        y.active = False
                        for e in enemy_hit:
                            # here we check which type of planes is attacked
                            if e in enemy2:
                                e.energy -= 1
                                if e.energy == 0:
                                    e.active = False
                            else:
                                e.active = False
                    if enemy3_hit:
                        y.active = False
                        # here we check which type of planes is attacked
                        e3.energy -= 1
                        if e3.energy == 0:
                            e3.active = False
                    if enemy2_hit:
                        y.active = False
                        for z in enemy2_hit:
                            z.energy -= 1
                            if z.energy == 0:
                                z.active = False
                    if boss_hit:
                        y.active = False
                        boss1.energy -= 1
                        if boss1.energy == 0:
                            boss1.active = False
                            level == 8

            # here we check the condition of the enemy3
            if e3.active and not level == 7:
                e3.move()
                screen.blit(e3.image, e3.rect)
                # here we draw the total blood of the enemy plane
                pygame.draw.line(screen, BLACK, \
                                 (e3.rect.left, e3.rect.top - 5),\
                                 (e3.rect.right, e3.rect.top - 5),\
                                 2)
                # when the energy is bigger than 20%, it will be green. else, it will be red
                energy_remain = e3.energy / enemy.Enemy3.energy
                if energy_remain > 0.35:
                    energy_color = GREEN
                else:
                    energy_color = RED
                pygame.draw.line(screen, energy_color,\
                                 (e3.rect.left, e3.rect.top - 5),\
                                 (e3.rect.left + e3.rect.width * energy_remain,\
                                 e3.rect.top - 5), 2)
            else:
                if not level == 7:
                    if not (delay % 3):
                        # here we draw the destory pictures of the plane
                        screen.blit(e3.destroy_images[en3_destroy_index],
                                    e3.rect)
                        en3_destroy_index = (en3_destroy_index + 1) % 4
                        if en3_destroy_index == 0:
                            score += 1000
                            e3.reset()
            if e3.rect.top > 960 and not level == 7:
                e3.reset()

            for each in enemy2:
                if each.active and not level == 7:
                    each.move()
                    screen.blit(each.image, each.rect)
                    # here we draw the total blood of the enemy plane
                    pygame.draw.line(screen, BLACK, \
                                     (each.rect.left, each.rect.top - 5),\
                                     (each.rect.right, each.rect.top - 5),\
                                     2)
                    # when the energy is bigger than 20%, it will be green. else, it will be red
                    energy_remain = each.energy / enemy.Enemy2.energy
                    if energy_remain > 0.35:
                        energy_color = GREEN
                    else:
                        energy_color = RED
                    pygame.draw.line(screen, energy_color,\
                                     (each.rect.left, each.rect.top - 5),\
                                     (each.rect.left + each.rect.width * energy_remain,\
                                     each.rect.top - 5), 2)
                else:
                    if not level == 7:
                        if not (delay % 3):
                            # here we draw the destory pictures of the plane
                            screen.blit(each.destroy_images[e2_destroy_index],
                                        each.rect)
                            e2_destroy_index = (e2_destroy_index + 1) % 4
                            if e2_destroy_index == 0:
                                score += 500
                                each.reset()
                if each.rect.top > 960 and not level == 7:
                    each.reset()

            for each in enemy1:
                if each.active and not level == 7:
                    each.move()
                    screen.blit(each.image, each.rect)
                else:
                    if not level == 7:
                        if not (delay % 3):
                            # here we draw the destory pictures of the plane
                            screen.blit(each.destroy_images[e1_destroy_index],
                                        each.rect)
                            e1_destroy_index = (e1_destroy_index + 1) % 4
                            if e1_destroy_index == 0:
                                score += 100
                                each.reset()

            for each in enemy4:
                if each.active and not level == 7:
                    each.move()
                    screen.blit(each.image, each.rect)
                else:
                    if not level == 7:
                        if not (delay % 3):
                            # here we draw the destory pictures of the plane
                            screen.blit(each.destroy_images[e4_destroy_index],
                                        each.rect)
                            e4_destroy_index = (e4_destroy_index + 1) % 4
                            if e4_destroy_index == 0:
                                score += 100
                                each.reset()

            for each in enemy5:
                if each.active and not level == 7:
                    each.move()
                    screen.blit(each.image, each.rect)
                else:
                    if not level == 7:
                        if not (delay % 3):
                            # here we draw the destory pictures of the plane
                            screen.blit(each.destroy_images[e5_destroy_index],
                                        each.rect)
                            e5_destroy_index = (e5_destroy_index + 1) % 4
                            if e5_destroy_index == 0:
                                score += 100
                                each.reset()

            for each in enemy6:
                if each.active and not level == 7:
                    each.move()
                    screen.blit(each.image, each.rect)
                else:
                    if not level == 7:
                        if not (delay % 3):
                            # here we draw the destory pictures of the plane
                            screen.blit(each.destroy_images[e6_destroy_index],
                                        each.rect)
                            e6_destroy_index = (e6_destroy_index + 1) % 4
                            if e6_destroy_index == 0:
                                score += 100
                                each.reset()

            for each in enemy7:
                if each.active and not level == 7:
                    each.move()
                    screen.blit(each.image, each.rect)
                else:
                    if not level == 7:
                        if not (delay % 3):
                            # here we draw the destory pictures of the plane
                            screen.blit(each.destroy_images[e7_destroy_index],
                                        each.rect)
                            e7_destroy_index = (e7_destroy_index + 1) % 4
                            if e7_destroy_index == 0:
                                score += 100
                                each.reset()

            # here we draw the score
            score_text = score_font.render("Score : %s" % str(score), True,
                                           BLACK)
            screen.blit(score_text, (10, 5))

        # here we creat the ending
        elif life_num == 0:
            # here we stop dropping the support
            pygame.time.set_timer(supply_time, 0)

            if not recorded:
                recorded = True
                # here we read the highest record
                with open("record.txt.txt", "r") as f:
                    record_score = int(f.read())

                # here we change the highest record
                if score > record_score:
                    with open("record.txt.txt", "w") as f:
                        f.write(str(score))

            # here we draw the ending picture
            record_score_text = score_font.render(
                "Best was : %d" % record_score, True, BLACK)
            screen.blit(record_score_text, (50, 50))

            gameover_text1 = gameover_font.render("Your Score", True, BLACK)
            gameover_text1_rect = gameover_text1.get_rect()
            gameover_text1_rect.left, gameover_text1_rect.top = \
                                      (width - gameover_text1_rect.width) // 2, height // 2
            screen.blit(gameover_text1, gameover_text1_rect)

            gameover_text2 = gameover_font.render(str(score), True, BLACK)
            gameover_text2_rect = gameover_text2.get_rect()
            gameover_text2_rect.left, gameover_text2_rect.top = \
                                      (width - gameover_text2_rect.width) // 2, \
                                      gameover_text1_rect.bottom + 10
            screen.blit(gameover_text2, gameover_text2_rect)

            again_rect.left, again_rect.top = \
                             (width - again_rect.width) // 2, \
                             gameover_text2_rect.bottom + 50
            screen.blit(again_image, again_rect)

            gameover_rect.left, gameover_rect.top = \
                                (width - again_rect.width) // 2, \
                                again_rect.bottom + 10
            screen.blit(gameover_image, gameover_rect)

            # here we set the mouse
            # if the player click left mouse
            if pygame.mouse.get_pressed()[0]:
                # here we get the coordination of the mouse
                pos = pygame.mouse.get_pos()
                # if the player click restart
                if again_rect.left < pos[0] < again_rect.right and \
                   again_rect.top < pos[1] < again_rect.bottom:
                    main()
                # if the player click exit
                elif gameover_rect.left < pos[0] < gameover_rect.right and \
                     gameover_rect.top < pos[1] < gameover_rect.bottom:
                    pygame.quit()
                    sys.exit()

        # here we draw the bomb
        bomb_text = bomb_font.render("x %d" % bomb_num, True, BLACK)
        text_rect = bomb_text.get_rect()
        screen.blit(bomb_image, (10, height - 10 - bomb_rect.height))
        screen.blit(bomb_text,
                    (20 + bomb_rect.width, height - 5 - text_rect.height))

        # here we draw the number of lives of myplane
        if life_num:
            for i in range(life_num):
                screen.blit(life_image, \
                            (width-(i+1)*life_rect.width+30, \
                             height-life_rect.height+35))

        # here we draw the pause and continue picture
        screen.blit(paused_image, paused_rect)

        # here we change the value of delay
        delay -= 1
        if not delay:
            delay = 120

        pygame.display.flip()

        clock.tick(60)
Esempio n. 30
0
#!/usr/bin/python

import time
from background import background
from Kamaelia.UI.Pygame.Text import Textbox, TextDisplayer
from LikeFile import LikeFile
background().start()

import Queue
TD = LikeFile(
         TextDisplayer(position=(20, 90),
                       text_height=36,
                       screen_width=900,
                       screen_height=200,
                       background_color=(130,0,70),
                       text_color=(255,255,255)
                      )
     ).activate()

TB = LikeFile(
        Textbox(position=(20, 340),
                text_height=36,
                screen_width=900,
                screen_height=400,
                background_color=(130,0,70),
                text_color=(255,255,255)
               )
     ).activate()

message = "hello\n"
while 1:
def main():

    #creacion de objetos para el programa
    bg = background.background(settings.pantalla,
                               "01.png",
                               alpha=True,
                               posicion=settings.screen_center)
    barra = img.img(settings.pantalla,
                    "001.png",
                    posicion=settings.screen_center)

    #control de los textos
    l0 = text.text(settings.pantalla,
                   color=(255, 255, 255),
                   nombre="COOPBL.ttf",
                   tamano=settings.text_tamano_1,
                   posicion=(40, 405),
                   linea=u"Marcelo")
    l1 = text.text_anim_01(settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           tamano=settings.text_tamano_1,
                           velocidad=settings.text_speed_1,
                           color=(255, 255, 255),
                           posicion=(25, 455),
                           linea=u"Puta, y ahora como chucha voy a permutar ")
    l2 = text.text_anim_01(settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           tamano=settings.text_tamano_1,
                           velocidad=settings.text_speed_1,
                           color=(255, 255, 255),
                           posicion=(25, 495),
                           linea=u"transgénicos...")
    l3 = text.text_anim_01(settings.pantalla,
                           nombre="ARLRDBD.ttf",
                           tamano=settings.text_tamano_1,
                           velocidad=settings.text_speed_1,
                           color=(255, 255, 255),
                           posicion=(25, 535),
                           linea="")
    lista = [l1, l2, l3]

    #marcelo
    marcelo = sprites.personaje(settings.pantalla, posicion=(-300, 450))
    marcelo.add("marcelo.png")
    marcelo.add("marcelo01.png")
    x2 = pygame.transform.scale2x(marcelo.imagenes[0])
    marcelo.imagenes[0] = x2
    x3 = pygame.transform.scale2x(marcelo.imagenes[1])
    marcelo.imagenes[1] = x3
    marcelo.current(0)
    marcelo.anim_01((150, 450), 180)

    #marmota
    marmota = sprites.personaje(settings.pantalla, posicion=(1000, 450))
    marmota.add("marmota.png")
    marmota.add("marmota01.png")

    #utiles
    indicador = 0

    mouse = cursor.cursor()
    bgmusic = bgm.bgm("003.mp3")
    running = True

    #acciones de uso unico
    bgmusic.play(inicio=2.0)

    #bucle principal
    while running:
        #variables que se comprueban cada bucle

        #lista de los eventos que se ejecutaron
        for evento in pygame.event.get():
            if evento.type == pygame.KEYDOWN:
                if evento.key == pygame.K_z:
                    marcelo.end_anim_01()
                    marmota.end_anim_01()
                    if not (l3.renderizado):
                        for linea in lista:
                            linea.velocidad = 5000
                    else:
                        indicador += 1

            if evento.type == pygame.KEYUP:
                if evento.key == pygame.K_z:
                    for linea in lista:
                        if indicador == 16:
                            break
                        linea.velocidad = settings.text_speed_1

            if evento.type == pygame.QUIT:
                running = False

        #manejo de textos
        if indicador == 1:
            indicador += 1
            marcelo.current(1)
            marmota.current(0)
            #modificamos textos
            l0.line(u"Voz Sexona")
            lista[0].void_line(
                u"Solo tienes que viajar hacia el mar Atlántico")
            lista[1].void_line("")
            lista[2].void_line("")

        if indicador == 3:
            indicador += 1
            marcelo.current(0)
            marmota.current(1)
            #modificamos textos
            l0.line(u"Marcelo")
            lista[0].void_line(u"Ohh! Pero que sorpresa!")
            lista[1].void_line("")
            lista[2].void_line("")

        if indicador == 5:
            indicador += 1
            marmota.anim_01((600, 450), 180)

            #modificamos los textos
            l0.line(u"Marcelo")
            lista[0].void_line(
                u"Es una marmota sexona índica magnética leedora ")
            lista[1].void_line(u"de mentes transversales impulsadas hacia el ")
            lista[2].void_line(u"infinito y lo desconocido!")

        if indicador == 7:
            indicador += 1
            marcelo.current(1)
            marmota.current(0)
            #modificamos los textos
            l0.line(u"Marmota Sexona")
            lista[0].void_line(u"No tienes porque sorpenderte hijo mio")
            lista[1].void()
            lista[2].void()

        if indicador == 9:
            indicador += 1
            marcelo.current(0)
            marmota.current(1)
            #modificamos los textos
            l0.line(u"Marcelo")
            lista[0].void_line(u"Dame una buena razón para no sorpenderme")
            lista[1].void()
            lista[2].void()

        if indicador == 11:
            indicador += 1
            marcelo.current(1)
            marmota.current(0)
            #modificamos los textos
            l0.line(u"Jesucristo")
            lista[0].void_line(
                u"Lo que pasa es que soy Jesucristo, pero se me")
            lista[1].void_line(u"perdió mi gorro y tengo que ir a buscarlo")
            lista[2].void_line(u"")

        if indicador == 13:
            indicador += 1
            marmota.anim_01((1000, -200), 60)

            #modificamos los textos
            l0.line(u"Jesucristo")
            lista[0].void_line(u"así que chaoo chaoo nos vemos, no olviden")
            lista[1].void_line(
                u"rendirme culto y subscribirse a la iglesia católica,")
            lista[2].void_line(u"soy Jesucristo y te deseo buenas noches.")

        if indicador == 15:
            indicador += 1
            marcelo.current(0)
            marmota.current(1)
            #modificamos textos
            l0.line(u"Marcelo")
            lista[0].velocidad = 2
            lista[0].void_line(u". . .")
            if lista[0].renderizado: lista[0].velocidad = settings.text_speed_1
            lista[1].void()
            lista[2].void()

        #termino de la pantalla
        if indicador == 17:
            running = False
            s3.main()

        #actualizacion de objetos en pantalla
        bg.update()
        mouse.update()
        marcelo.update()
        marmota.update()
        barra.update()
        l0.update()
        text.texto_lista_update(lista)
        if not (running): bgmusic.stop()

        #actualizamos la pantalla
        if running: pygame.display.flip()
        settings.reloj.tick(60)
Esempio n. 32
0
from background import background
from Emotion_Detection2 import Emotion_Detection
import cv2
import numpy as np
import pandas as pd
import pickle

emotion_model_path = 'Emotion Detection_Files/model.h5'  # Path for Emotion Classification Model
prototext = 'Emotion Detection_Files/deploy.prototxt.txt'  # Prototxt file for face detection
model = 'Emotion Detection_Files/res10_300x300_ssd_iter_140000.caffemodel'  # Model for face Detection
input_video = 'Example_Videos/fighting.mp4'  # Path for video
c = 0.7  # Confidence score for detecting the face of a person

background_labels, background_probabilities = background(input_video)

emotion_labels, emotion_probabilities = Emotion_Detection(
    emotion_model_path, prototext, model, input_video, c)

rows = []

if len(emotion_probabilities) == len(background_probabilities):
    for i in range(0, len(emotion_probabilities)):
        rows.append(
            emotion_probabilities[i] +
            background_probabilities[i])  # Concatenating the two lists.

print(rows)
print("Done")

model_path = 'finalized_model.sav'
loaded_model = pickle.load(open(model_path, 'rb'))
Esempio n. 33
0
    if filterkword == 'NONE':
        filter = filter
    else:
        filter = image[0].header[filterkword]
    if airmasskword == 'NONE':
        airmass = int(airmass)
    else:
        airmass = image[0].header[airmasskword]
    if gainkword == 'NONE':
        gain = int(gain)
    else:
        gain = image[0].header[gainkword]

    #Compute background sky level through random median sampling:
    #Inputs: data array, nxn size of random subarray to use for sampling, and number of desired sampling iterations
    back, skyvals = background(maskedData, backsize, backnum)

    #Create desired inset of total data array:
    if framearea == 'half':
        #Find midpoint of image data
        mid = len(Data) / 2
        #Take an inset of data that is half of area
        inset = Data[round(mid / 2):3 * round(mid / 2),
                     round(mid / 2):3 * round(mid / 2)]
        xlow = 0
        xhigh = 0
        ylow = 0
        yhigh = 0
    if framearea == 'whole':
        #Use entire data array as inset
        inset = Data
Esempio n. 34
0
 def __init__(self, master, _winheight, _winwidth):
     self.master = master
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.history = tk.Canvas(self.master,
                              bg="pink",
                              width=self.winwidth,
                              height=self.winheight)
     self.history.place(x=0, y=0)
     self.linewidth = 5  #线宽
     self.pointradius = 6
     # 背景
     bg = background(self.history, self.winheight, self.winwidth, "call")
     # 返回按钮
     bb = backbtn(self, self.history, self.winheight, self.winwidth, 9)
     bb.backbtn.place(x=bb.backbtnpadding, y=10)
     self.paddingl = 60  #水平的间隙
     self.paddingv = 50  #竖直方向的间隙
     self.matwidth = self.winwidth - self.paddingl * 2
     self.matheight = self.winheight - self.paddingv * 2
     self.perx = self.matwidth / 100
     self.pery = self.matheight / 100
     self.matcanvas = tk.Canvas(self.history,
                                bg="white",
                                width=self.matwidth,
                                height=self.matheight)
     self.matcanvas.place(x=self.paddingl, y=self.paddingv + 40)
     self.opointx = 10 * self.perx
     self.opointy = 90 * self.pery
     self.yheight = 80 * self.pery
     self.xwidth = 80 * self.perx
     self.highpressurelist = []
     self.highpressurescale = [90, 170]
     self.lowpressurescale = [50, 110]
     self.heartscale = [40, 130]
     self.safescalelist = [[self.highpressurescale[0], 140],
                           [self.lowpressurescale[0], 90], [60, 100]]
     self.lowpressurelist = []
     self.pressurelist = []
     self.datelist = []
     self.switchbtnwidth = 80
     self.switchbtnheight = 50
     self.curid = 0  #当前选择的模块
     self.btnpadding = 10
     self.switchimagenamelist = [
         "highpressure.jpg", "lowpressure.jpg", "heartrate.jpg"
     ]
     self.switchimageablenamelist = [
         "highpressureable.jpg", "lowpressureable.jpg", "heartrateable.jpg"
     ]
     self.switchimagelist = []
     self.switchimageablelist = []
     for i in range(0, len(self.switchimagenamelist)):
         self.switchimagelist.append(
             ImageTk.PhotoImage(
                 Image.open("srcimage/" +
                            self.switchimagenamelist[i]).resize(
                                (int(self.switchbtnwidth),
                                 int(self.switchbtnheight)))))
         self.switchimageablelist.append(
             ImageTk.PhotoImage(
                 Image.open("srcimage/" +
                            self.switchimageablenamelist[i]).resize(
                                (int(self.switchbtnwidth),
                                 int(self.switchbtnheight)))))
     self.menubtnlist = []
     for i in range(0, len(self.switchimagenamelist)):
         self.menubtnlist.append(
             tk.Button(self.matcanvas,
                       image=self.switchimageablelist[i],
                       width=self.switchbtnwidth,
                       height=self.switchbtnheight,
                       command=self.returnfun(i)))
         self.menubtnlist[i].place(
             x=self.btnpadding +
             (self.btnpadding + self.switchbtnwidth) * i,
             y=self.btnpadding)
     self.f = open("doc/heart.txt")
     line = self.f.readline().replace("\n", "")
     count = 0
     while line and count < 5:
         count = count + 1
         self.highpressurelist.append(int(line))
         line = self.f.readline().replace("\n", "")
         self.pressurelist.append(int(line))
         line = self.f.readline().replace("\n", "")
         self.lowpressurelist.append(int(line))
         line = self.f.readline().replace("\n", "")
         templist = []
         templist.append(int(line))
         line = self.f.readline().replace("\n", "")
         templist.append(int(line))
         line = self.f.readline().replace("\n", "")
         templist.append(int(line))
         if len(self.datelist) > 0:
             for i in range(0, 3):
                 if templist[i] != self.datelist[-1][i]:
                     self.datelist.append(templist)
         else:
             self.datelist.append(templist)
         line = self.f.readline().replace("\n", "")
     self.highpressurelength = self.highpressurescale[
         1] - self.highpressurescale[0]
     self.lowpressurelength = self.lowpressurescale[
         1] - self.lowpressurescale[0]
     self.heartlength = self.heartscale[1] - self.heartscale[0]
     self.datevalue = []
     self.scalelist = []
     self.datescale = [
         self.turnvalue(self.datelist[0]),
         self.turnvalue(self.datelist[-1])
     ]
     self.xlist = []
     for i in range(0, len(self.datelist)):
         self.datevalue.append(self.turnvalue(self.datelist[i]))
         self.scalelist.append((self.datevalue[i] - self.datescale[0]) /
                               (self.datescale[1] - self.datescale[0]))
         self.xlist.append(self.opointx +
                           self.perx * 70 * self.scalelist[i])
     self.changecanvas(self.curid)
     bg.showimage()
Esempio n. 35
0
    def __del__(self):
        if self.alive:
            self.shutdown()


if __name__ == "__main__":
    if 1:
        # So, does this code actually work? Or not?
        import time
        from Kamaelia.Protocol.HTTP.HTTPClient import SimpleHTTPClient

        class Foing(Axon.Component.component):
            def main(self):
                while True:
                    print "."

        bg = background().start()
        time.sleep(1)
        p = likefile(SimpleHTTPClient())
        p.put("http://google.com")
        p.put("http://slashdot.org")
        print "X"
        google = p.get()
        print "Y"
        slashdot = p.get()
        print "Z"
        time.sleep(1)
        print "google is", len(google), "bytes long, and slashdot is", len(slashdot), "bytes long."
        p.shutdown()