Minecraft

由 Minecraft 启发的简单程序,使用 Python 和 Pyglet。(Simple Minecraft-inspired program using Python and Pyglet)

  • 所有者: fogleman/Minecraft
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Minecraft

由 Minecraft 启发的简单演示,以 Python 和 Pyglet 编写。

http://www.youtube.com/watch?v=kC3lwK631X8

喜欢这个项目吗?

您可能还喜欢使用现代 OpenGL(GL 着色器语言)以 C 语言编写的其他 Minecraft 克隆。它的性能更好,生成的地形更好,并且可以将状态保存到 sqlite 数据库中。看这里:
https://github.com/fogleman/Craft

目标与愿景

我希望看到这个项目变成一种教育工具。孩子们喜欢 Minecraft,Python 是很棒的第一语言。这是一个让孩子们对编程感到兴奋的好机会。

该代码应具有良好的注释能力,并且更易于配置。进行一些简单的更改并快速查看结果应该很容易。

我认为将项目变成更多的库/API 会很棒。。。先导入一个 Python 包,然后使用/配置它来建立一个世界并运行它。这些东西...

import mc
world = mc.World(...)
world.set_block(x, y, z, mc.DIRT)
mc.run(world)

该 API 可能包含以下功能:

  • 易于配置的参数,例如重力,跳跃速度,步行速度等。
  • 用于地形生成的挂钩。

怎么运行

Mac

在 Mac OS X 上,您可能在以 64 位模式运行 Pyglet 时遇到问题。首先尝试以 32位模式运行Python:

arch -i386 python main.py

如果这不起作用,请默认将 Python 设置为以 32 位模式运行:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

假设您使用的是 OS X 默认 Python。适用于使用默认 Python 2.7 的 Lion 10.7,也可能适用于其他版本。如果没有,请提出一个问题。

或者尝试 Pyglet 1.2 alpha,它支持 64 位模式:

pip install https://pyglet.googlecode.com/files/pyglet-1.2alpha1.tar.gz 

如果没有 pip 或 git

对于 pip:

  • Mac 或 Linux:使用 sudo easy_install pip 安装(Mac 或 Linux) -- 或(Linux)在软件包管理器中找到名为 “python-pip” 的软件包。
  • Windows:使用链接的 .MSI安装程序安装 Distribute 然后安装 Pip。

对于 git:

  • Mac:先安装 Homebrew,然后再安装git。
  • Windows 或 Linux:请参阅 Pro Git 书中的 Install Git。

请参阅该项目的 Wiki 以安装 Python,以及其他提示。

怎么玩

  • 移动
    • W:向前
    • S:回来
    • A:向左扫射
    • D:向右扫射
    • 鼠标:环顾四周
    • 空间:跳跃
    • 标签:切换飞行模式
  • 建造
    • 选择要创建的块类型:
      • 1:砖头
      • 2:草
      • 3:沙
    • 鼠标左键:删除块
    • 鼠标右键单击:创建块
  • 退出
    • ESC:释放鼠标,然后关闭窗口

(The first version translated by vz on 2020.08.08)

主要指標

概覽
名稱與所有者fogleman/Minecraft
主編程語言Python
編程語言Python (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2012-01-30 15:28:39
推送於2023-06-10 17:18:28
最后一次提交2020-12-22 19:57:03
發布數0
用户参与
星數5.4k
關注者數246
派生數1.3k
提交數65
已啟用問題?
問題數81
打開的問題數49
拉請求數19
打開的拉請求數29
關閉的拉請求數37
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Minecraft

Simple Minecraft-inspired demo written in Python and Pyglet.

http://www.youtube.com/watch?v=kC3lwK631X8

Like this project?

You might also like my other Minecraft clone written in C using modern OpenGL (GL shader language). It performs better, has better terrain generation and saves state to a sqlite database. See here:

https://github.com/fogleman/Craft

Goals and Vision

I would like to see this project turn into an educational tool. Kids love Minecraft and Python is a great first language.
This is a good opportunity to get children excited about programming.

The code should become well commented and more easily configurable. It should be easy to make some simple changes
and see the results quickly.

I think it would be great to turn the project into more of a library / API... a Python package that you import and then
use / configure to setup a world and run it. Something along these lines...

import mc

world = mc.World(...)
world.set_block(x, y, z, mc.DIRT)
mc.run(world)

The API could contain functionality for the following:

  • Easily configurable parameters like gravity, jump velocity, walking speed, etc.
  • Hooks for terrain generation.

How to Run

pip install pyglet
git clone https://github.com/fogleman/Minecraft.git
cd Minecraft
python main.py

Mac

On Mac OS X, you may have an issue with running Pyglet in 64-bit mode. Try running Python in 32-bit mode first:

arch -i386 python main.py

If that doesn't work, set Python to run in 32-bit mode by default:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes 

This assumes you are using the OS X default Python. Works on Lion 10.7 with the default Python 2.7, and may work on other versions too. Please raise an issue if not.

Or try Pyglet 1.2 alpha, which supports 64-bit mode:

pip install https://pyglet.googlecode.com/files/pyglet-1.2alpha1.tar.gz 

If you don't have pip or git

For pip:

  • Mac or Linux: install with sudo easy_install pip (Mac or Linux) - or (Linux) find a package called something like 'python-pip' in your package manager.
  • Windows: install Distribute then Pip using the linked .MSI installers.

For git:

  • Mac: install Homebrew first, then brew install git.
  • Windows or Linux: see Installing Git from the Pro Git book.

See the wiki for this project to install Python, and other tips.

How to Play

Moving

  • W: forward
  • S: back
  • A: strafe left
  • D: strafe right
  • Mouse: look around
  • Space: jump
  • Tab: toggle flying mode

Building

  • Selecting type of block to create:
    • 1: brick
    • 2: grass
    • 3: sand
  • Mouse left-click: remove block
  • Mouse right-click: create block

Quitting

  • ESC: release mouse, then close window