53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
# Example file showing a basic pygame "game loop"
|
|
import pygame
|
|
# pygame setup
|
|
pygame.init()
|
|
display = pygame.display.Info()
|
|
screen = pygame.display.set_mode((display.current_w, display.current_h), flags=pygame.FULLSCREEN)
|
|
clock = pygame.time.Clock()
|
|
running = True
|
|
|
|
screen.fill("black")
|
|
import sys
|
|
if len(sys.argv[1:3]) == 2:
|
|
XSTRIPE, YSTRIPE = [int(i) for i in sys.argv[1:3]]
|
|
else:
|
|
XSTRIPE = 128
|
|
YSTRIPE = 8
|
|
def mapsf(width=display.current_w, height=display.current_w):
|
|
for i in range(width*height):
|
|
sno = i // (XSTRIPE * YSTRIPE)
|
|
ord = i % (XSTRIPE * YSTRIPE)
|
|
base_x = sno % (width // XSTRIPE) * XSTRIPE
|
|
base_y = sno // (width // XSTRIPE) * YSTRIPE
|
|
sx = ord % XSTRIPE + base_x
|
|
sy = ord // XSTRIPE + base_y
|
|
yield sy * width + sx
|
|
|
|
maps = [(x%XSTRIPE)+1920*(x//XSTRIPE) for x in range(XSTRIPE*YSTRIPE)]
|
|
maps += [x+1*XSTRIPE for x in maps]
|
|
it = iter(mapsf())
|
|
#for _ in range(8*8*16*16*(15*8)+18000*5):
|
|
# next(it)
|
|
#for _ in range(8*8*16*16*(15*8)):
|
|
# next(it)
|
|
while running:
|
|
# poll for events
|
|
# pygame.QUIT event means the user clicked X to close your window
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
|
|
# fill the screen with a color to wipe away anything from last frame
|
|
|
|
# RENDER YOUR GAME HERE
|
|
|
|
# flip() the display to put your work on screen
|
|
i = next(it)
|
|
screen.set_at((i % 1920, i // 1920), 'white')
|
|
pygame.display.flip()
|
|
|
|
|
|
#clock.tick(120) # limits FPS to 60
|
|
|
|
pygame.quit()
|