def draw(self, surface, flags):              
        bp = intpos(self._worldobj.body.position)
        rotimg = Cache().getRotatedImage(self._imageName, math.degrees(-self._worldobj.body.angle))
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(rotimg, (bp[0] -w/2, bp[1] -h/2))

        #if flags["DEBUG"]:
        #pygame.draw.line(surface, (64, 128, 255), bp, intpos(self._worldobj.body.position - (self._worldobj.pull / 50, 0)))
        if flags["DEBUG"]:
            bp = intpos(self._worldobj.body.position)
            wrapcircle(surface, (64, 64, 255), bp, self._worldobj.influence_range, self._world.size, 3)
            if self._worldobj.type == WormHole.RANDOM:
                # make 'X' for Random
                pygame.draw.line(surface, (64, 64, 255), intpos(self._worldobj.body.position - (self._worldobj.influence_range, self._worldobj.influence_range)), intpos(self._worldobj.body.position + (self._worldobj.influence_range, self._worldobj.influence_range)), 5)
                pygame.draw.line(surface, (64, 64, 255), intpos(self._worldobj.body.position - (-self._worldobj.influence_range, self._worldobj.influence_range)), intpos(self._worldobj.body.position + (-self._worldobj.influence_range, self._worldobj.influence_range)), 5)
            elif self._worldobj.type == WormHole.FIXED_POINT:
                pygame.draw.line(surface, (64, 64, 255), bp, intpos(self._worldobj.exit))
                wrapcircle(surface, (64, 64, 255), intpos(self._worldobj.exit), self._worldobj.radius / 2, self._world.size, 2) # 'target'
            elif self._worldobj.type == WormHole.OTHER_CELESTIALBODY:
                c = (64, 64, 255)
                if isinstance(self._worldobj.exit, WormHole) and isinstance(self._worldobj.exit.exit, WormHole) and self._worldobj.exit.exit == self._worldobj:
                    c = (128, 192, 255) # check if linked in both directions - make brighter if two-way wormhole
                pygame.draw.line(surface, c, bp, intpos(self._worldobj.exit.body.position))
                wrapcircle(surface, c, intpos(self._worldobj.exit.body.position), self._worldobj.radius / 2, self._world.size, 2) # 'target'

        super(WormHoleGUI, self).draw(surface, flags)
Exemplo n.º 2
0
 def __init__(self, asteroid, world):
     super(AsteroidGUI, self).__init__(asteroid, world)
     if not hasattr(self, '_imageName'):  # so Dragons can use this
         self._imageName = "Asteroids/Asteroid"
     self._imageName = self._imageName + str(
         random.randint(1,
                        Cache().getMaxImages(self._imageName)))
     self.__extra = (Cache().getImage(self._imageName).get_width() -
                     32) / 1.5
Exemplo n.º 3
0
    def draw(self, surface, flags):      
        ang = 45 - self._worldobj.body.velocity.angle_degrees
        rang = math.radians(self._worldobj.body.velocity.angle_degrees)
        #rotimg = pygame.transform.rotate(self.surface, ang)
        rotimg = Cache().getRotatedImage(self._imageName, ang)
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(rotimg, (self._worldobj.body.position[0] - w / 2 - self.__extra * math.cos(rang), self._worldobj.body.position[1] - h / 2 - self.__extra * math.sin(rang)))

        super(AsteroidGUI, self).draw(surface, flags)
 def __init__(self, ship, world):
     super(ShipGUI, self).__init__(ship, world)
     self.surface = Cache().getImage("Ships/ship" + repr(ship.player.image))
     self.dying = False
     self.dead = False
     self.dyframe = 0
     if ShipGUI._exsurface == None:
         ShipGUI._exsurface = Cache().getImage("Ships/ExplosionWarp")
         ShipGUI._shieldsurface = Cache().getImage("Ships/Shield")
         ShipGUI._shieldhudsurface = Cache().getImage("HUD/Shield")
    def draw(self, surface, flags):              
        bp = intpos(self._worldobj.body.position)
        rotimg = Cache().getRotatedImage(self._imageName, math.degrees(-self._worldobj.body.angle))
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(rotimg, (bp[0] -w/2, bp[1] -h/2))

        if flags["DEBUG"]:            
            pygame.draw.line(surface, (64, 128, 255), bp, intpos(self._worldobj.body.position - (self._worldobj.pull / 50, 0)))

        super(NebulaGUI, self).draw(surface, flags)
Exemplo n.º 6
0
    def draw(self, surface, flags):              
        bp = intpos(self._worldobj.body.position)
        rotimg = Cache().getRotatedImage(self._imageName, math.degrees(-self._worldobj.body.angle))
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(rotimg, (bp[0] -w/2, bp[1] -h/2))

        if flags["DEBUG"]:            
            pygame.draw.line(surface, (64, 128, 255), bp, intpos(self._worldobj.body.position - (self._worldobj.pull / 50, 0)))

        super(NebulaGUI, self).draw(surface, flags)
Exemplo n.º 7
0
    def draw(self, surface, flags):
        bp = intpos(self._worldobj.body.position)
        rotimg = Cache().getRotatedImage(
            self._imageName, math.degrees(-self._worldobj.body.angle))
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(rotimg, (bp[0] - w / 2, bp[1] - h / 2))

        #if flags["DEBUG"]:
        #pygame.draw.line(surface, (64, 128, 255), bp, intpos(self._worldobj.body.position - (self._worldobj.pull / 50, 0)))
        if flags["DEBUG"]:
            bp = intpos(self._worldobj.body.position)
            wrapcircle(surface, (64, 64, 255), bp,
                       self._worldobj.influence_range, self._world.size, 3)
            if self._worldobj.type == WormHole.RANDOM:
                # make 'X' for Random
                pygame.draw.line(
                    surface, (64, 64, 255),
                    intpos(self._worldobj.body.position -
                           (self._worldobj.influence_range,
                            self._worldobj.influence_range)),
                    intpos(self._worldobj.body.position +
                           (self._worldobj.influence_range,
                            self._worldobj.influence_range)), 5)
                pygame.draw.line(
                    surface, (64, 64, 255),
                    intpos(self._worldobj.body.position -
                           (-self._worldobj.influence_range,
                            self._worldobj.influence_range)),
                    intpos(self._worldobj.body.position +
                           (-self._worldobj.influence_range,
                            self._worldobj.influence_range)), 5)
            elif self._worldobj.type == WormHole.FIXED_POINT:
                pygame.draw.line(surface, (64, 64, 255), bp,
                                 intpos(self._worldobj.exit))
                wrapcircle(surface, (64, 64, 255), intpos(self._worldobj.exit),
                           self._worldobj.radius / 2, self._world.size,
                           2)  # 'target'
            elif self._worldobj.type == WormHole.OTHER_CELESTIALBODY:
                c = (64, 64, 255)
                if isinstance(self._worldobj.exit, WormHole) and isinstance(
                        self._worldobj.exit.exit, WormHole
                ) and self._worldobj.exit.exit == self._worldobj:
                    c = (
                        128, 192, 255
                    )  # check if linked in both directions - make brighter if two-way wormhole
                pygame.draw.line(surface, c, bp,
                                 intpos(self._worldobj.exit.body.position))
                wrapcircle(surface, c,
                           intpos(self._worldobj.exit.body.position),
                           self._worldobj.radius / 2, self._world.size,
                           2)  # 'target'

        super(WormHoleGUI, self).draw(surface, flags)
Exemplo n.º 8
0
    def draw(self, surface, flags):
        ang = 45 - self._worldobj.body.velocity.angle_degrees
        rang = math.radians(self._worldobj.body.velocity.angle_degrees)
        #rotimg = pygame.transform.rotate(self.surface, ang)
        rotimg = Cache().getRotatedImage(self._imageName, ang)
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(
            rotimg,
            (self._worldobj.body.position[0] - w / 2 -
             self.__extra * math.cos(rang), self._worldobj.body.position[1] -
             h / 2 - self.__extra * math.sin(rang)))

        super(AsteroidGUI, self).draw(surface, flags)
Exemplo n.º 9
0
    def draw(self, surface, flags):
        self.anicount += 1
        if self.anicount == self.anispeed:
            self.anicount = 0
            self.anirot += self.anidirection
            if self.anirot >= 360:
                self.anirot = 0
            elif self.anirot <= 0:
                self.anirot = 360
        rotimg = Cache().getRotatedImage(self._imageName, self.anirot)
        w, h = rotimg.get_rect().size
        # TODO: convert world to graphics coordinates
        surface.blit(rotimg, (self._worldobj.body.position[0] - w / 2, self._worldobj.body.position[1] - h / 2))

        if flags["DEBUG"]:
            bp = intpos(self._worldobj.body.position)
            wrapcircle(surface, (64, 64, 255), bp, self._worldobj.gravityFieldLength, self._world.size, 3)
            pygame.draw.line(
                surface,
                (64, 128, 255),
                intpos(self._worldobj.body.position - (0, self._worldobj.gravityFieldLength)),
                intpos(self._worldobj.body.position - (0, self._worldobj.gravityFieldLength - self._worldobj.pull)),
            )
            pygame.draw.line(
                surface,
                (64, 128, 255),
                intpos(self._worldobj.body.position - (self._worldobj.gravityFieldLength, 0)),
                intpos(self._worldobj.body.position - (self._worldobj.gravityFieldLength - self._worldobj.pull, 0)),
            )
            pygame.draw.line(
                surface,
                (64, 128, 255),
                intpos(self._worldobj.body.position + (self._worldobj.gravityFieldLength, 0)),
                intpos(self._worldobj.body.position + (self._worldobj.gravityFieldLength - self._worldobj.pull, 0)),
            )
            pygame.draw.line(
                surface,
                (64, 128, 255),
                intpos(self._worldobj.body.position + (0, self._worldobj.gravityFieldLength)),
                intpos(self._worldobj.body.position + (0, self._worldobj.gravityFieldLength - self._worldobj.pull)),
            )
            # radius
            surface.blit(
                debugfont().render(repr(self._worldobj.gravityFieldLength), False, (255, 255, 192)),
                intpos((bp[0], bp[1] - self._worldobj.gravityFieldLength - 16)),
            )

        super(PlanetGUI, self).draw(surface, flags)
Exemplo n.º 10
0
    def __init__(self, planet, world):
        super(PlanetGUI, self).__init__(planet, world)

        self.anicount = 0
        self.anirot = 0

        if isinstance(planet, BlackHole):
            self._imageName = "Planets/BlackHole"
            self.anispeed = random.randint(12, 24)
            self.anidirection = -1
            self.zorder = -3
        elif isinstance(planet, Star):
            self._imageName = "Planets/Star"
            self.anispeed = random.randint(2, 4)
            self.anidirection = -1
            self.zorder = -2
        elif isinstance(planet, Constellation):
            self._imageName = "Constellations/Constellation"
            self.anispeed = 0
            self.anidirection = 0
            self.anirot = random.randint(-180, 180)
            self.zorder = -4
        else:
            self._imageName = "Planets/Planet"
            self.anispeed = random.randint(24, 48)
            self.anidirection = random.randint(0, 1)
            self.zorder = -1
        #eif
        self._imageName = self._imageName + str(random.randint(1, Cache().getMaxImages(self._imageName)))
        
        if self.anidirection == 0: self.anidirection = -1
Exemplo n.º 11
0
 def __init__(self, wormhole, world):
     super(WormHoleGUI, self).__init__(wormhole, world)
     self._imageName = "WormHoles/WormHole"
     self._imageName = self._imageName + str(
         random.randint(1,
                        Cache().getMaxImages(self._imageName)))
     #self._dist = wormhole.minor
     self.zorder = -4
Exemplo n.º 12
0
    def __init__(self, worldobj, world):
        self._worldobj = worldobj
        self._world = world
        self.dying = False
        self.dead = False
        self._points = None
        if self._worldobj.__dict__.has_key("points"):
            self._dist = int(max(self._worldobj.points[0]))
            self._points = self._worldobj.shape.get_points()
            self._lp = intpos(self._worldobj.body.position)
        elif self._worldobj.__dict__.has_key("radius"):
            self._dist = int(self._worldobj.radius)
        else:
            self._dist = 16

        if GUIEntity._healthbar == None:
            GUIEntity._healthbar = Cache().getImage("HUD/Health")
            GUIEntity._energybar = Cache().getImage("HUD/Energy")
Exemplo n.º 13
0
 def __init__(self, ship, world):
     super(ShipGUI, self).__init__(ship, world)
     self.surface = Cache().getImage("Ships/ship" + repr(ship.player.image))
     self.dying = False
     self.dead = False
     self.dyframe = 0
     if ShipGUI._exsurface == None:
         ShipGUI._exsurface = Cache().getImage("Ships/ExplosionWarp")
         ShipGUI._shieldsurface = Cache().getImage("Ships/Shield")
         ShipGUI._shieldhudsurface = Cache().getImage("HUD/Shield")
Exemplo n.º 14
0
    def draw(self, surface, flags):      
        ang = 45 - self._worldobj.body.velocity.angle_degrees
        rang = math.radians(self._worldobj.body.velocity.angle_degrees)
        #rotimg = pygame.transform.rotate(self.surface, ang)
        rotimg = Cache().getRotatedImage(self._imageName, ang)
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(rotimg, (self._worldobj.body.position[0] - w / 2 - self.__extra * math.cos(rang), self._worldobj.body.position[1] - h / 2 - self.__extra * math.sin(rang)))

        # Draw Dragon attack area
        if flags["DEBUG"] and isinstance(self._worldobj, Dragon) and self._worldobj.influence_range > 0:
            bp = intpos(self._worldobj.body.position)
            wrapcircle(surface, (64, 64, 255), bp, self._worldobj.influence_range, self._world.size, 3)
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position - (0, self._worldobj.influence_range)), intpos(self._worldobj.body.position - (0, self._worldobj.influence_range + self._worldobj.attack_speed)))
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position - (self._worldobj.influence_range, 0)), intpos(self._worldobj.body.position - (self._worldobj.influence_range + self._worldobj.attack_speed, 0)))
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position + (self._worldobj.influence_range, 0)), intpos(self._worldobj.body.position + (self._worldobj.influence_range + self._worldobj.attack_speed, 0)))
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position + (0, self._worldobj.influence_range)), intpos(self._worldobj.body.position + (0, self._worldobj.influence_range + self._worldobj.attack_speed)))
            # radius
            surface.blit(debugfont().render(repr(self._worldobj.influence_range), False, (255, 255, 192)), intpos((bp[0], bp[1] - self._worldobj.influence_range - 16)))

        super(AsteroidGUI, self).draw(surface, flags)
Exemplo n.º 15
0
 def __init__(self, nebula, world):
     super(NebulaGUI, self).__init__(nebula, world)
     if isinstance(nebula, Quasar):
         self._imageName = "Nebula/Quasar"
     else:
         self._imageName = "Nebula/Nebula"
     self._imageName += repr(int(nebula.major) * 2) + "x" + repr(
         int(nebula.minor) * 2) + "-"
     self._imageName += str(
         random.randint(1,
                        Cache().getMaxImages(self._imageName)))
     self._dist = nebula.minor
     self.zorder = -5
Exemplo n.º 16
0
    def draw(self, surface, flags):      
        self.anicount += 1
        if self.anicount == self.anispeed:
            self.anicount = 0
            self.anirot += self.anidirection
            if self.anirot >= 360: self.anirot = 0
            elif self.anirot <= 0: self.anirot = 360
        rotimg = Cache().getRotatedImage(self._imageName, self.anirot)
        w, h = rotimg.get_rect().size
        #TODO: convert world to graphics coordinates
        surface.blit(rotimg, (self._worldobj.body.position[0] -w/2, self._worldobj.body.position[1] -h/2))

        if flags["DEBUG"] and isinstance(self._worldobj, Influential) and self._worldobj.influence_range > 0:
            bp = intpos(self._worldobj.body.position)
            wrapcircle(surface, (64, 64, 255), bp, self._worldobj.influence_range, self._world.size, 3)
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position - (0, self._worldobj.influence_range)), intpos(self._worldobj.body.position - (0, self._worldobj.influence_range - self._worldobj.pull)))
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position - (self._worldobj.influence_range, 0)), intpos(self._worldobj.body.position - (self._worldobj.influence_range - self._worldobj.pull, 0)))
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position + (self._worldobj.influence_range, 0)), intpos(self._worldobj.body.position + (self._worldobj.influence_range - self._worldobj.pull, 0)))
            pygame.draw.line(surface, (64, 128, 255), intpos(self._worldobj.body.position + (0, self._worldobj.influence_range)), intpos(self._worldobj.body.position + (0, self._worldobj.influence_range - self._worldobj.pull)))
            # radius
            surface.blit(debugfont().render(repr(self._worldobj.influence_range), False, (255, 255, 192)), intpos((bp[0], bp[1] - self._worldobj.influence_range - 16)))

        super(PlanetGUI, self).draw(surface, flags)
class BaubleWrapper(GUIEntity):
    def __init__(self, obj, world):
        self.surface = Cache().getScaledImage("Games/Bauble" + str(obj.value),
                                              obj.weight**0.27)
        self.adjust = self.surface.get_width() / 2
        super(BaubleWrapper, self).__init__(obj, world)

    def draw(self, surface, flags):
        surface.blit(
            self.surface,
            intpos((self._worldobj.body.position[0] - self.adjust,
                    self._worldobj.body.position[1] - self.adjust)))

        if flags["DEBUG"] and self._worldobj.weight > 1:
            bp = intpos(self._worldobj.body.position)
            # id text
            surface.blit(
                debugfont().render(str(self._worldobj.weight), False,
                                   (192, 192, 192)),
                (bp[0] + self.adjust, bp[1] - 4))

        super(BaubleWrapper, self).draw(surface, flags)
Exemplo n.º 18
0
 def __init__(self, obj, world):
     super(OutpostWrapper, self).__init__(obj, world)
     self.surface = Cache().getImage(
         "Games/Outpost" +
         str(random.randint(1,
                            Cache().getMaxImages("Games/Outpost"))))
Exemplo n.º 19
0
class ShipGUI(GUIEntity):
    _exsurface = None
    _shieldsurface = None
    _shieldhudsurface = None

    """description of class"""
    def __init__(self, ship, world):
        super(ShipGUI, self).__init__(ship, world)
        self.surface = Cache().getImage("Ships/ship" + repr(ship.player.image))
        self.dying = False
        self.dead = False
        self.dyframe = 0
        if ShipGUI._exsurface == None:
            ShipGUI._exsurface = Cache().getImage("Ships/ExplosionWarp")
            ShipGUI._shieldsurface = Cache().getImage("Ships/Shield")
            ShipGUI._shieldhudsurface = Cache().getImage("HUD/Shield")

    def draw(self, surface, flags, sp=None):
        if sp == None:
            sp = self._worldobj.body.position
        # Check if Thrusting or Braking
        state = 0

        # TODO: Notify Ship of Start/End of Commands...?

        yoff = 0
        if self._worldobj.commandQueue.containstype(CloakCommand):
            yoff = 64

        if self._worldobj.commandQueue.containstype(WarpCommand):
            state = 6
        elif self._worldobj.commandQueue.containstype(BrakeCommand):
            state = 5
        else:
            cmd = self._worldobj.commandQueue.containstype(ThrustCommand) # HACK? TODO - One loop
            if cmd != None:
                #pygame.draw.circle(surface, (255, 255, 0), intpos(pos + cmd.getForceVector(self._worldobj.thrusterForce, self._worldobj.rotationAngle, 0.02)), 5)
                state = 1 + ['L','F','R','B'].index(cmd.direction)
            #eif
        #eif

        # Rotate to Current Direction
        rotimg = pygame.transform.rotate(self.surface.subsurface(pygame.Rect(64 * state, yoff, 64, 64)), self._worldobj.rotationAngle - 90)
        w, h = rotimg.get_rect().size
        bp = intpos(sp)
        pos = intpos(sp - (w/2, h/2))

        if len(self._worldobj.lasernodes) > 0 and sp == self._worldobj.body.position:
            for i in range(0, len(self._worldobj.lasernodes)+1, 2):
                if i < len(self._worldobj.lasernodes)-1:
                    pygame.draw.line(surface, self._worldobj.player.color, self._worldobj.lasernodes[i], self._worldobj.lasernodes[i+1], 3)
                elif i < len(self._worldobj.lasernodes):
                    pygame.draw.line(surface, self._worldobj.player.color, self._worldobj.lasernodes[i], intpos(self._worldobj.body.position), 3)
                #eif

        # Draw
        surface.blit(rotimg, pos)

        gp = (sp[0] - 32, sp[1] - 32) #adjusted fixed graphic size
        # Draw shield
        if self._worldobj.commandQueue.containstype(RaiseShieldsCommand) and self._worldobj.shield.value > 0:
            surface.blit(ShipGUI._shieldsurface, gp)

        # Draw explosion
        if self.dying:
            surface.blit(ShipGUI._exsurface.subsurface(pygame.Rect(64 * self.dyframe, 0, 64, 64)), gp)
            self.dyframe += 1
            if self.dyframe == 16:
                self.dead = True
                self.dying = False

        if flags["NAMES"]:
            # HACK TODO: Ship name should be from team
            text = namefont().render(self._worldobj.player.name, False, self._worldobj.player.color)
            surface.blit(text, (bp[0]-text.get_width()/2, bp[1]-44))

        if flags["DEBUG"]:
            #wrapcircle(surface, (0, 255, 0), bp, 4, self._world.size)  # Position            
            wrapcircle(surface, (255, 255, 0), bp, self._worldobj.radarRange, self._world.size, 1) # Radar            

        if flags["STATS"] and self._worldobj.shield.maximum > 0:
            # Shield Bar
            pygame.draw.rect(surface, (0, 0, 96), pygame.Rect(bp[0]-16, bp[1] + 21, 32, 5))

            if flags["DEBUG"]:
                surface.blit(debugfont().render(repr(int(100 * self._worldobj.shield.percent)), False, (255, 255, 255)), (bp[0]+18, bp[1] + 16))
            surface.blit(ShipGUI._shieldhudsurface, (bp[0]-15, bp[1] + 22), pygame.Rect(0, 0, 30 * self._worldobj.shield.percent, 3))
            
        if flags["GAME"] and self._worldobj.player.score > 0:
            surface.blit(infofont().render(("%.1f" % self._worldobj.player.score) + " Pts", False, (0, 255, 255)), (bp[0]-24, bp[1] + 32))

        super(ShipGUI, self).draw(surface, flags, sp)
class ShipGUI(GUIEntity):
    _exsurface = None
    _shieldsurface = None
    _shieldhudsurface = None
    """description of class"""
    def __init__(self, ship, world):
        super(ShipGUI, self).__init__(ship, world)
        self.surface = Cache().getImage("Ships/ship" + repr(ship.player.image))
        self.dying = False
        self.dead = False
        self.dyframe = 0
        if ShipGUI._exsurface == None:
            ShipGUI._exsurface = Cache().getImage("Ships/ExplosionWarp")
            ShipGUI._shieldsurface = Cache().getImage("Ships/Shield")
            ShipGUI._shieldhudsurface = Cache().getImage("HUD/Shield")

    def draw(self, surface, flags, sp=None):
        if sp == None:
            sp = self._worldobj.body.position
        # Check if Thrusting or Braking
        state = 0

        # TODO: Notify Ship of Start/End of Commands...?

        yoff = 0
        steer = self._worldobj.commandQueue.containstype(SteerCommand)
        if steer and steer.orgdeg != 0:
            if steer.orgdeg > 0:
                steer = -math.sin(steer.percent() * math.pi)
            else:
                steer = math.sin(steer.percent() * math.pi)
            # TODO: Figure out best way to determine when ship facing opposite direction and should 'bank' other way
            #if abs(self._worldobj.rotationAngle - self._worldobj.body.velocity.angle_degrees) % 360 > 180:
            #    steer = -steer
        else:
            steer = 0

        if self._worldobj.commandQueue.containstype(CloakCommand):
            yoff = 64

        if self._worldobj.commandQueue.containstype(WarpCommand):
            state = 6
        elif self._worldobj.commandQueue.containstype(BrakeCommand):
            state = 5
        else:
            cmd = self._worldobj.commandQueue.containstype(
                ThrustCommand)  # HACK? TODO - One loop
            if cmd != None:
                #pygame.draw.circle(surface, (255, 255, 0), intpos(pos + cmd.getForceVector(self._worldobj.thrusterForce, self._worldobj.rotationAngle, 0.02)), 5)
                state = 1 + ['L', 'F', 'R', 'B'].index(cmd.direction)
            #eif
        #eif

        # Rotate to Current Direction
        scaled = self.surface.subsurface(pygame.Rect(64 * state, yoff, 64, 64))
        if steer != 0:
            newimg = pygame.Surface((64, 64), pygame.SRCALPHA)
            if steer > 0:
                newimg.blit(
                    pygame.transform.scale(scaled,
                                           (64 - int(16 * abs(steer)), 64)),
                    (int(steer * 16), 0))
            else:
                newimg.blit(
                    pygame.transform.scale(scaled,
                                           (64 - int(16 * abs(steer)), 64)),
                    (0, 0))
            scaled = newimg
        rotimg = pygame.transform.rotate(scaled,
                                         self._worldobj.rotationAngle - 90)
        w, h = rotimg.get_rect().size
        bp = intpos(sp)
        pos = intpos(sp - (w / 2, h / 2))

        if len(self._worldobj.lasernodes
               ) > 0 and sp == self._worldobj.body.position:
            for i in range(0, len(self._worldobj.lasernodes) + 1, 2):
                if i < len(self._worldobj.lasernodes) - 1:
                    pygame.draw.line(surface, self._worldobj.player.color,
                                     self._worldobj.lasernodes[i],
                                     self._worldobj.lasernodes[i + 1], 3)
                elif i < len(self._worldobj.lasernodes):
                    pygame.draw.line(surface, self._worldobj.player.color,
                                     self._worldobj.lasernodes[i],
                                     intpos(self._worldobj.body.position), 3)
                #eif

        # Draw
        surface.blit(rotimg, pos)

        gp = (sp[0] - 32, sp[1] - 32)  #adjusted fixed graphic size
        # Draw shield
        if self._worldobj.commandQueue.containstype(
                RaiseShieldsCommand) and self._worldobj.shield.value > 0:
            surface.blit(ShipGUI._shieldsurface, gp)

        # Draw explosion
        if self.dying:
            surface.blit(
                ShipGUI._exsurface.subsurface(
                    pygame.Rect(64 * self.dyframe, 0, 64, 64)), gp)
            self.dyframe += 1
            if self.dyframe == 16:
                self.dead = True
                self.dying = False

        if flags["NAMES"]:
            # HACK TODO: Ship name should be from team
            text = namefont().render(self._worldobj.player.name, False,
                                     self._worldobj.player.color)
            surface.blit(text, (bp[0] - text.get_width() / 2, bp[1] - 44))

        if flags["DEBUG"]:
            #wrapcircle(surface, (0, 255, 0), bp, 4, self._world.size)  # Position
            wrapcircle(surface, (255, 255, 0), bp, self._worldobj.radarRange,
                       self._world.size, 1)  # Radar

        if flags["STATS"] and self._worldobj.shield.maximum > 0:
            # Shield Bar
            pygame.draw.rect(surface, (0, 0, 96),
                             pygame.Rect(bp[0] - 16, bp[1] + 21, 32, 5))

            if flags["DEBUG"]:
                surface.blit(
                    debugfont().render(
                        repr(int(100 * self._worldobj.shield.percent)), False,
                        (255, 255, 255)), (bp[0] + 18, bp[1] + 16))
            surface.blit(
                ShipGUI._shieldhudsurface, (bp[0] - 15, bp[1] + 22),
                pygame.Rect(0, 0, 30 * self._worldobj.shield.percent, 3))

        if flags["GAME"] and self._worldobj.player.score > 0:
            surface.blit(
                infofont().render(
                    ("%.1f" % self._worldobj.player.score) + " Pts", False,
                    (0, 255, 255)), (bp[0] - 24, bp[1] + 32))

        super(ShipGUI, self).draw(surface, flags, sp)
 def __init__(self, obj, world):
     self.surface = Cache().getScaledImage("Games/Bauble" + str(obj.value),
                                           obj.weight**0.27)
     self.adjust = self.surface.get_width() / 2
     super(BaubleWrapper, self).__init__(obj, world)
 def __init__(self, nebula, world):
     super(NebulaGUI, self).__init__(nebula, world)
     self._imageName = "Nebula/Nebula" + repr(int(nebula.major) * 2) + "x" + repr(int(nebula.minor) * 2) + "-"
     self._imageName = self._imageName + str(random.randint(1, Cache().getMaxImages(self._imageName)))
     self._dist = nebula.minor
     self.zorder = -5
 def __init__(self, obj, world):
     super(SpaceMineGUI, self).__init__(obj, world)
     if SpaceMineGUI._mine_surface == None:
         SpaceMineGUI._mine_surface = Cache().getImage("Mines/Mine")
 def __init__(self, obj, world):
     super(TorpedoGUI, self).__init__(obj, world)
     self.surface = Cache().getImage("Ships/Torpedo")
Exemplo n.º 25
0
 def __init__(self, obj, world):
     super(OutpostWrapper, self).__init__(obj, world)
     self.surface = Cache().getImage("Games/HomeBase")
Exemplo n.º 26
0
            if width.find("x") != -1:
                cfg.set(
                    "World", "width",
                    str(int(resolution[0] * float(width.replace("x", ""))))
                )  # as per doc, need to cast back to store as string, will unbox as int again later
            if height.find("x") != -1:
                cfg.set(
                    "World", "height",
                    str(int(resolution[1] * float(height.replace("x", "")))))

        max_images = cfg.getint("Application", "ship_images")
        # auto-detect number of ship images
        if max_images == 0:
            cfg.set("Application", "ship_images",
                    str(Cache().getMaxImages("Ships/ship") +
                        1))  # ship index starts at 0

        rungame = cfg.get("Game", "game")

        print "Attempting to Load Game: ", rungame

        game = None
        if rungame != "Basic" and rungame != None and rungame.strip() != "":
            mod = None
            try:
                mod = import_module("Game." + rungame)
                game = mod.__dict__[rungame + "Game"](cfg)
                logging.info("Running Game: " + rungame)
            except:
                logging.error("Could not start Game " + rungame)