Trying to attach text to cards from Ren'Py Cardgame Framework

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
User avatar
DraconicMentalist
Newbie
Posts: 1
Joined: Thu Dec 27, 2018 2:39 am
Contact:

Trying to attach text to cards from Ren'Py Cardgame Framework

#1 Post by DraconicMentalist »

As the header says, I'm try to find a way to attach text to card objects from Ren'Py Cardgame Framework, so I can quickly track and modify the stats of cards for a card game I'm working on, without having to redraw a large number of cards every time I need to tweak them or add a new effect.

I've tried to do so via the add_marker() method, but I'm not sure if I'm doing something wrong, or if it simply won't take text displayables. I've yet to get it to display images either, and I don't quite know why. Regardless, every attempt has resulted in the card in question either vanishing, or becoming unresponsive to attempts to click and drag.

If add_marker() can't do that, what sort of approach might I be able to take to layer text or images over a card, and have the card still behave correctly? I'm willing to alter the code of the framework and learn some pretty advanced concepts if I need to, but I just don't know where to start, so I'm reaching out here in hopes somebody more experienced can point me in the right direction.

I have a code sample, but the current code of the game simply moves a single card from one stack to another in response to a mouse click, then ends the game. I'll post it anyway on the off chance it helps, though. Please excuse the lack of comments, as I'm changing things pretty rapidly trying to figure out what I can make the Cardgame Framework do:

Code: Select all

label dragondate:

init python:
    class dTable(object):
        def __init__(self):
            LEFT = 100
            TOP = 100
            COL_SPACING = 200
            ROW_SPACING = 200
            moved = False

            self.table = t = Table(base="card/base.png", back="card/base.png")
            self.teststack = t.stack(LEFT, TOP, xoff=0, yoff=0, show=100, click=True, drag=DRAG_TOP, drop=True)
            self.card1 = t.card(1, "card/1.png", "card/base.png")
            self.card2 = t.card(2, "card/2.png", "card/base.png")
            t.set_faceup(1, True)
            self.teststack.append(1)
            self.stack2 = t.stack(300, TOP, xoff=0, yoff=0, show=100, click=True, drag=DRAG_TOP,drop=True)
            self.stack2.append(2)
            t.add_marker(1, "images/bottom.png")
            t.set_faceup(1, True)



        def stackclick(self, evt):
            if self.teststack:
                #self.teststack.remove(1)
                self.stack2.append(1)
                moved = False

        def interact(self):
            evt = ui.interact()
            rv = False
            # Check the various events, and dispatch them to the methods
            # that handle them.
            if evt.type == "click":
                if evt.stack == self.teststack:
                    rv = self.stackclick(evt)
                    state = "win"


        def show(self):
            self.table.show()

        def hide(self):
            self.table.hide()

        def set_sensitive(self, value):
            self.table.set_sensitive(value)
Thanks in advance for any advice or assistance, and let me know if there's any other information I need to provide!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]