Beispiel #1
0
def run(sample_number, resolution):
    global engine, screen
    print("hi")
    screen = pygame.display.set_mode(resolution if resolution else (600, 600))
    engine = Engine(screen)
    globals()[f"sample_{sample_number}"]()
    engine.start()
Beispiel #2
0
def lint_and_run_game(pylint_args, fullscreen, resolution):
    """Run pylint, get the output, parse it, initialize the game and run it."""
    animal_groups = create_animals(parse(lint(pylint_args)))
    flags = pygame.FULLSCREEN if fullscreen else 0
    if not resolution and not fullscreen:
        resolution = (600, 600)
    screen = pygame.display.set_mode((0, 0) if fullscreen else resolution,
                                     flags)
    organize_groups(screen, animal_groups)
    engine = Engine(screen)
    for animal_group in animal_groups:
        engine.add_animals(*animal_group)
    engine.start()
Beispiel #3
0
def test_game():
    animal1 = Animal(shape="Y", max_health=2, size=40)
    animal2 = Animal(shape="X", max_health=2, size=40)

    animal1.also_likes_to_eat(animal2)
    animal2.also_likes_to_eat(animal1)

    screen = pygame.display.set_mode((600, 600))

    animal1.put_relative(30, 30, screen)
    animal2.put_relative(60, 60, screen)

    engine = Engine(screen)
    engine.add_animals(animal1, animal2)
    engine.start()
Beispiel #4
0
class GameWindow(QMainWindow):
    def __init__(self, menu, players):
        super().__init__()

        self.menu = menu

        self.setWindowTitle('Code with Fire')
        self.setGeometry(200, 50, 800, 650)

        self.player_names = players
        self.alive_players = len(players)

        self.game_engine = Engine()
        self.game_screen = Screen(self.game_engine)
        self.score_manager = ScoreManager(self.game_screen)

        self.setCentralWidget(self.game_screen)
        self.create_menu_bar()

        self.start_game(players)

    def start_game(self, players):
        if len(players) == 1:
            start_one_player_game(self, self.game_engine, self.game_screen,
                                  self.score_manager)
        elif len(players) == 2:
            start_two_player_game(self, self.game_engine, self.game_screen,
                                  self.score_manager)

        self.game_engine.start()

    def create_menu_bar(self):
        pause_button = QAction(QIcon(None), '&Pausar Juego', self)
        pause_button.setShortcut('Ctrl+P')
        pause_button.triggered.connect(self.game_engine.toggle_pause)

        quit_button = QAction(QIcon(None), '&Cerrar Juego', self)
        quit_button.setShortcut('Ctrl+E')
        quit_button.triggered.connect(self.quit_game)

        actions = self.menuBar().addMenu('&Menú')
        actions.addAction(pause_button)
        actions.addAction(quit_button)

    # I pass the key events to the game screen widget.
    def keyPressEvent(self, event):
        self.game_screen.keyPressEvent(event)

    def keyReleaseEvent(self, event):
        self.game_screen.keyReleaseEvent(event)

    def player_death(self, player_death_event):
        player_score = (self.player_names[player_death_event.player],
                        player_death_event.score)
        HighScores.add_and_save_highscore(list(HighScores.get_highscores()),
                                          player_score)

        self.alive_players -= 1

        if self.alive_players <= 0:
            self.end_game()

    def quit_game(self):
        player_score = (self.player_names[0], self.score_manager.score)
        HighScores.add_and_save_highscore(list(HighScores.get_highscores()),
                                          player_score)

        self.end_game()

    def end_game(self):
        self.game_engine.stop = True
        self.hide()

        QWidget().setLayout(
            self.menu.layout()
        )  # Simple hack to empty the current layout - https://stackoverflow.com/a/10439207
        self.menu.initialize()
        self.menu.show()
        self.menu.open_highscores()
Beispiel #5
0
#!/usr/bin/env python2

# from network import Channel
# import socket
# import time
# from ctypes import cdll
import platform
# import sys
# import os

# sys.path.append(os.path.abspath())

from game.engine import Engine
engine = Engine()
engine.start()


def init_steam():
    #     arch, _ = platform.architecture()
    #     if arch == '64bit':
    #         i9c = cdll.LoadLibrary('./i9c_64.so')
    #     else:
    #         i9c = cdll.LoadLibrary('./i9c_32.so')
    #
    #     i9c.api_init()
    #     i9c.api_request_ticket()
    #     #time.sleep(3)
    #     #i9c.api_get_ticket()
    libsteam_api = cdll.LoadLibrary('old/libsteam_api.so')
    libsteam_api.SteamAPI_Init()
Beispiel #6
0
#!/usr/bin/env python2

# from network import Channel
# import socket
# import time
# from ctypes import cdll
import platform
# import sys
# import os

# sys.path.append(os.path.abspath())

from game.engine import Engine
engine = Engine()
engine.start()

def init_steam():
#     arch, _ = platform.architecture()
#     if arch == '64bit':
#         i9c = cdll.LoadLibrary('./i9c_64.so')
#     else:
#         i9c = cdll.LoadLibrary('./i9c_32.so')
#
#     i9c.api_init()
#     i9c.api_request_ticket()
#     #time.sleep(3)
#     #i9c.api_get_ticket()
    libsteam_api = cdll.LoadLibrary('old/libsteam_api.so')
    libsteam_api.SteamAPI_Init()
#     steam_
    # steam_user = libsteam_api.SteamUser()