Page 1 of 1

[SOLVED] Values and Displaying Images Not Working

Posted: Sun Apr 18, 2021 8:48 pm
by LewdEdits
The purpose of this code is to speed up, slow down and show the "Car" based on values. My problem is when I accelerate, it will switch between cars without any issue.

Speed 0 = Car_0
Speed 1 = Car_1
Speed 2 = Car_2
Speed 3 = Car_3

The issue is, the image stays on Car_3 when slowing down. Below is the code I'm using, any suggestions would help.
And if you have any questions, I will do my best to answer them.

Code: Select all

label CarSpeedSelect:
        "Start Moving" if CarMoveStart == True and CarSpeedValue == 0:
            $ CarSpeedValue += 1
            call CarImageShow
            jump CarSpeedSelect

        "Move Faster" if CarSpeedShow == True:
            $ CarSpeedValue += 1
            call CarImageShow
            jump CarSpeedSelect

        "Move Slower" if CarSlowShow == True:
            $ CarSpeedValue -= 1
            call CarImageShow
            jump CarSpeedSelect


label CarImageShow:

    if VehicleValueTracking == 5:
        if CarSpeedValue == 0:
            $ CarSpeedShow = False
            $ CarSlowShow = False
            screen Street
            show Car_0

        elif CarSpeedValue == 1:
            $ CarSpeedShow = True
            $ CarSlowShow = False
            screen Street
            show Car_1

        elif CarSpeedValue == 2:
            $ CarSpeedShow = True
            $ CarSlowShow = True
            screen Street
            show Car_2

        elif CarSpeedValue == 3:
            $ CarSpeedShow = False
            $ CarSlowShow = True
            screen Street
            show Car_3

      

    elif VehicleValueTracking == 6:
        if CarSpeedValue == 0:
            $ CarSpeedShow = False
            $ CarSlowShow = False
            screen Street
            show Bike_0

        elif CarSpeedValue == 3:
            $ CarSpeedShow = False
            $ CarSlowShow = True
            screen Street
            show Bike_1

        elif CarSpeedValue == 2:
            $ CarSpeedShow = True
            $ CarSlowShow = True
            screen Street
            show Bike_2

        elif CarSpeedValue == 1:
            $ CarSpeedShow = True
            $ CarSlowShow = False
            screen Street
            show Bike_3

    return

Re: Values and Displaying Images Not Working

Posted: Mon Apr 19, 2021 2:05 am
by Ocelot
Try to define Car_X images, so they wouldn't be in the same place on screen and check wgat happens. I am pretty positive that Car_2 is still displayed, as it should, just below Car_3, but I would like clarification, that this is indeed the problem.

Re: Values and Displaying Images Not Working

Posted: Mon Apr 19, 2021 4:26 am
by Imperf3kt
A few years ago I was doing something similar for a card game that had the exact same issue.
In the end I found it better to use condition switch.
https://www.renpy.org/doc/html/displaya ... tionSwitch

Re: Values and Displaying Images Not Working

Posted: Mon Apr 19, 2021 11:14 pm
by LewdEdits
Ocelot wrote:
Mon Apr 19, 2021 2:05 am
Try to define Car_X images, so they wouldn't be in the same place on screen and check wgat happens. I am pretty positive that Car_2 is still displayed, as it should, just below Car_3, but I would like clarification, that this is indeed the problem.
Yup, that seems to have been the issue, I'm still getting the hang of coding. So now, the question I asked myself is why it was doing that from what I recalled, when you pulled up a new scene, it should remove everything and display the new background along with any image called.....

And that's when I realized I wasn't using the scene function, rather the screen function. I switched out "screen" for "scene" and it seems to have resolved my issue. Thank you for the suggestion!


Imperf3kt wrote:
Mon Apr 19, 2021 4:26 am
A few years ago I was doing something similar for a card game that had the exact same issue.
In the end I found it better to use condition switch.
https://www.renpy.org/doc/html/displaya ... tionSwitch
I'll have to look into this, it might simplify things out in the long run vs what I'm using now. Thank you for the suggestion.