Files
o.nmgjg.com.cn/RPG_Sample/main.py
Tommmy 17b314407f 上传文件至 RPG_Sample
一个纯终端的RPG游戏基本样例
包含键盘、鼠标交互等

Signed-off-by: Tommmy <pinetree985@gmail.com>
2025-05-14 08:19:41 +08:00

31 lines
822 B
Python

# main.py
import curses
from menus import main_menu, start_game_menu, settings_menu, credits_menu
from world import game_loop, init_objects
from config import init_colors, player, camera
def main(stdscr):
curses.curs_set(0)
init_colors()
h,w=stdscr.getmaxyx()
height, width = h-1, w
player["x"],player["y"]=0,0
camera["x"],camera["y"] = player["x"]-width//2, player["y"]-height//2
init_objects(width, height)
while True:
choice=main_menu(stdscr)
if choice==-1: break
elif choice==0:
mode=start_game_menu(stdscr)
if mode in (0,1): game_loop(stdscr, width, height)
elif choice==1: settings_menu(stdscr)
elif choice==2: credits_menu(stdscr)
elif choice==3: break
if __name__=="__main__":
curses.wrapper(main)