• JonB

    You cannot change the settings app setting from pythonista.

    The function disables the idle timer for pythonista only (and only for this launch) so that your script will not be interrupted by going to sleep.

    posted in Pythonista read more
  • JonB

    So you have code which is moving your laser, but it is only running once?

    Go back and look at all of your code to see if your indentation is correct. If you want laser movement code to run every update cycle, and it isn't, there must be some control code (if, for, with, while, etc ) that is preventing it from running.

    What will help you in this case is to break your update function into functions that you call, so that you can better follow the program flow. Once an indented section of code gets to be longer than a screenfull, that's a good indication that you might need a function.

    For instance, if each button had it's own method. Or, if all of your touch handling had it's own method. Then your update method would be easier for you to follow:

    def update (self):
       handleTouches(self)
       moveLasers(self)
       checkCollisions(self)
       spawnEnemies(self)
    

    posted in Pythonista read more
  • JonB

    No. Trying the Socratic method to get him to think about his own code...

    This would be simpler if the touch code and laser update code were their own functions, as they are completely independent. The fact that he shares a direction variable name is what is confusing him.

    The touch code creates a laser. The laser created is spawned, and the code that sets the rotation and initial offset.

    The code that moves the lasers is completely separate (one needn't have touch code at all to move laser objects). Lasers move even when buttons are not touched. So, how can you figure out what direction a given laser should travel?

    posted in Pythonista read more
  • JonB

    @BurntRice okay, so

    l.position += direction*75
    

    Let's think about this for a minute. Where have you defined direction? Remember, the goal here in the movement code is to figure out the direction for EACH laser that you are moving. So, you need to figure out the direction Vector2 based on each laser's rotation.

    posted in Pythonista read more
  • JonB

    Post your code. The last version you posted had the laser motion code INSIDE the touch handling code, which means the code would only execute when the fire button was being pressed.

    posted in Pythonista read more
  • JonB

    Move the for l in self.lasers loop to the proper indentation level. This should not be inside any of the touch handling code.

    You will then use the l.rotation to set the motion direction.

    Also, you will eventually need code that deletes lasers once they are off screen ( in that loop, check if laser.bbox is in self.bbox)

    posted in Pythonista read more
  • JonB

    For doing 1:1 character replacements, maketrans plus translate makes for clean code. You list all the characters you are replacing in one string, all the replacements in the second, and all the characters to delete in the third argument to maketrans.

    posted in Pythonista read more
  • JonB

    If you want help, you need to explain what the problem is, what you have tried. For instance you might start by saying "help, my lasers now don't even spawn in the right position" to which someone might ask (maybe even you), gee, did you remember to set the laser position when you spawned it?

    Or you might be wondering why the laser w only move when you are touching the button. In which case one could respond that you maybe didn't fix the indentation as previously mentioned. The act of typing out "for some reason my lasers only move when I am touching the fire button" might make you look at the code that moves your lasers, or look at the code that runs when the fire button is pressed.

    You might be wondering "hey, I updated the code to use direction, but all lasers seem to use the direction from when the button was pressed", which would allow someone to point out that if you want to use it in your laser update loop, it needs to be defined inside said loop (using the rotation of the looped laser object), or store it as an attribute of the laser object.

    I would encourage you to try to understand your own code before asking for help. Then you can be specific about what you tried, what debugging you added in to understand the program flow, or what you think should be happening vs what is actually happening.

    posted in Pythonista read more
  • JonB

    Dont hold your breath. What feature in 3.8 are you desperately missing?

    posted in Pythonista read more
  • JonB

    @Shock9616 I don't have an iPad mouse, but what happens when you use one with pythonista? Reading through the docs, it seems like it might just work, or, if not we could simply swizzle the appropriate delegate method to enable it.

    Bluetooth Keyboard is supported in pythonista-- is there something specific that isn't working?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!