orb.py

Created by wperez274

Created on September 19, 2023

1.06 KB


# Type your text herefrom kandinsky import *
from kandinsky import *
from time import sleep

from turtle import color
# Define screen dimensions
WIDTH = 320
HEIGHT = 222

# Initialize rectangle properties
rect_width = 20
rect_height = 20
rect_color = color(255, 0, 0)  # Red

# Define initial position and variables for circular motion
center_x = WIDTH // 2
center_y = HEIGHT // 2
radius = 50
angle = 0
angular_speed = 0.02  # Adjust this for speed of rotation

# Main loop
while True:
    # Clear the screen
    fill_rect(0, 0, WIDTH, HEIGHT, color(255, 255, 255))  # Fill with white background

    # Calculate new position of the rectangle
    x = center_x + int(radius * cos(angle))
    y = center_y + int(radius * sin(angle))

    # Draw the rectangle at the new position
    fill_rect(x - rect_width // 2, y - rect_height // 2, rect_width, rect_height, rect_color)

    # Update the angle for the circular motion
    angle += angular_speed

    # Delay for a short time to control animation speed (you may need to adjust this)
    sleep(0.02)  # Sleep for 100 milliseconds

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.