Beispiel #1
0
    def test_stop_end_loop(self):
        window = Window(1, 1)

        def _loop_stopper(_):
            if _loop_stopper.counter > 1:
                _loop_stopper.fail()
            _loop_stopper.counter += 1
            window.stop()
        _loop_stopper.fail = self.fail
        _loop_stopper.counter = 0

        window.loop(_loop_stopper)

        self.assertEqual(_loop_stopper.counter, 1)
Beispiel #2
0
    def test_run_couple_of_times_then_stop(self):
        window = Window(1, 1)

        def _loop_stopper(_):
            if _loop_stopper.counter > 5:
                _loop_stopper.fail()
            _loop_stopper.counter += 1
            if _loop_stopper.counter == 5:
                window.stop()

        _loop_stopper.fail = self.fail
        _loop_stopper.counter = 0

        window.loop(_loop_stopper)

        self.assertEqual(_loop_stopper.counter, 5)
Beispiel #3
0
4
0.000000 0.459098 0.594324 0.000000 0.000000 0.000000 1.000000 0.729412 0.000000 0.000000 1 0 0
0.594324 0.677796 0.809683 0.729412 0.000000 0.000000 1.000000 1.000000 0.545098 0.196078 1 0 0
0.809683 0.853088 0.899833 1.000000 0.545098 0.196078 1.000000 0.972549 0.937255 0.074510 1 0 0
0.899833 0.948247 1.000000 0.972549 0.937255 0.074510 1.000000 0.976471 0.968627 0.831373 1 0 0
"""
}


if __name__ == '__main__':
    import sys
    from game import Screen, Window

    WINSIZE = (1000, 200)
    screen = Screen(WINSIZE)
    window = Window(WINSIZE)
    screen.add(window)

    for name in sys.argv[1:]:
        gradient = get(name)

        if gradient.multi_gradients:
            for gname in gradient.gradients:
                print("%s:%s" % (name, gname), end='')
                for x in range(WINSIZE[0]):
                    window.draw_line((x, 0),
                                     (x, WINSIZE[1]),
                                     gradient.color(x / WINSIZE[0], gname))
                screen.update()
                input()
        else:
Beispiel #4
0
        if r1.intersects(r2):
            self.steroid.on_collide_with_player()
            self.player_life -= 10
        self.steroid.angle += 5
        self.steroid.update(window)

    def on_key_press(self, symbol, modifiers):
        pass


# -----------------------------------------------------------------------------
# Processo principal do jogo
# -----------------------------------------------------------------------------

# 1 - Criação da janela de jogo
window = Window(width=game.SIZE[0], height=game.SIZE[1], resizable=True)
window.set_caption(game.TITLE + " - Initializing...")
window.set_mouse_visible(False)

# 2 - Instanciação do que for necessário (elementos globais)
music_player = SoundManager()  # Tocador de músicas
game.scene = SceneTitle()  # Cena inicial do jogo

# 3 - Definição das configurações principais
clock.set_fps_limit(game.FPS)
glEnable(GL_BLEND)  # Habilitar canal alpha #1
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)  # Habilitar canal alpha #2

# 4 - Definição do loop principal
while 1:
    pyglet.clock.tick()
Beispiel #5
0
"""Main function loop."""

from game import Game, Window, Particle
from pygame.color import Color
import random
import sys

# Declare constants
SCREEN_SIZE = Window(1280, 720)
SCREEN_COLOR = Color("#f5f5f5")
COLOR_PALETTE = [
    (194, 227, 236),
    (253, 243, 184),
    (251, 215, 183),
    (236, 180, 191),
    (198, 172, 199),
]
MAX_PARTICLES = 100
PARTICLE_SIZE = 25

# Store particles
particles = []


def game_logic(game: Game) -> None:
    """Any game logic."""
    # Capture any important events
    event = game.manager.event.poll()
    if event.type == game.manager.QUIT:
        # Quit game
        game.running = False
Beispiel #6
0
from game import Game, Window

DISPLAY_SIZE = (800, 600)

win = Window(DISPLAY_SIZE)
game = Game(win)


def main():
    game.game_loop()


if __name__ == "__main__":
    main()
Beispiel #7
0
def main():
    window = Window.Window()
    start_view = HomeView.HomeView()
    window.show_view(start_view)
    arcade.run()
Beispiel #8
0
        )
        if r1.intersects(r2):
           self.steroid.on_collide_with_player()
           self.player_life -= 10
        self.steroid.angle += 5
        self.steroid.update(window)

    def on_key_press(self, symbol, modifiers):
        pass

# -----------------------------------------------------------------------------
# Processo principal do jogo
# -----------------------------------------------------------------------------

# 1 - Criação da janela de jogo
window = Window(width=game.SIZE[0], height=game.SIZE[1], resizable=True)
window.set_caption(game.TITLE + " - Initializing...")
window.set_mouse_visible(False)

# 2 - Instanciação do que for necessário (elementos globais)
music_player = SoundManager()                       # Tocador de músicas
game.scene = SceneTitle()                           # Cena inicial do jogo

# 3 - Definição das configurações principais
clock.set_fps_limit(game.FPS)
glEnable(GL_BLEND)                                  # Habilitar canal alpha #1
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)   # Habilitar canal alpha #2

# 4 - Definição do loop principal
while 1:
    pyglet.clock.tick()
Beispiel #9
0
#!/usr/bin/env python3
# runner.py
from game import Window

__author__ = 'Seth Tinglof'
__version__ = '1.0'

if __name__ == '__main__':
    window = Window()
Beispiel #10
0
"""
A main entry point of the app
"""
import sys
import os

from game import GameManager, AssetsProvider, Window
from settings import Settings

if __name__ == '__main__':
    if getattr(sys, 'frozen', False):
        # noinspection PyProtectedMember
        # pyre-ignore[16]:
        os.chdir(sys._MEIPASS)  # pylint: disable=E0401, E1101, W0212

    window = Window(*Settings().get_window_size())

    asset_provider = AssetsProvider()

    game_manager = GameManager(window, asset_provider)

    window.loop(game_manager.game_loop)