0

I need help with beginner level of python

import pygame import sys import math # Initialize pygame pygame.init() # Set up the screen WIDTH, HEIGHT = 800, 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Bubbles Simulation") # Colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) BLUE = (0, 0, 255) # Parameters circle_radius = 200 bubble_radius = 10 bubble_gap = 10 bubble_speed = 2 num_bubbles = 1000 # Function to draw the circle def draw_circle(): pygame.draw.circle(screen, BLACK, (WIDTH // 2, HEIGHT // 2), circle_radius, 2) # Function to draw bubbles def draw_bubbles(bubbles): for bubble in bubbles: pygame.draw.circle(screen, WHITE, (bubble[0], bubble[1]), bubble_radius) # Main function def main(): # Initial positions of bubbles bubbles = [(WIDTH // 2, HEIGHT // 2 + circle_radius - bubble_radius - bubble_gap * i) for i in range(num_bubbles)] # Main loop while True: screen.fill(WHITE) draw_circle() draw_bubbles(bubbles) # Pop-in blac

24th Apr 2024, 5:30 PM
codeman days
codeman days - avatar
7 Antworten
+ 4
you can only import modules that are installed. sololearn Python playground is a sandbox. it does not support interactivity or gui.
24th Apr 2024, 5:35 PM
Lisa
Lisa - avatar
+ 2
yes, it means that pygame is probably not installed. even if we installed it, it wouldn't help us because the Python playground does not allow for GUI and interactivity. "sandbox" means that the playground only has limited features compared to a complete local installation on your computer.
24th Apr 2024, 6:22 PM
Lisa
Lisa - avatar
0
I keep getting error messages no matter where I go to try to input the code I went to Python 3 I just found this page and so far I've tried python I've tried Java I've tried a bunch of different ones to see if any of those work I went back to chat GPT and asked it what to do and it told me to install pie game I tried that it wouldn't accept pie game on Python 3 and it doesn't look like this app except pie game either
24th Apr 2024, 5:32 PM
codeman days
codeman days - avatar
0
So what I'm trying to do is make a model in motion showing the bubble transfer. The chatgpt seems to fully understand my requests for the end product but finding a player to see the code play on has been a 6 hour pulling my hair out issue already. I barely ran into the code section of solo learn. I'm not really wanting to learn any new language. Instead I've taught chatgpt my own 1-111 code as a language where it doesn't have to use words at all. It's still using them though and shouldn't be. Ignore what I say you don't want to deal with and help me get my model in view so I can make millions more Also are any of the players /builder interactive? Do any of them play motion videos like Julius? Julius wanted money from me.
24th Apr 2024, 5:42 PM
codeman days
codeman days - avatar
0
you can only import modules that are installed. sololearn Python playground is a sandbox. it does not support interactivity or gui. What's that mean? Pygane will not install in the sandbox? Do I need to put pip install pygame? Then the program?
24th Apr 2024, 6:17 PM
codeman days
codeman days - avatar
0
codeman days, I tried this code on pydroid 3 - it's python 3 for android, it's easy enough to use, it has a lot of libraries, including pygame, and if something is missing, it can be easily imported. So, this code throws an error on the line 52, in main: bubbles[i] = (bubbles[i][0], bubbles[i][1] - bubble_speed) IndexError: list index out of range If this cycle is forcibly interrupted, then you will see a partial operation of this code. You can do this here, just mark all the commands related to pygame and print bubbles: https://sololearn.com/compiler-playground/ckl6A8uM821A/?ref=app
25th Apr 2024, 11:38 AM
Solo
Solo - avatar