def cleanup(): if font is not None: sdl.ttf.closeFont(font) if music is not None: sdl.mixer.freeMusic(music) if renderer is not None: sdl.destroyRenderer(renderer) if window is not None: sdl.destroyWindow(window) sdl.ttf.quit() sdl.mixer.closeAudio() sdl.quit()
def main(): """Prepare the display, load images, and get our programming running.""" global IMAGES, window, renderer os.environ["SDL_VIDEO_CENTERED"] = "True" sdl.init(sdl.INIT_VIDEO) try: window = sdl.createWindow(CAPTION.encode('utf-8'), sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, SCREEN_SIZE[0], SCREEN_SIZE[1], 0) window = sdl.Window(window) renderer = sdl.Renderer(sdl.createRenderer(window, -1, 0)) IMAGES = load_resources() Control().main_loop() finally: sdl.quit()
# Run it... from __future__ import absolute_import import tmxrender try: tmxrender.run() finally: import sdl sdl.quit()
def quit(self): self.renderer.destroyRenderer() self.window.destroyWindow() sdl.quit()
white = surface.map_rgb((255, 255, 255)) black = surface.map_rgb((0, 0, 0)) while state != -1: e = sdl.events_poll() if e != -1: if e.get_type() == sdl.QUIT or e.get_type() == sdl.KEYDOWN: state = -1 continue for star in stars: surface.set_at(star[POS][X], star[POS][Y], black) star[POS][X] = star[POS][X] + star[VEL][X] star[POS][Y] = star[POS][Y] + star[VEL][Y] if (not (0 < star[POS][X] < w)) or (not (0 < star[POS][Y] < h)): star[POS][X] = cx star[POS][Y] = cy star[VEL][X] = math.sin((random.random() * 7) - 3) * 5 star[VEL][Y] = math.sin((random.random() * 7) - 3) * 5 surface.set_at(star[POS][X], star[POS][Y], white) surface.update_rect((0, 0, w, h)) sdl.quit()