• Slimebot32

    Thanks a lot, but the game keeps starting back up afterwards, any idea on why?

    d = input('enter the difficulty (0 to 100)')
    import time
    import random
    mn = 0
    from scene import *
    
    class game (Scene):
        def setup(self):
            self.background_color = '#000'
            self.ship = SpriteNode('spc:PlayerShip3Green')
            self.meteor = SpriteNode('spc:MeteorGrayMed1')
            self.star = SpriteNode('spc:Star2')
            self.ship.position = self.size / 3
            self.add_child(self.ship)
            if self.ship.frame.intersects(self.meteor.frame):
                exit()
    
            while random.randint(0,100) != 32:
                self.star = SpriteNode('spc:Star2')
                self.star.position = random.randint(0, 1000), random.randint(0,750)
                self.add_child(self.star)
                if self.ship.frame.intersects(self.meteor.frame):
                    exit()
    
        def spawn_meteor(self):
            self.meteor = SpriteNode('spc:MeteorGrayMed1')
            self.add_child(self.meteor)
            self.meteor.position = random.randint(0, 1000), random.randint(0, 750)
            if self.ship.frame.intersects(self.meteor.frame):
                exit()
            
        def update(self):
            if random.randint(0, 100 - int(d)) == 0:
                self.spawn_meteor()
            if self.ship.frame.intersects(self.meteor.frame):
                exit()
        
        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)
            if self.ship.frame.intersects(self.meteor.frame):
                exit()
            
    run(game(), show_fps=True)```

    posted in Pythonista read more
  • Slimebot32

    Can anyone tell me what im doing wrong here?

    d = input('enter the difficulty (0 to 100)')
    import time
    import random
    mn = 0
    from scene import *
    
    class game (Scene):
        def setup(self):
            self.background_color = '#000'
            self.ship = SpriteNode('spc:PlayerShip3Green')
            self.meteor = SpriteNode('spc:MeteorGrayMed1')
            self.star = SpriteNode('spc:Star2')
            self.ship.position = self.size / 3
            self.add_child(self.ship)
    
            while random.randint(0,100) != 32:
                self.star = SpriteNode('spc:Star2')
                self.star.position = random.randint(0, 1000), random.randint(0,750)
                self.add_child(self.star)
    
        def spawn_meteor(self):
            self.meteor = SpriteNode('spc:MeteorGrayMed1')
            self.add_child(self.meteor)
            self.meteor.position = random.randint(0, 1000), random.randint(0, 750)
            
        def update(self):
            if random.randint(0, 100 - int(d)) == 0:
                self.spawn_meteor()
            if self.ship.intersects(self.meteor):
                exit()
        
        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(game(), show_fps=True)```

    posted in Pythonista read more
  • Slimebot32

    Thanks, how do you add_child for a set()?

    posted in Pythonista read more
  • Slimebot32

    Thanks! I’m also wondering how to make multiple children of meteor at once, is this possible?

    import time
    import random
    from scene import *
    
    class game (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:MeteorGrayMed1')
        def spawn_meteor(self):
            self.add_child(self.meteor)
            self.meteor.position = random.randint(0, 1000), random.randint(0, 750)
            
        def update(self):
            if random.randint(0, 100) == 1:
                self.spawn_meteor()
        
        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(game(), show_fps=True)```

    posted in Pythonista read more
  • Slimebot32

    Sorry, but I’m confused why spawn_meteor says it isn’t defined

    import time
    import random
    from scene import *
    
    class game (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:MeteorGrayMed1')
        def spawn_meteor():
            self.add_child(self.meteor)
            self.meteor.position = random.randint(0, 1000), random.randint(0, 750)
            
        def update(self):
            if random.randint(0, 1000) == 1:
                spawn_meteor()
        
        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(game(), show_fps=True)```

    posted in Pythonista read more
  • Slimebot32

    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)
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!