Beispiel #1
0
    def __init__(self):
        # Set the current level
        self.current_level: Level = Level01()
        # Create the player
        self.player = Player(self.current_level.start.tile)
        self.guardian = Guardian(self.current_level.guardian)

        self.characters = pygame.sprite.Group()
        self.items = pygame.sprite.Group()
        self.item_tiles: List[Tile] = [
            tile_gui.tile
            for tile_gui in random.sample(self.current_level.floors, 3)
        ]
        self.needle = Item(self.item_tiles[0], ItemType.NEEDLE)
        self.pipe = Item(self.item_tiles[1], ItemType.PLASTIC_PIPE)
        self.ether = Item(self.item_tiles[2], ItemType.ETHER)
        self.items.add(self.needle, self.pipe, self.ether)
        self.characters.add(self.guardian, self.player)
        # Loop until the user clicks the close button.
        self.done = False
        self.score = Score(self.player, self.current_level.width * BLOCK_SIZE,
                           self.current_level.height * BLOCK_SIZE)
        self.gui = pygame.sprite.Group()
        self.gui.add(self.score)
        self.state = GameState.LOOKING_FOR_ITEMS

        self.game_over = pygame.sprite.Group()
        self.game_over.add(
            GameOver(self.current_level.width * BLOCK_SIZE,
                     self.current_level.height * BLOCK_SIZE))

        self.win = pygame.sprite.Group()
        self.win.add(
            EndLevel(self.current_level.width * BLOCK_SIZE,
                     self.current_level.height * BLOCK_SIZE))
    def __init__(self):
        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css)
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
        self.player = Player()
        self.scrapper = Scrapper()
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(os.getcwd(), 'gui/src/gui2.glade'))
        self.window = self.builder.get_object('mainWindow')
        self.window.set_title("Anime Tv Scrapper")
        self.window.set_size_request(860, 600)
        self.entry = self.builder.get_object('searchinput')

        self.back_button = self.builder.get_object('toolbutton1')
        self.back_button.connect("clicked", self.go_back)

        self.left_pane = self.builder.get_object('box2')
        self.links_frame = self.builder.get_object('scrolledwindow1')
        self.mainBox = self.builder.get_object('box1')
        self.test_frame = self.builder.get_object('viewport1')
        self.grid_helper = Grid()

        self.grid = self.grid_helper.get()
        self.links_frame.add(self.grid)

        self.entry.connect("activate", self.on_searchinput_activate)
        self.window.connect("window-state-event", self.on_window_state_event)
        self.window.connect('destroy', Gtk.main_quit)
        self.window.connect('delete-event', Gtk.main_quit)
        self.window.show_all()
 def loadPlayers(self, file):
     try:
         f = open(file, "rb")
         for line in f:
             if len(line) > 1:
                 self.activePlayers.append(
                     Player(self.globals, line.decode("UTF-8"), 0, 0, 0))
                 self.numPlayers += 1
     except:
         print("couldn't load players")
 def makePlayers(
     self
 ):  #generates the players, each one having less total skill than the previous
     scale = int(100 / self.numPlayers)
     total = 100
     for i in range(self.numPlayers):
         a, b, c = self.abc(total)
         self.activePlayers.append(Player(str(self.nameid), a, b, c))
         self.nameid += 1
         total -= scale
     if self.start_seeded == False:
         random.shuffle(self.activePlayers)
Beispiel #5
0
def add_player_to_config(index, player: Player, player_header: ConfigHeader):
    player_header.set_value(PARTICIPANT_CONFIG_KEY,
                            player.get_config_location(), index)
    player_header.set_value(PARTICIPANT_TEAM, player.get_team(), index)
    player_header.set_value(PARTICIPANT_LOADOUT_CONFIG_KEY,
                            player.get_loadout(), index)
class UI:

    grid = ""

    def __init__(self):
        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css)
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
        self.player = Player()
        self.scrapper = Scrapper()
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(os.getcwd(), 'gui/src/gui2.glade'))
        self.window = self.builder.get_object('mainWindow')
        self.window.set_title("Anime Tv Scrapper")
        self.window.set_size_request(860, 600)
        self.entry = self.builder.get_object('searchinput')

        self.back_button = self.builder.get_object('toolbutton1')
        self.back_button.connect("clicked", self.go_back)

        self.left_pane = self.builder.get_object('box2')
        self.links_frame = self.builder.get_object('scrolledwindow1')
        self.mainBox = self.builder.get_object('box1')
        self.test_frame = self.builder.get_object('viewport1')
        self.grid_helper = Grid()

        self.grid = self.grid_helper.get()
        self.links_frame.add(self.grid)

        self.entry.connect("activate", self.on_searchinput_activate)
        self.window.connect("window-state-event", self.on_window_state_event)
        self.window.connect('destroy', Gtk.main_quit)
        self.window.connect('delete-event', Gtk.main_quit)
        self.window.show_all()

    def on_searchinput_activate(self, widget):
        self.open()

    def on_window_state_event(self, widget, event, data=None):
        mask = Gdk.WindowState.FULLSCREEN
        fullscreen = widget.get_window().get_state() & mask == mask

        if fullscreen:
            #self.left_pane.set_visible(False)
            self.mainBox.set_homogeneous(True)
        else:
            #self.left_pane.set_visible(True)
            self.mainBox.set_homogeneous(False)

    def serie_clicked(self, widget, event, link):
        serie = self.scrapper.get_series(link.link)
        self.show_links(serie)

    def episode_clicked(self, widget, event, link):
        links = self.scrapper.get_episode(link.href)['links']
        self.player.set_links(links)
        self.player.set_title(link.title)
        self.player.open(links[0])

    def go_back(self, widget):
        self.test_frame.hide()
        self.links_frame.show()

    def show_links(self, serie):
        box = Gtk.VBox()

        for episod in serie['episodes']:
            button = Gtk.Button(episod.title)
            box.pack_start(button, False, False, 0)
            button.connect("button-press-event", self.episode_clicked, episod)
            button.show()

        box.show()
        self.links_frame.hide()
        self.test_frame.add(box)
        self.test_frame.show()

    def open(self, *args):
        search = Search()
        links = search.search(self.entry.get_text())

        self.grid_helper.refresh()

        for link in links:
            url = link.img
            text = Gtk.Label(link.title)
            text.set_line_wrap(True)
            response = urllib2.urlopen(url)
            input_stream = Gio.MemoryInputStream.new_from_data(response.read(), None)
            pixbuf = Pixbuf.new_from_stream(input_stream, None)
            image = Gtk.Image()
            image.set_from_pixbuf(pixbuf)

            box = Gtk.VBox()
            box.pack_start(image, False, False, 0)
            box.pack_start(text, False, False, 0)
            event_box = Gtk.EventBox()
            event_box.add(box)

            event_box.connect("button-press-event", self.serie_clicked, link)

            self.grid_helper.add_widget(event_box)

        self.grid_helper.load_widgets()
        self.window.show_all()
Beispiel #7
0
    args = parser.parse_args()
#--------END Command Line argument parser------------------------------------------------------

    subprocess.run(["reset"])
    #print(sys.path)
    fp_cfg = '/'.join([args.cam_path,args.cam_file])
    print (fp_cfg)
    if not os.path.isfile(fp_cfg) == True:
        print('ERROR: Invalid Configuration File: {:s}'.format(fp_cfg))
        sys.exit()
    print('Importing configuration File: {:s}'.format(fp_cfg))
    with open(fp_cfg, 'r') as json_data:
        cam = json.load(json_data)
        json_data.close()
    # print(cam)
    # for idx,item in enumerate(cam):
    #     print(idx+1, item['cam_name'])
    #     print(item['hires_url'])
    #     print(item['hires_url'])
    #     print()
    # sys.exit()


    # Initialize the Qt Application and the main window
    app = QtWidgets.QApplication(sys.argv)
    player = Player(cameras=cam)
    player.setWindowFlags(QtCore.Qt.MaximizeUsingFullscreenGeometryHint |
                          QtCore.Qt.FramelessWindowHint)
    player.show()
    sys.exit(app.exec_())
Beispiel #8
0
from gi.repository import Gtk, Gdk
from gui.player import Player
from videospider import Spider

Gdk.threads_enter()

player = Player()

spider = Spider()
link = spider.fetch("http://vodlocker.com/embed-5fw744toleey-650x370.html")
#player.set_title("etas")
player.open(link)

Gtk.main()
Gdk.threads_leave()
Beispiel #9
0
class Game:
    def __init__(self):
        # Set the current level
        self.current_level: Level = Level01()
        # Create the player
        self.player = Player(self.current_level.start.tile)
        self.guardian = Guardian(self.current_level.guardian)

        self.characters = pygame.sprite.Group()
        self.items = pygame.sprite.Group()
        self.item_tiles: List[Tile] = [
            tile_gui.tile
            for tile_gui in random.sample(self.current_level.floors, 3)
        ]
        self.needle = Item(self.item_tiles[0], ItemType.NEEDLE)
        self.pipe = Item(self.item_tiles[1], ItemType.PLASTIC_PIPE)
        self.ether = Item(self.item_tiles[2], ItemType.ETHER)
        self.items.add(self.needle, self.pipe, self.ether)
        self.characters.add(self.guardian, self.player)
        # Loop until the user clicks the close button.
        self.done = False
        self.score = Score(self.player, self.current_level.width * BLOCK_SIZE,
                           self.current_level.height * BLOCK_SIZE)
        self.gui = pygame.sprite.Group()
        self.gui.add(self.score)
        self.state = GameState.LOOKING_FOR_ITEMS

        self.game_over = pygame.sprite.Group()
        self.game_over.add(
            GameOver(self.current_level.width * BLOCK_SIZE,
                     self.current_level.height * BLOCK_SIZE))

        self.win = pygame.sprite.Group()
        self.win.add(
            EndLevel(self.current_level.width * BLOCK_SIZE,
                     self.current_level.height * BLOCK_SIZE))

    def collision_handler(self):
        hit_wall_list = [
            wall for wall in self.current_level.walls
            if wall.tile == self.player.next_tile()
        ]
        for wall in hit_wall_list:
            print(colored('player hit wall at  {}'.format(wall), 'red'))
            self.player.stop()

    def facing_guardian(self):
        if abs(self.player.tile.x -
               self.guardian.tile.x) + abs(self.player.tile.y -
                                           self.guardian.tile.y) == 1:
            if len(self.player.items) == 3:
                print("Guardian is down !")
                self.characters.remove(self.guardian)
                self.state = GameState.GUARDIAN_DOWN
            else:
                self.state = GameState.LOOSE

    def item_detection(self):
        block_hit_list: List[Item] = pygame.sprite.spritecollide(
            self.player, self.items, False)
        for block in block_hit_list:
            self.player.take_item(block.item_type)
            self.items.remove(block)
            print('On item {}'.format(block.item_type))

    def out_of_game(self):
        if self.player.change_x > 0 and self.player.tile.x == self.current_level.width - 1 \
                or self.player.change_x < 0 and self.player.tile.x == 0 \
                or self.player.change_y < 0 and self.player.tile.x == 0 \
                or self.player.change_y > 0 and self.player.tile.y == self.current_level.height - 1:
            self.player.stop()
            print('trying to get out of game')

    def game_loop(self, screen):

        # -------- Main Program Loop -----------
        while not self.done:

            for event in pygame.event.get():  # User did something
                if event.type == pygame.QUIT:  # If user clicked close
                    self.done = True  # Flag that we are done so we exit this loop
                if event.type == pygame.KEYUP:
                    if event.key in [
                            pygame.K_LEFT, pygame.K_RIGHT, pygame.K_UP,
                            pygame.K_DOWN
                    ]:
                        self.player.stop()

            if self.state in [
                    GameState.LOOKING_FOR_ITEMS, GameState.HAVE_WEAPON,
                    GameState.GUARDIAN_DOWN
            ]:

                pressed_keys = pygame.key.get_pressed()

                if pressed_keys[pygame.K_LEFT]:
                    self.player.go_left()
                if pressed_keys[pygame.K_RIGHT]:
                    self.player.go_right()
                if pressed_keys[pygame.K_UP]:
                    self.player.go_up()
                if pressed_keys[pygame.K_DOWN]:
                    self.player.go_down()

                self.collision_handler()
                self.out_of_game()

                self.item_detection()

                self.characters.update()
                self.current_level.update()
                self.score.update(self.state)

                if self.state != GameState.GUARDIAN_DOWN:
                    self.facing_guardian()
                else:
                    self.end_game()

                self.current_level.draw(screen)
                self.items.draw(screen)
                self.characters.draw(screen)
                self.gui.draw(screen)

            elif self.state == GameState.LOOSE:
                self.game_over.draw(screen)
            elif self.state == GameState.WIN:
                self.win.draw(screen)

            # Go ahead and update the screen with what we've drawn.
            pygame.display.flip()

            # pause the game loop to limit speed
            pygame.time.delay(100)

    def end_game(self):
        if self.player.tile == self.current_level.end.tile:
            self.state = GameState.WIN
Beispiel #10
0
'''
Created on 08-05-2012

@author: morti
'''

import upnpy
from gui.player import Player 

if __name__ == '__main__':
    
    window = Player()
    window.show()
    
    upnpy.run()