from math import * from random import * from random import randint as RAND from kandinsky import * from ion import * from time import * WIDTH = 320 HEIGHT = 222 rect_width = 20 rect_height = 20 rect_color = (255, 0, 0) frequency = 5 amplitude = 60 x_velocity=1 y_velocity=3 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, 40, WIDTH, HEIGHT-60, BG) y = int(HEIGHT / 2 + amplitude * sin(2 * pi * frequency * (WIDTH - x) / WIDTH)) fill_rect(x, y, rect_width, rect_height, rect_color) fill_rect(x+3, y+3, rect_width-6, rect_height-6, (RAND(80,255),0,0)) # 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 -= x_velocity y -= y_velocity if x<-20: fill_rect(0, 0, WIDTH, HEIGHT-40, BG) x=350 x = WIDTH - rect_width y = HEIGHT - rect_height draw_string("Frequency: "+str(round(frequency)),2,2,(0,255,255),(0,0,0)) draw_string("Amplitude: "+str(round(amplitude)),160,2,(0,255,0),(0,0,0)) draw_string("x_velocity: "+str(int(x_velocity)),2,18,(255,0,255),(0,0,0)) if keydown(KEY_LEFT): fill_rect(0,0,322,20,BG) frequency-=0.2 if keydown(KEY_RIGHT): fill_rect(0,0,322,20,BG) frequency+=0.2 if keydown(KEY_UP): fill_rect(0,0,322,20,BG) amplitude+=0.2 if keydown(KEY_DOWN): fill_rect(0,0,322,20,BG) amplitude-=0.2 if keydown(KEY_RIGHTPARENTHESIS): sleep(0.2) x_velocity+=1 if keydown(KEY_BACKSPACE): sleep(0.2) fill_rect(0,0,322,220,BG) frequency=0 amplitude=0 x_velocity=1 sleep(0.005) fill_rect(0,120,322,2,(0,0,255)) draw_string("USE ARROWS & [)], [Backspace = reset] ",2,205,"orange",BG)