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.


    [share] Grid-based game for Pythonista

    Pythonista
    4
    25
    16068
    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.
    • chriswilson
      chriswilson last edited by chriswilson

      I have been working on a simple game to try to learn the Scene module. Feel free to try it. I would welcome feedback of any sort. I am a beginner and so my code will not be particularly tidy!

      It consists of a few files (high score saving, configuration etc) and can be downloaded from GitHub here.

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

        I love the visual style and animations. It looks quite polished!

        To be honest though, I don't really understand what I'm supposed to do in the game. What do the colors and numbers mean? What's my goal? Maybe this is a variation of some popular game that I'm just unaware of?

        1 Reply Last reply Reply Quote 1
        • chriswilson
          chriswilson last edited by

          Thanks @omz
          Yeah I was thinking I need to provide instructions. The object is to clear a white path across the grid by pressing squares. Doing this toggles the 8 surrounding squares and takes the pressed square out of action (this can be reset using the second 'power-up' below the title).

          The other two 'power-ups' toggle all the squares, or allow you to toggle only a single square and not those around it.

          Score is awarded for maximising the number of squares in the path, and points are deducted for remaining white squares and squares that you pressed. It's possible to lose points in a given round. The timer gets quicker with each level.

          Unfortunately I imagine it will only work on iPhone 6/6S size screens, though I hope to change this.

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

            Ah! I think I understand it now (though I still fail a lot).

            Unfortunately I imagine it will only work on iPhone 6/6S size screens, though I hope to change this.

            Have you written this on an iPhone?

            I've played it on the iPad, and it scaled up quite well.

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

              Yes I wrote it on an iPhone. I did try to make the geometry relative to screen sizes, but don't have an iPad to check what it actually looks like! :)

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

                Your scaling works well, here's how it looks on an iPad:

                iPad screenshot

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

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • chriswilson
                    chriswilson last edited by chriswilson

                    That's good to see, thanks.

                    On iPhone it's like this:

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

                      This quite a challenging and fun game. I noticed that sometimes the game starts with a maze already connected. Is this intended and I am still supposed to maximize the number of white squares?

                      1 Reply Last reply Reply Quote 1
                      • chriswilson
                        chriswilson last edited by

                        @ywangd
                        Thanks for your comments.

                        Yes the grid setup is random and sometimes a path is already open. I could use a variant of the win-checking code to check for this and reshuffle the grid, but I have not done this yet.

                        As you say, it is still beneficial to maximise the size of the path anyway. You get a bonus if no white squares are left in the grid (bonus = rows + columns) and if your score is more than the grid size (rows * columns) you get one more of all three power-ups (whereas getting the star only gives you one of them).

                        If you don't use the power-ups and they reach maximum (9), further stars provide a bonus equal to the level number!

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

                          Thanks to @ccc for many useful edits. I've just learned a lot! :)

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

                            It would be nice if I could see my final score when the game ends.

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

                              @omz I have just committed a few changes on GitHub, including particle effects (hopefully tastefully minimal!) and the score persists at the end of a game until a new game is started.

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

                                Thanks! I'm starting to get the hang of this. :)

                                I noticed that the import for random.uniform was missing (see my pull request).

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

                                  @chriswilson Another minor issue: In the move_counters method, I think it should be self.squares in the list comprehensions (it's currently self.square which is undefined).

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

                                    Hi @omz
                                    I'm glad you're getting the hang of the game. Thanks for the pull request - I've merged it. The squares thing is now fixed as well - it must have changed during my edits earlier. Seems to working fine now.

                                    Thanks again!

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

                                      @chriswilson Oh, one other thing: Are you on Twitter? I sometimes tweet about cool projects that are made with Pythonista, and I'd like to give proper credit (I'll just link to your GitHub otherwise). There is a chriswilson, but that doesn't seem to be you.

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

                                        @omz Unfortunately I'm not on Twitter (yet). Feel free to link to my GitHub repo though. Thanks!

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

                                          Oh and I should say thanks to @Cethric and @JonB who helped with some queries in this post last month.

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

                                            @chriswilson Thanks, I've posted a little video (with custom color scheme).

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