def gameStart(): """use new or load to get the game going then hit the game loop soon after.""" visuals.start() actors.newPlayer() #for FPS counting timeStart = time.clock() clock = pygame.time.Clock() #__main loop__: global gameRunning gameRunning = True print 'player pos before mainloop', actors.player.rect.center #print '----- LOOP START -----' while gameRunning: visuals.screen.fill(visuals.WHITE) #extra lines drawCrossScreen() if stats.lineDraw: tools.inWhichGrid(actors.player, allGrids) pygame.draw.line(visuals.screen, visuals.RED, actors.player.getPos(), (200, 200), 10) #print 'player direction', actors.player.direction eventHandler() textDisplays() #loop over: men, bullets and shrapnel, AIs for object in MEN: object.shooter.getTarget() object.move() object.drawFrame() #a = object.calcAngle(RIGHT,(0.84996560382278508, -0.52683818418767669)) #object.doRotate(a) for object in BULLETS: object.update() for object in SHRAPNEL: object.update() for ai in AIs: ai.check() #FPS stuff stats.frame_count += 1 if stats.frame_count % 15 == 0: timeEnd = time.clock() stats.frame_rate = 15 / (timeEnd - timeStart) timeStart = timeEnd text = 'Frame = {0}, rate = {1:.2f} fps'.format(stats.frame_count, stats.frame_rate) fps_text = visuals.basicFont.render(text, True, (0,0,0)) visuals.screen.blit(fps_text, (10, 10)) stats.frame_history.append(text) visuals.pygame.display.flip() clock.tick(stats.FRAMERATE) sys.stdout.flush() ##print 'game running' ##testing for pos changed #print 'end loop:' #print '--original:', actors.player.originalXY #print '--rect:', actors.player.rect.center #print '--current:', actors.player.pos pygame.quit() print 'tried to quit'
#print '--rect:', actors.player.rect.center #print '--current:', actors.player.pos pygame.quit() print 'tried to quit' if __name__ == '__main__': """Run the following if module is top module""" #starts pygame visuals.start() #for FPS counting timeStart = time.clock() clock = pygame.time.Clock() #main loop: gameRunning = True while gameRunning: visuals.screen.fill(visuals.WHITE) #loop over: men, bullets and shrapnel, AIs for object in MEN: object.move() object.drawFrame()