Game loop within renpy for playing mini-games?
Posted: Mon Dec 19, 2016 10:01 pm
Generally a game follows this pattern:
Where the game gets updated and the user inputs gets processed at each iteration. With renpy, it handles the main game loop and inputs. If I want to add some super mario-like gameplay in between the visual novel stuff, how should it be handled? The mario world needs a constant loop to update the screen and to read user input, but renpy also needs to render blit the images to the screen.
I was playing with @nyaatrap's tilegenerator: https://github.com/nyaatrap/renpy-utili ... ilemap.rpy
He builds the initial map with
which is a custom displayable and then constructs the image to be rendered with:
I can then call this from renpy:
But this renders once and does not handle any keyboard/mouse input. Should the game loop for the world be handled in the init python block like this:
and then I can still call it with show screen map? Or does renpy have a preferred way of handling this?
Code: Select all
while notQuit:
game.update()
userInput.process()
I was playing with @nyaatrap's tilegenerator: https://github.com/nyaatrap/renpy-utili ... ilemap.rpy
He builds the initial map with
Code: Select all
tilemap = Tilemap(map1, tileset, 32,32)
Code: Select all
image map = tilemap
Code: Select all
label start:
show screen map
Code: Select all
init python:
tilemap = TileMap(...)
while notQuit:
tilemap.update()
userInput.process()
image map = tilemap