def __init__(self, label: str, icon: str, goto: DigiView, width: int = 200, border_color: Color = arcade.color.WHITE, border_width: int = 0, *args, **kwargs): try: self.icon = img_from_resource(charm.data.icons, f"{icon}.png") self.icon = self.icon.resize((width, width), PIL.Image.LANCZOS) except Exception: self.icon = generate_missing_texture_image(width, width) self.icon = PIL.ImageOps.expand(self.icon, border=border_width, fill=border_color) tex = arcade.Texture(f"_icon_{icon}", image=self.icon, hit_box_algorithm=None) super().__init__(texture=tex, *args, **kwargs) self.goto = goto self.label = arcade.Text(label, 0, 0, CharmColors.PURPLE, anchor_x='center', anchor_y="top", font_name="bananaslip plus plus", font_size=24) self.center_y = Settings.height // 2 self.jiggle_start = 0
def __init__(self, event: SSAEvent, file: SSAFile): self._event = event self.effect = event.effect self.end = event.end self.layer = event.layer self.marginl = event.marginl self.marginr = event.marginr self.marginv = event.marginv self.marked = event.marked self.name = event.name self.style = event.style self.start = event.start self.text = event.text self.type = event.type self.ssa_style = file.styles[self.style] self.start_time: Seconds = self.start / 1000 self.end_time: Seconds = self.end / 1000 self.length: Seconds = self.end_time - self.start_time self.label = arcade.Text( self.plaintext, self.x + self.marginx, self.y + self.marginy, color = (self.ssa_style.primarycolor.r, self.ssa_style.primarycolor.g, self.ssa_style.primarycolor.b), font_size = self.ssa_style.fontsize // 3, font_name = "bananaslip plus plus", bold = self.ssa_style.bold, italic = self.ssa_style.italic, anchor_x = self.anchor_x, anchor_y = self.anchor_y, align = self.anchor_x, width = Settings.width )
def setup(self): super().setup() self.current_cheat = "" self.instructions = arcade.Text( "Enter Cheat:", Settings.width // 2, (Settings.height // 3) * 2, arcade.color.BLACK, 48, align="center", anchor_x="center", anchor_y="center", width = Settings.width, font_name="bananaslip plus plus" ) self.cheat = arcade.Text( "", Settings.width // 2, Settings.height // 2, CharmColors.PURPLE, 72, align="center", anchor_x="center", anchor_y="center", width = Settings.width, font_name="bananaslip plus plus" ) self.more_instructions = arcade.Text( "SHIFT+BACKSPACE to exit.", Settings.width // 2, 10, arcade.color.BLACK, 24, align="center", anchor_x="center", width = Settings.width, font_name="bananaslip plus plus" ) # Generate "gum wrapper" background self.logo_width, self.small_logos_forward, self.small_logos_backward = generate_gum_wrapper(self.size)
def setup(self): super().setup() SPRITE_NAME = "scott" SPRITE_ANIM = "idle" self.sprite = sprite_from_adobe(SPRITE_NAME, ("bottom", "left")) self.sprite.fps = 24 self.sprite.bottom = 0 self.sprite.left = 0 self.sprite.set_animation(SPRITE_ANIM) self.anims = cycle(self.sprite.animations) self.anim_label = arcade.Text(SPRITE_ANIM, Settings.width // 2, Settings.height, font_size = 24, color = arcade.color.BLACK, anchor_x="center", anchor_y="top") self.data_label = arcade.Text("", Settings.width, 0, font_size = 24, color = arcade.color.BLACK, anchor_x="right", anchor_y="bottom", multiline=True, width=Settings.width, align="right") self.fps = self.sprite.fps self.paused = False # Generate "gum wrapper" background self.logo_width, self.small_logos_forward, self.small_logos_backward = generate_gum_wrapper(self.size)
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 setup(self): self.hit_start = None self.local_time = 0 arcade.set_background_color(CharmColors.FADED_GREEN) self.main_sprites = arcade.SpriteList() # Set up main logo logo_img = img_from_resource(charm.data.images, "logo.png") logo_texture = arcade.Texture("logo", logo_img) self.logo = arcade.Sprite(texture=logo_texture) self.logo.scale = 1 / 3 self.logo.center_x = self.size[0] // 2 self.logo.bottom = self.size[1] // 2 self.main_sprites.append(self.logo) self.egg_roll = random.randint(1, 1000) if self.egg_roll == 666: # it's tricky self.splash_text = "" self.splash_label = arcade.Text("CLOWN KILLS YOU", font_name='Impact', font_size=48, start_x=self.window.width // 2 + 100, start_y=self.window.height // 2, anchor_x='center', anchor_y='top', color=arcade.color.RED + (0xFF,)) else: self.splash_text = random.choice(pkg_resources.read_text(charm.data, "splashes.txt").splitlines()) self.splash_label = arcade.pyglet.text.Label("", font_name='bananaslip plus plus', font_size=24, x=self.window.width // 2, y=self.window.height // 2, anchor_x='left', anchor_y='top', color=CharmColors.PURPLE + (0xFF,)) # Generate "gum wrapper" background self.logo_width, self.small_logos_forward, self.small_logos_backward = generate_gum_wrapper(self.size) # Song details self.song_label = arcade.pyglet.text.Label("Run Around The Character Code!\nCamellia feat. nanahira\n3LEEP!", width=540, font_name='bananaslip plus plus', font_size=16, x=5, y=5, anchor_x='left', anchor_y='bottom', multiline=True, color=CharmColors.PURPLE + (0xFF,)) self.song_label.original_x = self.song_label.x self.song_label.x = -self.song_label.width # Press start prompt self.press_label = arcade.pyglet.text.Label("<press start>", font_name='bananaslip plus plus', font_size=32, x=self.window.width // 2, y=self.window.height // 4, anchor_x='center', anchor_y='center', color=CharmColors.PURPLE + (0xFF,)) self.welcome_label = arcade.Text(f"welcome, {getpass.getuser()}!", font_name='bananaslip plus plus', font_size=14, start_x=self.window.width // 2, start_y=6, anchor_x='center', anchor_y='bottom', color=(0, 0, 0) + (0xFF,))
# this is the shooter on_draw.left_leg = arcade.Rectangle(100, 10, 30, 7, arcade.color.RED, 0, 80) on_draw.right_leg = arcade.Rectangle(110, 10, 30, 7, arcade.color.RED, 0, 100) on_draw.body = arcade.Rectangle(105, 25, 30, 20, arcade.color.YELLOW, 0, 90) on_draw.neck = arcade.Rectangle(207, 60, 7, 4, arcade.color.BLACK, 1, 90) on_draw.head = arcade.Circle(210, 82, 10, arcade.color.BLACK, 3) on_draw.left_arm = arcade.Rectangle(170, 20, 30, 5, arcade.color.BLACK, 2, 70) on_draw.right_arm_1 = arcade.Rectangle(210, 50, 15, 5, arcade.color.BLACK, 2, 50) on_draw.right_arm_2 = arcade.Rectangle(220, 60, 15, 5, arcade.color.BLACK, 2, 130) # this draws the hoop on_draw.backboard = arcade.Line(730, 370, 730, 470, arcade.color.BLACK, 4) on_draw.hoop = arcade.Circle(700, 400, 30, arcade.color.DARK_GREEN, 2) # this is the text on the screen on_draw.shot_display = arcade.Text("Basketball", 50, 550, 50, arcade.color.PURPLE) # declare any variables that will move an object on_draw.ball_move_x = 2 on_draw.ball_move_y = 2 on_draw.arm_flick = -5 arcade.schedule(on_draw, 1 / 80) arcade.run()
def setup(self): super().setup() with LogSection(logger, "loading song data"): path = songspath / "fnf" / self.name self.songdata = FNFSong.parse(path) if not self.songdata: raise ValueError("No valid chart found!") with LogSection(logger, "scene"): self.scene = FNFSceneManager(self.songdata.charts[0]) self.highway_1 = self.scene.highway_1 self.highway_2 = self.scene.highway_2 self.engine = self.scene.engine self.player_sprite = self.scene.player_sprite with LogSection(logger, "loading sound"): soundfiles = [f for f in path.iterdir() if f.is_file() and f.suffix in [".ogg", ".mp3", ".wav"]] trackfiles = [arcade.load_sound(f) for f in soundfiles] self.tracks = TrackCollection(trackfiles) self.window.theme_song.volume = 0 with LogSection(logger, "loading text"): self.song_time_text = arcade.Text("??:??", (self.size[0] // 2), 10, font_size=24, anchor_x="center", color=arcade.color.BLACK, font_name="bananaslip plus plus") self.score_text = arcade.Text("0", (self.size[0] // 2), self.size[1] - 10, font_size=24, anchor_x="center", anchor_y="top", color=arcade.color.BLACK, font_name="bananaslip plus plus") self.judge_text = arcade.Text("", (self.size[0] // 2), self.size[1] // 2, font_size=48, anchor_x="center", anchor_y="center", color=arcade.color.BLACK, font_name="bananaslip plus plus") self.grade_text = arcade.Text("Clear", (self.size[0] // 2), self.size[1] - 135, font_size=16, anchor_x="center", anchor_y="center", color=arcade.color.BLACK, font_name="bananaslip plus plus") self.pause_text = arcade.Text("PAUSED", (self.size[0] // 2), (self.size[1] // 2), font_size=92, anchor_x="center", anchor_y="center", color=arcade.color.BLACK, font_name="bananaslip plus plus") self.dead_text = arcade.Text("DEAD.", (self.size[0] // 2), (self.size[1] // 3) * 2, font_size=64, anchor_x="center", anchor_y="center", color=arcade.color.BLACK, font_name="bananaslip plus plus") with LogSection(logger, "loading gum wrapper"): # Generate "gum wrapper" background self.logo_width, self.small_logos_forward, self.small_logos_backward = generate_gum_wrapper(self.size) with LogSection(logger, "finalizing"): self.last_camera_event = CameraFocusEvent(0, 2) self.last_spotlight_position = 0 self.last_spotlight_change = 0 self.go_to_spotlight_position = 0 self.spotlight_position = 0 self.hp_bar_length = 250 self.key_state = [False] * 4 self.player_sprite.set_animation("BF idle dance") self.player_sprite.scale = 0.5 self.player_sprite.right = Settings.width - 10 self.player_sprite.bottom = 10 self.player_anim = None self.player_anim_missed = False self.paused = False self.show_text = True self.success = True
on_draw.m_rectangle = arcade.Rectangle(400, 300, 27, 18, arcade.color.KOMBU_GREEN) on_draw.m_rectangle.change_x = 3 on_draw.m_rectangle.change_y = -3 on_draw.m_square = arcade.Square(50, 50, 27, arcade.color.LANGUID_LAVENDER, 6, 45) on_draw.m_square.change_y = 5 shapes = [on_draw.m_square, on_draw.m_rectangle, on_draw.m_circle] on_draw.point = arcade.Point(90, 90, 25, arcade.color.FOREST_GREEN) on_draw.point.change_y = .5 shapes.append(on_draw.point) on_draw.text = arcade.Text("Hello!!", 250, 300, 100, arcade.color.CHESTNUT) shapes.append(on_draw.text) on_draw.triangle = arcade.Triangle(40, 99, 100, 50, 55, 150, arcade.color.MAROON) on_draw.triangle.change_x = 2 on_draw.triangle.change_y = 4 shapes.append(on_draw.triangle) points = ([19, 24], [33, 107], [15, 66], [100, 75], [100, 90]) on_draw.polygon = arcade.Polygon(points, arcade.color.CYAN) on_draw.polygon.change_x = 6 on_draw.polygon.change_y = 2 shapes.append(on_draw.polygon) on_draw.parabola = arcade.Parabola(300, 450, 390, 50, arcade.color.INDIGO, 14)