Reputation: 53
I've trying to find a way for me to learn how to make a visual-novel like game in python/pygame WITHOUT using renpy. I have a few games that I written with pygame and I want to use that visual-novel part as a transition for the games in one whole bigger single game. I have searched a whole lot before coming here confused to why there is not a way to make a visual-novel type game without renpy in pygame.
I have a piece of code written down but if I were to display a line and the next, I would have to repeat the same code around forty times. How could I condense the code down and allow the player to actually click to get to the next text set (instead of waiting for three seconds like in the sample)?
Relevant sample code:
def two():
screen.blit(bg,bg_rect)
draw_text(screen, "C:", 26, width / 3, 426)
draw_text(screen, "R, it's this.", 22, width / 2, 466)
pg.display.flip()
time.sleep(3)
for event in pg.event.get():
if event.type == pg.QUIT:
pg.QUIT()
def one():
screen.blit(bg, bg_rect)
draw_text(screen, "R:", 26, width / 3, 426)
draw_text(screen, "C, don't think.", 22, width / 2, 466)
pg.display.flip()
time.sleep(3)
for event in pg.event.get():
if event.type == pg.QUIT:
pg.QUIT()
else:
two()
running = True
game_over = True
while running:
if game_over:
show_menu()
one()
two()
Thanks for sticking with me ;-;
Upvotes: 4
Views: 4435
Reputation: 1427
screenOne = {
"text": "Do you want to hangout?",
"options": ["Yes", "No", "Are you sure?"]
}
screenTwo = {
"text": "Are you ok?",
"options": ["I feel ok...", "No", "Feed me senpai..."]
}
def draw_stuff(currentScreen):
renderText(currentScreen["text"])
for option in currentScreen["options"]:
renderText(option)
currentScreen = screenOne
while (gameRunning):
draw_stuff(currentScreen)
without using pygame lingo but i think you get it.
EDIT ONE
mousePos = getMousePos()
optionButtons = [1, 2, 3]
for b in optionButtons:
if mousePos.x == optionButtons.x and mousePos.y == optionButtons.y:
getEvent(b)
again this is essentially pseudo code but it should help.
Upvotes: 1