[Python] I can't make sine wave visible [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    import pygame as pg
    import sys as sy
    import numpy as np

    game = True

    width = 900
    height = 600
    screen = pg.display.set_mode((width, height))
    pg.display.set_caption("UCBG")
    def main_menu():
    while game:
    screen.fill((0, 0, 0))
    pg.font.init()
    font = pg.font.SysFont("freemonospaced", 35)
    font_surf = font.render("UCBG", True, (255, 255, 255))
    screen.blit(font_surf, (width / 2 - 50, height / 2 - 100))
    # sine wave
    Ys = []
    t = 0
    r = 100
    xs, ys = 0, 540
    xs += (r * np.cos(t))
    ys += (r * np.sin(t))
    Ys.insert(0, ys)
    if len(Ys) > width:
    Ys.pop()
    for i in range(len(Ys)):
    pg.draw.circle(screen, (255,0,0),(i, Ys), 1, 1)

    t += 0.01

    pg.display.update()
    for e in pg.event.get():
    if e.type == pg.QUIT:
    sy.exit()
    main_menu()



    I thought that text would be in front of the sine wave and sine would just be the background but only text shows up. I tried re-arranging the code block but that didn't work. I'm clueless and it's my first time do a project in pygame withput guides.

    Continue reading...

Compartilhe esta Página