geom-demo/geom/screen.py
Matt Low c313b3e8ba Refactors
- Move all pygame draw calls into draw module
- Scrap indvidual shape modules for single 'geom' module
- Center of screen is now 0,0
2020-11-14 21:15:47 +04:00

42 lines
1.1 KiB
Python

import pygame
from .demos import aabb, vec_proj
from . import HEIGHT
from .colors import *
from .draw import text_screen
class Screen:
def __init__(self):
self.demos = [
vec_proj.VecProj(),
aabb.AABBDistance(),
aabb.PointAABBDistance(),
]
self.demo = 0
def handle_input(self):
for event in pygame.event.get(pygame.KEYDOWN):
if event.key == pygame.K_DOWN:
self.demo += 1
if self.demo >= len(self.demos):
self.demo = 0
elif event.key == pygame.K_UP:
self.demo -= 1
if self.demo < 0:
self.demo = len(self.demos) - 1
def draw_demo_list(self, surface):
y_offset = 10
for i in range(len(self.demos)):
text_screen(surface,
CYAN if self.demo == i else WHITE,
(10, y_offset + i * 20),
self.demos[i].title)
def render(self, surface):
self.handle_input()
self.demos[self.demo].render(surface)
self.draw_demo_list(surface)