Пример #1
0
 def setMouse(self):
     self.screenCrds = Vector2d(pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1])
     self.cursor = PEG_mainLoop.mainLoop().cam.convertCrds(self.screenCrds)
     self.cursor.x = PEG_helpers.truncateToMultiple(self.cursor.x, TILING_SIZE.x)
     self.cursor.y = PEG_helpers.truncateToMultiple(self.cursor.y, TILING_SIZE.y)
     if self.activeObject:
         self.activeObject.teleport(self.cursor)
 def draw(self):
     if self.dir == "left":
         self.activeSurface = self.flipSurface
     else:
         self.activeSurface = self.mainSurface
                 
     frameNum = (PEG_helpers.truncateToMultiple(pygame.time.get_ticks(),self.frames[self.state][1])/self.frames[self.state][1])%len(self.frames[self.state][0])
     PEG_mainLoop.mainLoop().cam.drawOnScreen(self.activeSurface, self.pos-self.drawOffset, pygame.Rect(self.frames[self.state][0][frameNum].x, self.frames[self.state][0][frameNum].y,40,80))
Пример #3
0
 def collide(self, e):
     """see super"""
     if isinstance(e, SolidEntity):
         col = PEG_helpers.collideSide(self.pos,e.pos)
         self.pos -= col
         #if collide with ground
         if col.y > 0:
             self.grounded = True
         if col.x != 0:
             self.vel.x = 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
 def isPointInside(self,pos):
     return PEG_helpers.livesIn(pos,self.pos)