def __init__(self, width, height, displaySurface): self.rendering = True self._display_surf = displaySurface self.overlay = overlay.Overlay(width, height) self.stars = stars.Stars(width, height) self.now = 0 self.regenerate_stars_trigger = 1
def __init__(self, main): self.main = main self.player = player.Player(self) self.projectiles = Projectiles(self) self.stars = stars.Stars(self) self.speed = 2
def initialize(size, fullscreen): global surface, rect, starobj try: flags = 0 if fullscreen: flags |= FULLSCREEN #depth = pygame.display.mode_ok(size, flags, 16) surface = pygame.display.set_mode(size, flags) #, depth) rect = surface.get_rect() pygame.mouse.set_visible(0) if surface.get_bytesize() == 1: loadpalette() except pygame.error as msg: raise pygame.error('Cannot Initialize Graphics') starobj = stars.Stars()
try: flags = 0 if fullscreen: flags |= FULLSCREEN #depth = pygame.display.mode_ok(size, flags, 16) surface = pygame.display.set_mode(size, flags) #, depth) rect = surface.get_rect() pygame.mouse.set_visible(0) if surface.get_bytesize() == 1: loadpalette() except pygame.error, msg: raise pygame.error, 'Cannot Initialize Graphics' + str(msg) starobj = stars.Stars() def switchfullscreen(): oldfull = surface.get_flags() & FULLSCREEN == FULLSCREEN newfull = game.display == 1 if newfull == oldfull: return global wantscreentoggle wantscreentoggle = 1 def dirty(rect): dirtyrects.append(rect)
# Setup display and initialise pi3d DISPLAY = pi3d.Display.create( x=50, y=50, near=0.05, far=100000, frames_per_second=20, samples=4) #note big far and small near plane values DISPLAY.set_background(0, 0, 0, 1) # black! CAM = pi3d.Camera() CAM2D = pi3d.Camera(is_3d=False) flatsh = pi3d.Shader("uv_flat") matsh = pi3d.Shader("mat_flat") target = pi3d.Sprite(camera=CAM2D, z=5.0, w=50, h=50) target.set_draw_details(flatsh, [pi3d.Texture("textures/target.png")]) import stars # tucked away in another file for tidyness! s = stars.Stars() font = pi3d.Font('fonts/NotoSans-Regular.ttf') name_loc = s.v[list( s.names)] # this will be a view of the full array, only for named stars label = pi3d.String(font=font, string='Sol', y=-250, is_3d=False, camera=CAM2D) label.set_shader(flatsh) t = threading.Thread(target=s.select_visible) # run in infinite loop t.daemon = True t.start() while not s.ready: # to ensure stars set up first time in select_visible time.sleep(0.1) ''' constelation lines ''' orion = [