Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Please help.
-
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)```
-
@Slimebot32 the traceback
if self.ship.intersects(self.meteor): AttributeError: '_scene2.SpriteNode' object has no attribute 'intersects'
explains that a SpriteNode does not have an attribute intersects..., only the Scene.Rect has it.
-
@Slimebot32 See here
if self.ship.frame.intersects(self.meteor.frame):
-
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)```
-
What do you think exit() is doing?
In particular, what module does it belong to?Neither Scene nor
scene
have an exit function. If you want to end the scene, try scene.view.close(). -
Quicker than me (just wake up), I wanted to post this link