[SOLVED]Want to display linking line between objects in Map screen

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
Love&Peace
Regular
Posts: 52
Joined: Wed Dec 17, 2014 8:19 pm
Contact:

[SOLVED]Want to display linking line between objects in Map screen

#1 Post by Love&Peace » Sat Dec 28, 2019 1:19 pm

Hi.
I want to display linking line between objects in Map screen.

Sample Image is here : https://drive.google.com/file/d/1bgTzWK ... sp=sharing

And here's my screen and source code : https://drive.google.com/file/d/1geBs7z ... sp=sharing

Code: Select all


screen test_map(area, area_map, linked, footholds, char):

    python:
        area_name = area.area_name

        char_pos_key = "base" + str(char.char_now_pos)


    add area.area_img

    frame:
        text "Place = " + area_name
        align (.5, .1)


    for key, value in footholds.items():
        add footholds[key][0] pos footholds[key][1]

    add char.char_icon pos footholds[char_pos_key][1]



    frame:
        
        vbox:
            label "Health"
            bar value StaticValue(char.char_health, 100):
                xmaximum 400
                ymaximum 50
        
        align (.05, .95)


    frame:
        textbutton "Back":
            action Return()

        align (.9, .9)

label test_label:

    python:

        test_ch_001 = StoryFactory.create("test")

        test_ch_001.title = "Test Episode"
        test_ch_001.label = "test_episode"
        test_ch_001.seen = False
        test_ch_001.lock = False

    jump test_episode

    return


label test_episode:
    python:

        base_001 = BaseFactory.create("1")
        base_002 = BaseFactory.create("1")
        base_003 = BaseFactory.create("1")
        base_004 = BaseFactory.create("1")
        base_005 = BaseFactory.create("1")

        base_001.base_number = 1
        base_002.base_number = 2
        base_003.base_number = 3
        base_004.base_number = 4
        base_005.base_number = 5

        base_001.base_name = "Test Base 1"
        base_002.base_name = "Test Base 2"
        base_003.base_name = "Test Base 3"
        base_004.base_name = "Test Base 4"
        base_005.base_name = "Test Base 5"

        base_001.visit_count = 0
        base_002.visit_count = 0
        base_003.visit_count = 0
        base_004.visit_count = 0
        base_005.visit_count = 0

        base_001.chapter = "test"
        base_002.chapter = "test"
        base_003.chapter = "test"
        base_004.chapter = "test"
        base_005.chapter = "test"

	## This dict is what I've seen in path finder algorithm.
	## Can I solve it with this approach?
        base_linked = {
            'base_001' : ( 'base_002'),
            'base_002' : ( 'base_001', 'base_003', 'base_004' ),
            'base_003' : ( 'base_002', 'base_004' ),
            'base_004' : ( 'base_002', 'base_004', 'base_005' ),
            'base_005' : ( 'base_004' )
        }


        def test_solid_maker(color, x, y):
            return Solid(color, xsize=x, ysize=y)

        f1 = test_solid_maker("#000", 100, 100)
        f2 = test_solid_maker("#000", 100, 100)
        f3 = test_solid_maker("#000", 100, 100)
        f4 = test_solid_maker("#000", 100, 100)
        f5 = test_solid_maker("#000", 100, 100)

        footholds = {
                "base1" : ( f1, (346, 768) ),
                "base2" : ( f2, (1346, 768) ),
                "base3" : ( f3, (848, 501) ),
                "base4" : ( f4, (284, 113) ),
                "base5" : ( f5, (1346, 119) )
        }

        map_001 = MapFactory.create("1")
        area_map = [ base_001, base_002, base_003, base_004, base_005 ]

        map_001.area_number = 1
        map_001.area_name = "Test Area"
        map_001.area_bases = ( base_001, base_002, base_003, base_004, base_005 )
        map_001.area_img = "test/test_bg.jpg"


        char_001 = CharacterFactory().create("1")

        char_001.char_name = "Test Character"
        char_001.char_icon = "test/char_icon.png"
        char_001.char_pre_pos = None
        char_001.char_now_pos = 2
        char_001.char_health = 100


    e "Instances were created."

    e "Run Developer Console and check them."

    call show_screen_test

    e "Now you go back to main menu"

    python:
        test_ch_001.seen = True

    return

label show_screen_test:
    call screen test_map(map_001, area_map, base_linked, footholds, char_001)

    return


Now, I don't know how to display linking lines, which can be shown in sample image.

I think I can solve it with CDD, but actually I don't understand what CDD is and how to use it. Even I've read documentation. :?
Can you tell me how to solve it?
Thanks. :D
Last edited by Love&Peace on Tue Dec 31, 2019 1:15 am, edited 1 time in total.

rames44
Veteran
Posts: 232
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Want to display linking line between objects in Map screen

#2 Post by rames44 » Sat Dec 28, 2019 1:28 pm

Couldn’t you just create a PNG image with transparent background and the lines and show it under the objects? Or are they dynamic?

Love&Peace
Regular
Posts: 52
Joined: Wed Dec 17, 2014 8:19 pm
Contact:

Re: Want to display linking line between objects in Map screen

#3 Post by Love&Peace » Mon Dec 30, 2019 7:54 pm

rames44 wrote:
Sat Dec 28, 2019 1:28 pm
Couldn’t you just create a PNG image with transparent background and the lines and show it under the objects? Or are they dynamic?
They're dynamic, Yes...T.T

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Want to display linking line between objects in Map screen

#4 Post by philat » Tue Dec 31, 2019 12:39 am

Code: Select all

init python:

    class Line(renpy.Displayable):
        def __init__(self, color, startPos, endPos, lineWidth=5, **kwargs):
            super(Line, self).__init__(**kwargs)
            self.color = color
            self.startPos = startPos
            self.endPos = endPos
            self.lineWidth = lineWidth
            self.width = config.screen_width
            self.height = config.screen_height

        def render(self, width, height, st, at):
            render = renpy.Render(self.width, self.height)
            canvas = render.canvas()

            canvas.line(self.color, self.startPos, self.endPos, width=self.lineWidth)

            return render            

screen test():
    for coords in lines:
        add Line("#FF0", coords[0], coords[1])

default lines = [
    ((150, 150), (180, 250)),
    ((320, 190), (180, 250)),
    ((100, 450), (180, 250)),
]

label start:

    pause
    show screen test
    pause
This is just an example of drawing the lines. You can figure out getting the right start/end points from your bases on your own lol

Love&Peace
Regular
Posts: 52
Joined: Wed Dec 17, 2014 8:19 pm
Contact:

Re: Want to display linking line between objects in Map screen

#5 Post by Love&Peace » Tue Dec 31, 2019 1:15 am

philat wrote:
Tue Dec 31, 2019 12:39 am


This is just an example of drawing the lines. You can figure out getting the right start/end points from your bases on your own lol
I really, REALLY appreciate for your help, and your kindness :D

I'll study CDD with your sample code! Thanks!

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: [SOLVED]Want to display linking line between objects in Map screen

#6 Post by philat » Tue Dec 31, 2019 1:20 am

별걸요. 새해 복 많이 받으세요 :)

Love&Peace
Regular
Posts: 52
Joined: Wed Dec 17, 2014 8:19 pm
Contact:

Re: [SOLVED]Want to display linking line between objects in Map screen

#7 Post by Love&Peace » Tue Dec 31, 2019 11:10 am

philat wrote:
Tue Dec 31, 2019 1:20 am
별걸요. 새해 복 많이 받으세요 :)
아니, 한국 사람이셨어.....;;

Post Reply

Who is online

Users browsing this forum: Bing [Bot], span4ev