pygame.init() WIDTH = 800 HEIGHT = 800 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Testing game") clock = pygame.time.Clock() timer = 0 ended = False speed = 0 angle = 90 ts = mylibpg.SimpleText(screen, 'Vel: 0', (WIDTH - 120, HEIGHT - 90), 20, mylibpg.COLOR_RED) ta = mylibpg.SimpleText(screen, 'Angle: 90', (WIDTH - 120, HEIGHT - 50), 20, mylibpg.COLOR_RED) w = mylibpg.StaticAsset(screen, './assets/world_70.png', (WIDTH / 2, HEIGHT / 2)) asteroid = mylibpg.StaticAsset(screen, './assets/asteroid.png', (WIDTH / 2, HEIGHT * 0.1)) v = mylibpg.Vector(screen, (0, 0), 0, 90) world_asteroid = mylibpg.Locator(w, asteroid) while not ended: elapsed = clock.get_time()
pygame.init() WIDTH = 500 HEIGHT = 500 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Testing game") clock = pygame.time.Clock() timer = 0 ended = False speed = 0 w = mylibpg.StaticAsset(screen, './assets/world_70.png', (50, 200)) t = mylibpg.SimpleText(screen, 'Vel: 0', (WIDTH - 120, HEIGHT - 50), 20, mylibpg.COLOR_RED) v = mylibpg.Vector(screen, (0, 0), 0, 90) while not ended: elapsed = clock.get_time() for event in pygame.event.get(): if event.type == pygame.KEYUP: if event.key == 273: speed += 1 elif event.key == 274: speed -= 1 if event.type == pygame.QUIT: ended = True
pygame.init() WIDTH = 500 HEIGHT = 500 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Testing game") clock = pygame.time.Clock() timer = 0 ended = False t = mylibpg.SimpleText(screen, 'Testing', (30, 30), 20, mylibpg.COLOR_RED) t.set_font('./assets/Optima.ttc') while not ended: for event in pygame.event.get(): if event.type == pygame.QUIT: ended = True screen.fill(mylibpg.COLOR_BLACK) t.set_text('Time elapsed: ' + str(timer / 1000)).visualize() pygame.display.update() timer += clock.get_time() clock.tick(10)
WIDTH = 500 HEIGHT = 500 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Testing game") clock = pygame.time.Clock() timer = 0 ended = False angle = 0 v = mylibpg.Vector(screen, (WIDTH / 2, HEIGHT / 2), WIDTH * 0.35, 90, mylibpg.COLOR_WHITE) t = mylibpg.SimpleText(screen, str(angle), (10, 10), 20, mylibpg.COLOR_RED) while not ended: for event in pygame.event.get(): if event.type == pygame.KEYUP: if event.key == 273: angle += 5 elif event.key == 274: angle -= 5 if event.type == pygame.QUIT: ended = True screen.fill(mylibpg.COLOR_BLACK)