• PeterG

    @ccc, just something I need , very nice indeed! I import a game, that for grand-son and daughter, and run it before the background cardimages are shown, meeaning I am on the way for an 4-level game ...
    Next try, just using one of the marvallous available games , as next levels ..
    .. Topscore files will be used for further interaction ..

    Thanks to your example ... Helps a lot 😊 , happy OpaPeter

    posted in Pythonista read more
  • PeterG

    @ccc very nice example.
    What and why flex=name ? Can't find the meaning of it

    posted in Pythonista read more
  • PeterG

    So opa has to follow the Game-tutorials ,,, , got a starting picture to use. Oh oh, more difficult then thaught 😉 . Using the second tutorial-script as a start .. By the way, how to show here a pocture? It is a strange alien and at the top 4 ' houses' with an .. Saying rood, pars, geel en groen (red,violet, yelow, green).
    This picture fills at version ZERO 3/4 of the screen ok. The puppet has to be moved by tilting the Ipad right, left, up, down. The background changes to the colors, told to .. in the four houses. Too high, the message with red background shows, trankated, oh no you must go down!

    And now my question: how to implent a level , if the puppet stays say a (short while) in one of the upper houses. My idea is to use one of the very nice example games , either to remove all shown colourd squares .. Or to touch 3 (or more) same colourd ' block' to remove for a high score. If this game is in stop-wait and asks for play again, it should not play again but start automatically the from opa built lvel ZERO game, (remembering the last toscore and which one) ...

    My poor zero version i think I can upload it to gist ... But how to upload to gist the used (scanned) picture I got from my (grand)kids??

    Any idea to help me further is appreciated very much 😊

    PKHG = PeterG

    posted in General Discussion read more
  • PeterG

    @ccc THAT was the real timesaver, thanks a lot 😉

    posted in Pythonista read more
  • PeterG

    #! python2
    # Piano
    # 
    # A simple multi-touch piano.
    
    from scene import *
    import sound
    from itertools import chain
    
    class Key (object):
        def __init__(self, frame):
            self.frame = frame
            self.name = None
            self.touch = None
            self.color = Color(1, 1, 1)
            self.highlight_color = Color(0.9, 0.9, 0.9)
            
        def hit_test(self, touch):
            return touch.location in self.frame
    
    class Piano (Scene):
        def setup(self):
            self.white_keys = []
            self.black_keys = []
            white_key_names = ['Piano_C3','Piano_D3', 'Piano_E3',
                               'Piano_F3', 'Piano_G3', 'Piano_A3', 
                               'Piano_B3', 'Piano_C4', 'Piano_D4',
                               'Piano_E4', 'Piano_F4', 'Piano_G4']
            #white_key_names_nogniiet = #['Piano_02','Piano_D2','Piano_E2','Piano_F2','Piano_G2','Piano_A2','Piano_B2','Piano_C3']
            black_key_names = ['Piano_C3#', 'Piano_D3#', 'Piano_F3#', 
                               'Piano_G3#', 'Piano_A3#', 'piano:C4#',
                               'Piano_D4#', 'Piano_F4#']
            for key_name in chain(white_key_names, black_key_names):
                sound.load_effect(key_name)
            white_positions = range(12)
            black_positions = [0.5, 1.5, 3.5, 4.5, 5.5, 7.5, 8.5, 10.5]
            key_w = self.size.w / 2# pkhg factor 0.5 
            key_h = self.size.h / 8 /2
            for i in range(len(white_key_names)):
                pos = white_positions[i]
                key = Key(Rect(0, pos * key_h, key_w, key_h))
                key.name = white_key_names[i]
                self.white_keys.append(key)
            for i in range(len(black_key_names)):
                pos = black_positions[i]
                key = Key(Rect(0, pos * key_h + 10, key_w * 0.6, key_h - 20))
                key.name = black_key_names[i]
                key.color = Color(0, 0, 0)
                key.highlight_color = Color(0.2, 0.2, 0.2)
                self.black_keys.append(key)
            
        def draw(self):
            stroke_weight(1)
            stroke(0.5, 0.5, 0.5)
            for key in chain(self.white_keys, self.black_keys):
                if key.touch is not None:
                    fill(*key.highlight_color.as_tuple())
                else:
                    fill(*key.color.as_tuple())
                rect(*key.frame.as_tuple())
        
        def touch_began(self, touch):
            for key in chain(self.black_keys, self.white_keys):
                if key.hit_test(touch):
                    key.touch = touch
                    sound.play_effect(key.name)
                    return
        
        def touch_moved(self, touch):
            hit_key = None
            for key in chain(self.black_keys, self.white_keys):
                hit = key.hit_test(touch)
                if hit and hit_key is None:
                    hit_key = key
                    if key.touch is None:
                        key.touch = touch
                        sound.play_effect(key.name)
                if key.touch == touch and key is not hit_key:
                    key.touch = None
                    
        def touch_ended(self, touch):
            for key in chain(self.black_keys, self.white_keys):
                if key.touch == touch:
                    key.touch = None
    
    run(Piano(), PORTRAIT)
    

    Append the Piano till G4

    posted in Pythonista read more
  • PeterG

    Yes PeterG and PKHG are the same. Asking as PKHG for the forgotton password did not work 2-3 times, therfore a new account...

    posted in Pythonista read more
  • PeterG

    Yes you are right , so the game starts now 😉
    Eg can ask for a Name, BUT then there is nothing to go back to somewhere, have to reboot Ipad
    self.game_state is not defined ERROR

    Same, can activate picture choice see a lot of possibilities BUT NO further action possible?!?!???

    posted in Pythonista read more
  • PeterG

    Thanks ,
    Stupid Peter, was not aware that searching if contents like site-packages are visible I can search for the directory and tap there on the zip file , etc, in stash indeed the unzip -t zipfilenamezip works very nice
    Thanks helping a again Pyhonista user (first uses several years ago and than not using it)
    Peter

    posted in Pythonista read more
  • PeterG

    Thanks for ...
    I have the latest source I think.
    The game does not run , it stops al the line trying to run ui- menu
    And I have yet no idea where ui-menu comes from , where it has to be found, with what source content ..

    posted in Pythonista read more
  • PeterG

    Who is willing to help understanding the code, to add more working buttons?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!