def __init__(self, w, h, screen, user, main_menu):
        self.w = w
        self.h = h
        self.screen = screen
        self.user = user
        self.main_menu = main_menu
        self.buttons = sp.RenderUpdates()
        self.menu_buttons = sp.RenderUpdates()
        self.statusBoxDict = dict()
        self.statusBoxes = sp.RenderUpdates()
        self.bg = pg.Surface((w, h))
        self.star_bg()
        self.planets = []
        self.active_planet = None
        self.pressed = None
        self.exit_menu_shown = False
        self.selected_planet = None
        self.clusterNames = {}
        self.ships = sp.RenderUpdates()
        self.power = 0.5

        self.gameOverMsg = GameOverMsg(300, 160, (w - 300) // 2, (h - 150) // 2, self.main_menu)
        self.gameOver = False

        self.add_status_box("status", "Do you want to exit to main menu?", w // 2, h // 2 - 50)
        self.add_menu_button("YES", pg.Rect((w - 300) // 2, (h - 50) // 2, 300, 50), self.main_menu)
        self.add_menu_button("NO", pg.Rect((w - 300) // 2, (h - 50) // 2 + 60, 300, 50), self.hide_exit_menu)
        self.power_button = self.add_button('{0:.0f}%'.format(self.power * 100), pg.Rect(w - 60, h - 100, 50, 50),
                                            self.hide_exit_menu)
Exemple #2
0
 def __init__(self, w, h):
     super().__init__()
     self.w, self.h = w, h
     self.buttons = sp.RenderUpdates()
     self.textBoxDict = dict()
     self.statusBoxDict = dict()
     self.statusBoxes = sp.RenderUpdates()
     self.pressed = None
     self.textBoxActive = None
     self.bg = pg.Surface((w, h))
     self.bg.fill((0, 0, 0))
def pauseScreen(overlaySVG=None):
    """Display a "Paused" screen and suspend

    This default implementation will not do anything to shut down your
    simulation or other code running in other threads.  It will merely block
    this thread (the pygame thread) until an event shows up in the
    eventwrap queue.

    Returns a surface to pass to restoreScreen to continue...
    """
    from olpcgames import svgsprite
    if not overlaySVG:
        from olpcgames.data import sleeping_svg
        overlaySVG = sleeping_svg.data
    screen = pygame.display.get_surface()
    old_screen = screen.copy()  # save this for later.
    pause_sprite = svgsprite.SVGSprite(overlaySVG, )
    pause_sprite.rect.center = screen.get_rect().center
    group = sprite.RenderUpdates()
    group.add(pause_sprite)

    # dim the screen and display the 'paused' message in the center.
    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
    dimmed = screen.copy()
    dimmed.set_alpha(128)
    screen.fill(BLACK)
    screen.blit(dimmed, (0, 0))

    group.draw(screen)
    return old_screen
Exemple #4
0
    def __init__(self, gameMap, teamNo, serverBridge):
        self.run = True
        self.serverBridge = serverBridge

        # create teams
        self.teamNo = teamNo
        Team.teams = []
        for i in range(gameMap.players):
            if i == self.teamNo:
                Team(Game.OWNCOLOR)
            else:
                Team()
        self.alive = True

        # start the map
        self.map = gameMap
        # self.bg = pg.Surface((self.map.w, self.map.h))
        # self.bg.fill((0, 0, 0))
        self.bg = pgen.genStarBG(self.map.w, self.map.h)
        self.map.draw(self.bg)

        # make ship containers
        self.ships = sp.RenderUpdates()
        self.clusterNames = dict()

        self.selected = False
Exemple #5
0
    def __init__(self):
        pygame.init()
        pygame.display.set_caption(Game.NAME)
        self.screen = pygame.display.set_mode(Game.SCREEN_SIZE)
        self.clock = pygame.time.Clock()
        self.group = sprite.RenderUpdates()
        self.background = pygame.image.load(
            os.path.sep.join(["sprites", "background.jpg"])).convert()
        self.screen.blit(self.background, (0, 0))
        self.tanks = []
        self.barriers = []

        # interface with a server
        self.interface = None
 def __init__(self, color, seed, x, y, size=36):
     self.seed = seed
     self.generator = random.Random(seed)
     self.color = color
     self.size = size
     self.sprites = sprite.RenderUpdates()
     self.sprite = sprite.Sprite()
     self.dirName = get_dir()
     self._path = self.dirName + "ghost_" + self.color + ".png"
     img = pygame.image.load(self._path)
     self.sprite.image = pygame.transform.scale(img, (self.size, self.size))
     self.sprites.add(self.sprite)
     self.position = (x, y)
     self.startposition = self.position
     self.reset()
 def __init__(self, buddy, startx, starty, color = 'green', size=36):
     self.buddy = buddy
     self.nick = buddy.props.nick
     self.score = 0
     self.color = color
     self.size = size
     self.startposition = (startx, starty)
     self.hidden = False
     self.bonusplayers = None
     self.opensprites = sprite.RenderUpdates()
     self.closedsprites = sprite.RenderUpdates()
     self.dirName = get_dir()
     self.open = sprite.Sprite()
     self.closed = sprite.Sprite()
     self._path = self.dirName + "pacman-" + self.color
     img = pygame.image.load(self._path + "-open-right.png")
     self.open.image = pygame.transform.scale(img, (self.size, self.size))
     img = pygame.image.load(self._path + "-closed.png")
     self.closed.image = pygame.transform.scale(img, (self.size, self.size))
     self.opensprites.add(self.open)
     self.closedsprites.add(self.closed)
     self.mouthClosed = 1
     self.supertime = 0
     self.reset()
Exemple #8
0
from pygame import sprite

tiles = sprite.Group()
overlays = sprite.Group()
camera_relative = sprite.Group()
layeredItems = sprite.LayeredUpdates()

all = sprite.RenderUpdates()
Exemple #9
0
 def __init__(self, w, h, players):
     super().__init__()
     self.w, self.h = w, h
     self.players = players
     self.pTexts = sp.RenderUpdates()
     self.pNameDict = dict()