omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    fps drops rapid when "boss" SpriteNode appears

    Pythonista
    spritenode scene
    5
    12
    6848
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Bjucha
      Bjucha @JonB last edited by

      @JonB thanks I did not think of that, will try to fix it Thank you

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        Thousands of bosses... Nightmare!!

        1 Reply Last reply Reply Quote 0
        • Bjucha
          Bjucha last edited by

          @JonB Thanks the solution was simple, I just didn't see it, @ccc yeah one big bad boss is enough
          But now He needs some cool firepower. Will update you when he is ready for a fight

          1 Reply Last reply Reply Quote 0
          • Bjucha
            Bjucha last edited by

            Ok so now the fps is fixed and the boss is just one big UFO.
            But now I have a new problem(No suprise there) When the boss appears he fires one laser shot,
            but no more. What I'm trying to do is to make him fire lasers all the time (after all he is the boss) but I cant call such a function from update() since the boss is a class and not in the gamefield,
            My question: Is there a way in update() to point to spawn:boss() function (or is there a way inside the that function to create something that update all the time)
            Sorry for the long post, basically: how do my boss keep firing until he is removed from scene?

            1 Reply Last reply Reply Quote 0
            • omz
              omz last edited by

              @Bjucha You could make the boss a property of your scene (i.e. set self.boss = ... when you spawn it). That way, the boss could have a last_shot_time property, you check that in update, and if it's bigger than, say, 1 second, you set last_shot_time to the current time, and fire a shot.

              Bjucha 1 Reply Last reply Reply Quote 0
              • Bjucha
                Bjucha @omz last edited by

                @omz hmm I really sorry but I don't really understand. what do you mean with property of my scene? and shall that property be inside the spawn_boss()
                function? or in the gamefield?

                1 Reply Last reply Reply Quote 0
                • ccc
                  ccc last edited by ccc

                  def spawn_boss(self):
                      self.boss = Boss(parent=self, position = (100, 600))
                  
                  1 Reply Last reply Reply Quote 0
                  • Bjucha
                    Bjucha last edited by

                    Haven't been able to get it to work yet, but Im currently trying a different approach that could work.

                    1 Reply Last reply Reply Quote 0
                    • flight_714
                      flight_714 last edited by

                      I realize this is a few weeks old, but had a few thoughts.

                      I typically add scene objects of a shared type to a list and then iterate over a method of their class in update.

                      So at the end up the enemy class init I would add 'enemies.append(self)' and then in the scene update method add 'for enemy in enemies': enemy.cooldown() or something to that to that effect.

                      Obviously, you'd have to write a bit more AI methods for the enemy ships, so you'd probably want to subclass them to save space.

                      Bjucha 1 Reply Last reply Reply Quote 0
                      • Bjucha
                        Bjucha @flight_714 last edited by

                        @flight_714

                        Thanks for the tip. I did get it to work by using

                        counter = 10 
                        		while counter != 0:
                        			Action.wait(2)
                        			self.items.append(boss)
                        			bossfires = SpriteNode('spc:BoltBronze', parent=self)
                        			bossfires.position = boss.position + (-50, 30)
                        			bossfires.z_position = -1
                        			b = random.uniform(10.0, 2500)
                        			actions = [A.move_to(b, 100, 2 * 2), A.remove()]
                        																
                        			bossfires.run_action(A.sequence(actions))
                        			self.bossfires.append(bossfires)
                        			Action.wait(2)
                        			counter = counter - 1```
                        
                        This works but is not really "perfect" for me. But will look at what you suggested and see if I can use it.
                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB Forums | Contributors