def draw(self): for sprite in self.bullets: sprite.draw() for sprite in self.monsters: sprite.draw() self.ship.draw()
def drawAt( s, screen, sprite, objx, objy, screenRect ): # Map co-ords of screen screenx, screeny, screenw, screenh = screenRect # Sanity checks if objx < screenx or objy < screeny or objx > (screenx + screenw) \ or objy > (screeny + screenh): return objscreenx = (objx - screenx) * s.tilew objscreeny = (objy - screeny) * s.tileh sprite.draw( screen, objscreenx, objscreeny )
j += 1 i += 1 glDisable(GL_TEXTURE_2D) glPopMatrix() for e in entity.Entity.entities: # xs = list(map((lambda (x,_): x), e.vertices())) # if max(xs) < groundoffset - width / 2: # continue # if min(xs) > groundoffset + width / 2: # continue # if e.player: # account for texture-based player too # sprclass.draw(e, pos = (width / 2, height / 2)) if e.sprite: sprclass.draw(e) else: glBegin(GL_POLYGON) glColor3fv(e.colour) for x, y in e.vertices(): glVertex2f(x, y) glEnd() pygame.display.flip() endticks = pygame.time.get_ticks() delay = (FDELAY - (endticks - startticks)) #print "processing time: {}, delay: {}, bulletcount: {}" .format((endticks - startticks), delay, bulletcount) if delay > 0: pygame.time.delay(int( round(delay))) # make variable based on processing time
j += 1 i += 1 glDisable(GL_TEXTURE_2D) glPopMatrix() for e in entity.Entity.entities: # xs = list(map((lambda (x,_): x), e.vertices())) # if max(xs) < groundoffset - width / 2: # continue # if min(xs) > groundoffset + width / 2: # continue # if e.player: # account for texture-based player too # sprclass.draw(e, pos = (width / 2, height / 2)) if e.sprite: sprclass.draw(e) else: glBegin(GL_POLYGON) glColor3fv(e.colour) for x, y in e.vertices(): glVertex2f(x, y) glEnd() pygame.display.flip() endticks = pygame.time.get_ticks() delay = FDELAY - (endticks - startticks) # print "processing time: {}, delay: {}, bulletcount: {}" .format((endticks - startticks), delay, bulletcount) if delay > 0: pygame.time.delay(int(round(delay))) # make variable based on processing time