python方舟生存进化小游戏

import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *

def init():
    pygame.init()
    display = (800, 600)
    pygame.display.set_mode(display, DOUBLEBUF | OPENGL)

    gluPerspective(45, (display[0] / display[1]), 0.1, 50.0)
    glTranslatef(0.0, 0.0, -5)

def draw_cube():
    vertices = (
        (1, -1, -1),
        (1, 1, -1),
        (-1, 1, -1),
        (-1, -1, -1),
        (1, -1, 1),
        (1, 1, 1),
        (-1, -1, 1),
        (-1, 1, 1)
    )

    edges = (
        (0, 1),
        (1, 2),
        (2, 3),
        (3, 0),
        (4, 5),
        (5, 6),
        (6, 7),
        (7, 4),
        (0, 4),
        (1, 5),
        (2, 6),
        (3, 7)
    )

    glBegin(GL_LINES)
    for edge in edges:
        for vertex in edge:
            glVertex3fv(vertices[vertex])
    glEnd()

def game_loop():
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        glRotatef(1, 3, 1, 1)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        draw_cube()
        pygame.display.flip()
        pygame.time.wait(10)

def play_game():
    init()
    game_loop()

play_game()
import random

def display_intro():
    print("欢迎来到方舟生存进化!")
    print("你将探索一个神秘的岛屿,收集资源,建造基地,生存下去。")
    print()

def explore_island():
    print("你开始探索岛屿...")
    print("你发现了一些资源:木材、石头、食物")
    print()

def build_shelter():
    print("你决定建造一个避难所...")
    print("你收集了足够的木材和石头,成功建造了一个简易避难所。")
    print()

def hunt():
    print("你开始狩猎...")
    print("你成功捕获了一只野兽,获得了食物和皮毛。")
    print()

def craft_tools():
    print("你利用资源制作工具...")
    print("你成功制作了一把石斧和一把木剑。")
    print()

def play_game():
    display_intro()
    while True:
        action = input("请选择你的行动:\n1. 探索岛屿\n2. 建造避难所\n3. 狩猎\n4. 制作工具\n5. 结束游戏\n你的选择是:")
        print()
        if action == "1":
            explore_island()
        elif action == "2":
            build_shelter()
        elif action == "3":
            hunt()
        elif action == "4":
            craft_tools()
        elif action == "5":
            print("游戏结束!")
            break
        else:
            print("无效的选择,请重新输入。")
            print()

play_game()

两个版本。

你可能感兴趣的:(python入门教程,整活系列,python,pygame,开发语言)