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.


    Game Tutorial Script Errors

    Pythonista
    tutorial bug
    3
    3
    2113
    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.
    • adrius42
      adrius42 last edited by adrius42

      I am a pre-newby, so please bear with me.

      Running on iOS12.1 using iPad mini

      The Game Tuorials, which are great have some basic problems... perhaps recent iOS changes have caused the issues?

      The gravity exemplar in the game tutorial only works using g.y rather than g.x

      The direction of movement is also the wrong way

      Perhaps this is deliberate to encourage problem solving, but it added confusion for me.

      BTW I love this app, though I am finding huge assumptions of prior knowledge especially relating to file storage.and new script creation.

      Still feeling like I jumped in at the deep end.

      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @adrius42 last edited by

        @adrius42, the example seems to be running normally on my iPhone. Could you maybe be a bit more specific about what is not working for you? Have you maybe changed something and it did not work, or what?

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

          if you add

          	print('X:{:.2f} Y:{:.2f} Z:{:0.2f}'.format(*g))
          

          after the g = gravity() line in update, this will print the gravity direction (it will show up at the very bottom line, or will show up in console later when you stop the script)

          The gravity vector is the direction if gravity, relative to your phone's physical coordinate system: Z points out of the screen, Y points from home button to camera, and X points right in normal portrait mode.

          When you hold your phone up to a wall, so you are looking at the screen in front of you with the home button on the bottom edge like you would normally hold it to make a phone call, gravity should read near -1 in Y, but 0 for the other axes.

          If you then rotate it 90 degrees counter clockwise, so the home button is on the right side, but screen still vertical, X should read -1.

          if you lay it flat on the table, screen up, Z should be near -1 and the other two are near zero.
          If you hold it screen

          If you confirm that is the case, i think one of two things happened.

          1. Make sure you are not running in any sort of split screen mode. im not sure how scene behaves when you run split screen.

          2. Also, make sure you have this line

          	run(Game(), PORTRAIT, show_fps=True)
          

          if you had changed to LANDSCAPE, or nothing at all, then things would be as you described, since the game logic assumes that g.x is left/right. if you are in landscape, g.y increases when you tip left/right, while g.x would change by tipping forward/back.

          in case you editing something by accident, the motion logic looks like

          		if abs(g.x) > 0.05:
          			x = self.player.position.x
          			# The components of the gravity vector are in the range 0.0 to 1.0, so we have to multiply it with some factor to move the player more quickly. 40 works pretty well, but feel free to experiment. 
          			max_speed = 40
          			# We simply add the x component of the gravity vector to the current position, and clamp the value between 0 and the scene's width, so the alien doesn't move outside of the screen boundaries.
          			x = max(0, min(self.size.w, x + g.x * max_speed))
          			self.player.position = (x, 32)
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors