Pygame
Last updated
Was this helpful?
Was this helpful?
pygame.init()
BLACK = (0, 0, 0)
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))fps_clock = pygame.time.Clock()
fps = 60.0
dt = fps_clock.tick(fps)# Initialize GumUI
myUi = GumUI()
myUi.initialize(screen) # `screen` is a Surface you wish GUM to draw to https://www.pygame.org/docs/ref/surface.htmlchild = GraphicalUiElement(InvisibleRenderable())
myUi.RootElement.Children.Add(child)
child.XUnits = Converters.GeneralUnitType.PixelsFromSmall
child.Width = 32
child.YUnits = Converters.GeneralUnitType.PixelsFromSmall
child.Height = 32while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit() myUi.update()
screen.fill(BLACK) # Fill the screen with black.
myUi.draw()
pygame.display.flip()
dt = fps_clock.tick(fps)child = GraphicalUiElement(InvisibleRenderable())
myUi.RootElement.Children.Add(child)
child.XUnits = Converters.GeneralUnitType.PixelsFromSmall
child.X = 100
child.Y = 100
child.Width = 200
child.YUnits = Converters.GeneralUnitType.PixelsFromSmall
child.Height = 200grandChild = GraphicalUiElement(InvisibleRenderable())
child.Children.Add(grandChild)
grandChild.XUnits = Converters.GeneralUnitType.PixelsFromSmall
grandChild.X = 10
grandChild.Y = 10
grandChild.Width = 100
grandChild.YUnits = Converters.GeneralUnitType.PixelsFromSmall
grandChild.Height = 100