So basically I'm trying to add minigames/puzzles to my VN. I found some interesting ones online, but I'm having a hard time figuring out how to program them.
For example, look at the following puzzle:
The objective is to link the nodes so that each one has as many nodes linked to it as the number inside it. I was thinking the player would either click one node and drag into another, or click two, and then a line would be drawn. And there lies my question. I know how to use imagebuttons (for the clicking), but how do I draw the lines that link the two nodes? I'm only fluent in Java, so I know I should use a function where I'd provide parameters that would give me the coordinates of the ends of the lines, but that's as far as I could get. What is a function that would help me here?
This is what it looks like solved:
I need to draw lines on the screen during a minigame
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.
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.
- PyTom
- Ren'Py Creator
- Posts: 16088
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: I need to draw lines on the screen during a minigame
I'd suggest not drawing lines, especially if you'd like the style there. Just have images of lines, and show them in the right places.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: I need to draw lines on the screen during a minigame
Alright, that works for me. Thanks a bunch.
Also, another thing. Is it possible to use ATL to move an image a certain distance, instead of to a certain spot? For example, I'd like to move the character 100 units to the right, regardless of where he is, when he presses a key. I had the idea of using the image's current position +100 as the new xpos, but I don't know how to "obtain" the image's current position.
- PyTom
- Ren'Py Creator
- Posts: 16088
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: I need to draw lines on the screen during a minigame
The answer is "not really". While you can do stuff like use xoffset and yoffset, you almost certainly want your game to keep a model of what's where, and then use ATL or Screen language to present that model to the player.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: I need to draw lines on the screen during a minigame
When a transform acts upon a displayable, it basically wraps the displayable in a container and moves/rotates/fades/dissolves that container while storing the relevant values in that container. (It actually uses sub transforms/containers which is one more step of complexity)
When a screen is redrawn, the queued transforms are all executed and the result is a change to how the displayable looks - it might fade, rotate and move all in one redraw (based upon multiple transforms executing)
As such, the transform(s) store the information rather than the displayable storing it...
An ATL move from 100,0 to 200,0 over 1 second would first create a wrapper transform which would spawn child transforms at each step which would basically just snapshot the position at a single point of the move.
The current version of Ren'py does not require a transform to tell a displayable about what it is doing.
For example, it does not tell the displayable, "I have moved you to xpos 121, ypos 0"
As such, from the displayable, it is rather awkward to find out exactly where it is on the screen dynamically.
As PyTom says, the most sensible way is to store the variable values within the code, keep track of those and then use them within transforms where needed. This 'should' also make it easier to incorporate the positions/changes within the save, checkpoint and rollback facilities that Ren'py has
When a screen is redrawn, the queued transforms are all executed and the result is a change to how the displayable looks - it might fade, rotate and move all in one redraw (based upon multiple transforms executing)
As such, the transform(s) store the information rather than the displayable storing it...
An ATL move from 100,0 to 200,0 over 1 second would first create a wrapper transform which would spawn child transforms at each step which would basically just snapshot the position at a single point of the move.
The current version of Ren'py does not require a transform to tell a displayable about what it is doing.
For example, it does not tell the displayable, "I have moved you to xpos 121, ypos 0"
As such, from the displayable, it is rather awkward to find out exactly where it is on the screen dynamically.
As PyTom says, the most sensible way is to store the variable values within the code, keep track of those and then use them within transforms where needed. This 'should' also make it easier to incorporate the positions/changes within the save, checkpoint and rollback facilities that Ren'py has
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], trailsiderice