|
|
|
|
@ -69,10 +69,14 @@ class GameWindow:
|
|
|
|
|
self.renderer.copy(sprite, dstrect=sprite.position) |
|
|
|
|
|
|
|
|
|
def draw_image(self, x, y, sprite, tag, anchor="nw"): |
|
|
|
|
if not self.is_in_visible_area(x, y): |
|
|
|
|
return |
|
|
|
|
sprite.position = (x+self.w_offset, y+self.h_offset) |
|
|
|
|
self.renderer.copy(sprite, dstrect=sprite.position) |
|
|
|
|
|
|
|
|
|
def draw_rectangle(self, x, y, width, height, tag, outline="red", filling=None): |
|
|
|
|
if not self.is_in_visible_area(x, y): |
|
|
|
|
return |
|
|
|
|
x, y = x + self.w_offset, y + self.h_offset |
|
|
|
|
if filling: |
|
|
|
|
self.renderer.fill((x, y, width, height), sdl2.ext.Color(*filling)) |
|
|
|
|
@ -106,6 +110,9 @@ class GameWindow:
|
|
|
|
|
def full_screen(self,flag): |
|
|
|
|
sdl2.SDL_SetWindowFullscreen(self.window.window, flag) |
|
|
|
|
|
|
|
|
|
def is_in_visible_area(self, x, y): |
|
|
|
|
return -self.w_offset <= x <= self.width - self.w_offset and -self.h_offset <= y <= self.height - self.h_offset |
|
|
|
|
|
|
|
|
|
def mainloop(self, **kwargs): |
|
|
|
|
while self.running: |
|
|
|
|
performance_start = sdl2.SDL_GetPerformanceCounter() |
|
|
|
|
|