How to make a character jump?

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
Moonspeck
Regular
Posts: 35
Joined: Thu Jan 07, 2016 12:30 pm
Projects: Sentimental Trickster, new BL fantasy dating sim
Organization: Lovenuts
itch: lazuli
Contact:

How to make a character jump?

#1 Post by Moonspeck »

Hello,

Do you know how to make a character sprite do a little jump? I've been searching for this but couldn't find it anywhere. I have a general idea but I feel it requires a lot of experimentation with movement and ease. Maybe someone has already figured it out? Thanks in advance!

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: How to make a character jump?

#2 Post by RicharDann »

Adjusting the ypos with an ATL transform, supposing you have your characters aligned to the bottom of the screen (that's 1.0 on the y-axis), it could be something like this:

Code: Select all

transform small_jump:
  
    linear .1 ypos .9 #Move the character to 0.9 (a little up, it starts at 1.0) in 0.1 second
    linear .1 ypos 1.0 #Move the character back to ypos 1.0

label start:

    show mary 

    m "I'm so happy!"
    
    show mary at center, small_jump
The most important step is always the next one.

User avatar
Moonspeck
Regular
Posts: 35
Joined: Thu Jan 07, 2016 12:30 pm
Projects: Sentimental Trickster, new BL fantasy dating sim
Organization: Lovenuts
itch: lazuli
Contact:

Re: How to make a character jump?

#3 Post by Moonspeck »

RicharDann wrote: Wed Oct 18, 2017 3:11 pm Adjusting the ypos with an ATL transform, supposing you have your characters aligned to the bottom of the screen (that's 1.0 on the y-axis), it could be something like this:

Code: Select all

transform small_jump:
  
    linear .1 ypos .9 #Move the character to 0.9 (a little up, it starts at 1.0) in 0.1 second
    linear .1 ypos 1.0 #Move the character back to ypos 1.0

label start:

    show mary 

    m "I'm so happy!"
    
    show mary at center, small_jump
Yes, this is exactly what I needed. Looks good, thank you very much!

User avatar
Belgerum
Regular
Posts: 110
Joined: Thu Nov 06, 2014 12:24 am
Skype: belgerum09
Soundcloud: Belgerum
itch: Belgerum
Contact:

Re: How to make a character jump?

#4 Post by Belgerum »

I would personally use code that's a tiny bit different, if you want to experiment a bit:

This version uses easein and easeout to make the movement a little more smooth, and uses yoffset instead of ypos so that the transform can be used from any starting point, not just the bottom of the screen.

Code: Select all

transform small_jump:
    easein 0.1 yoffset -0.1
    easeout 0.1 yoffset 0.1

edgebug
Regular
Posts: 41
Joined: Thu Jun 30, 2016 11:44 pm
Contact:

Re: How to make a character jump?

#5 Post by edgebug »

The jump works beautifully!!!

I'd like to combine the jump with a dissolve expression change, but it doesn't... work.

Code: Select all

  show andy sad bothhands with dissolve at right, small_jump
It gives me an error code that says "end of line expected."

I mean, I know I can do both functions--the jump and the dissolve--one after the other, but I'd like it to be simultaneous. Is this possible?

User avatar
Belgerum
Regular
Posts: 110
Joined: Thu Nov 06, 2014 12:24 am
Skype: belgerum09
Soundcloud: Belgerum
itch: Belgerum
Contact:

Re: How to make a character jump?

#6 Post by Belgerum »

You have the order wrong. The "at" statement should be before the "with" statement.

Code: Select all

show andy sad bothhands at right, small_jump with dissolve

User avatar
Moonspeck
Regular
Posts: 35
Joined: Thu Jan 07, 2016 12:30 pm
Projects: Sentimental Trickster, new BL fantasy dating sim
Organization: Lovenuts
itch: lazuli
Contact:

Re: How to make a character jump?

#7 Post by Moonspeck »

Belgerum wrote: Wed Oct 18, 2017 6:03 pm I would personally use code that's a tiny bit different, if you want to experiment a bit:

This version uses easein and easeout to make the movement a little more smooth, and uses yoffset instead of ypos so that the transform can be used from any starting point, not just the bottom of the screen.

Code: Select all

transform small_jump:
    easein 0.1 yoffset -0.1
    easeout 0.1 yoffset 0.1
Thank you so much for another great jump code!

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: How to make a character jump?

#8 Post by RicharDann »

Belgerum wrote: Wed Oct 18, 2017 6:03 pm I would personally use code that's a tiny bit different, if you want to experiment a bit:

This version uses easein and easeout to make the movement a little more smooth, and uses yoffset instead of ypos so that the transform can be used from any starting point, not just the bottom of the screen.

Code: Select all

transform small_jump:
    easein 0.1 yoffset -0.1
    easeout 0.1 yoffset 0.1
OMG I knew there had to be a way to use it from any starting point but I couldn't find it at all when I looked it up some time ago, that's why so far I had to stick with the code I presented ealier. I'll have to rewrite a lot of my code now but it's well worth it, Thank you thank you so much!
The most important step is always the next one.

Post Reply

Who is online

Users browsing this forum: No registered users