def __init__(self, width, height, title): """ Initializer """ super().__init__(width, height, title, resizable=True) # Sprite lists self.player_list = None self.wall_list = None # Set up the player self.player_sprite = None # Physics engine so we don't run into walls. self.physics_engine = None # Track the current state of what key is pressed self.left_pressed = False self.right_pressed = False # Store our tile map self.tile_map = None # Create the cameras. One for the GUI, one for the sprites. # We scroll the 'sprite world' but not the GUI. self.camera_sprites = arcade.Camera(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT) self.camera_gui = arcade.Camera(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT)
def __init__(self): """ Initializer """ # Call the parent class initializer super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "Sprite Example") # Sprite lists self.player_list = None self.wall_list = None # Set up the player self.player_sprite = None # This variable holds our simple "physics engine" self.physics_engine = None # Create the cameras. One for the GUI, one for the sprites. # We scroll the 'sprite world' but not the GUI. self.camera_for_sprites = arcade.Camera(SCREEN_WIDTH, SCREEN_HEIGHT) self.camera_for_gui = arcade.Camera(SCREEN_WIDTH, SCREEN_HEIGHT)
def __init__(self, width, height, title): """ Initializer """ super().__init__(width, height, title, resizable=True) # Sprite lists self.player_list = None self.wall_list = None # Set up the player self.player_sprite = None # Physics engine so we don't run into walls. self.physics_engine = None # Create the cameras. One for the GUI, one for the sprites. # We scroll the 'sprite world' but not the GUI. self.camera_sprites = arcade.Camera(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT) self.camera_gui = arcade.Camera(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT)
def __init__(self, window: Window = None, *, back: View = None, fade_in: float = 0, bg_color = (0, 0, 0)): super().__init__(window) self.back = back self.shown = False self.size = self.window.get_size() self.local_time = 0 self.fade_in = fade_in self.bg_color = bg_color self.camera = arcade.Camera(Settings.width, Settings.height, self.window) self.debug_options = { "camera_scale": 1, "box": False} self._errors: list[list[CharmException, float]] = []
def setup(self): super().setup() # Load song and get waveform with LogSection(logger, "loading song and waveform"): with pkg_resources.path(charm.data.audio, "fourth_wall.wav") as p: self._song = arcade.load_sound(p) load = librosa.load(p, mono=True) self.waveform: ndarray[float] = load[0] self.sample_rate: int = load[1] # Create an index of samples with LogSection(logger, "indexing samples"): samples: list[SoundPoint] = [] for n, s in enumerate(self.waveform): samples.append(SoundPoint((1 / self.sample_rate) * n, s)) self.samples = nindex.Index(samples, "time") # Create an index of beats with LogSection(logger, "indexing beats"): self.bpm, beats = librosa.beat.beat_track(y = self.waveform, sr = self.sample_rate, units = "time") self.beats = nindex.Index([Beat(t) for t in beats[::2]], "time") self.chart_available = False # Create an index of chart notes with LogSection(logger, "parsing chart"): path = songspath / "fnf" / "fourth-wall" self.songdata = FNFSong.parse(path) if self.songdata: with LogSection(logger, "indexing notes"): self.chart_available = True self.player_chart = nindex.Index(self.songdata.charts[0].notes, "time") enemy_chart = self.songdata.get_chart(2, self.songdata.charts[0].difficulty) self.enemy_chart = nindex.Index(enemy_chart.notes, "time") with LogSection(logger, "generating highway"): self.highway = FNFHighway(self.songdata.charts[0], (((Settings.width // 3) * 2), 0), auto = True) # Create background stars with LogSection(logger, "creating stars"): self.star_camera = arcade.Camera() self.stars = arcade.SpriteList() self.scroll_speed = 20 # px/s stars_per_screen = 100 star_height = Settings.height + int(self._song.source.duration * self.scroll_speed) star_amount = int(stars_per_screen * (star_height / Settings.height)) logger.info(f"Generating {star_amount} stars...") for i in range(star_amount): sprite = arcade.SpriteCircle(5, arcade.color.WHITE + (255,), True) sprite.center_x = randint(0, Settings.width) sprite.center_y = randint(-(star_height - Settings.height), Settings.height) self.stars.append(sprite) with LogSection(logger, "creating text"): self.text = arcade.Text("Fourth Wall by Jacaris", Settings.width / 4, Settings.height * (0.9), font_name = "Determination Sans", font_size = 32, align="center", anchor_x="center", anchor_y="center", width = Settings.width) with LogSection(logger, "making gradient"): # Gradient self.gradient = arcade.create_rectangle_filled_with_colors( [(-250, Settings.height), (Settings.width + 250, Settings.height), (Settings.width + 250, -250), (-250, -250)], [arcade.color.BLACK, arcade.color.BLACK, arcade.color.DARK_PASTEL_PURPLE, arcade.color.DARK_PASTEL_PURPLE] ) with LogSection(logger, "loading sprites"): self.scott_atlas = arcade.TextureAtlas((8192, 8192)) self.sprite_list = arcade.SpriteList(atlas = self.scott_atlas) self.sprite = sprite_from_adobe("scott", ("bottom", "left")) self.boyfriend = sprite_from_adobe("bfScott", ("bottom", "right")) self.sprite_list.append(self.sprite) self.sprite_list.append(self.boyfriend) self.sprite.cache_textures() self.boyfriend.cache_textures() self.sprite.bottom = 0 self.sprite.left = 0 self.boyfriend.bottom = 0 self.boyfriend.right = Settings.width - 50 self.sprite.set_animation("idle") self.boyfriend.set_animation("idle") # Settings with LogSection(logger, "finalizing setup"): self.multiplier = 250 self.y = Settings.height // 2 self.line_width = 1 self.x_scale = 2 self.resolution = 4 self.beat_time = 0.5 self.show_text = False # RAM self.pixels: list[tuple[int, int]] = [(0, 0) * Settings.width] self.last_beat = -self.beat_time self.last_enemy_note: FNFNote = None self.last_player_note: FNFNote = None self.did_harcode = False
def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE, update_rate=1 / FPS_CAP, enable_polling=True) icon = pyglet_img_from_resource(charm.data.images, "charm-icon32t.png") self.set_icon(icon) self.delta_time = 0.0 self.time = 0.0 self.fps_checks = 0 self.debug = False self.show_fps = True self.show_log = False self.sounds: dict[str, arcade.Sound] = {} self.theme_song: pyglet.media.Player = None self.fps_averages = [] arcade.draw_text("abc", 0, 0) # force font init self.debug_camera = arcade.Camera(SCREEN_WIDTH, SCREEN_HEIGHT) self.fps_label = pyglet.text.Label("???.? FPS", font_name='bananaslip plus plus', font_size=12, x=0, y=self.height, anchor_x='left', anchor_y='top', color=(0, 0, 0) + (0xFF, )) self.fps_shadow_label = pyglet.text.Label( "???.? FPS", font_name='bananaslip plus plus', font_size=12, x=1, y=self.height - 1, anchor_x='left', anchor_y='top', color=(0xAA, 0xAA, 0xAA) + (0xFF, )) self.more_info_label = pyglet.text.Label( "DEBUG", font_name='bananaslip plus plus', font_size=12, x=0, y=self.height - self.fps_label.content_height - 5, multiline=True, width=Settings.width, anchor_x='left', anchor_y='top', color=(0, 0, 0) + (0xFF, )) self.alpha_label = pyglet.text.Label("ALPHA", font_name='bananaslip plus plus', font_size=16, x=self.width - 5, y=5, anchor_x='right', anchor_y='bottom', color=(0, 0, 0) + (32, )) self.debug_log = DebugLog() self.log = self.debug_log.layout self.log.position = (5, 5) # Menu sounds for soundname in ["back", "select", "valid"]: with pkg_resources.path(charm.data.audio, f"sfx-{soundname}.wav") as p: self.sounds[soundname] = arcade.load_sound(p) for soundname in ["error", "warning", "info"]: with pkg_resources.path(charm.data.audio, f"error-{soundname}.wav") as p: self.sounds["error-" + soundname] = arcade.load_sound(p) cheats = [] self.cheats = {c: False for c in cheats} self.title_view = TitleView()
def __init__(self, sprite_list: arcade.SpriteList, z: float) -> None: self.sprite_list = sprite_list self._z = z self._camera = arcade.Camera() self._camera.scale = self._z ** 2