我试图找到一种方法来学习如何在不使用renpy的情况下制作类似于python/pygame中的游戏这样的视觉小说。我有几个游戏,我写的游戏,我想使用视觉小说部分,作为一个过渡的游戏,在一个更大的单一游戏。在来到这里之前,我已经搜索了很多东西,弄不明白为什么没有一种方法可以制作一款视觉新颖的游戏,而不需要玩游戏的折叠式游戏。
我已经写下了一段代码,但是如果我要显示一行和下一行,我将不得不重复相同的代码大约40次。我如何压缩代码并允许播放机实际单击以获得下一个文本集(而不是像在示例中那样等待3秒)?
相关样本代码:
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()谢谢你陪着我;-;
发布于 2017-05-29 11:18:59
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)但我想你明白了。
编辑一个
mousePos = getMousePos()
optionButtons = [1, 2, 3]
for b in optionButtons:
if mousePos.x == optionButtons.x and mousePos.y == optionButtons.y:
getEvent(b)同样,这本质上是伪代码,但应该会有所帮助。
https://stackoverflow.com/questions/44238199
复制相似问题