fogleman / Minecraft

Simple Minecraft-inspired program using Python and Pyglet
MIT License
5.25k stars 1.24k forks source link

Crafting system #12

Closed Jimx- closed 11 years ago

Jimx- commented 11 years ago

I've added some block classes and a simple crafting system

fogleman commented 11 years ago

This looks incomplete? How does the crafting work?

Jimx- commented 11 years ago

Well, it's very simple. Use recipes.add_recipe() to add a recipe and call recipes.craft() with a list of input blocks/items to get the id of the output block/item.

For example, if you want to create a recipe like: a replace grass with '#'(this can be any type of symbol) and we get a map {'#': grass_block} , the recipe becomes: a1 put the three rows in a string list (the shape list): a3 add recipe: a4 empty rows and columns will be removed, so it's equivalent to: a5

When you want to craft things, call recipes.craft() with the input block list: a6 and the id of the output block will be returned.

Still, empty rows and columns will be removed, so a7 is also acceptable to craft a dirt block.

We can't craft things without a crafting table. And I am working on it:)

jminardi commented 11 years ago

I am not sure what @fogleman's goals are for this repo, but I see it as a small demonstration of the power of python + pyglet. This is an incredible example to show kids what is possible and I think it would benefit from staying simple.

Just my two cents

StephenFluin commented 11 years ago

@jminardi Whether or not that it is his intent to start an open source version of Minecraft, he has partially done it. Based on the patches coming in, it seems like there is some community enthusiasm around a Python open source version thereof. If he doesn't want it, then someone should step up and form a community around this idea.

fogleman commented 11 years ago

My original intent was just to get some practice in 3D. Minecraft seemed like a good start. That was like a year ago. Then my project went viral out of nowhere. :)

I do want to keep it simple. There seems to be a lot of interest in using this as a learning tool for beginners. That sounds great. I have some vague ideas about how things could be improved to move toward that goal... hooks for terrain generation, easier configuration for various parameters like gravity, etc. If I get some time, I might work on things like that. It'd be cool to see pull requests along those lines.

It might be nice to turn it into a package - more of an API.

import mc
world = mc.World(...)
world.set_block(x, y, z, mc.DIRT)
mc.run()
silent1mezzo commented 11 years ago

@fogleman You should probably mention that in the README then just so people don't start building out the entire game.