Skip to content

Commit

Permalink
Make sure display.flip is called on windows OS
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsmile committed Feb 27, 2018
1 parent 21d808c commit 4e2dc6e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions render.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf8 -*-

import sys
import time
import pygame
import logging
Expand All @@ -18,7 +19,7 @@ def __init__(self):
pygame.display.init()
pygame.display.set_caption("tank4eta")
self.fullscreen = FULLSCREEN

self.should_flip = False
self.show_fps = False
self.fps = 0
self.ndi = pygame.display.Info()
Expand All @@ -31,6 +32,8 @@ def __init__(self):
initial=True
)
self.set_render_resolution(RESOLUTION)
if sys.platform.startswith('win'):
self.should_flip = True

def set_render_resolution(self, resolution):
if self.render_resolution == resolution:
Expand Down Expand Up @@ -59,6 +62,8 @@ def draw(self, sprites=[]):
def update(self, changed):
self.draw_fps()
pygame.display.update(changed)
if self.should_flip:
pygame.display.flip()

def draw_fps(self):
if not self.show_fps:
Expand Down Expand Up @@ -163,13 +168,13 @@ def toggle_full_screen(self, force_fullscreen_to=None, initial=False):
self.resolution = (self.ndi.current_w, self.ndi.current_h)
self.screen = pygame.display.set_mode(
self.resolution,
pygame.FULLSCREEN | pygame.HWSURFACE
pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE
)
else:
self.resolution = RESOLUTION
self.screen = pygame.display.set_mode(
self.resolution,
pygame.HWSURFACE
pygame.DOUBLEBUF | pygame.HWSURFACE
)

self.display_info = pygame.display.Info()
Expand Down

0 comments on commit 4e2dc6e

Please sign in to comment.