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.


    Drawing with Pythonistas modules

    Pythonista
    3
    3
    3119
    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.
    • midkin
      midkin last edited by ccc

      Hey there.

      I 've been trying to create the Pong Game in Pythonista.
      I have created the game in my PC using python's tkinter module.

      However, I am having a difficulty in which library to use. Scene? Ui?

      Till now I have tried:

      import scene
      
      
      class TutoScene1(scene.Scene):
          def setup(self):
              self.background_color = 'green'
              self.item = scene.ShapeNode(scene.rect(0,0,0,0), color = 'red', position = (self.size.w / 2, self.size.h / 2), anchor_point = (0.5, 0.5), parent = self)
          
          def update(self):
              max_speed = 5
              x, y, z = scene.gravity()
              pos = self.item.position
              pos.x = self.item.position.x + x * max_speed
              pos.y = self.item.position.y + y * max_speed
              self.item.position = pos
      
      
      scene.run(TutoScene1(), scene.PORTRAIT)
      

      And:

      import scene
      import ui
      
      
      class TutoScene2(scene.Scene):
          def setup(self):
              self.background_color = 'black'
              self.paddle = ui.Path.rect(0, 0, 200, 50)
              self.ball = ui.Path.oval(100, 100, 400, 200)
      
      
      scene.run(TutoScene2(), scene.PORTRAIT)
      

      In the first example dimensions don't work as they should (I get the same Rect no matter the x, y, width, height and in the 2nd example I don't know how to make things slow up (like give them colors etc)

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

        Here is an example pong program. I hope it helps. (It is not well tested. It is just for illustration.)
        https://gist.github.com/balachandrana/d2bbb4ec151bd706e87f1f38c90181f6

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

          To create the Pong game in Pythonista, you have a couple of options for the library you can use. Pythonista is an integrated development environment (IDE) for iOS that allows you to write and run Python code on your iOS device. The choice of library depends on your specific requirements and preferences. Here's a brief overview of your options:

          Scene Module:
          The scene module in Pythonista is well-suited for creating 2D games, including Pong. It provides a simple and intuitive way to handle graphics and animations. You can create custom scenes, sprites, and animations using this module. This option is a great choice for game development, and it offers a high level of control over the graphical elements of your game.

          Ui Module:
          The ui module is more focused on creating user interfaces for iOS applications. While it may be possible to create a Pong game using ui, it's not the most straightforward choice, as it's not specifically designed for game development. If you want to create a game-like interface with buttons and controls, you could use ui for that aspect, but for the game mechanics and graphics, the scene module is typically a better choice.

          Given your intention to create a Pong game, the scene module is a more suitable option. It allows you to work with the game's graphics, animations, and interactions in a more game-oriented way. You can handle the game's logic, ball movement, and paddle controls more efficiently with the scene module.

          If you're already familiar with Python's tkinter module for creating the game on your PC, transitioning to the scene module in Pythonista should be a smoother process for developing your Pong game.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors