-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreen.py
More file actions
46 lines (36 loc) · 1.12 KB
/
screen.py
File metadata and controls
46 lines (36 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pygame
import time
WIDTH = 64
HEIGHT = 32
SCALE = 15
class Screen:
def __init__(self):
pygame.init()
self.framebuffer = [[0 for x in range(64)] for x in range(32)]
self.screen = pygame.display.set_mode((WIDTH*SCALE,HEIGHT*SCALE), flags=pygame.RESIZABLE)
pygame.display.set_caption("Chip 8 emulator")
self.screen.fill((255,255,255))
pygame.display.flip()
def draw(self):
self.screen.fill((255,255,255))
for y in range(HEIGHT):
for x in range(WIDTH):
if self.framebuffer[y][x]:
rect = pygame.Rect(x*SCALE, y*SCALE, SCALE, SCALE)
pygame.draw.rect(self.screen, (0,0,0), rect)
pygame.display.flip()
def main():
pass
disp = Screen()
for y in range(HEIGHT):
for x in range(WIDTH):
if (x + y) % 2 == 0:
disp.framebuffer[y][x] = 1
disp.draw()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if __name__ == "__main__":
main()