Hacker News new | past | comments | ask | show | jobs | submit login
Minecraft clone in Python with Pyglet (slideshare.net)
171 points by edne on June 28, 2014 | hide | past | web | favorite | 40 comments



What bothers me here is that people claim to program "Minecraft in X lines", when in fact all they create is a block (voxel) game engine. Minecraft is much more than that, it has redstone circuits, farming, mobs, structures, biomes, potion brewing, netherworld, fire, etc... Mind you, I don't want to belittle anyone's efforts. I think this is an awesome programming project. But its description is misleading.


Don't forget that Minecraft was originally just a game where you could walk around and place or destroy blocks. None of the fancy stuff you're talking about was added until the game started taking off.


Right. Many of these clones are basically Minecraft Classic, which I would call just Minecraft, I very much like it.

Though Minecraft Classic had multiplayer, which this does not.


No, that was Infiniminer. Minecraft was, from the start, "Infiniminer but with action-RPG elements."


Your logic simply disallow any meaningful discussion. After all, everything starts small.


And if I cloned myself right now, my clone wouldn't have all my experiences or learning or history, so the description of cloning must be misleading.


Line count is always misleading.


I think scales of magnitude are informative. The difference between 100 and 200 lines or 10,000 and 20,000 are probably not useful, but you can get an idea of the scale of a project when you compare orders of magnitude. At the smallest scale, the recent ray caster was an example where the amount of code mattered a great deal.


I implemented Minecraft in Bash in 2 lines.

  yaourt -S minecraft
  minecraft


Original author here. Saw a lot of traffic to my GitHub repo and wondered where it was coming from.

The Python clone I wrote is pretty cool and minimal, but I'm much more proud of a clone I later wrote in C:

https://github.com/fogleman/Craft

This one is much more performant and has way more features, including online multiplayer. The server is in Python.

Here's a video of it:

https://www.youtube.com/watch?v=tScCneiTGm4

Anyway, happy to answer any questions.


Love the Python version. Am planning to use it on our local CoderDojo to help teach kids to code some basic concepts etc. Awesome job! Thanks!


Why did you choose to store the state in a database? It seems like an unusual choice for a game.


Not really. Databases are very common in gamedev but, most of the time, they are not relational and are ad-hoc (i.e the database program is coded in-house). All of this for performance.



Thanks. My son has been asking me how to write games, and has spent some time looking around in the code for the Raspberry Pi version of Minecraft. Maybe we can make some headway in this version because even dumb old Dad can handle 500 lines.


I've created a tutorial for making a 2D version of Minecraft using Python and Pygame. Obviously the end result is a _much_ simpler game than Minecraft, but it is useful in teaching things like 2D arrays and dictionaries.

http://usingpython.com/pygame-intro/


Thanks. That will be fun to look at too.


If you do try the tutorial, i'd love to see what you create! :)


HTML5 games! They're easy, quick to set up, the feedback is instant and they're fun to play! I've been making HTML5 games as part of short, two hour collaborative coding exercises at work and it's awesome. Here's a recent one we did based on Flappy Bird [1].

I made a few bootstrap scripts here [2] to make it easier to get up and running.

1. https://github.com/hoorayimhelping/Flabby-Bird 2. https://github.com/hoorayimhelping/HTML5-GameKit


I recommend http://phaser.io/


I cannot recommend pyglet strongly enough for learning graphics and game programming, it is so quick to get started with.

I wonder if anyone has written some learn to code tutorials with it.


My wife recently began learning python with the book "Hello Python." It seems like a solid intro from what I read. The book uses hunt the wumpus as its starting example. If you combine that with Steve Johnson's excellent Pyglet tutorial[1] you could probably get to writing games pretty quick.

[1] http://steveasleep.com/pyglettutorial.html


A few years back it seemed that pyglet was dead. I am glad to see that this isn't the case.


Isn't "import minecraft" enough?


Relevant xkcd reference :

http://xkcd.com/353/


Yes, this 500 lines statement is somewhat misleading. This program isn't written on Python, rather on a large specific library which does a lot of heavy lifting.

It's better than nothing, though, to be able to look at an app dissected even to a few large blocks.

Kudos.


Pyglet handles a lot of low-level drudgery involved in talking to OpenGL, setting up a window, dealing with input, etc. It's similar to SDL or GLFW in that regard.

I've written that code several times, and honestly nobody is any less of a programmer for using that instead of dealing with the bullshit themselves.

It's similar to complaining about using the Node abstractions for IO instead of manually adding that yourself--it's just being silly.


When there are libraries to do the heavy lifting for you, I would still say that the 500 lines is rather accurate. I have never taken the "X lines of code" to refer to all the libraries included, but rather to the lines of code necessary for a new user to write in order to make something that works.

I agree that it can be distorted, by defining everything as an external library, but it does give a good measure of how quickly one can pick up a new tool and make something useful.


We have different definitions here. As poster above said, in the limit it's just "import minecraft". I'd then argue after e.g. Paul Graham in "On Lisp" that you're modifying language when you're adding new facilities - like functions - to it. That allows you to much easier solve your problem - in the language which you created for that, rather than in the original language.

In this example a lot was done in the external library which was imported. The rest is a little bit of Python with crucial use of those facilities offered by imported library. So I'd say it's not Python - by much - which this program is written on. But that's just a definition - I find it useful to define it this way, but it's certainly not the only possibility.


Why is it called "Minecraft in 500 lines of Python" when the slides mention 8000 lines?


The original project[1] was a very simple 500 line implementation of Minecraft. There is a fork[2] of that project with 8000 lines of code and many more features.

[1]https://github.com/fogleman/Minecraft

[2]https://github.com/boskee/Minecraft


I used [1] above as the basis for a few sessions at our local coderdojo, it gave an opportunity to get the kids to hack some python and get visually interesting results. http://damianmooney.wordpress.com/2014/03/08/a-maze-in-pytho... is the kind of thing we ended up working on


I think the 8000 lines is after the release on github, which added lots of new functionalities.


Its not a Minecraft clone and almost none of them are. The thing that people don't get about Minecraft is its not just blocks. Its the combination of the interesting open world generation, blocks, resource gathering, crafting, and crucially, initially very difficult enemies that motivate those activities. It is fun to build an awesome fort to protect against creepers and skeletons and also to create farms so you don't starve. He also created a very performant cross platform engine believe it or not. Almost none of the "clones" include or get half of those elements right.


Has anyone heard of Bravo? It's actually minecraft in python... https://github.com/bravoserver/bravo


It's only a Minecraft server, not the client.


[deleted]



Minecraft in 1 line of Windows Batch:

     start minecraft.exe


This is actually more relevant than one might guess. If you export about 90% of the heavy lifting into a library (that might not even be written by you) then of course you can write anything in a very small program. I would interpret that "Minecraft in 1 line of Batch" as very short note to that fact. Therefore it is a relevant criticism of the linked article.


We changed the title to be less linkbaity.




Registration is open for Startup School 2019. Classes start July 22nd.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: