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.


    Help! I need help thinking of python projects I can do.

    Pythonista
    7
    35
    10857
    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.
    • stephen
      stephen @Bumbo Cactoni last edited by

      @Bumbo-Cactoni

      
      from scene import *
      
      def Dirt(parent, pos, size=(64, 64)):
          sn=SpriteNode(
              texture=Texture('plf:Ground_GrassCenter'),
              parent=parent,
              anchor_point=(0.0, 0.0),
              size=size,
              position=pos)
          return sn
      
      def Stone(parent, pos, size=(64, 64)):
          sn=SpriteNode(
              texture=Texture('plf:Ground_DirtCenter'),
              parent=parent,
              anchor_point=(0.0, 0.0),
              size=size,
              position=pos)
          return sn
      
      def fixed_position(x, fixed_val=64):
          return x - x%fixed_val
              
      class MyScene(Scene):
          def setup(self):
              self.active_block=None
              self.anchor_point=(0.0, 0.0),
              self.dirt_button=Dirt(self, (self.size[0]/2-80, self.size[1]-196))
              self.stone_button=Stone(self, (self.size[0]/2+80, self.size[1]-196))
              
          
          
          def touch_began(self, touch):
              if touch.location in self.dirt_button.frame:
                  self.active_block=Dirt(self, touch.location)
              if touch.location in self.stone_button.frame:
                  self.active_block=Stone(self, touch.location)
          
          def touch_moved(self, touch):
              if self.active_block:
                  self.active_block.position=touch.location
              
              
          def touch_ended(self, touch):
              x, y = self.active_block.position
              self.active_block.position=(fixed_position(x), fixed_position(y))
              self.active_block=None
        
      run(MyScene())
      
      
      1 Reply Last reply Reply Quote 1
      • Bumbo Cactoni
        Bumbo Cactoni last edited by

        Thank you! I would not have been able to figure that out on my own.

        stephen 1 Reply Last reply Reply Quote 0
        • Bumbo Cactoni
          Bumbo Cactoni last edited by Bumbo Cactoni

          @stephen
          Also, is there any way to set my own sprite/look for the objects? Like, make the dirt one look however I want it to?

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

            texture=Texture('plf:Ground_DirtCenter') is what sets the look. Other textures (images) are available to you as discussed in the Pythonista docs You can access built-in images in Pythonista using the [+] button at the top of the editor.

            1 Reply Last reply Reply Quote 0
            • stephen
              stephen @Bumbo Cactoni last edited by

              @Bumbo-Cactoni said:

              Thank you! I would not have been able to figure that out on my own.

              no problem 😎 and im sure you would of got the hang of it. its only intimidating at first then once you get a couple projects done it goes smoothly.

              @Bumbo-Cactoni said:

              @stephen
              Also, is there any way to set my own sprite/look for the objects? Like, make the dirt one look however I want it to?

              just create a png jpg or tiff image, then import it and inside Texture() pass the string path or ui.Image for the one you made. keep in mind the balance of filesize to quality. and resizing if your going to use multiple coppies you want to change scale instead of size.

              freindly tip:

              Use a dict to cache your Texture for performance.

              
              class MyScene(Scene):
                  def setup(self):
                      self.cache={"dirt":Texture('path/img1.png', "stone":Texture('path/img2.png'}
                  
                  def Dirt(self):
                      node=SpriteNode(
                          texture=self.cache['dirt'],
                          parent=parent,
                          anchor_point=(0.0, 0.0),
                          size=size,
                          position=pos)
                      return node
              

              instead of creating a new Texture each time

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

                @Bumbo-Cactoni I'm a bit late to the party, but you could always check out Cambidge IGCSE Computer Science past papers. Just search for them in your favourite search engine. They provide beginner level excercises and solutions, since the exams are aimed at students with 2 years of coding experience.
                Just be aware that for every year, there's one paper with a coding excercise (the one you want) and one paper with theory (boring).

                I had to pass this exam in 2018, just as an example
                There's more here.

                1 Reply Last reply Reply Quote 1
                • Bumbo Cactoni
                  Bumbo Cactoni last edited by

                  Thank you

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

                    @Bumbo-Cactoni
                    Can you think of something useful that you would use often? Even if it’s an app that you already have, you could write a clone from scratch. My first Python app will be an app that helps me with my small business (tracking and logging actions taken and status of individual jobs). It will automate/streamline a lot of the day-to-day stuff I do repetitively, help me stay organized, and prevent things from “slipping through the cracks”. I’m in the beginning phase, outlining the workflow and functionality. Once that’s done, I’ll do some screen mockups. Then...Pythonista time!

                    1 Reply Last reply Reply Quote 0
                    • Bumbo Cactoni
                      Bumbo Cactoni last edited by

                      @donnybahama
                      I have found something to set my mind on, which will actually be quite useful when finished. My 17 year-old brother has a self-run business where he uses his pickup to haul off people’s yard and house junk. I am currently designing a sort of calendar for him to schedule jobs. I know he could just use the calendar app, but I needed something to do. Anyways, I could also use some help with the scene module, as there are no instructions online, due to it being a pythonista-exclusive module.

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

                        @Bumbo-Cactoni, sounds like a cool project. I have yet to see a really good touch and visualization-friendly scheduling app on iOS.

                        For something like this, I would strongly recommend using the ui module instead of scene. On top of a
                        feeling based on years of using Pythonista, I base this recommendation on some real arguments:

                        1. scene is meant for games.
                        2. ui has built-in support for element level touch management and supporting stuff for e.g. gestures.
                        3. ui is based on native iOS components in a way that is pretty well understood here. This means that if something does not work the way you want, it can most often be fixed or expanded with objc_util.
                        4. I think you can tap into a broader set of experience in the forum.
                        1 Reply Last reply Reply Quote 0
                        • Bumbo Cactoni
                          Bumbo Cactoni last edited by

                          @mikael
                          Thanks for the suggestion! Also, do you happen to know how to use the ui module well? Just like scene, there are no tutorials online for me to follow.

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

                            @Bumbo-Cactoni, maybe, if you describe in broad terms what you want to make happen, we can start from there.

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

                              See ui-tutorial at https://github.com/Pythonista-Tools/Pythonista-Tools/blob/master/UI.md

                              1 Reply Last reply Reply Quote 1
                              • Bumbo Cactoni
                                Bumbo Cactoni last edited by

                                @ccc
                                Thanks for the link, and @mikael I don’t even know what I want to make happen. I’m probably going to read through some of the tutorial, so I can figure out something cool that would match the calendar I’m trying to design. I’ll get back to you in a lil bit.

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