I'm trying to figure out why the colliding balls section is only rotating the pilot ball, I'm just not used to python enough to figure it out yet. It looks like all the balls should have their own rotation set randomly but they never actually transform.
Anyone able to explain what is going on there and how to get them to all rotate?
ren'py tutorial demo_transform
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.
ren'py tutorial demo_transform
- Attachments
-
- demo_transform.rpy
- (6.01 KiB) Downloaded 132 times
-
- Regular
- Posts: 27
- Joined: Wed Mar 07, 2012 7:52 am
- Completed: Tales of Atlantis
- Projects: LDVELH
- Location: France
- Contact:
Re: ren'py tutorial demo_transform
Hello everyBody
No answer ?
I'am very interrest in too, because i have the same problem with this part of code.
Why only the pilot ball rotate ? (all the other balls rotate only one time..)
Thanks
All the best
No answer ?
I'am very interrest in too, because i have the same problem with this part of code.
Why only the pilot ball rotate ? (all the other balls rotate only one time..)
Thanks
All the best
Code: Select all
init python:
class Ball(object):
def __init__(self, filename, x, y, function=None):
self.transform = Transform(child=filename, xanchor=0.5, yanchor=0.5, rotate=10, function=function)
self.x = x
self.y = y
self.drotate = renpy.random.uniform(0, 180)
# This is called by the first transform. It updates all of the
# transforms.
def balls_update(pilot, st, at):
global last_time
RADIUS = 75 / 2
LEFT = RADIUS
RIGHT = 800 - RADIUS
TOP = RADIUS
BOTTOM = 600 - RADIUS
# The pilot is the first ball in our list, and he's the one
# that gets last_time updated.
if last_time is None:
dt = 0
else:
dt = st - last_time
last_time = st
# Update the transforms.
for i in balls:
# This is the code that deals with Ren'Py to update the
# various transforms. Note that we use absolute coordinates
# to position ourselves with subpixel accuracy.
i.transform.rotate += 5
i.transform.xpos = absolute(i.x)
i.transform.ypos = absolute(i.y)
i.transform.update()
return 0
#### LANCES DE DES #####
label _des:
python:
last_time = None
# Define a list of ball objects.
balls = [
Ball("dice-1.png", 100, 150, function=balls_update),
Ball("dice-2.png", 200, 150),
Ball("dice-3.png", 300, 150),
Ball("dice-4.png", 400, 150),
Ball("dice-5.png", 500, 150),
Ball("dice-6.png", 600, 150),
]
# Add each ball's transform to the screen.
for i, b in enumerate(balls):
renpy.show("des%d" % i, what=b.transform)
-
- Regular
- Posts: 27
- Joined: Wed Mar 07, 2012 7:52 am
- Completed: Tales of Atlantis
- Projects: LDVELH
- Location: France
- Contact:
Re: ren'py tutorial demo_transform
Nobody ? :'-(
-
- Veteran
- Posts: 356
- Joined: Tue Aug 12, 2008 12:02 pm
- Projects: Valentine Square (writer) Spiral Destiny (programmer)
- Location: The treacherous Brazilian Rainforest
- Contact:
Re: ren'py tutorial demo_transform
You are only passing the update function to the first Ball you create. You should pass it to the others:
Code: Select all
# Define a list of ball objects.
balls = [
Ball("dice-1.png", 100, 150, function=balls_update),
Ball("dice-2.png", 200, 150, function=balls_update),
Ball("dice-3.png", 300, 150, function=balls_update),
Ball("dice-4.png", 400, 150, function=balls_update),
Ball("dice-5.png", 500, 150, function=balls_update),
Ball("dice-6.png", 600, 150, function=balls_update),
]
Keep your script in your Dropbox folder.
It allows you to share files with your team, keeps backups of previous versions, and is ridiculously easy to use.
It allows you to share files with your team, keeps backups of previous versions, and is ridiculously easy to use.
-
- Regular
- Posts: 27
- Joined: Wed Mar 07, 2012 7:52 am
- Completed: Tales of Atlantis
- Projects: LDVELH
- Location: France
- Contact:
Re: ren'py tutorial demo_transform
Thanks for your attention warrior.
I've already tested this, but it doesn't work either.
In this case, all the balls rotate only one time.
I've already tested this, but it doesn't work either.
In this case, all the balls rotate only one time.
Re: ren'py tutorial demo_transform
@Atlantis
If you just want to rotate dice images and not interested in Transform how about this instead of script of tutorial?
If you just want to rotate dice images and not interested in Transform how about this instead of script of tutorial?
Code: Select all
init python:
for index in range(1,7):
renpy.image('dice-%d' % i,
'dice-%d.png' % i)
transform rotating:
rotate 0 ypos 150
linear 1.0 rotate 360
repeat
label start:
show dice-1 at rotating:
xpos 100
show dice-2 at rotating:
xpos 200
# .......
-
- Regular
- Posts: 27
- Joined: Wed Mar 07, 2012 7:52 am
- Completed: Tales of Atlantis
- Projects: LDVELH
- Location: France
- Contact:
Re: ren'py tutorial demo_transform
First of all, Thanks a lot backansi for your answer !!
And..
It works !!! (with a couple of synthax modifications
Thanks again and I need to learn more deeply the renpy's documentation for severals functions..
ps : And excuse my ill english
And..
It works !!! (with a couple of synthax modifications
Thanks again and I need to learn more deeply the renpy's documentation for severals functions..
ps : And excuse my ill english
Who is online
Users browsing this forum: voluorem