Move() and cubic functions
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.
Move() and cubic functions
I've just started looking into this. Here's what I want : instead of using a simple linear interpolation as Move does right now, I'd like either a Move with some "function" option, or simply other Moves using something else than a linear function.
What I have so far : in renpy.display.layout I found Motion, Move and Interpolate. I see where the interpolate function is and that's exactly what I'd like to change by offering others than this one.
What's said though, is that the functions need to be pickleable... Interpolate also being a Class, I wonder if there's a way to define these in the script ô_o... I'm a bit afraid I'd have to make the changes in the Ren'Py code itself ^^;... Wouldn't be too horrible in a way but uh... I'm afraid I'll break stuff XD.
So yea, I'll try things right now but in the meantime, I wouldn't mind precisions on how I could work this out.
Of course, the overarching goal of this is to allow movements to start out slow, then speed up, then slow down, and other things like that, allowing smoother animations in the end ^^
What I have so far : in renpy.display.layout I found Motion, Move and Interpolate. I see where the interpolate function is and that's exactly what I'd like to change by offering others than this one.
What's said though, is that the functions need to be pickleable... Interpolate also being a Class, I wonder if there's a way to define these in the script ô_o... I'm a bit afraid I'd have to make the changes in the Ren'Py code itself ^^;... Wouldn't be too horrible in a way but uh... I'm afraid I'll break stuff XD.
So yea, I'll try things right now but in the meantime, I wouldn't mind precisions on how I could work this out.
Of course, the overarching goal of this is to allow movements to start out slow, then speed up, then slow down, and other things like that, allowing smoother animations in the end ^^
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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:
Well, you can just copy the definition of Interpolate into a python block inside an init block, and change it to your liking. Functions defined inside an python (but not python hide) block inside an init block should be pickleable. What happens is that python stores the name of the function or class, and then the system needs to look it up again after unserialization. Since this happens after the init phase, everything will be there and things should work.
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
Ok, made this work. Do you think anyone would be interested in this ? Could it even be added to Ren'Py ? So far I have "ease" using power functions (quadratic, cubic, etc...), circular functions and sinusoidal functions.
Not being good at maths, I only managed to have a variable value on power functions. I don't know if it's possible with the other ones.
Not being good at maths, I only managed to have a variable value on power functions. I don't know if it's possible with the other ones.
-
- Eileen-Class Veteran
- Posts: 1314
- Joined: Mon Sep 19, 2005 2:15 am
- Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
- Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
- Organization: Watercolorheart Studios
- IRC Nick: BCS
- Tumblr: adminwatercolor
- Deviantart: itsmywatercolorheart
- Github: Watercolordevdev
- Skype: heartnotes
- Soundcloud: Watercollider
- itch: watercolorheart
- Location: Florida
- Contact:
He's talking about varying the speed of the movement transition over time - currently, if you just use the Move on its own, it moves with a fixed speed - effectively the "speed over time" graph is a zeroth-power (flat) function. If one were to use instead (for instance) a y=-1*x*x function (which produces a pleasing hump) with a suitable offset, it would be possible to have movement which started off slow (the left of the hump) sped up in the middle (the peak of the hump) then slowed to a halt at the end rather than the sudden and abrupt halt you get with the fixed-speed function.BCS wrote:I have no idea what you just said. Well, I do actually because I went all the way up to Calculus, but what I mean is that I'm not sure how that relates to movement ...
I must admit, I'm pretty curious to see your code, Monele, even leaving aside that it would be a useful feature - wouldn't you need to make sure that the function you were using had a fixed and known integral between the start and finish points to be able to use it for interpolation readily? Or am I over-thinking the problem?
[EDIT: Unless... is the interpolation more of a "find my position between these two points at time t" thing, where you only need to know the maximum of the graph? I guess I should really look at the existing code first...]
No!BCS wrote: I didn't know that functions were pickleable ....... don't they taste like brine then? D:
Vinegar!
'Picklable' just means that Python can save them, and thus Ren'Py can save a game in which they're used (which is pretty important, for obvious reasons)...
Server error: user 'Jake' not found
http://monele.clearlyseen.net/Divers/easeExample.html
#1 : linear motion
#2 : with acceleration and then deceleration.
Smoothes out movements and makes things less... "blocky" ? ^^;. Like comparing a sawtooth wave with a sinusoidal wave.
There should be ways to simulate bounces and even elasticity this way. I'll try to use elasticity for explosions so it shakes less and less through time.
EDIT : Jake > I'll admit I don't understand half of what I've coded XD... But I didn't have any problem with interpolation. I just used what was already in there for linear movements... and yes it's a function returning the position based on time, start pos and end pos. Nifty maths actually ^.^. I just changed the very boring "t" into "t**2" and other things
#1 : linear motion
#2 : with acceleration and then deceleration.
Smoothes out movements and makes things less... "blocky" ? ^^;. Like comparing a sawtooth wave with a sinusoidal wave.
There should be ways to simulate bounces and even elasticity this way. I'll try to use elasticity for explosions so it shakes less and less through time.
EDIT : Jake > I'll admit I don't understand half of what I've coded XD... But I didn't have any problem with interpolation. I just used what was already in there for linear movements... and yes it's a function returning the position based on time, start pos and end pos. Nifty maths actually ^.^. I just changed the very boring "t" into "t**2" and other things
Yeah, the more I thought about it the more I thought that I was taking a far too physics-based and far too not-really-easily-programmable approach to the question.monele wrote:and yes it's a function returning the position based on time, start pos and end pos. Nifty maths actually ^.^. I just changed the very boring "t" into "t**2" and other things
Server error: user 'Jake' not found
This does mean distributing more graphics than you'd otherwise need to, and getting an animation that doesn't get any smoother as the rendering framerate increases, though... if it's simple to do it in code, it's a far neater solution.DaFool wrote:1.) Get Macromedia Flash
2.) Import the graphic
3.) Tween the animation to your heart's content
4.) export the frames, and convert them to transparent png if necessary.
Server error: user 'Jake' not found
Yes but that's not *FUN* . Why would I spend hours in front of my keyboard at night, trying to figure out how to define the quadratic function for easing out otherwise ?DaFool wrote:monele...
1.) Get Macromedia Flash
2.) Import the graphic
3.) Tween the animation to your heart's content
4.) export the frames, and convert them to transparent png if necessary.
No physics necessary
No really, it works, and I've actually needed this *exact* thing for work today which is like... a sign from heaven ? XD
I'll try to optimize the classes and stuff (would like to have *one* function with a "function" parameter) and post this later tonight.
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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:
I'm thinking at some point I'll add a parameter to Motion, Move, and Pan that makes them distort time. (To be honest, I thought that parameter was already there.)
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
BTW, the tiny demo I came up with for Motion documentation brings a smile to my face.
All about the cheesy humor.
http://www.bishoujo.us/wiki/Functions/Motion
All about the cheesy humor.
http://www.bishoujo.us/wiki/Functions/Motion
Who is online
Users browsing this forum: No registered users