I’m making a basic game (I’m new to python) and am wondering why the app freezes when I try to run this code.
import time
import random
from scene import *
class MyScene (Scene):
def setup(self):
self.background_color = '#6F6'
self.ship = SpriteNode('spc:PlayerShip3Green')
self.ship.position = self.size / 3
self.add_child(self.ship)
self.meteor = SpriteNode('spc:MeteorGrayBig4')
while True:
self.meteor.position = random.randint(0, 1000), random.randint(0, 750)
self.add_child(self.meteor)
time.sleep(1)
def touch_moved(self, touch):
x, y = touch.location
move_action = Action.move_to(x, y, 0.3)
move_action2 = Action.move_to(x, y, 1)
self.ship.run_action(move_action)
self.meteor.run_action(move_action2)
run(MyScene(), show_fps=True)