I am starting to learn Arcade and I had trouble running the following simple script on a new M2 MacBook. The loop never runs. Funny thing is that it runs without the while loop. The code runs smoothly both on my windows PC and my old Mac (both using the same python version). I am completely clueless as to what the issue might be. Could it be the new chip?
import arcade
import random
class Ball:
def __init__(self):
self.x = 0
self.y = 0
self.size = 5
self.color = [10,0,0]
def create(self):
arcade.draw_circle_filled(self.x, self.y, self.size, self.color)
arcade.open_window(800,800,'ball')
arcade.set_background_color(arcade.color.WHITE)
arcade.start_render()
ball_1 = Ball()
while True:
random_x = random.randrange(0, 800)
random_y = random.randrange(0, 800)
random_color_1 = random.randrange(0, 256)
random_color_2 = random.randrange(0, 256)
random_color_3 = random.randrange(0, 256)
random_color = [random_color_1,random_color_2, random_color_3]
ball_1.x = random_x
ball_1.y = random_y
ball_1.color = random_color
ball_1.size = random.randrange(10, 30)
ball_1.create()
arcade.finish_render()
arcade.run()
Try using
classapproach (which is recommended way to buildarcadeapps — see starting template):