コード例 #1
0
 def draw(self, surf):
     Screen.draw(self, surf)
     self.ships.draw(surf)
     self.boulders.draw(surf)
     self.boulderFragments.draw(surf)
     self.healthBar.draw(surf, (0, 0))
     self.scoreDisplay.draw(surf)
コード例 #2
0
ファイル: screens.py プロジェクト: jceipek/Mind-Rush
    def __init__(self, size, ui):
        Ship.imageCache = Screen.imageCache
        Boulder.imageCache = Screen.imageCache
        BoulderFragment.imageCache = Screen.imageCache
        ScrollingCodeBackground.textCache = Screen.textCache
        ScrollingCodeBackground.resolution = Screen.resolution
        Counter.textCache = Screen.textCache
        Counter.resolution = Screen.resolution

        background = ScrollingCodeBackground()
        Screen.__init__(self, background, size, ui)

        self.ships = pygame.sprite.Group()
        ship = Ship(self, pos=(size[0]/2,size[1]), screenBoundaries=(0,0)+size)
        self.ships.add(ship) #May change if we add more ships (multiplayer?)
        for ship in self.ships:
            ship.move((0,-ship.rect.height/2))
            ship.targetPosition = ship.position

        self.boulders = pygame.sprite.Group()
        self.nextBoulderTime = 0

        self.boulderFragments = pygame.sprite.Group()

        self.healthBar = Bar(100,int(size[0]*0.72),int(size[1]*0.05),fullColor=(255,0,0),emptyColor=(0,0,0), borderSize=int(size[1]*0.005), borderColor=(255,255,255))

        self.scoreDisplay = Counter(0,(self.healthBar.surface.get_rect().width,0))

        musicPath = pathJoin(('music','Music.ogg'))
        pygame.mixer.music.load(musicPath)
        pygame.mixer.music.play(-1)
コード例 #3
0
class IntroInstance(Instance):
    def __init__(self):
        self.screen = Screen(curses.LINES - 1, curses.COLS - 1)
        self.pad = self.screen.pad
        self.h = 30
        self.w = 124
        self.H = self.screen.H
        self.W = self.screen.W
        self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)

    def process_key_event(self, key):
        if key == ord(' ') or key == ord('\n'):
            from controller.create_hero_handler import CreateHeroHandler
            return CreateHeroHandler(), False
        from controller.splash_screen_handler import SplashScreenHandler
        return SplashScreenHandler(self), False

    def invoke(self):
        self.screen.clear()
        self.print()
        self.screen.refresh()

    def print(self):
        y = self.dy
        x = self.dx
        h = self.h
        w = self.w

        draw_window(self.pad, y, x, h, w, 'Пролог',
                    'Нажмите [Enter] или [Space] для продолжения')
        self._print_description()

    def _print_description(self):
        draw_pic(self.pad, self.dy + 2, self.dx + 2, PIC)
コード例 #4
0
    def __init__(self, size, ui):
        background = Background((0, 0, 0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        Ship.imageCache = Screen.imageCache

        self.ship = TestShip(self,
                             pos=(size[0] / 2, size[1]),
                             screenBoundaries=(0, 0) + size)
        self.ship.move((0, -self.ship.rect.height / 2))

        self.menuItems = []
        self.addMenuItem(
            MenuItem('You are about to calibrate your eye circuit',
                     (self.resolution[0] // 2, int(self.resolution[1] * .1)),
                     scaleSize=.75))
        self.addMenuItem(
            MenuItem('Follow the ship with your eyes',
                     (self.resolution[0] // 2, int(self.resolution[1] * .17)),
                     scaleSize=.75))
        self.addMenuItem(
            MenuItem('Start',
                     (self.resolution[0] // 2, int(self.resolution[1] * .31)),
                     scaleSize=.75))

        self.shipPositions = []
        self.eyePositions = []

        self.running = False
コード例 #5
0
ファイル: engine.py プロジェクト: Friedenspanzer/spacegame
    def __init__(self):
        self.world = esper.World()
        self.event_handler = EventHandler()
        self.screen = Screen(self.world)
        self.sidebar = Sidebar(self.world)
        self.console = Console(self.world)

        self.last_update = time.monotonic()
        self.accumulator = 0

        rand_x = Random()
        rand_y = Random()

        # Add player ship
        self.player_ship = factory.player_ship(self.world)
        self.world.component_for_entity(self.player_ship,
                                        Selectable).selected_main = True

        # Add some asteroids
        for i in range(20):
            asteroid = factory.asteroid(self.world)
            position = Position(int(50 * rand_x.guass(0, 0.3)),
                                int(50 * rand_y.guass(0, 0.3)))
            self.world.add_component(asteroid, position)

        # Add patroling enemy
        enemy = factory.enemy_fighter(self.world)
        enemy_behaviour: Behaviour = self.world.component_for_entity(
            enemy, Behaviour)
        enemy_behaviour.behaviours.append(
            BehaviourPatrol((10, 10), (10, -10), 2))

        # Add processors
        self.__initialize_processors()
コード例 #6
0
    def update(self, *args):
        gameTime, frameTime = args[:2]
        Screen.update(self, *args)
        self.ships.update(*args)
        self.boulders.update(*args)
        self.boulderFragments.update(*args)

        #For every boulder colliding with a ship,
        #kill the boulder & lose health
        for ship in self.ships:
            for boulder in ship.testMaskCollision(self.boulders):
                ship.health -= boulder.damage
                self.healthBar.updateBarWithValue(ship.health)
                boulder.kill()
                if ship.health <= 0:
                    #Kill ship, etc...
                    for ship in self.ships:
                        deadScreen = DeadScreen(self.resolution, self._ui,
                                                ship.score)
                    self._ui.clearTopScreen()
                    self._ui.addActiveScreens(deadScreen)
                    pygame.mixer.music.stop()

        if gameTime >= self.nextBoulderTime:
            boulderPos = random.randint(0, self.resolution[0]), 0
            a = (4**random.random() - 1) / 2
            boulderVel = (a, abs(1 - a))
            self.boulders.add(
                Boulder(self,
                        pos=boulderPos,
                        vel=boulderVel,
                        screenBoundaries=(0, 0) + self.resolution))
            self.nextBoulderTime = gameTime + random.randint(200, 1000)
コード例 #7
0
ファイル: screens.py プロジェクト: jceipek/Mind-Rush
    def update(self, *args):
        gameTime, frameTime = args[:2]
        Screen.update(self, *args)
        self.ships.update(*args)
        self.boulders.update(*args)
        self.boulderFragments.update(*args)

        #For every boulder colliding with a ship,
        #kill the boulder & lose health
        for ship in self.ships:
            for boulder in ship.testMaskCollision(self.boulders):
                ship.health -= boulder.damage
                self.healthBar.updateBarWithValue(ship.health)
                boulder.kill()
                if ship.health <= 0:
                    #Kill ship, etc...
                    for ship in self.ships:
                        deadScreen = DeadScreen(self.resolution, self._ui, ship.score)
                    self._ui.clearTopScreen()
                    self._ui.addActiveScreens(deadScreen)
                    pygame.mixer.music.stop()

        if gameTime >= self.nextBoulderTime:
            boulderPos = random.randint(0,self.resolution[0]), 0
            a = (4**random.random()-1)/2
            boulderVel = (a,abs(1-a))
            self.boulders.add(Boulder(self, pos=boulderPos, vel=boulderVel, screenBoundaries=(0,0)+self.resolution))
            self.nextBoulderTime = gameTime + random.randint(200,1000)
コード例 #8
0
ファイル: screens.py プロジェクト: jceipek/Mind-Rush
 def draw(self, surf):
     Screen.draw(self, surf)
     self.ships.draw(surf)
     self.boulders.draw(surf)
     self.boulderFragments.draw(surf)
     self.healthBar.draw(surf,(0,0))
     self.scoreDisplay.draw(surf)
コード例 #9
0
 def __init__(self):
     self.screen = Screen(curses.LINES - 1, curses.COLS - 1)
     self.pad = self.screen.pad
     self.h = 30
     self.w = 124
     self.H = self.screen.H
     self.W = self.screen.W
     self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)
コード例 #10
0
ファイル: pysnake.py プロジェクト: dbrizov/PySnake
def run():
    pygame.init()
    Screen.init(width=500, height=420, flags=0, depth=32)

    EntitySpawner.spawnEntity(GameControllerEntity)

    GameLoop(fps=60).run()
    pygame.quit()
コード例 #11
0
ファイル: screens.py プロジェクト: jceipek/Mind-Rush
    def __init__(self, size, ui, score):
        background = Background((0,0,0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache

        self.menuItems = []
        self.title = MenuItem('Game Over',(self.resolution[0]//2,int(self.resolution[1]*.15)), scaleSize=1.5)
        self.addMenuItem(MenuItem('Score: %d' % (score,),(self.resolution[0]//2, int(self.resolution[1]*.3))))
        self.addMenuItem(MenuItem('Replay',(int(self.resolution[0]*.3),self.resolution[1]//2)))
        self.addMenuItem(MenuItem('Main Menu',(int(self.resolution[0]*.7),self.resolution[1]//2)))
コード例 #12
0
 def __init__(self):
     self.screen = Screen()
     self.running = True
     self.tab = 0
     self.target = 0
     self.escaped = 0
     self.tabs = [
         Library(self.screen),
         Settings(self.screen),
         Console(self.screen)
     ]
     self.debug = False
コード例 #13
0
ファイル: pysnake.py プロジェクト: dbrizov/PySnake
    def tick(self, deltaTime):
        boardPos = self.getSnake().getBoard().getTransform().position
        self._surface.fill(Color.NONE)
        for pos in self.getSnake().getBodyPositions():
            rectPos = boardPos + Vector2(pos.y * self.rectSize.x, pos.x * self.rectSize.y)
            pygame.draw.rect(self._surface, self.bodyColor, (rectPos.x, rectPos.y, self.rectSize.x, self.rectSize.y))
            pygame.draw.rect(
                self._surface,
                self.borderColor,
                (rectPos.x, rectPos.y, self.rectSize.x, self.rectSize.y),
                self.borderWidth)

        Screen.getSurface().blit(self._surface, Vector2(0, 0))
コード例 #14
0
ファイル: screens.py プロジェクト: jceipek/Mind-Rush
    def __init__(self, size, ui):
        background = Background((0,0,0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        MenuItem.resolution = Screen.resolution

        self.title = MenuItem('Options',(self.resolution[0]//2,int(self.resolution[1]/4)), scaleSize=1.5)
        self.menuItems = []
        self.addMenuItem(MenuItem('Back',(int(self.resolution[0]*(2/3.0)),self.resolution[1]//2)))
        self.addMenuItem(MenuItem('Calibrate',(int(self.resolution[0]*(1/3.0)),self.resolution[1]//2,)))
        #self.addMenuItem(MenuItem('Input Settings',(int(self.resolution[0]*.5),self.resolution[1]//2)))

        self.organizeMenuItems()
コード例 #15
0
ファイル: menuItems.py プロジェクト: jceipek/Shades
    def __init__(self, size, ui):
        background = Background((0,0,0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        MenuItem.imageCache = Screen.imageCache
        MenuItem.resolution = Screen.resolution

        self.menuItems = []
        self.title = MenuItem('MindRush',(self.resolution[0]//2,int(self.resolution[1]/4)), scaleSize=1.5)
        self.addMenuItem(MenuItem('Play',(int(self.resolution[0]*(1/3.0)),self.resolution[1]//2,)))
        self.addMenuItem(MenuItem('Options',(int(self.resolution[0]*.5),self.resolution[1]//2)))
        self.addMenuItem(MenuItem('Exit',(int(self.resolution[0]*(2/3.0)),self.resolution[1]//2)))

        self.organizeMenuItems()
コード例 #16
0
 def __init__(self, screen):
     self.choices = [
         'Солдат Содружества', 'Инженер Содружества', 'Псионик класса А',
         'Псионик класса Б', 'Солест'
     ]
     self.dx = max(0, screen.W // 2 - 170 // 2)
     self.dy = max(0, screen.H // 2 - len(self.choices) - 7)
     self.screen = screen
     self.pad = screen.get_pad()
     self.menu_screen = Screen(H=len(self.choices) + 2,
                               W=23,
                               fromy=self.dy + 2,
                               fromx=self.dx + 2)
     self.menu = MenuInstance(self.menu_screen, self.choices)
     self._set_current_choice_info(0)
コード例 #17
0
ファイル: screens.py プロジェクト: jceipek/Mind-Rush
    def __init__(self, size, ui):
        background = Background((0,0,0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        Ship.imageCache = Screen.imageCache

        self.ship = TestShip(self, pos=(size[0]/2,size[1]), screenBoundaries=(0,0)+size)
        self.ship.move((0,-self.ship.rect.height/2))

        self.menuItems = []
        self.addMenuItem(MenuItem('You are about to calibrate your eye circuit',(self.resolution[0]//2,int(self.resolution[1]*.1)),scaleSize=.75))
        self.addMenuItem(MenuItem('Follow the ship with your eyes',(self.resolution[0]//2,int(self.resolution[1]*.17)),scaleSize=.75))
        self.addMenuItem(MenuItem('Start',(self.resolution[0]//2,int(self.resolution[1]*.31)),scaleSize=.75))

        self.shipPositions = []
        self.eyePositions = []

        self.running = False
コード例 #18
0
 def __init__(self):
     super().__init__()
     if Globals.PAUSE_MENU in Globals.instances:
         self.instance = Globals.instances[Globals.PAUSE_MENU]
     else:
         self.instance = MenuInstance(
             Screen(curses.LINES - 1, curses.COLS - 1),
             ["Назад в игру", "Выход"])
         Globals.instances[Globals.PAUSE_MENU] = self.instance
コード例 #19
0
    def run(self):
        running = True
        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    running = False

            Time.tick_Internal()

            EntitySpawner.resolveEntitySpawnRequests_Internal()
            EntitySpawner.resolveEntityDestroyRequests_Internal()

            Input.tick_Internal(Time.getDeltaTime())

            for entity in EntitySpawner.getEntities():
                entity.tick_Internal(Time.getDeltaTime() * Time.getTimeScale())

            Screen.repaint()
コード例 #20
0
 def __init__(self, clazz=None, instance=None, overlay=None):
     super().__init__(instance, overlay)
     if instance is None:
         if Globals.DUNGEON in Globals.instances:
             self.instance = Globals.instances[Globals.DUNGEON]
         else:
             from engine.instances.dungeon_instance import DungeonInstance
             self.instance = DungeonInstance(
                 Screen(curses.LINES - 11, curses.COLS - 1), clazz)
             Globals.instances[Globals.DUNGEON] = self.instance
コード例 #21
0
ファイル: pysnake.py プロジェクト: dbrizov/PySnake
    def init(self):
        Entity.init(self)
        self._renderComponent = self.addComponent(
            SnakeRenderComponent(Screen.getSize(), CELL_SIZE, CELL_BORDER_WIDTH, Color.RED, Color.BLACK))

        self._inputComponent = self.addComponent(InputComponent())
        self._inputComponent.bindAction("left", InputEvent.EVENT_TYPE_PRESSED, lambda: self.changeDirection(DIRECTION_LEFT))
        self._inputComponent.bindAction("right", InputEvent.EVENT_TYPE_PRESSED, lambda: self.changeDirection(DIRECTION_RIGHT))
        self._inputComponent.bindAction("up", InputEvent.EVENT_TYPE_PRESSED, lambda: self.changeDirection(DIRECTION_UP))
        self._inputComponent.bindAction("down", InputEvent.EVENT_TYPE_PRESSED, lambda: self.changeDirection(DIRECTION_DOWN))
コード例 #22
0
    def __init__(self, size, ui, score):
        background = Background((0, 0, 0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache

        self.menuItems = []
        self.title = MenuItem(
            'Game Over',
            (self.resolution[0] // 2, int(self.resolution[1] * .15)),
            scaleSize=1.5)
        self.addMenuItem(
            MenuItem('Score: %d' % (score, ),
                     (self.resolution[0] // 2, int(self.resolution[1] * .3))))
        self.addMenuItem(
            MenuItem('Replay',
                     (int(self.resolution[0] * .3), self.resolution[1] // 2)))
        self.addMenuItem(
            MenuItem('Main Menu',
                     (int(self.resolution[0] * .7), self.resolution[1] // 2)))
コード例 #23
0
 def __init__(self):
     super().__init__()
     self.h = 9
     self.w = 82
     self.H = curses.LINES - 1
     self.W = curses.COLS - 1
     self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)
     self.screen = Screen(self.h, self.w, self.dy, self.dx)
     self.pad = self.screen.pad
     self.text = 'Базовое обучение завершено. Если Вы забыли нужную клавишу, то нажмите [H] для вызова помощи. Удачи!'
コード例 #24
0
 def __init__(self):
     super().__init__()
     if Globals.MAIN_MENU in Globals.instances:
         self.instance = Globals.instances[Globals.MAIN_MENU]
     else:
         self.instance = MenuInstance(
             Screen(curses.LINES - 1, curses.COLS - 1),
             ["Новая игра", "Загрузить", "Об игре", "Выход"],
             'Fix ignore in neigh4')
         Globals.instances[Globals.MAIN_MENU] = self.instance
コード例 #25
0
 def __init__(self, instance=None):
     super().__init__(instance)
     if self.instance is None:
         if Globals.MESSAGE_LOG in Globals.instances:
             self.instance = Globals.instances[Globals.MESSAGE_LOG]
         else:
             from engine.instances.message_log_instance import MessageLogInstance
             #map_name = Globals.instances[Globals.DUNGEON]
             screen = Screen(curses.LINES-1, curses.COLS-1)
             self.instance = MessageLogInstance(screen)
             Globals.instances[Globals.MESSAGE_LOG] = self.instance
コード例 #26
0
 def __init__(self):
     super().__init__()
     self.h = 9
     self.w = 82
     self.H = curses.LINES - 1
     self.W = curses.COLS - 1
     self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)
     self.screen = Screen(self.h, self.w, self.dy, self.dx)
     self.pad = self.screen.pad
     self.text = 'Продолжайте атаковать противника, нажимая клавишу [Пробел], пока он не умрёт. После этого нажмите ' \
                 '[A] для выхода из режима боя.'
コード例 #27
0
 def __init__(self, instance=None):
     super().__init__(instance)
     if self.instance is None:
         if Globals.INVENTORY in Globals.instances:
             self.instance = Globals.instances[Globals.INVENTORY]
         else:
             from engine.instances.inventory_instance import InventoryInstance
             dungeon = Globals.instances[Globals.DUNGEON]
             screen = Screen(curses.LINES - 1, curses.COLS - 1)
             self.instance = InventoryInstance(screen, dungeon.player)
             Globals.instances[Globals.INVENTORY] = self.instance
コード例 #28
0
    def __init__(self, size, ui):
        background = Background((0, 0, 0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        MenuItem.resolution = Screen.resolution

        self.title = MenuItem(
            'Options', (self.resolution[0] // 2, int(self.resolution[1] / 4)),
            scaleSize=1.5)
        self.menuItems = []
        self.addMenuItem(
            MenuItem('Back', (int(self.resolution[0] *
                                  (2 / 3.0)), self.resolution[1] // 2)))
        self.addMenuItem(
            MenuItem('Calibrate', (
                int(self.resolution[0] * (1 / 3.0)),
                self.resolution[1] // 2,
            )))
        #self.addMenuItem(MenuItem('Input Settings',(int(self.resolution[0]*.5),self.resolution[1]//2)))

        self.organizeMenuItems()
コード例 #29
0
 def __init__(self):
     super().__init__()
     self.h = 9
     self.w = 82
     self.H = curses.LINES - 1
     self.W = curses.COLS - 1
     self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)
     self.screen = Screen(self.h, self.w, self.dy, self.dx)
     self.pad = self.screen.pad
     self.text = 'Для перемещения используйте стрелки. Одно перемещение обычно тратит один ход. Пока вы стоите, ' \
                 'время не идёт, так что вы всегда можете как следует обдумать свои действия. Попробуйте подвигаться' \
                 ' с помощью стрелок.'
コード例 #30
0
 def __init__(self):
     super().__init__()
     self.h = 9
     self.w = 82
     self.H = curses.LINES - 1
     self.W = curses.COLS - 1
     self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)
     self.screen = Screen(self.h, self.w, self.dy, self.dx)
     self.pad = self.screen.pad
     self.text = 'Отлично! А теперь попробуем осмотреться. Для того, чтобы переключиться в режим обзора, нажмите ' \
                 '[Enter]. В этом режиме с помощью стрелочек вы можете двигать курсор по всему уровню, получая при ' \
                 'этом подробную информацию о любом объекте под курсором. Для выхода из режима обзора нажмите [Enter].'
コード例 #31
0
    def __init__(self, size, ui):
        Ship.imageCache = Screen.imageCache
        Boulder.imageCache = Screen.imageCache
        BoulderFragment.imageCache = Screen.imageCache
        ScrollingCodeBackground.textCache = Screen.textCache
        ScrollingCodeBackground.resolution = Screen.resolution
        Counter.textCache = Screen.textCache
        Counter.resolution = Screen.resolution

        background = ScrollingCodeBackground()
        Screen.__init__(self, background, size, ui)

        self.ships = pygame.sprite.Group()
        ship = Ship(self,
                    pos=(size[0] / 2, size[1]),
                    screenBoundaries=(0, 0) + size)
        self.ships.add(ship)  #May change if we add more ships (multiplayer?)
        for ship in self.ships:
            ship.move((0, -ship.rect.height / 2))
            ship.targetPosition = ship.position

        self.boulders = pygame.sprite.Group()
        self.nextBoulderTime = 0

        self.boulderFragments = pygame.sprite.Group()

        self.healthBar = Bar(100,
                             int(size[0] * 0.72),
                             int(size[1] * 0.05),
                             fullColor=(255, 0, 0),
                             emptyColor=(0, 0, 0),
                             borderSize=int(size[1] * 0.005),
                             borderColor=(255, 255, 255))

        self.scoreDisplay = Counter(
            0, (self.healthBar.surface.get_rect().width, 0))

        musicPath = pathJoin(('music', 'Music.ogg'))
        pygame.mixer.music.load(musicPath)
        pygame.mixer.music.play(-1)
コード例 #32
0
 def __init__(self):
     super().__init__()
     self.h = 11
     self.w = 82
     self.H = curses.LINES - 1
     self.W = curses.COLS - 1
     self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)
     self.screen = Screen(self.h, self.w, self.dy, self.dx)
     self.pad = self.screen.pad
     self.text = 'Помните, что движение курсора в любом режиме не отнимает игровых ходов. ' \
                 'А теперь опробуйте боевой режим. Подойдите вплотную к Гуано (G) и нажмите [A]. Активируется режим ' \
                 'атаки. Он очень похож на режим обзора с той лишь разницей, что отображается подробная информация о ' \
                 'противнике и имеется возможность атаковать. Затем наведите курсор на цель и нажмите [Пробел] для атаки. '
コード例 #33
0
ファイル: pysnake.py プロジェクト: dbrizov/PySnake
    def init(self):
        Entity.init(self)
        self._inputComponent = self.addComponent(InputComponent())
        self._inputComponent.bindAction("submit", InputEvent.EVENT_TYPE_PRESSED, self.restart)
        self._inputComponent.bindAction("cancel", InputEvent.EVENT_TYPE_PRESSED, self.quit)
        self._inputComponent.bindAction("pause", InputEvent.EVENT_TYPE_PRESSED, self.togglePaused)

        self._backgroundEntity = EntitySpawner.spawnEntity(Entity)
        self._backgroundEntity.addComponent(RectRenderComponent(Screen.getSize(), Screen.getSize(), Color.BLACK))

        self._boardEntity = EntitySpawner.spawnEntity(BoardEntity, CELL_MATRIX)

        self._snakeEntity = EntitySpawner.spawnEntity(SnakeEntity, self._boardEntity, 5, 3, Vector2(3, 3), DIRECTION_RIGHT)
        self._snakeEntity.onFoodEaten += lambda: self.spawnFood()
        self._snakeEntity.onFoodEaten += lambda: self.setScore(self._score + 1)
        self._snakeEntity.onFoodEaten += lambda: self.increaseSnakeSpeed()
        self._snakeEntity.onDeath += lambda: self.setGameOver(True)
        self.spawnFood()

        self._pausedTextEntity = self.createTextEntity("PAUSED")
        pausedTextRectSize = self._pausedTextEntity.getComponent(TextRenderComponent).getRectSize()
        boardRectSize = Vector2(self._boardEntity.getCols() * CELL_SIZE.x, self._boardEntity.getRows() * CELL_SIZE.y)
        self._pausedTextEntity.getTransform().position = Vector2((boardRectSize.x - pausedTextRectSize.x) // 2,
                                                                 (boardRectSize.y - pausedTextRectSize.y) // 2)

        self._gameOverTextEntity = self.createTextEntity("GAME OVER")
        gameOverTextRectSize = self._gameOverTextEntity.getComponent(TextRenderComponent).getRectSize()
        self._gameOverTextEntity.getTransform().position = Vector2((boardRectSize.x - gameOverTextRectSize.x) // 2,
                                                                   (boardRectSize.y - gameOverTextRectSize.y) // 2)

        self._scoreTextEntity = self.createTextEntity("SCORE:0")
        self._scoreTextEntity.getTransform().position = Vector2(0, boardRectSize.y)

        self._score = 0
        self._gameOver = False
        self.setGameOver(self._gameOver)
        self._paused = True
        self.setPaused(self._paused)
コード例 #34
0
    def __init__(self, inventory, cell):
        super().__init__()
        self.cell = cell
        self.loot = cell.loot
        self.inventory = inventory
        self.current = 0

        self.h = len(self.loot.items) + 5
        self.w = 82
        self.H = curses.LINES - 1
        self.W = curses.COLS - 1
        self.dy, self.dx = get_dy_dx(self.H, self.W, self.h, self.w)
        self.screen = Screen(self.h, self.w, self.dy, self.dx)
        self.pad = self.screen.pad
コード例 #35
0
    def __init__(self, size, ui):
        background = Background((0, 0, 0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        MenuItem.imageCache = Screen.imageCache
        MenuItem.resolution = Screen.resolution

        self.menuItems = []
        self.title = MenuItem(
            'MindRush', (self.resolution[0] // 2, int(self.resolution[1] / 4)),
            scaleSize=1.5)
        self.addMenuItem(
            MenuItem('Play', (
                int(self.resolution[0] * (1 / 3.0)),
                self.resolution[1] // 2,
            )))
        self.addMenuItem(
            MenuItem('Options',
                     (int(self.resolution[0] * .5), self.resolution[1] // 2)))
        self.addMenuItem(
            MenuItem('Exit', (int(self.resolution[0] *
                                  (2 / 3.0)), self.resolution[1] // 2)))

        self.organizeMenuItems()
コード例 #36
0
    def __init__(self, screen, clazz):
        self.screen = screen
        self.pad = screen.get_pad()
        self.mode = Action.MODE_MOVE
        self.gui = self._init_gui()
        self.player = Hero(clazz, None, None)
        self.__load_map()

        from engine.instances.inventory_instance import InventoryInstance
        Globals.instances[Globals.INVENTORY] = InventoryInstance(
            Screen(curses.LINES - 1, curses.COLS - 1), self.player)
        self.selection = Selection(screen, self.player)
        self.h = len(self.cells)
        self.w = len(self.cells[0])

        self.tutorial_stage = TUT_MOVE
        self.tutorial_move_count = 0
        self.overlay = None
        self.tut_updated = False
コード例 #37
0
 def _init_gui(self):
     vdiff = curses.LINES - self.screen.H
     guiscreen = Screen(vdiff, curses.COLS - 1, curses.LINES - vdiff - 1, 0)
     return GUI(guiscreen)
コード例 #38
0
ファイル: menuItems.py プロジェクト: jceipek/Shades
 def draw(self, surf):
     Screen.draw(self, surf)
     self.title.draw(surf)
     for menuItem in self.menuItems:
         menuItem.draw(surf)
コード例 #39
0
ファイル: gameScreen.py プロジェクト: jceipek/Shades
 def __init__(self, size, ui):
     Screen.__init__(self, None, size, ui)
     self.setup()