[Solved]Problem with fixed positions

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
zabuzaeldemonio
Regular
Posts: 103
Joined: Sun Jan 08, 2017 7:24 pm
Projects: Call Me
Location: Spain
Contact:

[Solved]Problem with fixed positions

#1 Post by zabuzaeldemonio »

As the title indicates, I have a problem with the fixed positions, more specifically I can not get fixed positions for the party selection system that I have found.
The system I got it from here:
viewtopic.php?f=51&t=16943

The relevant code is this screen_demo.rpy:

Code: Select all

label party_screen_demo:

    
    # The Party Screen demo does not assume any particular foreknowledge, but concentrates on the 
    # screen itself and not the battle-engine classes used in it; setting up fighters is covered
    # in other tutorials.
    
    # First, just to get some fighters to play with, we'll set up a few basic fighters:

    # The first way that you can call the party screen is to simply use a Python command, which will output the
    # new party as the return from the screen.
    # The parameters to the screen are detailed in battle-screens.rpy, but in brief:
    # - available: the list of fighters who can join the party
    # - required: the list of fighters who cannot be removed from the party
    # - minSize: the minimum party size
    # - maxSize: the maximum party size
    


    # Just to display it, we'll get all the fighter names



    # If you prefer, you can call the screen in Ren'PyScript:
    # (Here we're passing in the party parameter to set the initial line-up to the same as the previous
    # screen's choices.)

    call screen party_select(party=party, available=[bob, geoff, prueba, prueba2, prueba3], required=[bob], minSize=1, maxSize=4)
    $ renpy.retain_after_load()
    # You'll have to pull the party list out of the _return variable like this, though.
    default available = []
    default required = []
    default listSort = defaultSortKey
    python:
        numero = 0
        xSize = int(config.screen_width * 0.9)
        ySize = int(config.screen_height * 0.9)

        # First we convert all the lists into sets just in case -
        # we don't want to have a fighter who's both in the party
        # and also available to add to the party!
        
        availableSet = set(available)
        partySet = set(party)
        requiredSet = set(required)

        currentParty = requiredSet | partySet
        availableSet = availableSet - currentParty
        
        currentParty = sorted(currentParty, key=listSort)
        availableSet = sorted(availableSet, key=listSort)
        
        currentSize = len(currentParty)

        for f in party:
                                                        if f.Name == 'Zaki':
                                                            nombre1 = f.Name
                                                            if numero == 1:
                                                                    geoffSprite = BattleSprite('geoff', anchor=(-1.44, -1.84), placeMark=(650,485))
                                                                    geoff.SetSprite(geoffSprite)
                                                            if numero == 2:
                                                                    geoffSprite = BattleSprite('geoff', anchor=(-2.84, -1.54), placeMark=(650,485))
                                                                    geoff.SetSprite(geoffSprite)
                                                            if numero == 3:
                                                                    geoffSprite = BattleSprite('geoff', anchor=(-1.44, -1.64), placeMark=(650,485))
                                                                    geoff.SetSprite(geoffSprite)
                                                                
                                                        if f.Name == 'Zako':
                                                            nombre2 = f.Name
                                                            currentSize = currentSize
                                                            if numero == 1:
                                                                    pruebaSprite = BattleSprite('prueba', anchor=(-1.44, -1.84), placeMark=(650,485))
                                                                    prueba.SetSprite(pruebaSprite)
                                                            if numero == 2:
                                                                     pruebaSprite = BattleSprite('prueba', anchor=(-2.84, -1.54), placeMark=(1100,405))
                                                                     prueba.SetSprite(pruebaSprite)        
                                                            if numero == 3:
                                                                     pruebaSprite = BattleSprite('prueba', anchor=(-1.44, -1.64), placeMark=(650,485))
                                                                     prueba.SetSprite(pruebaSprite)
                                                                 
                                                        if f.Name == 'Zama':
                                                            nombre3 = f.Name
                                                            if numero == 1:
                                                                    prueba3Sprite = BattleSprite('prueba3', anchor=(-1.44, -1.84), placeMark=(650,485))
                                                                    prueba3.SetSprite(prueba3Sprite)
                                                            if numero == 2:
                                                                    prueba3Sprite = BattleSprite('prueba3', anchor=(-2.84, -1.54), placeMark=(1100,405))
                                                                    prueba3.SetSprite(prueba3Sprite)
                                                            if numero == 3:
                                                                    prueba3Sprite = BattleSprite('prueba3', anchor=(-3.99, -1.92), placeMark=(650,485))
                                                                    prueba3.SetSprite(prueba3Sprite)
                                                        if f.Name == 'Zai':
                                                            nombre3 = f.Name
                                                            if numero == 1:
                                                                    prueba2Sprite = BattleSprite('prueba2', anchor=(-1.44, -1.84), placeMark=(650,485))
                                                                    prueba2.SetSprite(prueba2Sprite)
                                                            if numero == 2:
                                                                    prueba2Sprite = BattleSprite('prueba2', anchor=(-2.84, -1.54), placeMark=(1100,405))
                                                                    prueba2.SetSprite(prueba2Sprite)
                                                            if numero == 3:
                                                                    prueba2Sprite = BattleSprite('prueba2', anchor=(-1.44, -1.64), placeMark=(650,485))
                                                                    prueba2.SetSprite(prueba2Sprite)
                                                                
                                                        numero =  numero + 1
    $ party=_return
I would like to know if anyone has managed to maintain fixed positions, since the system keeps me in relative positions

If anyone wants to look at the code more in depth I facilitate the project (the game is in Spanish, but the code is not), to test the party selection system should click on the second logo and then continue advancing to show a Battle system and check positions.

project = https://mega.nz/#!7p1imbgS!XdxLhteKYZLl ... 8d9wwjUbII

Thank you very much for your time, I would try to solve it by myself, but I have been trying for several weeks with chaotic results, the current code is the closest I have been to achieving my purpose of fixed positions.

P.D = I know that some of the positions are the same, but since he said it does not matter and that the positions change when adding x character to the party, for example, if we add Zaki and Zako, Zaki would have a different position than this: Zaki and Zai, Although the zaki anchor was the same.
My personal Project:
Image

Post Reply

Who is online

Users browsing this forum: AWizardWithWords, Ocelot