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.
Hi!
It is the first time I try to program a game on Renpy and, although I read the documentation, I would like to know how to improve the performance.
I don't know how to optimize the speed of the character when it crosses the screen.
Are there equivalent expressions of this code but in python language?
# You can place the script of your game in this file.
init:
image man = "man.png"
# Keymap
python hide:
def overlay():
ui.keymap(K_LEFT=renpy.curried_call_in_new_context("left"))
config.overlay_functions.append(overlay)
def overlay():
ui.keymap(K_RIGHT=renpy.curried_call_in_new_context("right"))
config.overlay_functions.append(overlay)
def overlay():
ui.keymap(K_UP=renpy.curried_call_in_new_context("up"))
config.overlay_functions.append(overlay)
def overlay():
ui.keymap(K_DOWN=renpy.curried_call_in_new_context("down"))
config.overlay_functions.append(overlay)
# The game starts here.
label start:
$ leftpressed = False
$ rightpressed = False
$ uppressed = False
$ downpressed = False
$ distance_x = 0
$ distance_y = 0
scene caff
"Movement: Up, down, left, right"
label loop:
show man at Position(xpos = distance_x, ypos = distance_y + 20)
if leftpressed:
if distance_x > 0:
$ distance_x -= 10
if rightpressed:
if distance_x < 650:
$ distance_x += 10
if downpressed:
if distance_y < 650:
$ distance_y += 10
if uppressed:
if distance_y > 0:
$ distance_y -= 10
$ renpy.pause(0.0000001)
while distance_x == 650 and distance_y == 650:
e "coordinate: (X=650, y=650)"
jump loop
jump loop
label left:
$ leftpressed = True
$ rightpressed = False
$ uppressed = False
$ downpressed = False
return
label right:
$ rightpressed = True
$ leftpressed = False
$ uppressed = False
$ downpressed = False
return
label up:
$ uppressed = True
$ leftpressed = False
$ rightpressed = False
$ downpressed = False
return
label down:
$ downpressed = True
$ leftpressed = False
$ rightpressed = False
$ uppressed = False
return
PD: Sorry for my level of English. My native language is Spanish.
PD2: The character does not stop when I stop pressing one of the buttons
Last edited by bonnie_641 on Mon Jan 15, 2018 7:35 pm, edited 1 time in total.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question.
If it's your first time with Ren'Py, probably you should start with some more simple.
I'm not sure if I fully understand your code, but I think that your code never says that "not pressing" = "stopping".
The key press decides which variable is True, and the other are False. But not-pressing does not change anything, so the variable that is True continues to be True in every cycle of the loop, so there is no reason to stop.
I understand the code: the character can moving in 4 directions (up, down, left and right) and if it arrives at coordenate execute an action (for example a message)
EDIT:
The problems are:
1. The image don't stop when I release the button.
Is it correct if I write it that way?
If I do not press the left button ... nothing happens.
2. The character are moving very slow. (Is there some alternative (in python or pygame, UDD, etc.?)
It's possible that my nivel of English cause misunderstanding. I apologize for that.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question.
Thank you very much The first option was what I wanted ♥ ♥ ♥
Thanks for your help.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question.