def start_simon(self): if not self.game: self.game = SimonNumbers() self.game.quit_button.on_click = self.handle_exit arcade.set_window(self.game) self.game.game_start() self.set_visible(False)
def test_window(twm): import arcade width = 800 height = 600 title = "My Title" resizable = True arcade.open_window(width, height, title, resizable) arcade.set_background_color(arcade.color.AMAZON) w = arcade.get_window() assert w is not None # Make sure the arguments get passed to the window if not twm: assert w.width == width assert w.height == height assert w.caption == title assert w.resizeable is resizable assert w.current_view is None arcade.set_window(w) w.background_color = 255, 255, 255, 255 assert w.background_color == (255, 255, 255, 255) w.set_mouse_visible(True) w.set_size(width, height) p = arcade.get_projection() assert isinstance(p, np.ndarray) v = arcade.get_viewport() if not twm: assert v[0] == 0 # The lines below fail. Why? assert v[1] == width - 1 assert v[2] == 0 assert v[3] == height - 1 factor = arcade.get_scaling_factor() assert factor > 0 factor = arcade.get_scaling_factor(w) assert factor > 0 arcade.start_render() arcade.finish_render() def f(): pass arcade.schedule(f, 1 / 60) arcade.pause(0.01) arcade.close_window() arcade.open_window(width, height, title, resizable) arcade.quick_run(0.01)
def main() -> None: """ Main function. Can be run for a GameView in debug mode """ window = arcade.Window(title=constants.SCREEN_TITLE, width=constants.SCREEN_WIDTH, height=constants.SCREEN_HEIGHT) arcade.set_window(window) game = GameView(debug=True) window.show_view(game) arcade.run()
def on_mouse_press(self, x, y, button, modifiers): """ Called whenever mouse is pressed. :param: key (key) - key pressed :param: modifiers - life cycle method :post: Checks to see if the mouse was pressed and advances the game state if it was """ player2 = Player(DummyView.players[0].num_of_ships) next_player_ships_placement = AI_place(player2) self.window.show_view(next_player_ships_placement) if DummyView.iterations == 2 and not DummyView.has_ran: arcade.get_window().set_visible(False) player1 = DummyView.players[0] player2 = DummyView.players[1] GAME = aiGame(player1, player2) arcade.set_window(GAME.player1_other_board) arcade.schedule(GAME.run, 0.25) DummyView.has_ran = True
def test_window(): import arcade width = 800 height = 600 title = "My Title" resizable = True arcade.open_window(width, height, title, resizable) arcade.set_background_color(arcade.color.AMAZON) w = arcade.get_window() assert w is not None # Make sure the arguments get passed to the window assert w.width == width assert w.height == height assert w.caption == title assert w.resizeable is resizable arcade.set_window(w) p = arcade.get_projection() assert p is not None v = arcade.get_viewport() assert v[0] == 0 # The lines below fail. Why? # assert v[1] == width - 1 assert v[2] == 0 # assert v[3] == height - 1 arcade.start_render() arcade.finish_render() def f(): pass arcade.schedule(f, 1 / 60) arcade.pause(0.01) arcade.close_window() arcade.open_window(width, height, title, resizable) arcade.quick_run(0.01)
def test_window(): import arcade width = 800 height = 600 title = "My Title" resizable = True arcade.open_window(width, height, title, resizable) arcade.set_background_color(arcade.color.AMAZON) w = arcade.get_window() assert w is not None arcade.set_window(w) p = arcade.get_projection() assert p is not None v = arcade.get_viewport() assert v[0] == 0 assert v[1] == width - 1 assert v[2] == 0 assert v[3] == height - 1 arcade.start_render() arcade.finish_render() def f(): pass arcade.schedule(f, 1 / 60) arcade.pause(0.01) arcade.close_window() arcade.open_window(width, height, title, resizable) arcade.quick_run(0.01)
def main(): window = TestWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) arcade.set_window(window) arcade.run()
def main(): window = JumpWINDOW(SCREEN_WIDTH, SCREEN_HEIGHT) arcade.set_window(window) arcade.run()
def main(): window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT) arcade.set_window(window) arcade.run()
def __init__(self, width: int = 800, height: int = 600, title: str = 'Arcade Window', fullscreen: bool = False, resizable: bool = False, update_rate: Optional[float] = 1 / 60, antialiasing: bool = True, screen: pyglet.canvas.Screen = None): """ Construct a new window :param int width: Window width :param int height: Window height :param str title: Title (appears in title bar) :param bool fullscreen: Should this be full screen? :param bool resizable: Can the user resize the window? :param float update_rate: How frequently to update the window. :param bool antialiasing: Should OpenGL's anti-aliasing be enabled? """ if antialiasing: config = pyglet.gl.Config(major_version=3, minor_version=3, double_buffer=True, sample_buffers=1, samples=4) else: config = pyglet.gl.Config(major_version=3, minor_version=3, double_buffer=True) try: super().__init__(width=width, height=height, caption=title, resizable=resizable, config=config, vsync=False) self.register_event_type('update') self.register_event_type('on_update') except pyglet.window.NoSuchConfigException: raise NoOpenGLException( "Unable to create an OpenGL 3.3+ context. " "Check to make sure your system supports OpenGL 3.3 or higher." ) if antialiasing: try: gl.glEnable(gl.GL_MULTISAMPLE_ARB) except pyglet.gl.GLException: print("Warning: Anti-aliasing not supported on this computer.") if update_rate: from pyglet import compat_platform if compat_platform == 'darwin' or compat_platform == 'linux': # Set vsync to false, or we'll be limited to a 1/30 sec update rate possibly self.context.set_vsync(False) self.set_update_rate(update_rate) super().set_fullscreen(fullscreen, screen) # This used to be necessary on Linux, but no longer appears to be. # With Pyglet 2.0+, setting this to false will not allow the screen to # update. It does, however, cause flickering if creating a window that # isn't derived from the Window class. # self.invalid = False set_window(self) self._current_view: Optional[View] = None self.textbox_time = 0.0 self.key: Optional[int] = None self.ui_manager = arcade.experimental.gui.UIManager(self) self._ctx: ArcadeContext = ArcadeContext(self) set_viewport(0, self.width - 1, 0, self.height - 1) self._background_color: Color = (0, 0, 0, 0) # Required for transparency self._ctx.enable(self.ctx.BLEND) self._ctx.blend_func = self.ctx.BLEND_DEFAULT
self.height / 2 + 100, arcade.color.BLACK, 30) arcade.draw_text("SURVIVE TIME : " + str(int(self.world.time)), self.width / 2 - 170, self.height / 2, arcade.color.BLACK, 30) def on_draw(self): arcade.start_render() if (self.current_state == GAME_RUNNING): self.heart_sprite.draw() for sprite in self.rock_sprites: sprite.draw() self.man_sprite.draw() arcade.draw_text("SURVIVE TIME : " + str(int(self.world.time)), self.width - 260, self.height - 40, arcade.color.BURNT_SIENNA, 20) arcade.draw_text("HP : " + str(self.world.hp), self.width - 570, self.height - 40, arcade.color.BURNT_SIENNA, 20) else: self.game_over_screen() def on_key_press(self, key, key_modifiers): self.world.on_key_press(key, key_modifiers) if __name__ == '__main__': window = WallRunnerGameWindow(SCREEN_WIDTH, SCREEN_HEIGHT) arcade.set_window(window) arcade.run()
def main(): window = FlappyDotWindow(SCREEN_WIDTH, SCREEN_HEIGHT) arcade.set_window(window) arcade.run()
def __init__(self, width: int = 800, height: int = 600, title: str = 'Arcade Window', fullscreen: bool = False, resizable: bool = False, update_rate: Optional[float] = 1/60, antialiasing: bool = True): """ Construct a new window :param int width: Window width :param int height: Window height :param str title: Title (appears in title bar) :param bool fullscreen: Should this be full screen? :param bool resizable: Can the user resize the window? :param float update_rate: How frequently to update the window. :param bool antialiasing: Should OpenGL's anti-aliasing be enabled? """ if antialiasing: config = pyglet.gl.Config(major_version=3, minor_version=3, double_buffer=True, sample_buffers=1, samples=4) else: config = pyglet.gl.Config(major_version=3, minor_version=3, double_buffer=True) try: super().__init__(width=width, height=height, caption=title, resizable=resizable, config=config, vsync=False) except pyglet.window.NoSuchConfigException: raise NoOpenGLException("Unable to create an OpenGL 3.3+ context. " "Check to make sure your system supports OpenGL 3.3 or higher.") if antialiasing: try: gl.glEnable(gl.GL_MULTISAMPLE_ARB) except pyglet.gl.GLException: print("Warning: Anti-aliasing not supported on this computer.") # Required for transparency gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) if update_rate: from pyglet import compat_platform if compat_platform == 'darwin' or compat_platform == 'linux': # Set vsync to false, or we'll be limited to a 1/30 sec update rate possibly self.context.set_vsync(False) self.set_update_rate(update_rate) super().set_fullscreen(fullscreen) self.invalid = False set_window(self) set_viewport(0, self.width, 0, self.height) self.current_view: Optional[View] = None self.button_list: List[gui.TextButton] = [] self.dialogue_box_list: List[gui.DialogueBox] = [] self.text_list: List[gui.Text] = [] self.textbox_list: List[gui.TextBox] = [] self.textbox_time = 0.0 self.key: Optional[int] = None
def main(): window = GameWindow() arcade.set_window(window) arcade.run()
def main(): window = VisualNovelWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) arcade.set_window(window) arcade.run()
def main(): window = MonsterWindow(SCREEN_WIDTH, SCREEN_HEIGHT) arcade.set_window(window) arcade.run()
def __init__( self, width: int = 800, height: int = 600, title: str = 'Arcade Window', fullscreen: bool = False, resizable: bool = False, update_rate: Optional[float] = 1 / 60, antialiasing: bool = True, gl_version: Tuple[int, int] = (3, 3), screen: pyglet.canvas.Screen = None, style: Optional[str] = pyglet.window.Window.WINDOW_STYLE_DEFAULT, visible: bool = True, vsync: bool = False, gc_mode: str = "context_gc", center_window: bool = False, samples: int = 4, enable_polling: bool = True): # In certain environments we can't have antialiasing/MSAA enabled. # Detect replit environment if os.environ.get("REPL_ID"): antialiasing = False config = None # Attempt to make window with antialiasing if antialiasing: try: config = pyglet.gl.Config( major_version=gl_version[0], minor_version=gl_version[1], double_buffer=True, sample_buffers=1, samples=samples, ) display = pyglet.canvas.get_display() screen = display.get_default_screen() config = screen.get_best_config(config) except pyglet.window.NoSuchConfigException: LOG.warning( "Skipping antialiasing due missing hardware/driver support" ) config = None antialiasing = False # If we still don't have a config if not config: config = pyglet.gl.Config( major_version=3, minor_version=3, double_buffer=True, ) try: super().__init__(width=width, height=height, caption=title, resizable=resizable, config=config, vsync=vsync, visible=visible, style=style) self.register_event_type('update') self.register_event_type('on_update') except pyglet.window.NoSuchConfigException: raise NoOpenGLException( "Unable to create an OpenGL 3.3+ context. " "Check to make sure your system supports OpenGL 3.3 or higher." ) if antialiasing: try: gl.glEnable(gl.GL_MULTISAMPLE_ARB) except pyglet.gl.GLException: LOG.warning( "Warning: Anti-aliasing not supported on this computer.") if update_rate: self.set_update_rate(update_rate) self.set_vsync(vsync) super().set_fullscreen(fullscreen, screen) # This used to be necessary on Linux, but no longer appears to be. # With Pyglet 2.0+, setting this to false will not allow the screen to # update. It does, however, cause flickering if creating a window that # isn't derived from the Window class. # self.invalid = False set_window(self) self._current_view: Optional[View] = None self.current_camera: Optional[arcade.Camera] = None self.textbox_time = 0.0 self.key: Optional[int] = None self.flip_count: int = 0 self.static_display: bool = False self._ctx: ArcadeContext = ArcadeContext(self, gc_mode=gc_mode) set_viewport(0, self.width, 0, self.height) self._background_color: Color = (0, 0, 0, 0) # See if we should center the window if center_window: self.center_window() if enable_polling: self.keyboard = pyglet.window.key.KeyStateHandler() self.mouse = pyglet.window.mouse.MouseStateHandler() self.push_handlers(self.keyboard, self.mouse) else: self.keyboard = None self.mouse = None
def close(self): """ Close the Window. """ super().close() # Make sure we don't reference the window any more set_window(None) pyglet.clock.unschedule(self._dispatch_updates)
def main(): window = FourElementsRunWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) arcade.set_window(window) arcade.run()
self.scoreboard.draw() else: self.home.draw() def update(self, delta_time): if self.status == "game": self.control_fruit.update() self.map.update() if not self.map.animal_C: self.status = "scoreboard" self.control_fruit.mouse.shooting = True elif self.status == "scoreboard": self.scoreboard.update() if self.scoreboard.status == "change": self.status = "home" self.control_fruit = Slingshot_fruit() self.map = Map_F(SCREEN_WIDTH, SCREEN_HEIGHT, self.control_fruit) self.control_fruit.sync(self.map) self.scoreboard = Score_F(self.map, self.control_fruit.mouse) self.home = Home_F(self.control_fruit.mouse) else: self.home.update() if self.home.status == "change": self.status = "game" if __name__ == '__main__': runGame = GameWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "TheForest") arcade.set_window(runGame) arcade.run()
def main(): window = SnakeWindow(SCREEN_WIDTH, SCREEN_HEIGHT) arcade.set_window(window) arcade.run()
def main(): """ Main method """ window = MyGame() window.setup() arcade.run() arcade.set_window(None)