예제 #1
0
def CalcFps():
	global current_fps
	Background.CalcPositions()
	while is_game_running:
		if Player.is_player_moving:
			Background.CalcPositions()
		Background.Display(screen)
		Player.Display(screen)
		Display.Display(screen)
		pygame.display.flip()
		current_fps+=1
		if is_game_paused == True:
			while ResumeGame() == None:
				timing.tick()
예제 #2
0
def Fps():
    global current_fps
    #Initialisation des modules:
    while is_tps_init_finished == False:
        time.sleep(0.01)
    Player.DisplayInit(screen_size)
    Background.Init(screen_size)
    World.PostInit(Background.GetBackgroundBlockNumber())
    Display.Init()
    while is_game_running:
        if Player.is_player_moving:
            Background.CalcPositions()
        Background.Display(screen)
        Player.Display(screen)
        Display.Display(screen, screen_size)
        pygame.display.flip()
        current_fps += 1
        if is_game_paused == True:
            while ResumeGame() == None:
                timing.tick()
예제 #3
0
        #while datetime.timestamp(datetime.now()) < next_tick:
        #	timing.tick()
        time.sleep(next_tick - datetime.timestamp(datetime.now()) -
                   tick_time_fix)


calc_perf()
#DoTick()
timer_tick = threading.Timer(0.1, DoTick)
timer_tick.start()

#Boucle principale
while is_game_running:
    #On définit le fond de l'écran
    #screen.fill(screen_color)
    Background.Display(screen)
    Player.Display(screen)

    #Lecture des évènements d'entrée
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            is_game_running = False
        elif event.type == pygame.KEYDOWN:
            Player.EventManager(event)
            Background.EventManager(event)
            if event.key == pygame.K_p:
                ShowMessage("Jeu en pause", 100, "arial", "red", 500, 200)
                ShowMessage("Appuyez sur une touche pour continuer...", 20,
                            "arial", "red", 500, 300)
                is_game_paused = True
        elif event.type == pygame.KEYUP: