コード例 #1
0
    def update(self):
        #grab input
        mousePos = pygame.mouse.get_pos()
        for e in PEG_mainLoop.mainLoop().eventList:
            if e.type == pygame.MOUSEBUTTONUP:
                if PEG_helpers.livesIn(mousePos,Rect2d(self.pos.x+20,80,120,120)):
                    network = PEG_mainLoop.mainLoop().entityDict['Network']
#===============================================================================
#                    #TODO figure out why I have this here???
#                    for s in network.enDict.keys():
#                        network.destroyList.append(s)
#                    self.scan = not self.scan
#                    print "scan mode: ", self.scan
#===============================================================================
#===============================================================================
#                    PEG_mainLoop.mainLoop().entityDict['EffectMenu'].addEffect(PEG_effects.quickEffect(3, Vector2d(300,200), COLOR_CHARTREUSE, 150))
#                    PEG_mainLoop.mainLoop().entityDict['EffectMenu'].addEffect(PEG_effects.quickEffect(2, Vector2d(300,200), (255,255,255), 300))
#                    PEG_mainLoop.mainLoop().entityDict['EffectMenu'].addEffect(PEG_effects.quickEffect(6, Vector2d(300,200), (255,255,255), 300))
#                    PEG_mainLoop.mainLoop().entityDict['EffectMenu'].addEffect(PEG_effects.quickEffect(4))
#===============================================================================
#===============================================================================
#                if PEG_helpers.livesIn(mousePos,Rect2d(self.pos.x+20,200,120,120)):
#                    print "box2"
#                if PEG_helpers.livesIn(mousePos,Rect2d(self.pos.x+20,340,120,120)):
#                    print "box3"
#===============================================================================

        if PEG_mainLoop.mainLoop().entityDict['Network'].server:
            mousePos = pygame.mouse.get_pos()
            for e in PEG_mainLoop.mainLoop().eventList:
                if e.type == pygame.MOUSEBUTTONUP:
                    data = dict()
                    data['type'] = "position"
                    data['entity'] = "PowerSourceEn"
                    data['x'] = mousePos[0]
                    data['y'] = mousePos[1]
                    data['name'] = "ThePSource" 
                    data['team'] = "neutral"
                    data['sides'] = "123"
                    network = PEG_mainLoop.mainLoop().entityDict['Network']
                    network.processNetMessage(data)
                    if network.state == "waiting":
                        network.changeState("starting")
                    
                    
            self.selectMode = False
            
        if self.selectMode:
            self.select.update()
            if self.select.destroy:
                self.selectMode = False
                del self.select
コード例 #2
0
 def isPointInside(self,pos):
     return PEG_helpers.livesIn(pos,self.pos)