import arcade import assets import gamestate import renderers import controls import text SCREEN_WIDTH = 256 SCREEN_HEIGHT = 224 class Game(arcade.Window): def __init__(self): super().__init__( SCREEN_WIDTH, SCREEN_HEIGHT, "Defeat the Party", resizable=True, ) self.screen_width = SCREEN_WIDTH self.screen_height = SCREEN_HEIGHT self.mosaic = 1 self.mos_enabled = False self.game_texture = self.ctx.texture( (SCREEN_WIDTH, SCREEN_HEIGHT), components=4, ) self.game_texture.filter = (self.ctx.NEAREST, self.ctx.NEAREST) self.framebuffer = self.ctx.framebuffer( color_attachments=[self.game_texture], ) self.renderer = renderers.TextureRenderer(self.ctx) def on_update(self, dt): gamestate.update(game, dt) controls.update() def on_key_press(self, symbol, modifiers): controls.key_press(symbol) def on_key_release(self, symbol, modifiers): controls.key_release(symbol) def on_draw(self): self.framebuffer.use() self.framebuffer.clear() self.ctx.viewport = (0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) gamestate.draw(self) self.use() self.clear() self.ctx.viewport = (0, 0, self.width, self.height) scale = max( 1, min( self.width // SCREEN_WIDTH, self.height // SCREEN_HEIGHT, ), ) scaled_width = SCREEN_WIDTH * scale scaled_height = SCREEN_HEIGHT * scale x = (self.width - scaled_width) // 2 y = (self.height - scaled_height) // 2 self.renderer.render( self.game_texture, x, y, scaled_width, scaled_height, self.mosaic, self.mos_enabled ) game = Game() arcade.run()