import curses
import time
import math

def main(stdscr):
    curses.curs_set(0)      
    stdscr.nodelay(True)                  
    stdscr.timeout(50)                    

    curses.start_color()
    curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_YELLOW)
    curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK)

    text = "  HW in making DemoScene  "
    width = curses.COLS
    pos = width

    t = 0  # time counter for sine wave

    while True:
        stdscr.clear()
        height, width = stdscr.getmaxyx()

        # Sine wave vertical offset
        wave_y = int((math.sin(t) + 5) + (height // 2))

        # Choose color based on wave position
        if (t // 5) % 3 == 0:
            color = curses.color_pair(1)
        elif (t // 5) % 3 == 1:
            color = curses.color_pair(2)
        else:
            color = curses.color_pair(3)

        # Draw text with wave effect
        if 0 <= pos < width:
            stdscr.attron(color)
            try:
                stdscr.addstr(wave_y, pos, text)
            except curses.error:
                pass
            stdscr.attroff(color)

        # Update position and wave
        pos -= 1
        t += 0.2  # speed of wave oscillation

        if pos < -len(text):
            pos = width

        stdscr.refresh()
        time.sleep(0.05)

        key = stdscr.getch()
        if key == ord('q'):
            break

curses.wrapper(main)

