from math import * from random import * from kandinsky import * from ion import * from time import * WIDTH = 320 HEIGHT = 222 rect_width = 20 rect_height = 20 rect_color = color(255, 0, 0) frequency = 5 amplitude = 60 x = WIDTH - rect_width y = HEIGHT - rect_height - 18 BG=(0,0,0) fill_rect(0, 0, WIDTH, HEIGHT, BG) while x >= -rect_width and y >= -rect_height: fill_rect(0, 20, WIDTH, HEIGHT, BG) y = int(HEIGHT / 2 + amplitude * sin(2 * pi * frequency * (WIDTH - x) / WIDTH)) fill_rect(x, y, rect_width, rect_height, rect_color) # Add circular movement # circular_radius = 10 # Adjust this for the size of the circular movement # circular_speed = 0.03 # Adjust this for the speed of the circular movement # circular_x = x + int(circular_radius * cos(circular_speed * x)) # circular_y = y + int(circular_radius * sin(circular_speed * x)) # fill_rect(circular_x, circular_y, rect_width, rect_height, color(50, 0, 5)) # Blue circle x -= 1 y -= 3 if x<-20: fill_rect(0, 20, WIDTH, HEIGHT, color(255, 255, 255)) x=350 x = WIDTH - rect_width y = HEIGHT - rect_height draw_string("Amplitude: "+str(round(amplitude)),160,2,(0,255,0),(0,0,0)) draw_string("Frequency: "+str(round(frequency)),2,2,(0,255,255),(0,0,0)) if keydown(KEY_LEFT): fill_rect(0,0,322,220,BG) frequency-=0.2 if keydown(KEY_RIGHT): fill_rect(0,0,322,220,BG) frequency+=0.2 if keydown(KEY_UP): fill_rect(0,0,322,220,BG) amplitude+=0.2 if keydown(KEY_DOWN): fill_rect(0,0,322,220,BG) amplitude-=0.2 if keydown(KEY_BACKSPACE): sleep(0.2) fill_rect(0,0,322,220,BG) frequency=0 amplitude=0 sleep(0.005) fill_rect(0,120,322,2,(0,0,255)) draw_string("USE ARROWS",100,202,(255,0,0),BG)