Minecraft

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

  • Owner: fogleman/Minecraft
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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)

Main metrics

Overview
Name With Ownerfogleman/Minecraft
Primary LanguagePython
Program languagePython (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2012-01-30 15:28:39
Pushed At2023-06-10 17:18:28
Last Commit At2020-12-22 19:57:03
Release Count0
用户参与
Stargazers Count5.4k
Watchers Count246
Fork Count1.3k
Commits Count65
Has Issues Enabled
Issues Count81
Issue Open Count49
Pull Requests Count19
Pull Requests Open Count29
Pull Requests Close Count37
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

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