diff --git a/af-ZA/images/banner.png b/af-ZA/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/af-ZA/images/banner.png differ diff --git a/af-ZA/images/blockbeneath.gif b/af-ZA/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/af-ZA/images/blockbeneath.gif differ diff --git a/af-ZA/images/helloworld.gif b/af-ZA/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/af-ZA/images/helloworld.gif differ diff --git a/af-ZA/images/lava.png b/af-ZA/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/af-ZA/images/lava.png differ diff --git a/af-ZA/images/mcpi-block-test.png b/af-ZA/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/af-ZA/images/mcpi-block-test.png differ diff --git a/af-ZA/images/mcpi-flowers-grass.png b/af-ZA/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/af-ZA/images/mcpi-flowers-grass.png differ diff --git a/af-ZA/images/mcpi-flowers-sky.png b/af-ZA/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/af-ZA/images/mcpi-flowers-sky.png differ diff --git a/af-ZA/images/mcpi-flowers.png b/af-ZA/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/af-ZA/images/mcpi-flowers.png differ diff --git a/af-ZA/images/mcpi-flying.png b/af-ZA/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/af-ZA/images/mcpi-flying.png differ diff --git a/af-ZA/images/mcpi-game.png b/af-ZA/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/af-ZA/images/mcpi-game.png differ diff --git a/af-ZA/images/mcpi-idle.png b/af-ZA/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/af-ZA/images/mcpi-idle.png differ diff --git a/af-ZA/images/mcpi-install.png b/af-ZA/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/af-ZA/images/mcpi-install.png differ diff --git a/af-ZA/images/mcpi-inventory.png b/af-ZA/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/af-ZA/images/mcpi-inventory.png differ diff --git a/af-ZA/images/mcpi-setblock.png b/af-ZA/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/af-ZA/images/mcpi-setblock.png differ diff --git a/af-ZA/images/mcpi-setblock2.png b/af-ZA/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/af-ZA/images/mcpi-setblock2.png differ diff --git a/af-ZA/images/mcpi-setblocks.png b/af-ZA/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/af-ZA/images/mcpi-setblocks.png differ diff --git a/af-ZA/images/mcpi-start.png b/af-ZA/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/af-ZA/images/mcpi-start.png differ diff --git a/af-ZA/images/mcpi-tnt-blocks.png b/af-ZA/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/af-ZA/images/mcpi-tnt-blocks.png differ diff --git a/af-ZA/images/mcpi-tnt-explode.png b/af-ZA/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/af-ZA/images/mcpi-tnt-explode.png differ diff --git a/af-ZA/images/mcpi-tnt.png b/af-ZA/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/af-ZA/images/mcpi-tnt.png differ diff --git a/af-ZA/images/menu.png b/af-ZA/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/af-ZA/images/menu.png differ diff --git a/af-ZA/images/minecraft-pi-banner.png b/af-ZA/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/af-ZA/images/minecraft-pi-banner.png differ diff --git a/af-ZA/images/minecraft-pi-shortcut.png b/af-ZA/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/af-ZA/images/minecraft-pi-shortcut.png differ diff --git a/af-ZA/meta.yml b/af-ZA/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/af-ZA/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/af-ZA/step_1.md b/af-ZA/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/af-ZA/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/af-ZA/step_2.md b/af-ZA/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/af-ZA/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/af-ZA/step_3.md b/af-ZA/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/af-ZA/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/af-ZA/step_4.md b/af-ZA/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/af-ZA/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/af-ZA/step_5.md b/af-ZA/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/af-ZA/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/af-ZA/step_6.md b/af-ZA/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/af-ZA/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/af-ZA/step_7.md b/af-ZA/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/af-ZA/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/af-ZA/step_8.md b/af-ZA/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/af-ZA/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/af-ZA/step_9.md b/af-ZA/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/af-ZA/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/ar-SA/images/banner.png b/ar-SA/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/ar-SA/images/banner.png differ diff --git a/ar-SA/images/blockbeneath.gif b/ar-SA/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/ar-SA/images/blockbeneath.gif differ diff --git a/ar-SA/images/helloworld.gif b/ar-SA/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/ar-SA/images/helloworld.gif differ diff --git a/ar-SA/images/lava.png b/ar-SA/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/ar-SA/images/lava.png differ diff --git a/ar-SA/images/mcpi-block-test.png b/ar-SA/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/ar-SA/images/mcpi-block-test.png differ diff --git a/ar-SA/images/mcpi-flowers-grass.png b/ar-SA/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/ar-SA/images/mcpi-flowers-grass.png differ diff --git a/ar-SA/images/mcpi-flowers-sky.png b/ar-SA/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/ar-SA/images/mcpi-flowers-sky.png differ diff --git a/ar-SA/images/mcpi-flowers.png b/ar-SA/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/ar-SA/images/mcpi-flowers.png differ diff --git a/ar-SA/images/mcpi-flying.png b/ar-SA/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/ar-SA/images/mcpi-flying.png differ diff --git a/ar-SA/images/mcpi-game.png b/ar-SA/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/ar-SA/images/mcpi-game.png differ diff --git a/ar-SA/images/mcpi-idle.png b/ar-SA/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/ar-SA/images/mcpi-idle.png differ diff --git a/ar-SA/images/mcpi-install.png b/ar-SA/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/ar-SA/images/mcpi-install.png differ diff --git a/ar-SA/images/mcpi-inventory.png b/ar-SA/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/ar-SA/images/mcpi-inventory.png differ diff --git a/ar-SA/images/mcpi-setblock.png b/ar-SA/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/ar-SA/images/mcpi-setblock.png differ diff --git a/ar-SA/images/mcpi-setblock2.png b/ar-SA/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/ar-SA/images/mcpi-setblock2.png differ diff --git a/ar-SA/images/mcpi-setblocks.png b/ar-SA/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/ar-SA/images/mcpi-setblocks.png differ diff --git a/ar-SA/images/mcpi-start.png b/ar-SA/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/ar-SA/images/mcpi-start.png differ diff --git a/ar-SA/images/mcpi-tnt-blocks.png b/ar-SA/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/ar-SA/images/mcpi-tnt-blocks.png differ diff --git a/ar-SA/images/mcpi-tnt-explode.png b/ar-SA/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/ar-SA/images/mcpi-tnt-explode.png differ diff --git a/ar-SA/images/mcpi-tnt.png b/ar-SA/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/ar-SA/images/mcpi-tnt.png differ diff --git a/ar-SA/images/menu.png b/ar-SA/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/ar-SA/images/menu.png differ diff --git a/ar-SA/images/minecraft-pi-banner.png b/ar-SA/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/ar-SA/images/minecraft-pi-banner.png differ diff --git a/ar-SA/images/minecraft-pi-shortcut.png b/ar-SA/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/ar-SA/images/minecraft-pi-shortcut.png differ diff --git a/ar-SA/meta.yml b/ar-SA/meta.yml new file mode 100644 index 0000000..6d752a7 --- /dev/null +++ b/ar-SA/meta.yml @@ -0,0 +1,37 @@ +--- +title: الشروع في البداية مع ماينكرافت باي +hero_image: images/banner.png +description: تذوق لأول مرة برمجة عالم الماينكرافت +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: المقدمة + - + title: ما ستحتاج إليه + - + title: الشروع في البداية مع ماينكرافت باي + - + title: شغّل ماينكرافت + - + title: استخدم الواجهة البرمجية لبايثون + - + title: إسقاط الكتل بينما تمشي + - + title: اللّعب بكتل المتفجرات (التِّي أَنْ تِي) + - + title: المرح مع الحمم المتدفقة. + - + title: ما التالي؟ diff --git a/ar-SA/step_1.md b/ar-SA/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/ar-SA/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/ar-SA/step_2.md b/ar-SA/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/ar-SA/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/ar-SA/step_3.md b/ar-SA/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/ar-SA/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/ar-SA/step_4.md b/ar-SA/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/ar-SA/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/ar-SA/step_5.md b/ar-SA/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/ar-SA/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/ar-SA/step_6.md b/ar-SA/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/ar-SA/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/ar-SA/step_7.md b/ar-SA/step_7.md new file mode 100644 index 0000000..c940bf8 --- /dev/null +++ b/ar-SA/step_7.md @@ -0,0 +1,32 @@ +## اللّعب بكتل المتفجرات (التي ان تي) + +كتلة أخرى مثيرة للاهتمام هي التيانتي! لوضع كتلة تيانتي عادية استخدم: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +مع ذلك, كتلة التيانتي هذه حقاً مملة. حاول تطبيق `data` ك `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +الآن استخدم سيفك و انقر بالأيسر على كتلة التيانتي: ستفعل و ستنفجر في غضون ثوان! + +حاول الآن صنع مكعب كبير من كتل التيانتي! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +الآن سترى مكعبًا كبيرًا مليئًا بكتل التيانتي. انطلق ونشط إحدى الكتل و اهرب بعيداً لمشاهدة العرض! سيكون عرض الرسومات بطيئًا جداً للعدد الكبير من الأشياء المتغيرة في آن. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/ar-SA/step_8.md b/ar-SA/step_8.md new file mode 100644 index 0000000..9892cf1 --- /dev/null +++ b/ar-SA/step_8.md @@ -0,0 +1,43 @@ +## المرح مع الحمم المتدفقة. + +كتلة ممتع جداً اللّعب بها هي الحمم المتدفقة. + +```python +من mcpi.minecraft استورد Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +جد الكتلة التي وضعتها للتو ، و يفترض أن ترى الحمم تتدفق من الكتلة إلى الأرض. + +الجميل في الحمم هو أنها عندما تبرد تتحول إلى صخرة. انتقل لمكان آخر في عالمك وجرب هذا: + +```python +من mcpi.minecraft استورد Minecraft +من time استورد sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +يمكنك تعديل خيار `sleep` للسماح بتدفق أكثر أو أقل من الحمم. + +![الحمم](images/lava.png) \ No newline at end of file diff --git a/ar-SA/step_9.md b/ar-SA/step_9.md new file mode 100644 index 0000000..cbf75a7 --- /dev/null +++ b/ar-SA/step_9.md @@ -0,0 +1,11 @@ +## ما التالي؟ + +يمكنك القيام بالكثير الآن أنت تعرف طريقك حول عالم مينيكرافت Minecraft وكيفية استخدام واجهة بايثون Python. + +### لعبة شبكية + +إذا قام عدة أشخاص بتوصيل العديد من رازبيري باي Raspberry Pis بشبكة محلية، يمكنهم الإنضمام إلى نفس عالم ماينكرافت Minecraft واللعب معًا. يمكن للاعبين رؤية بعضهم البعض في عالم ماينكرافت Minecraft. + +### واجهة برمجة التطبيق API + +لمزيد من التوثيقات الأوسع حول الدوال و لائحة كاملة لمعرفات الكتل انظر مرجع واجهة برمجة التطبيق API على [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/ca-ES/images/banner.png b/ca-ES/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/ca-ES/images/banner.png differ diff --git a/ca-ES/images/blockbeneath.gif b/ca-ES/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/ca-ES/images/blockbeneath.gif differ diff --git a/ca-ES/images/helloworld.gif b/ca-ES/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/ca-ES/images/helloworld.gif differ diff --git a/ca-ES/images/lava.png b/ca-ES/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/ca-ES/images/lava.png differ diff --git a/ca-ES/images/mcpi-block-test.png b/ca-ES/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/ca-ES/images/mcpi-block-test.png differ diff --git a/ca-ES/images/mcpi-flowers-grass.png b/ca-ES/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/ca-ES/images/mcpi-flowers-grass.png differ diff --git a/ca-ES/images/mcpi-flowers-sky.png b/ca-ES/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/ca-ES/images/mcpi-flowers-sky.png differ diff --git a/ca-ES/images/mcpi-flowers.png b/ca-ES/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/ca-ES/images/mcpi-flowers.png differ diff --git a/ca-ES/images/mcpi-flying.png b/ca-ES/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/ca-ES/images/mcpi-flying.png differ diff --git a/ca-ES/images/mcpi-game.png b/ca-ES/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/ca-ES/images/mcpi-game.png differ diff --git a/ca-ES/images/mcpi-idle.png b/ca-ES/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/ca-ES/images/mcpi-idle.png differ diff --git a/ca-ES/images/mcpi-install.png b/ca-ES/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/ca-ES/images/mcpi-install.png differ diff --git a/ca-ES/images/mcpi-inventory.png b/ca-ES/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/ca-ES/images/mcpi-inventory.png differ diff --git a/ca-ES/images/mcpi-setblock.png b/ca-ES/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/ca-ES/images/mcpi-setblock.png differ diff --git a/ca-ES/images/mcpi-setblock2.png b/ca-ES/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/ca-ES/images/mcpi-setblock2.png differ diff --git a/ca-ES/images/mcpi-setblocks.png b/ca-ES/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/ca-ES/images/mcpi-setblocks.png differ diff --git a/ca-ES/images/mcpi-start.png b/ca-ES/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/ca-ES/images/mcpi-start.png differ diff --git a/ca-ES/images/mcpi-tnt-blocks.png b/ca-ES/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/ca-ES/images/mcpi-tnt-blocks.png differ diff --git a/ca-ES/images/mcpi-tnt-explode.png b/ca-ES/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/ca-ES/images/mcpi-tnt-explode.png differ diff --git a/ca-ES/images/mcpi-tnt.png b/ca-ES/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/ca-ES/images/mcpi-tnt.png differ diff --git a/ca-ES/images/menu.png b/ca-ES/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/ca-ES/images/menu.png differ diff --git a/ca-ES/images/minecraft-pi-banner.png b/ca-ES/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/ca-ES/images/minecraft-pi-banner.png differ diff --git a/ca-ES/images/minecraft-pi-shortcut.png b/ca-ES/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/ca-ES/images/minecraft-pi-shortcut.png differ diff --git a/ca-ES/meta.yml b/ca-ES/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/ca-ES/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/ca-ES/step_1.md b/ca-ES/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/ca-ES/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/ca-ES/step_2.md b/ca-ES/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/ca-ES/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/ca-ES/step_3.md b/ca-ES/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/ca-ES/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/ca-ES/step_4.md b/ca-ES/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/ca-ES/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/ca-ES/step_5.md b/ca-ES/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/ca-ES/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/ca-ES/step_6.md b/ca-ES/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/ca-ES/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/ca-ES/step_7.md b/ca-ES/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/ca-ES/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/ca-ES/step_8.md b/ca-ES/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/ca-ES/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/ca-ES/step_9.md b/ca-ES/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/ca-ES/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/cs-CZ/images/banner.png b/cs-CZ/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/cs-CZ/images/banner.png differ diff --git a/cs-CZ/images/blockbeneath.gif b/cs-CZ/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/cs-CZ/images/blockbeneath.gif differ diff --git a/cs-CZ/images/helloworld.gif b/cs-CZ/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/cs-CZ/images/helloworld.gif differ diff --git a/cs-CZ/images/lava.png b/cs-CZ/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/cs-CZ/images/lava.png differ diff --git a/cs-CZ/images/mcpi-block-test.png b/cs-CZ/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/cs-CZ/images/mcpi-block-test.png differ diff --git a/cs-CZ/images/mcpi-flowers-grass.png b/cs-CZ/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/cs-CZ/images/mcpi-flowers-grass.png differ diff --git a/cs-CZ/images/mcpi-flowers-sky.png b/cs-CZ/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/cs-CZ/images/mcpi-flowers-sky.png differ diff --git a/cs-CZ/images/mcpi-flowers.png b/cs-CZ/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/cs-CZ/images/mcpi-flowers.png differ diff --git a/cs-CZ/images/mcpi-flying.png b/cs-CZ/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/cs-CZ/images/mcpi-flying.png differ diff --git a/cs-CZ/images/mcpi-game.png b/cs-CZ/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/cs-CZ/images/mcpi-game.png differ diff --git a/cs-CZ/images/mcpi-idle.png b/cs-CZ/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/cs-CZ/images/mcpi-idle.png differ diff --git a/cs-CZ/images/mcpi-install.png b/cs-CZ/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/cs-CZ/images/mcpi-install.png differ diff --git a/cs-CZ/images/mcpi-inventory.png b/cs-CZ/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/cs-CZ/images/mcpi-inventory.png differ diff --git a/cs-CZ/images/mcpi-setblock.png b/cs-CZ/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/cs-CZ/images/mcpi-setblock.png differ diff --git a/cs-CZ/images/mcpi-setblock2.png b/cs-CZ/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/cs-CZ/images/mcpi-setblock2.png differ diff --git a/cs-CZ/images/mcpi-setblocks.png b/cs-CZ/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/cs-CZ/images/mcpi-setblocks.png differ diff --git a/cs-CZ/images/mcpi-start.png b/cs-CZ/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/cs-CZ/images/mcpi-start.png differ diff --git a/cs-CZ/images/mcpi-tnt-blocks.png b/cs-CZ/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/cs-CZ/images/mcpi-tnt-blocks.png differ diff --git a/cs-CZ/images/mcpi-tnt-explode.png b/cs-CZ/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/cs-CZ/images/mcpi-tnt-explode.png differ diff --git a/cs-CZ/images/mcpi-tnt.png b/cs-CZ/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/cs-CZ/images/mcpi-tnt.png differ diff --git a/cs-CZ/images/menu.png b/cs-CZ/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/cs-CZ/images/menu.png differ diff --git a/cs-CZ/images/minecraft-pi-banner.png b/cs-CZ/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/cs-CZ/images/minecraft-pi-banner.png differ diff --git a/cs-CZ/images/minecraft-pi-shortcut.png b/cs-CZ/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/cs-CZ/images/minecraft-pi-shortcut.png differ diff --git a/cs-CZ/meta.yml b/cs-CZ/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/cs-CZ/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/cs-CZ/step_1.md b/cs-CZ/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/cs-CZ/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/cs-CZ/step_2.md b/cs-CZ/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/cs-CZ/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/cs-CZ/step_3.md b/cs-CZ/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/cs-CZ/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/cs-CZ/step_4.md b/cs-CZ/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/cs-CZ/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/cs-CZ/step_5.md b/cs-CZ/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/cs-CZ/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/cs-CZ/step_6.md b/cs-CZ/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/cs-CZ/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/cs-CZ/step_7.md b/cs-CZ/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/cs-CZ/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/cs-CZ/step_8.md b/cs-CZ/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/cs-CZ/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/cs-CZ/step_9.md b/cs-CZ/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/cs-CZ/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/da-DK/images/banner.png b/da-DK/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/da-DK/images/banner.png differ diff --git a/da-DK/images/blockbeneath.gif b/da-DK/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/da-DK/images/blockbeneath.gif differ diff --git a/da-DK/images/helloworld.gif b/da-DK/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/da-DK/images/helloworld.gif differ diff --git a/da-DK/images/lava.png b/da-DK/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/da-DK/images/lava.png differ diff --git a/da-DK/images/mcpi-block-test.png b/da-DK/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/da-DK/images/mcpi-block-test.png differ diff --git a/da-DK/images/mcpi-flowers-grass.png b/da-DK/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/da-DK/images/mcpi-flowers-grass.png differ diff --git a/da-DK/images/mcpi-flowers-sky.png b/da-DK/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/da-DK/images/mcpi-flowers-sky.png differ diff --git a/da-DK/images/mcpi-flowers.png b/da-DK/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/da-DK/images/mcpi-flowers.png differ diff --git a/da-DK/images/mcpi-flying.png b/da-DK/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/da-DK/images/mcpi-flying.png differ diff --git a/da-DK/images/mcpi-game.png b/da-DK/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/da-DK/images/mcpi-game.png differ diff --git a/da-DK/images/mcpi-idle.png b/da-DK/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/da-DK/images/mcpi-idle.png differ diff --git a/da-DK/images/mcpi-install.png b/da-DK/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/da-DK/images/mcpi-install.png differ diff --git a/da-DK/images/mcpi-inventory.png b/da-DK/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/da-DK/images/mcpi-inventory.png differ diff --git a/da-DK/images/mcpi-setblock.png b/da-DK/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/da-DK/images/mcpi-setblock.png differ diff --git a/da-DK/images/mcpi-setblock2.png b/da-DK/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/da-DK/images/mcpi-setblock2.png differ diff --git a/da-DK/images/mcpi-setblocks.png b/da-DK/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/da-DK/images/mcpi-setblocks.png differ diff --git a/da-DK/images/mcpi-start.png b/da-DK/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/da-DK/images/mcpi-start.png differ diff --git a/da-DK/images/mcpi-tnt-blocks.png b/da-DK/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/da-DK/images/mcpi-tnt-blocks.png differ diff --git a/da-DK/images/mcpi-tnt-explode.png b/da-DK/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/da-DK/images/mcpi-tnt-explode.png differ diff --git a/da-DK/images/mcpi-tnt.png b/da-DK/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/da-DK/images/mcpi-tnt.png differ diff --git a/da-DK/images/menu.png b/da-DK/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/da-DK/images/menu.png differ diff --git a/da-DK/images/minecraft-pi-banner.png b/da-DK/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/da-DK/images/minecraft-pi-banner.png differ diff --git a/da-DK/images/minecraft-pi-shortcut.png b/da-DK/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/da-DK/images/minecraft-pi-shortcut.png differ diff --git a/da-DK/meta.yml b/da-DK/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/da-DK/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/da-DK/step_1.md b/da-DK/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/da-DK/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/da-DK/step_2.md b/da-DK/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/da-DK/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/da-DK/step_3.md b/da-DK/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/da-DK/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/da-DK/step_4.md b/da-DK/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/da-DK/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/da-DK/step_5.md b/da-DK/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/da-DK/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/da-DK/step_6.md b/da-DK/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/da-DK/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/da-DK/step_7.md b/da-DK/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/da-DK/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/da-DK/step_8.md b/da-DK/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/da-DK/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/da-DK/step_9.md b/da-DK/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/da-DK/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/de-DE/images/banner.png b/de-DE/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/de-DE/images/banner.png differ diff --git a/de-DE/images/blockbeneath.gif b/de-DE/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/de-DE/images/blockbeneath.gif differ diff --git a/de-DE/images/helloworld.gif b/de-DE/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/de-DE/images/helloworld.gif differ diff --git a/de-DE/images/lava.png b/de-DE/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/de-DE/images/lava.png differ diff --git a/de-DE/images/mcpi-block-test.png b/de-DE/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/de-DE/images/mcpi-block-test.png differ diff --git a/de-DE/images/mcpi-flowers-grass.png b/de-DE/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/de-DE/images/mcpi-flowers-grass.png differ diff --git a/de-DE/images/mcpi-flowers-sky.png b/de-DE/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/de-DE/images/mcpi-flowers-sky.png differ diff --git a/de-DE/images/mcpi-flowers.png b/de-DE/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/de-DE/images/mcpi-flowers.png differ diff --git a/de-DE/images/mcpi-flying.png b/de-DE/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/de-DE/images/mcpi-flying.png differ diff --git a/de-DE/images/mcpi-game.png b/de-DE/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/de-DE/images/mcpi-game.png differ diff --git a/de-DE/images/mcpi-idle.png b/de-DE/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/de-DE/images/mcpi-idle.png differ diff --git a/de-DE/images/mcpi-install.png b/de-DE/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/de-DE/images/mcpi-install.png differ diff --git a/de-DE/images/mcpi-inventory.png b/de-DE/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/de-DE/images/mcpi-inventory.png differ diff --git a/de-DE/images/mcpi-setblock.png b/de-DE/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/de-DE/images/mcpi-setblock.png differ diff --git a/de-DE/images/mcpi-setblock2.png b/de-DE/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/de-DE/images/mcpi-setblock2.png differ diff --git a/de-DE/images/mcpi-setblocks.png b/de-DE/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/de-DE/images/mcpi-setblocks.png differ diff --git a/de-DE/images/mcpi-start.png b/de-DE/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/de-DE/images/mcpi-start.png differ diff --git a/de-DE/images/mcpi-tnt-blocks.png b/de-DE/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/de-DE/images/mcpi-tnt-blocks.png differ diff --git a/de-DE/images/mcpi-tnt-explode.png b/de-DE/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/de-DE/images/mcpi-tnt-explode.png differ diff --git a/de-DE/images/mcpi-tnt.png b/de-DE/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/de-DE/images/mcpi-tnt.png differ diff --git a/de-DE/images/menu.png b/de-DE/images/menu.png new file mode 100644 index 0000000..2e29a76 Binary files /dev/null and b/de-DE/images/menu.png differ diff --git a/de-DE/images/minecraft-pi-banner.png b/de-DE/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/de-DE/images/minecraft-pi-banner.png differ diff --git a/de-DE/images/minecraft-pi-shortcut.png b/de-DE/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/de-DE/images/minecraft-pi-shortcut.png differ diff --git a/de-DE/meta.yml b/de-DE/meta.yml new file mode 100644 index 0000000..a09611d --- /dev/null +++ b/de-DE/meta.yml @@ -0,0 +1,37 @@ +--- +title: Erste Schritte mit Minecraft Pi +hero_image: images/banner.png +description: Hol dir deinen ersten Vorgeschmack auf die Programmierung der Welt von Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Einleitung + - + title: Was du brauchen wirst + - + title: Erste Schritte mit Minecraft Pi + - + title: Minecraft öffnen + - + title: Benutze die Programmierschnittstelle von Python + - + title: Blöcke beim Gehen fallen lassen + - + title: Mit TNT-Blöcken spielen + - + title: Spaß mit fließender Lava. + - + title: Wie geht es weiter? diff --git a/de-DE/step_1.md b/de-DE/step_1.md new file mode 100644 index 0000000..a5fda2e --- /dev/null +++ b/de-DE/step_1.md @@ -0,0 +1,19 @@ +## Was du machen wirst + +In dieser Ressource erkundest du die virtuelle Welt von Minecraft Pi, der Sonderedition von Minecraft für Raspberry Pi. + +Du lernst, wie du den Spieler steuerst, manuell mit Blöcken baust und mithilfe der Python-Oberfläche die Welt um dich herum manipulierst. + +## Was du lernen wirst + +Wenn du dieser Ressource mit deinem Raspberry Pi folgst, lernst du: + +- Wie man auf Minecraft Pi zugreift und eine neue Welt erstellt +- Wie man die Python-Programmierumgebung IDLE zum Herstellen einer Verbindung mit Minecraft Pi nutzen kann +- Das Minecraft Python-API, zu verwenden um Text im Chat-Fenster zu veröffentlichen, die Koordinaten des Spielers zu finden, zu teleportieren und Strukturen aufzubauen +- Das Verwenden von Variablen zum Speichern von IDs für verschiedene Arten von Blöcken +- Mit dem Platzieren verschiedener Arten von Blöcken mit speziellen Attributen, zu experimentieren + +Diese Ressource umfasst Elemente aus den folgenden Abschnitten des [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Verwendung elementarer Programmiersprachelemente zur Erstellung einfacher Programme](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/de-DE/step_2.md b/de-DE/step_2.md new file mode 100644 index 0000000..d5aaa3b --- /dev/null +++ b/de-DE/step_2.md @@ -0,0 +1,54 @@ +## Was du brauchen wirst + +### Software + +#### Softwareinstallation + +Minecraft ist seit September 2014 standardmäßig in Raspbian installiert. + +![Minecraft Pi Desktop-Symbol](images/minecraft-pi-shortcut.png) + +Wenn du eine ältere Version von Raspbian verwendest, öffne ein Terminalfenster und gebe die folgenden Befehle ein (du musst hierfür online sein): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Sobald dies abgeschlossen ist, sollten Minecraft Pi und die Python-Bibliothek installiert sein. + +#### Minecraft testen + +Um Minecraft auszuführen, doppelklicke auf das Desktop-Symbol oder gib `minecraft-pi` in das Terminal ein. + +![](images/mcpi-start.png) + +Wenn Minecraft Pi geladen wurde, klicke auf **Start Game**, danach auf **Create new**. Du wirst feststellen, dass das enthaltene Fenster leicht versetzt ist. Dies bedeutet, dass du zum Ziehen des Fensters die Titelleiste hinter dem Minecraft-Fenster greifen musst. + +![](images/mcpi-game.png) + +Du bist jetzt in einem Minecraft-Spiel! + +#### Python testen + +Wenn Minecraft läuft und die Welt erstellt ist, lenke deinen Fokus vom Spiel weg, indem du die Taste `Tab` drückst, wodurch der Mauszeiger frei wird. Öffne Python 3 (IDLE) auf dem Desktop und verschiebe die Fenster so, dass sie nebeneinander liegen. + +Du kannst entweder Befehle direkt in das Python-Fenster eingeben oder eine Datei erstellen, um deinen Code zu speichern und ein anderes Mal erneut auszuführen. + +Wenn du eine Datei erstellen möchtest, gehe zu `Datei > Neues Fenster` und `Datei > Speichern`. Du möchtest das wahrscheinlich in deinem Home-Ordner oder einem neuen Projektordner speichern. + +Importiere zunächst die Minecraft-Bibliothek, stelle eine Verbindung zum Spiel her und teste sie, indem du die Meldung "Hello World" auf den Bildschirm schreibst: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello World") +``` + +Wenn du Befehle direkt in das Python-Fenster eingibst, drücke einfach nach jeder Zeile `Enter`. Wenn es sich um eine Datei handelt, speichere sie mit `Strg + S` und führe sie mit `F5` aus. Wenn dein Code ausgeführt wird, sollte deine Nachricht im Spiel auf dem Bildschirm angezeigt werden. + +![](images/mcpi-idle.png) + +Wenn du im Minecraft-Fenster "Hello World" siehst, kannst du mit dem nächsten Schritt fortfahren. \ No newline at end of file diff --git a/de-DE/step_3.md b/de-DE/step_3.md new file mode 100644 index 0000000..b908591 --- /dev/null +++ b/de-DE/step_3.md @@ -0,0 +1,5 @@ +## Erste Schritte mit Minecraft Pi + +Minecraft ist ein beliebtes Open-World-Sandkasten-Bauspiel. Für den Raspberry Pi ist eine kostenlose Version von Minecraft verfügbar. Es kommt auch mit einer Programmierschnittstelle. Dies bedeutet, dass du Befehle und Skripte in Python-Code schreiben kannst, um Dinge im Spiel automatisch zu bauen. Es ist eine großartige Möglichkeit, Python zu lernen! + +![Minecraft Pi Banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/de-DE/step_4.md b/de-DE/step_4.md new file mode 100644 index 0000000..b229d47 --- /dev/null +++ b/de-DE/step_4.md @@ -0,0 +1,35 @@ +## Minecraft starten + +Um Minecraft Pi auszuführen, öffne es über das Desktop-Menü oder gib `minecraft-pi` in das Terminal ein. + +![](images/menu.png) + +Wenn Minecraft Pi geladen wurde, klicke auf **Start Game** (englisch für "Spiel starten"), und dann auf **Create new** (also "neue Erstellen"). Du wirst feststellen, dass das umgebende Fenster leicht versetzt ist. Das bedeutet, dass du zum Ziehen des Fensters die Titelleiste hinter dem Minecraft-Fenster greifen musst. + +![](images/mcpi-game.png) + +Du bist jetzt in einem Minecraft-Spiel! Lauf herum, hacke Dinge und baue Dinge! + +Schaue dich mit der Maus um und verwende die folgenden Tasten auf der Tastatur: + +| Taste | Aktion | +|:------------------:|:--------------------:| +| W | Vorwärts | +| A | Links | +| S | Rückwärts | +| D | Rechts | +| E | Inventar | +| Leertaste | Springen | +| Doppelte Leertaste | Fliegen / Fallen | +| Esc | Pause / Spielmenü | +| Tab | Mauszeiger freigeben | + +Du kannst einen Gegenstand mit dem Mausrad aus der Schnellzugriffs-Leiste auswählen (oder die Zahlen auf deiner Tastatur verwenden) oder `E` drücken und etwas aus dem Inventar auswählen. + +![](images/mcpi-inventory.png) + +Du kannst auch zweimal auf die Leertaste tippen, um in die Luft zu fliegen. Du hörst auf zu fliegen, wenn du die Leertaste loslässt und wenn du erneut zweimal darauf tippst, fällst du auf den Boden zurück. + +![](images/mcpi-flying.png) + +Mit dem Schwert in der Hand kannst du auf Blöcke vor dir klicken, um sie zu entfernen (oder zu graben). Mit einem Block in der Hand kannst du diesen Block mit der rechten Maustaste vor dir platzieren oder mit der linken Maustaste einen Block entfernen. \ No newline at end of file diff --git a/de-DE/step_5.md b/de-DE/step_5.md new file mode 100644 index 0000000..8dd625f --- /dev/null +++ b/de-DE/step_5.md @@ -0,0 +1,162 @@ +## Die Python-Programmierschnittstelle verwenden + +Wenn Minecraft läuft und die Welt erschaffen wurde, bringe deinen Fokus vom Spiel weg, indem du die Taste `Tab` drückst, wodurch deine Maus frei wird. Öffne Python 3 über das Anwendungsmenü und verschiebe die Fenster so, dass sie nebeneinander liegen. + +Du kannst entweder Befehle direkt in das Python-Fenster eingeben oder eine Datei erstellen, um deinen Code zu speichern und ein anderes Mal erneut auszuführen. + +Wenn du eine Datei erstellen möchtest, gehe zu `Datei > Neues Fenster` und `Datei > Speichern`. Du möchtest das wahrscheinlich in deinem Home-Ordner oder einem neuen Projektordner speichern. + +Importiere zunächst die Minecraft-Bibliothek, stelle eine Verbindung zum Spiel her und teste sie, indem du die Meldung "Hallo Welt" auf den Bildschirm schreibst: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hallo Welt") +``` + +Wenn du Befehle direkt in das Python-Fenster eingibst, drücke einfach nach jeder Zeile `Enter`. Wenn es sich um eine Datei handelt, speichere sie mit `Strg + S` und führe sie mit `F5` aus. Wenn dein Code ausgeführt wird, sollte deine Nachricht im Spiel auf dem Bildschirm angezeigt werden. + +![](images/helloworld.gif) + +### Finde deinen Standort + +Um deinen Standort herauszufinden, tippe folgendes ein: + +```python +pos = mc.player.getPos() +``` + +`pos` enthält jetzt deinen Standort; Greife auf jeden Teil des Koordinatensatzes mit `pos.x`, `pos.y` und `pos.z` zu. + +Alternativ kann man die Koordinaten in getrennte Variablen umwandeln, indem man Pythons Auspackungstechnik verwendet: + +```python +x, y, z = mc.player.getPos() +``` + +Jetzt enthalten `x`, `y`und `z` jeden Teil deiner Positionskoordinaten. `x` und `z` sind die Laufrichtungen (vorwärts/rückwärts und links/rechts) und `y` ist oben/unten. + +Beachte, dass `getPos()` den aktuellen Standort des Spielers zurückgibt. Wenn du die Position veränderst, musst du die Funktion erneut aufrufen oder den gespeicherten Standort verwenden. + +### Teleportieren + +Du kannst nicht nur deinen aktuellen Standort ermitteln, sondern auch eine bestimmte Stelle angeben, zu der du teleportieren möchten. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +Das wird deinen Spieler 100 Felder in die Luft transportieren. Das bedeutet, dass du in die Mitte des Himmels teleportiert wirst und direkt wieder dorthin zurück fällst, wo du gestartet bist. + +Versuche dich an einen anderen Ort zu teleportieren! + +### Block setzen + +Du kannst einen einzelnen Block an einem bestimmten Koordinatensatz mit `mc.setBlock()` setzen: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Jetzt sollte ein Steinblock neben deiner Position erscheinen. Wenn er nicht unmittelbar vor dir liegt, kann er neben oder hinter dir sein. Kehre zum Minecraft-Fenster zurück und drehe dich mit der Maus an Ort und Stelle, bis du einen grauen Block direkt vor dir siehst. + +![](images/mcpi-setblock.png) + +Die an `setBlock` übergebenen Argumente sind `x`, `y`, `z` und `id`. `(x, y, z)` bezieht sich auf die Position in der Welt (wir haben einen Block von der Stelle angegeben, an der der Spieler steht mit `x + 1`) und die `id` bezieht sich auf die Art des Blocks, den wir platzieren wollen. `1` ist Stein. + +Andere Blöcke, die du ausprobieren kannst: + + Luft: 0 + Gras: 2 + Erde: 3 + + +Versuche nun, mit dem Block im Blick, ihn in etwas anderes zu verwandeln: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +Du solltest sehen, wie sich der graue Steinblock vor deinen Augen verändert! + +![](images/mcpi-setblock2.png) + +#### Blockkonstanten + +Du kannst eine eingebaute Blockkonstante verwenden, um deine Blöcke zu setzen, wenn du deren Namen kennst. Du benötigst jedoch zuerst eine weitere `Import` Zeile. + +```python +from mcpi import block +``` + +Jetzt kannst du Folgendes schreiben, um einen Block zu platzieren: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block-IDs sind ziemlich einfach zu erraten. Verwende einfach NUR GROSSBUCHSTABEN (und die englischen Namen der Blöcke). Hier sind einige Beispiele, um dich an die Art und Weise zu gewöhnen, wie sie benannt sind. + + WOOD_PLANKS #Holzplanken + WATER_STATIONARY #stehendes Wasser + GOLD_ORE #Golderz + GOLD_BLOCK #Goldblock + DIAMOND_BLOCK #Diamandblock + NETHER_REACTOR_CORE #Netherreaktorkern + + +### Block als Variable + +Wenn du die ID eines Blocks kennst, kann es hilfreich sein, ihn als Variable festzulegen. Du kannst den Namen oder die Ganzzahl-ID verwenden. + +```python +erde = 3 +mc.setBlock(x, y, z, erde) +``` + +oder + +```python +erde = block.DIRT.id +mc.setBlock(x, y, z, erde) +``` + +### Spezielle Blöcke + +Es gibt einige Blöcke mit zusätzlichen Eigenschaften, z. B. Wolle mit einer zusätzlichen Einstellung, mit der du die Farbe festlegen kannst. Um dies einzustellen, verwende den optionalen vierten Parameter in `setBlock`: + +```python +wolle = 35 +mc.setBlock(x, y, z, wolle, 1) +``` + +Hier setzt der vierte Parameter `1` die Wollfarbe auf Orange. Ohne den vierten Parameter wird sie auf den Standardwert (`0`) gesetzt, der weiß ist. Einige weitere Farben sind: + + 2: Magenta + 3: Hellblau + 4: Gelb + + +Probiere weitere Zahlen aus und beobachte wie sich der Block verändert! + +Andere Blöcke mit zusätzlichen Eigenschaften sind Holz (`17`): Eiche, Fichte, Birke usw.; hohes Gras (`31`): Strauch, Gras, Farn; Fackel (`50`): zeigt nach Osten, Westen, Norden, Süden; und mehr. Ausführliche Informationen findest du in der [API-Referenz](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). + +### Mehrere Blöcke setzen + +Genau wie du einen einzelnen Block mit `setBlock` setzen kannst, kannst du auch mit `setBlocks` ein Raumvolumen auf einmal ausfüllen: + +```python +stein = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stein) +``` + +Dadurch wird ein 10 x 10 x 10 Würfel mit massivem Stein gefüllt. + +![](images/mcpi-setblocks.png) + +Du kannst auch größere Volumen mit der Funktion `setBlocks` erstellen, die Generierung kann jedoch länger dauern! \ No newline at end of file diff --git a/de-DE/step_6.md b/de-DE/step_6.md new file mode 100644 index 0000000..9584243 --- /dev/null +++ b/de-DE/step_6.md @@ -0,0 +1,86 @@ +## Blöcke beim Gehen fallen lassen + +Jetzt weißt du, wie man Blöcke fallen lässt. Lass uns unsere sich ändernde Position verwenden, um Blöcke fallen zu lassen, wenn du gehst. + +Der folgende Code lässt eine Blume hinter dir fallen, wo immer du gehst: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +blume = 38 + +while True: +x, y, z = mc.player.getPos() +mc.setBlock(x, y, z, blume) +sleep(0.1) +``` + +Gehe jetzt eine Weile vorwärts und drehe dich um, um die Blumen zu sehen, die du zurückgelassen hast. + +![](images/mcpi-flowers.png) + +Da wir eine `while True` (also "solange Wahr") Schleife verwendet haben, wird dies für immer weitergehen. Um es zu stoppen, drücke im Python-Fenster `Strg + C`. + +Versuche durch die Luft zu fliegen und sieh die Blumen, die du am Himmel hinterlässt: + +![](images/mcpi-flowers-sky.png) + +Was wäre, wenn wir nur Blumen fallen lassen wollten, wenn der Spieler auf Gras läuft? Wir können `getBlock` verwenden, um herauszufinden von welchem Typ ein Block ist: + +```python +x, y, z = mc.player.getPos() # Spielerposition (x, y, z) +dieser_block = mc.getBlock(x, y, z) # Block-ID +print(dieser_block) +``` + +Das sagt dir die Stelle des Blocks *in* dem du gerade stehst (das wird `0` sein - ein Luftblock). Wir wollen wissen, *auf* welche Art von Block wir stehen. Dazu subtrahieren wir 1 vom Wert `y` und verwenden `getBlock()`, um zu bestimmen, auf welchem Blocktyp wir stehen: + +```python +x, y, z = mc.player.getPos() # Spielerposition (x, y, z) +block_drunter = mc.getBlock(x, y-1, z) # Block-ID +print(block_drunter) +``` + +Dies sagt uns die ID des Blocks, auf dem der Spieler steht. + +Teste dies, indem du eine Schleife laufen lässt, um die Block-ID von allem zu drucken, auf dem du gerade stehst: + +```python +while True: + x, y, z = mc.player.getPos() + block_drunter = mc.getBlock(x, y-1, z) + print(block_drunter) +``` + +![](images/blockbeneath.gif) + +Wir können eine `if` (also "falls") Anweisung verwenden, um zu entscheiden, ob wir eine Blume pflanzen oder nicht: + +```python +gras = 2 +blume = 38 + +while True: + x, y, z = mc.player.getPos() # Spielerposition (x, y, z) + block_drunter = mc.getBlock(x, y-1, z) # Block ID + + if block_drunter == gras: + mc.setBlock(x, y, z, blume) + sleep(0.1) +``` + +Vielleicht könnten wir als nächstes das Feld, auf der wir stehen, in Gras verwandeln, wenn es nicht schon Gras ist: + +```python +if block_drunter == gras: + mc.setBlock(x, y, z, blume) +else: + mc.setBlock(x, y-1, z, gras) +``` + +Jetzt können wir vorwärts gehen und wenn wir auf Gras gehen, lassen wir eine Blume zurück. Wenn der nächste Block kein Gras ist, verwandelt er sich in Gras. Wenn wir uns umdrehen und zurückgehen, lassen wir jetzt eine Blume hinter uns. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/de-DE/step_7.md b/de-DE/step_7.md new file mode 100644 index 0000000..775fdec --- /dev/null +++ b/de-DE/step_7.md @@ -0,0 +1,32 @@ +## Mit TNT-Blöcken spielen + +Ein weiterer interessanter Block ist TNT! Um einen normalen TNT-Block zu platzieren, verwende: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +Dieser TNT-Block ist jedoch ziemlich langweilig. Versuche, `Daten` als `1` hinzuzufügen: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Verwende jetzt dein Schwert und klicke mit der linken Maustaste auf den TNT-Block: Er wird aktiviert und explodiert in Sekundenschnelle! + +Versuche nun, einen großen Würfel aus TNT-Blöcken zu erstellen! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Jetzt siehst du einen großen Würfel voller TNT-Blöcke. Geh hin und aktiviere einen der Blöcke und renne dann weg, um die Show zu sehen! Das Rendern der Grafiken wird sehr langsam sein, da sich so viele Dinge gleichzeitig ändern. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/de-DE/step_8.md b/de-DE/step_8.md new file mode 100644 index 0000000..1b568ca --- /dev/null +++ b/de-DE/step_8.md @@ -0,0 +1,43 @@ +## Spaß mit fließender Lava. + +Ein Block, mit dem es viel Spaß macht zu spielen, ist fließende Lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Suche den Block, den du gerade platziert hast und du solltest sehen, wie Lava vom Block zum Boden fließt. + +Das Coole an Lava ist, dass sie beim Abkühlen zu Fels wird. Bewege dich an einen anderen Ort in deiner Welt und versuche Folgendes: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +wasser = 8 +luft = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, wasser) +sleep(4) +mc.setBlock(x+3, y+5, z, luft) + +``` + +Du kannst die `sleep`-Parameter anpassen, damit mehr oder weniger Lava fließen kann. + +![Lava](images/lava.png) \ No newline at end of file diff --git a/de-DE/step_9.md b/de-DE/step_9.md new file mode 100644 index 0000000..c93b9c6 --- /dev/null +++ b/de-DE/step_9.md @@ -0,0 +1,11 @@ +## Was kommt als Nächstes? + +Du kannst jetzt viel tun, da du dich jetzt in der Minecraft-Welt auskennst und weisst wie du die Python-Oberfläche verwendest. + +### Vernetztes Spiel + +Wenn mehrere Personen Raspberry Pis mit einem lokalen Netzwerk verbinden, können sie derselben Minecraft-Welt beitreten und zusammen spielen. Spieler können sich in der Minecraft-Welt sehen. + +### API-Referenz + +Eine ausführlichere Dokumentation der Funktionen und eine vollständige Liste der Block-IDs findest du in einer API-Referenz unter [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/el-GR/images/banner.png b/el-GR/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/el-GR/images/banner.png differ diff --git a/el-GR/images/blockbeneath.gif b/el-GR/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/el-GR/images/blockbeneath.gif differ diff --git a/el-GR/images/helloworld.gif b/el-GR/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/el-GR/images/helloworld.gif differ diff --git a/el-GR/images/lava.png b/el-GR/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/el-GR/images/lava.png differ diff --git a/el-GR/images/mcpi-block-test.png b/el-GR/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/el-GR/images/mcpi-block-test.png differ diff --git a/el-GR/images/mcpi-flowers-grass.png b/el-GR/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/el-GR/images/mcpi-flowers-grass.png differ diff --git a/el-GR/images/mcpi-flowers-sky.png b/el-GR/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/el-GR/images/mcpi-flowers-sky.png differ diff --git a/el-GR/images/mcpi-flowers.png b/el-GR/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/el-GR/images/mcpi-flowers.png differ diff --git a/el-GR/images/mcpi-flying.png b/el-GR/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/el-GR/images/mcpi-flying.png differ diff --git a/el-GR/images/mcpi-game.png b/el-GR/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/el-GR/images/mcpi-game.png differ diff --git a/el-GR/images/mcpi-idle.png b/el-GR/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/el-GR/images/mcpi-idle.png differ diff --git a/el-GR/images/mcpi-install.png b/el-GR/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/el-GR/images/mcpi-install.png differ diff --git a/el-GR/images/mcpi-inventory.png b/el-GR/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/el-GR/images/mcpi-inventory.png differ diff --git a/el-GR/images/mcpi-setblock.png b/el-GR/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/el-GR/images/mcpi-setblock.png differ diff --git a/el-GR/images/mcpi-setblock2.png b/el-GR/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/el-GR/images/mcpi-setblock2.png differ diff --git a/el-GR/images/mcpi-setblocks.png b/el-GR/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/el-GR/images/mcpi-setblocks.png differ diff --git a/el-GR/images/mcpi-start.png b/el-GR/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/el-GR/images/mcpi-start.png differ diff --git a/el-GR/images/mcpi-tnt-blocks.png b/el-GR/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/el-GR/images/mcpi-tnt-blocks.png differ diff --git a/el-GR/images/mcpi-tnt-explode.png b/el-GR/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/el-GR/images/mcpi-tnt-explode.png differ diff --git a/el-GR/images/mcpi-tnt.png b/el-GR/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/el-GR/images/mcpi-tnt.png differ diff --git a/el-GR/images/menu.png b/el-GR/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/el-GR/images/menu.png differ diff --git a/el-GR/images/minecraft-pi-banner.png b/el-GR/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/el-GR/images/minecraft-pi-banner.png differ diff --git a/el-GR/images/minecraft-pi-shortcut.png b/el-GR/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/el-GR/images/minecraft-pi-shortcut.png differ diff --git a/el-GR/meta.yml b/el-GR/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/el-GR/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/el-GR/step_1.md b/el-GR/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/el-GR/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/el-GR/step_2.md b/el-GR/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/el-GR/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/el-GR/step_3.md b/el-GR/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/el-GR/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/el-GR/step_4.md b/el-GR/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/el-GR/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/el-GR/step_5.md b/el-GR/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/el-GR/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/el-GR/step_6.md b/el-GR/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/el-GR/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/el-GR/step_7.md b/el-GR/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/el-GR/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/el-GR/step_8.md b/el-GR/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/el-GR/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/el-GR/step_9.md b/el-GR/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/el-GR/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/en-US/images/banner.png b/en-US/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/en-US/images/banner.png differ diff --git a/en-US/images/blockbeneath.gif b/en-US/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/en-US/images/blockbeneath.gif differ diff --git a/en-US/images/helloworld.gif b/en-US/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/en-US/images/helloworld.gif differ diff --git a/en-US/images/lava.png b/en-US/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/en-US/images/lava.png differ diff --git a/en-US/images/mcpi-block-test.png b/en-US/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/en-US/images/mcpi-block-test.png differ diff --git a/en-US/images/mcpi-flowers-grass.png b/en-US/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/en-US/images/mcpi-flowers-grass.png differ diff --git a/en-US/images/mcpi-flowers-sky.png b/en-US/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/en-US/images/mcpi-flowers-sky.png differ diff --git a/en-US/images/mcpi-flowers.png b/en-US/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/en-US/images/mcpi-flowers.png differ diff --git a/en-US/images/mcpi-flying.png b/en-US/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/en-US/images/mcpi-flying.png differ diff --git a/en-US/images/mcpi-game.png b/en-US/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/en-US/images/mcpi-game.png differ diff --git a/en-US/images/mcpi-idle.png b/en-US/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/en-US/images/mcpi-idle.png differ diff --git a/en-US/images/mcpi-install.png b/en-US/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/en-US/images/mcpi-install.png differ diff --git a/en-US/images/mcpi-inventory.png b/en-US/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/en-US/images/mcpi-inventory.png differ diff --git a/en-US/images/mcpi-setblock.png b/en-US/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/en-US/images/mcpi-setblock.png differ diff --git a/en-US/images/mcpi-setblock2.png b/en-US/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/en-US/images/mcpi-setblock2.png differ diff --git a/en-US/images/mcpi-setblocks.png b/en-US/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/en-US/images/mcpi-setblocks.png differ diff --git a/en-US/images/mcpi-start.png b/en-US/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/en-US/images/mcpi-start.png differ diff --git a/en-US/images/mcpi-tnt-blocks.png b/en-US/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/en-US/images/mcpi-tnt-blocks.png differ diff --git a/en-US/images/mcpi-tnt-explode.png b/en-US/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/en-US/images/mcpi-tnt-explode.png differ diff --git a/en-US/images/mcpi-tnt.png b/en-US/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/en-US/images/mcpi-tnt.png differ diff --git a/en-US/images/menu.png b/en-US/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/en-US/images/menu.png differ diff --git a/en-US/images/minecraft-pi-banner.png b/en-US/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/en-US/images/minecraft-pi-banner.png differ diff --git a/en-US/images/minecraft-pi-shortcut.png b/en-US/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/en-US/images/minecraft-pi-shortcut.png differ diff --git a/en-US/meta.yml b/en-US/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/en-US/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/en-US/step_1.md b/en-US/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/en-US/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/en-US/step_2.md b/en-US/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/en-US/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/en-US/step_3.md b/en-US/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/en-US/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/en-US/step_4.md b/en-US/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/en-US/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/en-US/step_5.md b/en-US/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/en-US/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/en-US/step_6.md b/en-US/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/en-US/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/en-US/step_7.md b/en-US/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/en-US/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/en-US/step_8.md b/en-US/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/en-US/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/en-US/step_9.md b/en-US/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/en-US/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/es-ES/images/banner.png b/es-ES/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/es-ES/images/banner.png differ diff --git a/es-ES/images/blockbeneath.gif b/es-ES/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/es-ES/images/blockbeneath.gif differ diff --git a/es-ES/images/helloworld.gif b/es-ES/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/es-ES/images/helloworld.gif differ diff --git a/es-ES/images/lava.png b/es-ES/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/es-ES/images/lava.png differ diff --git a/es-ES/images/mcpi-block-test.png b/es-ES/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/es-ES/images/mcpi-block-test.png differ diff --git a/es-ES/images/mcpi-flowers-grass.png b/es-ES/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/es-ES/images/mcpi-flowers-grass.png differ diff --git a/es-ES/images/mcpi-flowers-sky.png b/es-ES/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/es-ES/images/mcpi-flowers-sky.png differ diff --git a/es-ES/images/mcpi-flowers.png b/es-ES/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/es-ES/images/mcpi-flowers.png differ diff --git a/es-ES/images/mcpi-flying.png b/es-ES/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/es-ES/images/mcpi-flying.png differ diff --git a/es-ES/images/mcpi-game.png b/es-ES/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/es-ES/images/mcpi-game.png differ diff --git a/es-ES/images/mcpi-idle.png b/es-ES/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/es-ES/images/mcpi-idle.png differ diff --git a/es-ES/images/mcpi-install.png b/es-ES/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/es-ES/images/mcpi-install.png differ diff --git a/es-ES/images/mcpi-inventory.png b/es-ES/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/es-ES/images/mcpi-inventory.png differ diff --git a/es-ES/images/mcpi-setblock.png b/es-ES/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/es-ES/images/mcpi-setblock.png differ diff --git a/es-ES/images/mcpi-setblock2.png b/es-ES/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/es-ES/images/mcpi-setblock2.png differ diff --git a/es-ES/images/mcpi-setblocks.png b/es-ES/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/es-ES/images/mcpi-setblocks.png differ diff --git a/es-ES/images/mcpi-start.png b/es-ES/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/es-ES/images/mcpi-start.png differ diff --git a/es-ES/images/mcpi-tnt-blocks.png b/es-ES/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/es-ES/images/mcpi-tnt-blocks.png differ diff --git a/es-ES/images/mcpi-tnt-explode.png b/es-ES/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/es-ES/images/mcpi-tnt-explode.png differ diff --git a/es-ES/images/mcpi-tnt.png b/es-ES/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/es-ES/images/mcpi-tnt.png differ diff --git a/es-ES/images/menu.png b/es-ES/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/es-ES/images/menu.png differ diff --git a/es-ES/images/minecraft-pi-banner.png b/es-ES/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/es-ES/images/minecraft-pi-banner.png differ diff --git a/es-ES/images/minecraft-pi-shortcut.png b/es-ES/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/es-ES/images/minecraft-pi-shortcut.png differ diff --git a/es-ES/meta.yml b/es-ES/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/es-ES/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/es-ES/step_1.md b/es-ES/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/es-ES/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/es-ES/step_2.md b/es-ES/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/es-ES/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/es-ES/step_3.md b/es-ES/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/es-ES/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/es-ES/step_4.md b/es-ES/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/es-ES/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/es-ES/step_5.md b/es-ES/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/es-ES/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/es-ES/step_6.md b/es-ES/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/es-ES/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/es-ES/step_7.md b/es-ES/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/es-ES/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/es-ES/step_8.md b/es-ES/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/es-ES/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/es-ES/step_9.md b/es-ES/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/es-ES/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/fi-FI/images/banner.png b/fi-FI/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/fi-FI/images/banner.png differ diff --git a/fi-FI/images/blockbeneath.gif b/fi-FI/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/fi-FI/images/blockbeneath.gif differ diff --git a/fi-FI/images/helloworld.gif b/fi-FI/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/fi-FI/images/helloworld.gif differ diff --git a/fi-FI/images/lava.png b/fi-FI/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/fi-FI/images/lava.png differ diff --git a/fi-FI/images/mcpi-block-test.png b/fi-FI/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/fi-FI/images/mcpi-block-test.png differ diff --git a/fi-FI/images/mcpi-flowers-grass.png b/fi-FI/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/fi-FI/images/mcpi-flowers-grass.png differ diff --git a/fi-FI/images/mcpi-flowers-sky.png b/fi-FI/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/fi-FI/images/mcpi-flowers-sky.png differ diff --git a/fi-FI/images/mcpi-flowers.png b/fi-FI/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/fi-FI/images/mcpi-flowers.png differ diff --git a/fi-FI/images/mcpi-flying.png b/fi-FI/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/fi-FI/images/mcpi-flying.png differ diff --git a/fi-FI/images/mcpi-game.png b/fi-FI/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/fi-FI/images/mcpi-game.png differ diff --git a/fi-FI/images/mcpi-idle.png b/fi-FI/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/fi-FI/images/mcpi-idle.png differ diff --git a/fi-FI/images/mcpi-install.png b/fi-FI/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/fi-FI/images/mcpi-install.png differ diff --git a/fi-FI/images/mcpi-inventory.png b/fi-FI/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/fi-FI/images/mcpi-inventory.png differ diff --git a/fi-FI/images/mcpi-setblock.png b/fi-FI/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/fi-FI/images/mcpi-setblock.png differ diff --git a/fi-FI/images/mcpi-setblock2.png b/fi-FI/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/fi-FI/images/mcpi-setblock2.png differ diff --git a/fi-FI/images/mcpi-setblocks.png b/fi-FI/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/fi-FI/images/mcpi-setblocks.png differ diff --git a/fi-FI/images/mcpi-start.png b/fi-FI/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/fi-FI/images/mcpi-start.png differ diff --git a/fi-FI/images/mcpi-tnt-blocks.png b/fi-FI/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/fi-FI/images/mcpi-tnt-blocks.png differ diff --git a/fi-FI/images/mcpi-tnt-explode.png b/fi-FI/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/fi-FI/images/mcpi-tnt-explode.png differ diff --git a/fi-FI/images/mcpi-tnt.png b/fi-FI/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/fi-FI/images/mcpi-tnt.png differ diff --git a/fi-FI/images/menu.png b/fi-FI/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/fi-FI/images/menu.png differ diff --git a/fi-FI/images/minecraft-pi-banner.png b/fi-FI/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/fi-FI/images/minecraft-pi-banner.png differ diff --git a/fi-FI/images/minecraft-pi-shortcut.png b/fi-FI/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/fi-FI/images/minecraft-pi-shortcut.png differ diff --git a/fi-FI/meta.yml b/fi-FI/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/fi-FI/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/fi-FI/step_1.md b/fi-FI/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/fi-FI/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/fi-FI/step_2.md b/fi-FI/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/fi-FI/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/fi-FI/step_3.md b/fi-FI/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/fi-FI/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/fi-FI/step_4.md b/fi-FI/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/fi-FI/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/fi-FI/step_5.md b/fi-FI/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/fi-FI/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/fi-FI/step_6.md b/fi-FI/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/fi-FI/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/fi-FI/step_7.md b/fi-FI/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/fi-FI/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/fi-FI/step_8.md b/fi-FI/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/fi-FI/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/fi-FI/step_9.md b/fi-FI/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/fi-FI/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/fr-FR/images/banner.png b/fr-FR/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/fr-FR/images/banner.png differ diff --git a/fr-FR/images/blockbeneath.gif b/fr-FR/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/fr-FR/images/blockbeneath.gif differ diff --git a/fr-FR/images/helloworld.gif b/fr-FR/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/fr-FR/images/helloworld.gif differ diff --git a/fr-FR/images/lava.png b/fr-FR/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/fr-FR/images/lava.png differ diff --git a/fr-FR/images/mcpi-block-test.png b/fr-FR/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/fr-FR/images/mcpi-block-test.png differ diff --git a/fr-FR/images/mcpi-flowers-grass.png b/fr-FR/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/fr-FR/images/mcpi-flowers-grass.png differ diff --git a/fr-FR/images/mcpi-flowers-sky.png b/fr-FR/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/fr-FR/images/mcpi-flowers-sky.png differ diff --git a/fr-FR/images/mcpi-flowers.png b/fr-FR/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/fr-FR/images/mcpi-flowers.png differ diff --git a/fr-FR/images/mcpi-flying.png b/fr-FR/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/fr-FR/images/mcpi-flying.png differ diff --git a/fr-FR/images/mcpi-game.png b/fr-FR/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/fr-FR/images/mcpi-game.png differ diff --git a/fr-FR/images/mcpi-idle.png b/fr-FR/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/fr-FR/images/mcpi-idle.png differ diff --git a/fr-FR/images/mcpi-install.png b/fr-FR/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/fr-FR/images/mcpi-install.png differ diff --git a/fr-FR/images/mcpi-inventory.png b/fr-FR/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/fr-FR/images/mcpi-inventory.png differ diff --git a/fr-FR/images/mcpi-setblock.png b/fr-FR/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/fr-FR/images/mcpi-setblock.png differ diff --git a/fr-FR/images/mcpi-setblock2.png b/fr-FR/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/fr-FR/images/mcpi-setblock2.png differ diff --git a/fr-FR/images/mcpi-setblocks.png b/fr-FR/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/fr-FR/images/mcpi-setblocks.png differ diff --git a/fr-FR/images/mcpi-start.png b/fr-FR/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/fr-FR/images/mcpi-start.png differ diff --git a/fr-FR/images/mcpi-tnt-blocks.png b/fr-FR/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/fr-FR/images/mcpi-tnt-blocks.png differ diff --git a/fr-FR/images/mcpi-tnt-explode.png b/fr-FR/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/fr-FR/images/mcpi-tnt-explode.png differ diff --git a/fr-FR/images/mcpi-tnt.png b/fr-FR/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/fr-FR/images/mcpi-tnt.png differ diff --git a/fr-FR/images/menu.png b/fr-FR/images/menu.png new file mode 100644 index 0000000..1d0270d Binary files /dev/null and b/fr-FR/images/menu.png differ diff --git a/fr-FR/images/minecraft-pi-banner.png b/fr-FR/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/fr-FR/images/minecraft-pi-banner.png differ diff --git a/fr-FR/images/minecraft-pi-shortcut.png b/fr-FR/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/fr-FR/images/minecraft-pi-shortcut.png differ diff --git a/fr-FR/meta.yml b/fr-FR/meta.yml new file mode 100644 index 0000000..4da89d1 --- /dev/null +++ b/fr-FR/meta.yml @@ -0,0 +1,37 @@ +--- +title: Démarrer avec Minecraft Pi +hero_image: images/banner.png +description: Obtenir une première impression de la programmation du monde de Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: Ce dont tu auras besoin + - + title: Démarrer avec Minecraft Pi + - + title: Exécuter Minecraft + - + title: Utiliser l'interface de programmation Python + - + title: Laisser tomber des blocs en marchant + - + title: Jouer avec des blocs TNT + - + title: S'amuser avec de la lave qui coule. + - + title: Et ensuite ? diff --git a/fr-FR/step_1.md b/fr-FR/step_1.md new file mode 100644 index 0000000..013f375 --- /dev/null +++ b/fr-FR/step_1.md @@ -0,0 +1,19 @@ +## Introduction + +Au cours de ce projet, tu vas explorer le monde virtuel de Minecraft Pi, l'édition spéciale de Minecraft développée pour le Raspberry Pi. + +Tu apprendras à contrôler le joueur, à construire manuellement avec des blocs et à utiliser l'interface Python pour manipuler le monde autour de toi. + +## Ce que tu vas apprendre + +En suivant ce tutoriel avec ton Raspberry Pi, tu apprendras : + +- Comment accéder à Minecraft Pi et créer un nouveau monde +- Comment utiliser l'environnement de programmation Python IDLE pour se connecter à Minecraft Pi +- Comment utiliser Minecraft Python API pour écrire du texte sur la fenêtre de chat, trouver les coordonnées d'un joueur, se téléporter et construire des structures +- Comment utiliser des variables pour stocker les identifiants de différents types de blocs +- Expérimenter le placement de différents types de blocs avec des attributs spéciaux + +Ce projet couvre les éléments suivants du [Programme de Créativité Numérique de Raspberry Pi](https://www.raspberrypi.org/curriculum/) : + +- [Utiliser des concepts de base de programmation pour élaborer un programme simple](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/fr-FR/step_2.md b/fr-FR/step_2.md new file mode 100644 index 0000000..ecb9fe8 --- /dev/null +++ b/fr-FR/step_2.md @@ -0,0 +1,54 @@ +## Ce dont tu auras besoin + +### Logiciel + +#### Installation du logiciel + +Minecraft est installé par défaut dans Raspbian depuis septembre 2014. + +![Icône de bureau Minecraft Pi](images/minecraft-pi-shortcut.png) + +Si tu utilises une ancienne version de Raspbian, ouvre une fenêtre de terminal et tape les commandes suivantes (tu dois être en ligne) : + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Une fois cela terminé, Minecraft Pi et la bibliothèque Python devraient être installés. + +#### Tester Minecraft + +Pour exécuter Minecraft, double-clique sur l'icône du bureau ou tape la commande `minecraft-pi` dans le terminal. + +![](images/mcpi-start.png) + +Une fois Minecraft lancé, clique sur **Start Game**, suivi de **Create New**. Tu remarqueras que la fenêtre contenant est légèrement décalée. Cela signifie que pour faire glisser la fenêtre, tu dois saisir la barre de titre derrière la fenêtre Minecraft. + +![](images/mcpi-game.png) + +Tu es maintenant dans une partie de Minecraft! + +#### Tester Python + +Avec Minecraft en cours d'exécution, et le monde créé, éloignez-vous du jeu en appuyant sur la touche `Tab` qui libérera votre souris. Ouvre Python 3 (IDLE) sur le bureau et déplace les fenêtres pour qu'elles soient côte à côte. + +Tu peux taper soit des commandes directement dans la fenêtre Python ou créer un fichier afin de pouvoir enregistrer ton code et le réexécuter une autre fois. + +Si tu veux créer un fichier, va dans `File > New File` et `File > Save `. Tu voudras probablement l'enregistrer dans votre dossier de départ ou dans un nouveau dossier spécifique à ton projet. + +Commence par importer la bibliothèque Minecraft, crée une connexion au jeu et teste-la en affichant le message «Hello world» (bonjour le monde) à l'écran: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +Si tu entres des commandes directement dans la fenêtre Python, appuie simplement sur `Entrer` après chaque ligne. S'il s'agit d'un fichier, enregistre avec `Ctrl + S` et exécute avec `F5`. Lorsque ton code s'exécute, tu devrais voir ton message dans l'écran du jeu. + +![](images/mcpi-idle.png) + +Si tu vois "Hello world" dans la fenêtre Minecraft, tu es prêt à passer à l'étape suivante. \ No newline at end of file diff --git a/fr-FR/step_3.md b/fr-FR/step_3.md new file mode 100644 index 0000000..79d39b2 --- /dev/null +++ b/fr-FR/step_3.md @@ -0,0 +1,5 @@ +## Démarrer avec Minecraft Pi + +Minecraft est un jeu de construction populaire comme un bac à sable à monde ouvert. Une version gratuite de Minecraft est disponible pour le Raspberry Pi; il est également livré avec une interface de programmation. Cela signifie que tu peux écrire des commandes et des scripts en code Python pour créer automatiquement des éléments dans le jeu. C'est un excellent moyen d'apprendre Python! + +![Bannière Minecraft Pi](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/fr-FR/step_4.md b/fr-FR/step_4.md new file mode 100644 index 0000000..88392e6 --- /dev/null +++ b/fr-FR/step_4.md @@ -0,0 +1,35 @@ +## Exécuter Minecraft + +Pour exécuter Minecraft Pi, ouvre-le à partir du menu du bureau ou tape `minecraft-pi` dans le terminal. + +![](images/menu.png) + +Une fois Minecraft lancé, clique sur **Start Game**, suivi de **Create New**. Tu remarqueras que la fenêtre est légèrement décalée. Cela signifie que pour faire glisser la fenêtre, tu dois saisir la barre de titre derrière la fenêtre Minecraft. + +![](images/mcpi-game.png) + +Tu es maintenant dans une partie de Minecraft! Va te promener, hacker des trucs et construire des choses! + +Utilise la souris pour regarder autour de toi et utilise les touches suivantes sur le clavier: + +| Touche | Action | +|:-------------:|:--------------------------------:| +| W | Avant | +| A | Gauche | +| S | Arrière | +| D | Droite | +| E | Inventaire | +| Espace | Sauter | +| Double espace | Voler / Tomber | +| Esc | Pause / Menu du Jeu | +| Tab | Relâcher le curseur de la souris | + +Tu peux sélectionner un élément dans le panneau de dessin rapide avec la molette de défilement de la souris (ou utiliser les chiffres de ton clavier), ou appuyer sur `E` et sélectionner quelque chose dans l'inventaire. + +![](images/mcpi-inventory.png) + +Tu peux également appuyer deux fois sur la barre d'espace pour voler dans les airs. Tu arrêteras de voler lorsque tu relâcheras la barre d'espace, et si tu appuies deux fois dessus à nouveau, tu retomberas au sol. + +![](images/mcpi-flying.png) + +Avec l'épée à la main, tu peux cliquer sur des blocs devant toi pour les supprimer (ou pour creuser). Avec un bloc dans ta main, tu peux utiliser le clic droit pour placer ce bloc devant toi, ou le clic gauche pour supprimer un bloc. \ No newline at end of file diff --git a/fr-FR/step_5.md b/fr-FR/step_5.md new file mode 100644 index 0000000..975b408 --- /dev/null +++ b/fr-FR/step_5.md @@ -0,0 +1,162 @@ +## Utiliser l'interface de programmation Python + +Avec Minecraft en cours d'exécution, et le monde créé, éloigne-toi du jeu en appuyant sur la touche `Tab` ce qui libérera ta souris. Ouvre Python 3 (IDLE) sur le bureau et déplace les fenêtres pour qu'elles soient côte à côte. + +Tu peux soit taper des commandes directement dans la fenêtre Python ou créer un fichier afin de pouvoir enregistrer ton code et le réexécuter une autre fois. + +Si tu veux créer un fichier, va dans `File > New File` et `File > Save `. Tu voudras probablement l'enregistrer dans ton dossier de départ ou dans un nouveau dossier spécifique à ton projet. + +Commence par importer la bibliothèque Minecraft, crée une connexion au jeu et teste-la en affichant le message «Hello world» (bonjour le monde) à l'écran: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +Si tu entres des commandes directement dans la fenêtre Python, appuie simplement sur `Entrer` après chaque ligne. S'il s'agit d'un fichier, enregistre avec `Ctrl + S` et exécute avec `F5`. Lorsque ton code s'exécute, tu devrais voir ton message dans l'écran du jeu. + +![](images/helloworld.gif) + +### Trouver ta position + +Pour trouver ta position, tape : + +```python +pos = mc.player.getPos () +``` + +`pos` contient maintenant ta position; accède à chaque partie de ces coordonnées avec `pos.x`, `pos.y` et `pos.z`. + +Alternativement, une bonne façon d'obtenir les coordonnées dans des variables séparées est d'utiliser la technique de décomposition de Python: + +```python +x, y, z = mc.player.getPos () +``` + +Maintenant `x`, `y`, et `z` contiennent chaque partie de tes coordonnées de position. `x` et `z` sont les directions de marche (avant/arrière et gauche/droite) et `y` est haut/bas. + +Note que `getPos ()` renvoie l'emplacement du joueur à ce moment-là, et si tu déplaces la position, tu dois appeler à nouveau la fonction ou utiliser l'emplacement stocké. + +### Se téléporter + +En plus de connaître ta position actuelle, tu peux spécifier un emplacement particulier vers lequel te téléporter. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +Cela transportera ton joueur de 100 cases dans les airs. Cela signifie que tu te téléporteras au milieu du ciel et que tu retomberas directement là où tu as commencé. + +Essaye de te téléporter ailleurs! + +### Définir le bloc + +Tu peux placer un seul bloc à un ensemble donné de coordonnées avec `mc.setBlock ()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Maintenant, un bloc de pierre devrait apparaître à côté de l'endroit où tu te trouves. Si ce n'est pas immédiatement devant toi, il se peut que ce soit à côté ou derrière toi. Reviens à la fenêtre Minecraft et utilise la souris pour tourner sur place jusqu'à ce que tu voies un bloc gris directement devant toi. + +![](images/mcpi-setblock.png) + +Les arguments passés au `setBloc` sont `x`, `y`, `z` et `id`. Le `(x, y, z)` fait référence à la position dans le monde (nous avons spécifié un bloc ailleurs de l'endroit où se trouve le joueur avec `x + 1`) et le `id` fait référence au type de bloc que nous aimerions placer. `1` est de la pierre. + +D'autres blocs que tu peux essayer: + + Air : 0 + Herbe : 2 + Terre : 3 + + +Maintenant, avec le bloc en vue, essaye de le changer en autre chose: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +Tu devrais voir le bloc de pierre grise changer devant tes yeux! + +![](images/mcpi-setblock2.png) + +#### Constantes de bloc + +Tu peux utiliser des constantes de bloc intégrées pour définir tes blocs, si tu connais leurs noms. Tu auras toutefois besoin d'une autre ligne `importer` en premier. + +```python +from mcpi import block +``` + +Tu peux maintenant écrire ce qui suit pour placer un bloc: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Les identifiants de bloc sont assez faciles à deviner (si on connait l'anglais), écris les simplement en MAJUSCULES. Voici quelques exemples pour t'habituer à la façon dont ils sont nommés. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Bloc comme variable + +Si tu connais l'identifiant d'un bloc, il peut être utile de le définir comme variable. Tu peux utiliser le nom de l'identifiant ou son ID en forme de nombre entier. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +ou + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Blocs spéciaux + +Certains blocs ont des propriétés supplémentaires, comme la laine qui a un paramètre additionnel, tu peux en spécifier la couleur. Pour définir cela, utilise le quatrième paramètre optionnel dans `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Ici, le quatrième paramètre `1` règle la couleur de la laine à l'orange. Sans le quatrième paramètre, il est réglé sur la valeur par défaut (`0`) qui est le blanc. Quelques autres couleurs sont: + + 2: magenta + 3: bleu clair + 4: jaune + + +Essaie quelques nombres supplémentaires et regarde le bloc changer! + +D'autres blocs ayant des propriétés supplémentaires sont le bois (`17`): chêne, épicéa, bouleau, etc. les herbes hautes (`31`): arbuste, herbe, fougère; torche (`50`): pointant vers l'est, l'ouest, le nord, le sud; et plus encore. Consulte la [référence de la librairie](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) pour plus de détails. + +### Définir plusieurs blocs + +En plus de définir un seul bloc avec `setBlock` tu peux remplir un volume d'espace en une fois avec `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +Cela remplira un cube 10 x 10 x 10 de pierre solide. + +![](images/mcpi-setblocks.png) + +Tu peux créer de plus gros volumes avec la fonction `setBlocks` mais cela peut prendre plus de temps pour les générer ! \ No newline at end of file diff --git a/fr-FR/step_6.md b/fr-FR/step_6.md new file mode 100644 index 0000000..b95eb97 --- /dev/null +++ b/fr-FR/step_6.md @@ -0,0 +1,86 @@ +## Laisser tomber des blocs en marchant + +Maintenant que tu sais comment déposer des blocs, utilisons notre emplacement de déplacement pour déposer des blocs lorsque tu marches. + +Le code suivant laissera tomber une fleur derrière toi partout où tu marcheras: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Maintenant, avance pendant un moment et fais demi-tour pour voir les fleurs que tu as laissées derrière toi. + +![](images/mcpi-flowers.png) + +Puisque nous avons utilisé une boucle `while True` , cela durera indéfiniment. Pour l'arrêter, appuie sur `Ctrl + C` dans la fenêtre Python. + +Essaye de voler dans les airs et regarde les fleurs que tu laisses dans le ciel: + +![](images/mcpi-flowers-sky.png) + +Et si nous voulions seulement déposer des fleurs lorsque le joueur marche sur l'herbe? Nous pouvons utiliser `getBlock` pour savoir de quel type est un bloc : + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +Cela t'indique l'emplacement du bloc sur lequel tu te trouves (ce sera `0` - un bloc air). Nous voulons savoir *sur* quel type de bloc nous nous tenons . Pour cela, soustrayons 1 de `y` et utilisons `getBlock ()` pour déterminer sur quel type de bloc nous nous tenons: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +Cela nous indique l'ID du bloc sur lequel se trouve le joueur. + +Teste cela en exécutant une boucle pour imprimer l'ID du bloc sur n'importe lequel tu te trouves actuellement: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +Nous pouvons utiliser un `if` pour choisir de planter ou non une fleur: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Peut-être pourrions-nous ensuite transformer la dalle sur laquelle nous sommes debout en herbe si ce n'est pas déjà de l'herbe : + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Maintenant, nous pouvons avancer et si nous marchons sur l'herbe, nous laisserons une fleur derrière nous. Si le bloc suivant n'est pas de l'herbe, il se transforme en herbe. Lorsque nous nous retournons et revenons en arrière, nous laissons maintenant une fleur derrière nous. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/fr-FR/step_7.md b/fr-FR/step_7.md new file mode 100644 index 0000000..81d01cd --- /dev/null +++ b/fr-FR/step_7.md @@ -0,0 +1,32 @@ +## Jouer avec des blocs TNT + +Un autre bloc intéressant est TNT! Pour placer un bloc TNT normal, utilise: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +Cependant, ce bloc TNT est assez ennuyeux. Essaye de passer la valeur `1` à `data` : + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Maintenant, utilise ton épée et fais un clic gauche sur le bloc TNT: il sera activé et explosera en quelques secondes! + +Essaie maintenant de créer un gros cube de blocs TNT! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Maintenant tu verras un gros cube plein de blocs TNT. Va activer l'un des blocs puis pars vite pour regarder le spectacle! Le rendu des graphiques sera très lent car il y a tellement de choses qui sont modifiées à la fois. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/fr-FR/step_8.md b/fr-FR/step_8.md new file mode 100644 index 0000000..4b7efe5 --- /dev/null +++ b/fr-FR/step_8.md @@ -0,0 +1,43 @@ +## S'amuser avec de la lave qui coule. + +Un bloc avec lequel il est très amusant de jouer est la lave qui coule. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Trouve le bloc que tu viens de placer et tu devrais voir de la lave couler du bloc vers le sol. + +Ce qui est cool à propos de la lave, c'est que lorsqu'elle refroidit, elle devient de la roche. Déplace-toi vers un autre endroit de votre monde et essaye ceci: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +Tu peux ajuster les `sleep` pour permettre à plus ou moins de lave de couler. + +![lave](images/lava.png) \ No newline at end of file diff --git a/fr-FR/step_9.md b/fr-FR/step_9.md new file mode 100644 index 0000000..cd3aa56 --- /dev/null +++ b/fr-FR/step_9.md @@ -0,0 +1,11 @@ +## Et ensuite ? + +Tu peux faire beaucoup de choses maintenant que tu connais ton chemin dans le monde de Minecraft et que tu sais comment utiliser l'interface Python. + +### Jeu en réseau + +Si plusieurs personnes connectent des Raspberry Pi à un réseau local, elles peuvent rejoindre le même monde Minecraft et jouer ensemble. Les joueurs peuvent se voir dans le monde de Minecraft. + +### Référence de l'API + +Pour une documentation plus complète des fonctions et une liste complète des ID de bloc, consulte une référence d'API sur [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/he-IL/images/banner.png b/he-IL/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/he-IL/images/banner.png differ diff --git a/he-IL/images/blockbeneath.gif b/he-IL/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/he-IL/images/blockbeneath.gif differ diff --git a/he-IL/images/helloworld.gif b/he-IL/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/he-IL/images/helloworld.gif differ diff --git a/he-IL/images/lava.png b/he-IL/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/he-IL/images/lava.png differ diff --git a/he-IL/images/mcpi-block-test.png b/he-IL/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/he-IL/images/mcpi-block-test.png differ diff --git a/he-IL/images/mcpi-flowers-grass.png b/he-IL/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/he-IL/images/mcpi-flowers-grass.png differ diff --git a/he-IL/images/mcpi-flowers-sky.png b/he-IL/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/he-IL/images/mcpi-flowers-sky.png differ diff --git a/he-IL/images/mcpi-flowers.png b/he-IL/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/he-IL/images/mcpi-flowers.png differ diff --git a/he-IL/images/mcpi-flying.png b/he-IL/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/he-IL/images/mcpi-flying.png differ diff --git a/he-IL/images/mcpi-game.png b/he-IL/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/he-IL/images/mcpi-game.png differ diff --git a/he-IL/images/mcpi-idle.png b/he-IL/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/he-IL/images/mcpi-idle.png differ diff --git a/he-IL/images/mcpi-install.png b/he-IL/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/he-IL/images/mcpi-install.png differ diff --git a/he-IL/images/mcpi-inventory.png b/he-IL/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/he-IL/images/mcpi-inventory.png differ diff --git a/he-IL/images/mcpi-setblock.png b/he-IL/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/he-IL/images/mcpi-setblock.png differ diff --git a/he-IL/images/mcpi-setblock2.png b/he-IL/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/he-IL/images/mcpi-setblock2.png differ diff --git a/he-IL/images/mcpi-setblocks.png b/he-IL/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/he-IL/images/mcpi-setblocks.png differ diff --git a/he-IL/images/mcpi-start.png b/he-IL/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/he-IL/images/mcpi-start.png differ diff --git a/he-IL/images/mcpi-tnt-blocks.png b/he-IL/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/he-IL/images/mcpi-tnt-blocks.png differ diff --git a/he-IL/images/mcpi-tnt-explode.png b/he-IL/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/he-IL/images/mcpi-tnt-explode.png differ diff --git a/he-IL/images/mcpi-tnt.png b/he-IL/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/he-IL/images/mcpi-tnt.png differ diff --git a/he-IL/images/menu.png b/he-IL/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/he-IL/images/menu.png differ diff --git a/he-IL/images/minecraft-pi-banner.png b/he-IL/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/he-IL/images/minecraft-pi-banner.png differ diff --git a/he-IL/images/minecraft-pi-shortcut.png b/he-IL/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/he-IL/images/minecraft-pi-shortcut.png differ diff --git a/he-IL/meta.yml b/he-IL/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/he-IL/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/he-IL/step_1.md b/he-IL/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/he-IL/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/he-IL/step_2.md b/he-IL/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/he-IL/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/he-IL/step_3.md b/he-IL/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/he-IL/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/he-IL/step_4.md b/he-IL/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/he-IL/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/he-IL/step_5.md b/he-IL/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/he-IL/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/he-IL/step_6.md b/he-IL/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/he-IL/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/he-IL/step_7.md b/he-IL/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/he-IL/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/he-IL/step_8.md b/he-IL/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/he-IL/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/he-IL/step_9.md b/he-IL/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/he-IL/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/hi-IN/images/banner.png b/hi-IN/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/hi-IN/images/banner.png differ diff --git a/hi-IN/images/blockbeneath.gif b/hi-IN/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/hi-IN/images/blockbeneath.gif differ diff --git a/hi-IN/images/helloworld.gif b/hi-IN/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/hi-IN/images/helloworld.gif differ diff --git a/hi-IN/images/lava.png b/hi-IN/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/hi-IN/images/lava.png differ diff --git a/hi-IN/images/mcpi-block-test.png b/hi-IN/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/hi-IN/images/mcpi-block-test.png differ diff --git a/hi-IN/images/mcpi-flowers-grass.png b/hi-IN/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/hi-IN/images/mcpi-flowers-grass.png differ diff --git a/hi-IN/images/mcpi-flowers-sky.png b/hi-IN/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/hi-IN/images/mcpi-flowers-sky.png differ diff --git a/hi-IN/images/mcpi-flowers.png b/hi-IN/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/hi-IN/images/mcpi-flowers.png differ diff --git a/hi-IN/images/mcpi-flying.png b/hi-IN/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/hi-IN/images/mcpi-flying.png differ diff --git a/hi-IN/images/mcpi-game.png b/hi-IN/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/hi-IN/images/mcpi-game.png differ diff --git a/hi-IN/images/mcpi-idle.png b/hi-IN/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/hi-IN/images/mcpi-idle.png differ diff --git a/hi-IN/images/mcpi-install.png b/hi-IN/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/hi-IN/images/mcpi-install.png differ diff --git a/hi-IN/images/mcpi-inventory.png b/hi-IN/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/hi-IN/images/mcpi-inventory.png differ diff --git a/hi-IN/images/mcpi-setblock.png b/hi-IN/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/hi-IN/images/mcpi-setblock.png differ diff --git a/hi-IN/images/mcpi-setblock2.png b/hi-IN/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/hi-IN/images/mcpi-setblock2.png differ diff --git a/hi-IN/images/mcpi-setblocks.png b/hi-IN/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/hi-IN/images/mcpi-setblocks.png differ diff --git a/hi-IN/images/mcpi-start.png b/hi-IN/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/hi-IN/images/mcpi-start.png differ diff --git a/hi-IN/images/mcpi-tnt-blocks.png b/hi-IN/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/hi-IN/images/mcpi-tnt-blocks.png differ diff --git a/hi-IN/images/mcpi-tnt-explode.png b/hi-IN/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/hi-IN/images/mcpi-tnt-explode.png differ diff --git a/hi-IN/images/mcpi-tnt.png b/hi-IN/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/hi-IN/images/mcpi-tnt.png differ diff --git a/hi-IN/images/menu.png b/hi-IN/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/hi-IN/images/menu.png differ diff --git a/hi-IN/images/minecraft-pi-banner.png b/hi-IN/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/hi-IN/images/minecraft-pi-banner.png differ diff --git a/hi-IN/images/minecraft-pi-shortcut.png b/hi-IN/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/hi-IN/images/minecraft-pi-shortcut.png differ diff --git a/hi-IN/meta.yml b/hi-IN/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/hi-IN/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/hi-IN/step_1.md b/hi-IN/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/hi-IN/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/hi-IN/step_2.md b/hi-IN/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/hi-IN/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/hi-IN/step_3.md b/hi-IN/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/hi-IN/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/hi-IN/step_4.md b/hi-IN/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/hi-IN/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/hi-IN/step_5.md b/hi-IN/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/hi-IN/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/hi-IN/step_6.md b/hi-IN/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/hi-IN/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/hi-IN/step_7.md b/hi-IN/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/hi-IN/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/hi-IN/step_8.md b/hi-IN/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/hi-IN/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/hi-IN/step_9.md b/hi-IN/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/hi-IN/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/hu-HU/images/banner.png b/hu-HU/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/hu-HU/images/banner.png differ diff --git a/hu-HU/images/blockbeneath.gif b/hu-HU/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/hu-HU/images/blockbeneath.gif differ diff --git a/hu-HU/images/helloworld.gif b/hu-HU/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/hu-HU/images/helloworld.gif differ diff --git a/hu-HU/images/lava.png b/hu-HU/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/hu-HU/images/lava.png differ diff --git a/hu-HU/images/mcpi-block-test.png b/hu-HU/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/hu-HU/images/mcpi-block-test.png differ diff --git a/hu-HU/images/mcpi-flowers-grass.png b/hu-HU/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/hu-HU/images/mcpi-flowers-grass.png differ diff --git a/hu-HU/images/mcpi-flowers-sky.png b/hu-HU/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/hu-HU/images/mcpi-flowers-sky.png differ diff --git a/hu-HU/images/mcpi-flowers.png b/hu-HU/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/hu-HU/images/mcpi-flowers.png differ diff --git a/hu-HU/images/mcpi-flying.png b/hu-HU/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/hu-HU/images/mcpi-flying.png differ diff --git a/hu-HU/images/mcpi-game.png b/hu-HU/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/hu-HU/images/mcpi-game.png differ diff --git a/hu-HU/images/mcpi-idle.png b/hu-HU/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/hu-HU/images/mcpi-idle.png differ diff --git a/hu-HU/images/mcpi-install.png b/hu-HU/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/hu-HU/images/mcpi-install.png differ diff --git a/hu-HU/images/mcpi-inventory.png b/hu-HU/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/hu-HU/images/mcpi-inventory.png differ diff --git a/hu-HU/images/mcpi-setblock.png b/hu-HU/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/hu-HU/images/mcpi-setblock.png differ diff --git a/hu-HU/images/mcpi-setblock2.png b/hu-HU/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/hu-HU/images/mcpi-setblock2.png differ diff --git a/hu-HU/images/mcpi-setblocks.png b/hu-HU/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/hu-HU/images/mcpi-setblocks.png differ diff --git a/hu-HU/images/mcpi-start.png b/hu-HU/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/hu-HU/images/mcpi-start.png differ diff --git a/hu-HU/images/mcpi-tnt-blocks.png b/hu-HU/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/hu-HU/images/mcpi-tnt-blocks.png differ diff --git a/hu-HU/images/mcpi-tnt-explode.png b/hu-HU/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/hu-HU/images/mcpi-tnt-explode.png differ diff --git a/hu-HU/images/mcpi-tnt.png b/hu-HU/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/hu-HU/images/mcpi-tnt.png differ diff --git a/hu-HU/images/menu.png b/hu-HU/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/hu-HU/images/menu.png differ diff --git a/hu-HU/images/minecraft-pi-banner.png b/hu-HU/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/hu-HU/images/minecraft-pi-banner.png differ diff --git a/hu-HU/images/minecraft-pi-shortcut.png b/hu-HU/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/hu-HU/images/minecraft-pi-shortcut.png differ diff --git a/hu-HU/meta.yml b/hu-HU/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/hu-HU/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/hu-HU/step_1.md b/hu-HU/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/hu-HU/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/hu-HU/step_2.md b/hu-HU/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/hu-HU/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/hu-HU/step_3.md b/hu-HU/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/hu-HU/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/hu-HU/step_4.md b/hu-HU/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/hu-HU/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/hu-HU/step_5.md b/hu-HU/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/hu-HU/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/hu-HU/step_6.md b/hu-HU/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/hu-HU/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/hu-HU/step_7.md b/hu-HU/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/hu-HU/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/hu-HU/step_8.md b/hu-HU/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/hu-HU/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/hu-HU/step_9.md b/hu-HU/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/hu-HU/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/it-IT/images/banner.png b/it-IT/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/it-IT/images/banner.png differ diff --git a/it-IT/images/blockbeneath.gif b/it-IT/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/it-IT/images/blockbeneath.gif differ diff --git a/it-IT/images/helloworld.gif b/it-IT/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/it-IT/images/helloworld.gif differ diff --git a/it-IT/images/lava.png b/it-IT/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/it-IT/images/lava.png differ diff --git a/it-IT/images/mcpi-block-test.png b/it-IT/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/it-IT/images/mcpi-block-test.png differ diff --git a/it-IT/images/mcpi-flowers-grass.png b/it-IT/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/it-IT/images/mcpi-flowers-grass.png differ diff --git a/it-IT/images/mcpi-flowers-sky.png b/it-IT/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/it-IT/images/mcpi-flowers-sky.png differ diff --git a/it-IT/images/mcpi-flowers.png b/it-IT/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/it-IT/images/mcpi-flowers.png differ diff --git a/it-IT/images/mcpi-flying.png b/it-IT/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/it-IT/images/mcpi-flying.png differ diff --git a/it-IT/images/mcpi-game.png b/it-IT/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/it-IT/images/mcpi-game.png differ diff --git a/it-IT/images/mcpi-idle.png b/it-IT/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/it-IT/images/mcpi-idle.png differ diff --git a/it-IT/images/mcpi-install.png b/it-IT/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/it-IT/images/mcpi-install.png differ diff --git a/it-IT/images/mcpi-inventory.png b/it-IT/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/it-IT/images/mcpi-inventory.png differ diff --git a/it-IT/images/mcpi-setblock.png b/it-IT/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/it-IT/images/mcpi-setblock.png differ diff --git a/it-IT/images/mcpi-setblock2.png b/it-IT/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/it-IT/images/mcpi-setblock2.png differ diff --git a/it-IT/images/mcpi-setblocks.png b/it-IT/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/it-IT/images/mcpi-setblocks.png differ diff --git a/it-IT/images/mcpi-start.png b/it-IT/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/it-IT/images/mcpi-start.png differ diff --git a/it-IT/images/mcpi-tnt-blocks.png b/it-IT/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/it-IT/images/mcpi-tnt-blocks.png differ diff --git a/it-IT/images/mcpi-tnt-explode.png b/it-IT/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/it-IT/images/mcpi-tnt-explode.png differ diff --git a/it-IT/images/mcpi-tnt.png b/it-IT/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/it-IT/images/mcpi-tnt.png differ diff --git a/it-IT/images/menu.png b/it-IT/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/it-IT/images/menu.png differ diff --git a/it-IT/images/minecraft-pi-banner.png b/it-IT/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/it-IT/images/minecraft-pi-banner.png differ diff --git a/it-IT/images/minecraft-pi-shortcut.png b/it-IT/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/it-IT/images/minecraft-pi-shortcut.png differ diff --git a/it-IT/meta.yml b/it-IT/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/it-IT/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/it-IT/step_1.md b/it-IT/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/it-IT/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/it-IT/step_2.md b/it-IT/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/it-IT/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/it-IT/step_3.md b/it-IT/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/it-IT/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/it-IT/step_4.md b/it-IT/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/it-IT/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/it-IT/step_5.md b/it-IT/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/it-IT/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/it-IT/step_6.md b/it-IT/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/it-IT/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/it-IT/step_7.md b/it-IT/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/it-IT/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/it-IT/step_8.md b/it-IT/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/it-IT/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/it-IT/step_9.md b/it-IT/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/it-IT/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/ja-JP/images/banner.png b/ja-JP/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/ja-JP/images/banner.png differ diff --git a/ja-JP/images/blockbeneath.gif b/ja-JP/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/ja-JP/images/blockbeneath.gif differ diff --git a/ja-JP/images/helloworld.gif b/ja-JP/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/ja-JP/images/helloworld.gif differ diff --git a/ja-JP/images/lava.png b/ja-JP/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/ja-JP/images/lava.png differ diff --git a/ja-JP/images/mcpi-block-test.png b/ja-JP/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/ja-JP/images/mcpi-block-test.png differ diff --git a/ja-JP/images/mcpi-flowers-grass.png b/ja-JP/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/ja-JP/images/mcpi-flowers-grass.png differ diff --git a/ja-JP/images/mcpi-flowers-sky.png b/ja-JP/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/ja-JP/images/mcpi-flowers-sky.png differ diff --git a/ja-JP/images/mcpi-flowers.png b/ja-JP/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/ja-JP/images/mcpi-flowers.png differ diff --git a/ja-JP/images/mcpi-flying.png b/ja-JP/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/ja-JP/images/mcpi-flying.png differ diff --git a/ja-JP/images/mcpi-game.png b/ja-JP/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/ja-JP/images/mcpi-game.png differ diff --git a/ja-JP/images/mcpi-idle.png b/ja-JP/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/ja-JP/images/mcpi-idle.png differ diff --git a/ja-JP/images/mcpi-install.png b/ja-JP/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/ja-JP/images/mcpi-install.png differ diff --git a/ja-JP/images/mcpi-inventory.png b/ja-JP/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/ja-JP/images/mcpi-inventory.png differ diff --git a/ja-JP/images/mcpi-setblock.png b/ja-JP/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/ja-JP/images/mcpi-setblock.png differ diff --git a/ja-JP/images/mcpi-setblock2.png b/ja-JP/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/ja-JP/images/mcpi-setblock2.png differ diff --git a/ja-JP/images/mcpi-setblocks.png b/ja-JP/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/ja-JP/images/mcpi-setblocks.png differ diff --git a/ja-JP/images/mcpi-start.png b/ja-JP/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/ja-JP/images/mcpi-start.png differ diff --git a/ja-JP/images/mcpi-tnt-blocks.png b/ja-JP/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/ja-JP/images/mcpi-tnt-blocks.png differ diff --git a/ja-JP/images/mcpi-tnt-explode.png b/ja-JP/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/ja-JP/images/mcpi-tnt-explode.png differ diff --git a/ja-JP/images/mcpi-tnt.png b/ja-JP/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/ja-JP/images/mcpi-tnt.png differ diff --git a/ja-JP/images/menu.png b/ja-JP/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/ja-JP/images/menu.png differ diff --git a/ja-JP/images/minecraft-pi-banner.png b/ja-JP/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/ja-JP/images/minecraft-pi-banner.png differ diff --git a/ja-JP/images/minecraft-pi-shortcut.png b/ja-JP/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/ja-JP/images/minecraft-pi-shortcut.png differ diff --git a/ja-JP/meta.yml b/ja-JP/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/ja-JP/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/ja-JP/step_1.md b/ja-JP/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/ja-JP/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/ja-JP/step_2.md b/ja-JP/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/ja-JP/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/ja-JP/step_3.md b/ja-JP/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/ja-JP/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/ja-JP/step_4.md b/ja-JP/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/ja-JP/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/ja-JP/step_5.md b/ja-JP/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/ja-JP/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/ja-JP/step_6.md b/ja-JP/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/ja-JP/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/ja-JP/step_7.md b/ja-JP/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/ja-JP/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/ja-JP/step_8.md b/ja-JP/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/ja-JP/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/ja-JP/step_9.md b/ja-JP/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/ja-JP/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/kn-IN/images/banner.png b/kn-IN/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/kn-IN/images/banner.png differ diff --git a/kn-IN/images/blockbeneath.gif b/kn-IN/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/kn-IN/images/blockbeneath.gif differ diff --git a/kn-IN/images/helloworld.gif b/kn-IN/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/kn-IN/images/helloworld.gif differ diff --git a/kn-IN/images/lava.png b/kn-IN/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/kn-IN/images/lava.png differ diff --git a/kn-IN/images/mcpi-block-test.png b/kn-IN/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/kn-IN/images/mcpi-block-test.png differ diff --git a/kn-IN/images/mcpi-flowers-grass.png b/kn-IN/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/kn-IN/images/mcpi-flowers-grass.png differ diff --git a/kn-IN/images/mcpi-flowers-sky.png b/kn-IN/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/kn-IN/images/mcpi-flowers-sky.png differ diff --git a/kn-IN/images/mcpi-flowers.png b/kn-IN/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/kn-IN/images/mcpi-flowers.png differ diff --git a/kn-IN/images/mcpi-flying.png b/kn-IN/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/kn-IN/images/mcpi-flying.png differ diff --git a/kn-IN/images/mcpi-game.png b/kn-IN/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/kn-IN/images/mcpi-game.png differ diff --git a/kn-IN/images/mcpi-idle.png b/kn-IN/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/kn-IN/images/mcpi-idle.png differ diff --git a/kn-IN/images/mcpi-install.png b/kn-IN/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/kn-IN/images/mcpi-install.png differ diff --git a/kn-IN/images/mcpi-inventory.png b/kn-IN/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/kn-IN/images/mcpi-inventory.png differ diff --git a/kn-IN/images/mcpi-setblock.png b/kn-IN/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/kn-IN/images/mcpi-setblock.png differ diff --git a/kn-IN/images/mcpi-setblock2.png b/kn-IN/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/kn-IN/images/mcpi-setblock2.png differ diff --git a/kn-IN/images/mcpi-setblocks.png b/kn-IN/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/kn-IN/images/mcpi-setblocks.png differ diff --git a/kn-IN/images/mcpi-start.png b/kn-IN/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/kn-IN/images/mcpi-start.png differ diff --git a/kn-IN/images/mcpi-tnt-blocks.png b/kn-IN/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/kn-IN/images/mcpi-tnt-blocks.png differ diff --git a/kn-IN/images/mcpi-tnt-explode.png b/kn-IN/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/kn-IN/images/mcpi-tnt-explode.png differ diff --git a/kn-IN/images/mcpi-tnt.png b/kn-IN/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/kn-IN/images/mcpi-tnt.png differ diff --git a/kn-IN/images/menu.png b/kn-IN/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/kn-IN/images/menu.png differ diff --git a/kn-IN/images/minecraft-pi-banner.png b/kn-IN/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/kn-IN/images/minecraft-pi-banner.png differ diff --git a/kn-IN/images/minecraft-pi-shortcut.png b/kn-IN/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/kn-IN/images/minecraft-pi-shortcut.png differ diff --git a/kn-IN/meta.yml b/kn-IN/meta.yml new file mode 100644 index 0000000..a94d7c7 --- /dev/null +++ b/kn-IN/meta.yml @@ -0,0 +1,37 @@ +--- +title: Minecraft Pi ನೊಂದಿಗೆ ಪ್ರಾರಂಭಿಸುವುದು +hero_image: images/banner.png +description: Minecraft ಪ್ರಪಂಚವನ್ನು ಪ್ರೋಗ್ರಾಮಿಂಗ್ ಮಾಡುವ ನಿಮ್ಮ ಮೊದಲ ಅಭಿರುಚಿಯನ್ನು ಪಡೆಯಿರಿ +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: ಪರಿಚಯ + - + title: ನಿಮಗೆ ಬೇಕಾದುದು + - + title: Minecraft Pi ನೊಂದಿಗೆ ಪ್ರಾರಂಭಿಸುವುದು + - + title: Minecraft ಅನ್ನು ಚಲಾಯಿಸಿ + - + title: Python ಪ್ರೋಗ್ರಾಮಿಂಗ್ ಇಂಟರ್ಫೇಸ್ ಬಳಸಿ + - + title: ನೀವು ನಡೆಯುವಾಗ ಬ್ಲಾಕ್ ಗಳನ್ನು ಬೀಳಿಸುವುದು + - + title: TNT ಬ್ಲಾಕ್ ಗಳೊಂದಿಗೆ ಆಡುವುದು + - + title: ಹರಿಯುವ ಲಾವಾದೊಂದಿಗೆ ಮೋಜು. + - + title: ಮುಂದೆ ಏನು? diff --git a/kn-IN/step_1.md b/kn-IN/step_1.md new file mode 100644 index 0000000..ccffb22 --- /dev/null +++ b/kn-IN/step_1.md @@ -0,0 +1,19 @@ +## ನೀವು ಏನು ಮಾಡುವಿರಿ + +ಈ ಸಂಪನ್ಮೂಲದಲ್ಲಿ ನೀವು Raspberry Pi ಗಾಗಿ ತಯಾರಿಸಿದ Minecraft ನ ವಿಶೇಷ ಆವೃತ್ತಿಯಾದ Minecraft Pi ನ ವಾಸ್ತವ ಪ್ರಪಂಚವನ್ನು ಅನ್ವೇಷಿಸುವಿರಿ. + +ಆಟಗಾರನನ್ನು ಹೇಗೆ ನಿಯಂತ್ರಿಸುವುದು, ಬ್ಲಾಕ್‌ಗಳೊಂದಿಗೆ ಹಸ್ತಚಾಲಿತವಾಗಿ ನಿರ್ಮಿಸುವುದು ಮತ್ತು ನಿಮ್ಮ ಸುತ್ತಲಿನ ಪ್ರಪಂಚವನ್ನು ಕುಶಲತೆಯಿಂದ ನಿರ್ವಹಿಸಲು Python ಇಂಟರ್ಫೇಸ್ ಅನ್ನು ಹೇಗೆ ಬಳಸುವುದು ಎಂದು ನೀವು ಕಲಿಯುವಿರಿ. + +## ನೀವು ಏನು ಕಲಿಯುವಿರಿ + +ನಿಮ್ಮ Raspberry Pi ನೊಂದಿಗೆ ಈ ಸಂಪನ್ಮೂಲವನ್ನು ಅನುಸರಿಸುವ ಮೂಲಕ ನೀವು ಕಲಿಯುವಿರಿ: + +- Minecraft Pi ಅನ್ನು ಪ್ರವೇಶಿಸುವುದು ಮತ್ತು ಹೊಸ ಪ್ರಪಂಚವನ್ನು ಹೇಗೆ ರಚಿಸುವುದು +- Minecraft Pi ಗೆ ಸಂಪರ್ಕಿಸಲು Python ಪ್ರೋಗ್ರಾಮಿಂಗ್ ಪರಿಸರ IDLE ಅನ್ನು ಹೇಗೆ ಬಳಸುವುದು +- ಚಾಟ್ ವಿಂಡೋಗೆ ಪಠ್ಯವನ್ನು ಪೋಸ್ಟ್ ಮಾಡಲು, ಆಟಗಾರನ ನಿರ್ದೇಶಾಂಕಗಳನ್ನು ಕಂಡುಹಿಡಿಯಲು, ಟೆಲಿಪೋರ್ಟ್ ಮಾಡಲು ಮತ್ತು ರಚನೆಗಳನ್ನು ನಿರ್ಮಿಸಲು Minecraft Python API ಅನ್ನು ಹೇಗೆ ಬಳಸುವುದು +- ವಿವಿಧ ರೀತಿಯ ಬ್ಲಾಕ್‌ಗಳಿಗಾಗಿ ಐಡಿಗಳನ್ನು ಸಂಗ್ರಹಿಸಲು ವೇರಿಯಬಲ್ ಗಳನ್ನು ಹೇಗೆ ಬಳಸುವುದು +- ವಿಶೇಷ ಗುಣಲಕ್ಷಣಗಳೊಂದಿಗೆ ವಿವಿಧ ರೀತಿಯ ಬ್ಲಾಕ್ ಗಳನ್ನು ಇರಿಸುವ ಪ್ರಯೋಗ + +ಈ ಸಂಪನ್ಮೂಲವು [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/) ಇದರ ಪಠ್ಯಕ್ರಮವನ್ನು ಅನುಸರಿಸುತ್ತದೆ: + +- [ಸರಳ ಕಾರ್ಯಕ್ರಮಗಳನ್ನು ರಚಿಸಲು ಮೂಲ ಪ್ರೋಗ್ರಾಮಿಂಗ್ ರಚನೆಗಳನ್ನು ಬಳಸಿ](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/kn-IN/step_2.md b/kn-IN/step_2.md new file mode 100644 index 0000000..d349758 --- /dev/null +++ b/kn-IN/step_2.md @@ -0,0 +1,54 @@ +## ನಿಮಗೆ ಬೇಕಾದುದು + +### ಸಾಫ್ಟ್ವೇರ್ + +#### ಸಾಫ್ಟ್‌ವೇರ್ ಸ್ಥಾಪನೆ (Installation) + +Minecraft ಅನ್ನು ಪೂರ್ವನಿಯೋಜಿತವಾಗಿ Raspbian ನಲ್ಲಿ ಸೆಪ್ಟೆಂಬರ್ 2014 ರಿಂದ ಸ್ಥಾಪಿಸಲಾಗಿದೆ. + +![Minecraft Pi ಡೆಸ್ಕ್‌ಟಾಪ್ ಐಕಾನ್](images/minecraft-pi-shortcut.png) + +ನೀವು Raspbian ನ ಹಳೆಯ ಆವೃತ್ತಿಯನ್ನು ಬಳಸುತ್ತಿದ್ದರೆ, ಟರ್ಮಿನಲ್ ವಿಂಡೋವನ್ನು ತೆರೆಯಿರಿ ಮತ್ತು ಈ ಕೆಳಗಿನ ಆಜ್ಞೆಗಳನ್ನು ಟೈಪ್ ಮಾಡಿ (ನೀವು ಆನ್‌ಲೈನ್‌ನಲ್ಲಿರಬೇಕು): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +ಅದು ಮುಗಿದ ನಂತರ, Minecraft Pi ಮತ್ತು Python ಲೈಬ್ರರಿಯವನ್ನು ಸ್ಥಾಪಿಸಬೇಕು. + +#### Minecraft ಅನ್ನು ಪರೀಕ್ಷಿಸಿ + +Minecraft ಅನ್ನು ಚಲಾಯಿಸಲು ಡೆಸ್ಕ್‌ಟಾಪ್ ಐಕಾನ್ ಅನ್ನು ಡಬಲ್ ಕ್ಲಿಕ್ ಮಾಡಿ ಅಥವಾ `Minecraft-pi` ಅನ್ನು ಟರ್ಮಿನಲ್ ನಲ್ಲಿ ನಮೂದಿಸಿ. + +![](images/mcpi-start.png) + +Minecraft Pi ಲೋಡ್ ಮಾಡಿದಾಗ, **Start Game**(ಸ್ಟಾರ್ಟ್ ಗೇಮ್) ಕ್ಲಿಕ್ ಮಾಡಿ, ನಂತರ **Create new**(ಹೊಸದನ್ನು ರಚಿಸಿ) ಕ್ಲಿಕ್ ಮಾಡಿ. ಹೊಂದಿರುವ ವಿಂಡೋವನ್ನು ಸ್ವಲ್ಪಮಟ್ಟಿಗೆ ಸರಿದೂಗಿಸಲಾಗಿದೆ ಎಂದು ನೀವು ಗಮನಿಸಬಹುದು. ಇದರರ್ಥ ನಿಮ್ಮ ಸುತ್ತಲಿನ ವಿಂಡೋವನ್ನು ಎಳೆಯಲು Minecraft ವಿಂಡೋದ ಹಿಂದೆ ಇರುವ ಶೀರ್ಷಿಕೆ ಪಟ್ಟಿಯನ್ನು ಪಡೆದುಕೊಳ್ಳಬೇಕು. + +![](images/mcpi-game.png) + +ನೀವು ಈಗ Minecraft ಆಟದಲ್ಲಿದ್ದೀರಿ! + +#### Python ನ ಪರೀಕ್ಷಿಸಿ + +Minecraft ಚಾಲನೆಯಲ್ಲಿರುವಾಗ ಮತ್ತು ಪ್ರಪಂಚವನ್ನು ರಚಿಸಿದ ನಂತರ, `Tab` (ಟ್ಯಾಬ್) ಕೀ ಅನ್ನು ಒತ್ತುವ ಮೂಲಕ ನಿಮ್ಮ ಗಮನವನ್ನು ಆಟದಿಂದ ಬದಲಿಸಿ ದೂರವಿಡಿ, ಅದು ನಿಮ್ಮ ಮೌಸ್ ಅನ್ನು ಮುಕ್ತಗೊಳಿಸುತ್ತದೆ. ಡೆಸ್ಕ್‌ಟಾಪ್‌ನಲ್ಲಿ Python 3 (IDLE) ತೆರೆಯಿರಿ ಮತ್ತು ವಿಂಡೊಗಳನ್ನು ಸರಿಸಿ. ಇದರಿಂದ ಅವು ಅಕ್ಕಪಕ್ಕದಲ್ಲಿರುತ್ತವೆ. + +ನೀವು ಆಜ್ಞೆಗಳನ್ನು ನೇರವಾಗಿ Python ವಿಂಡೋಗೆ ಟೈಪ್ ಮಾಡಬಹುದು ಅಥವಾ ಫೈಲ್ ಅನ್ನು ರಚಿಸಬಹುದು. ಇದರಿಂದ ನಿಮ್ಮ ಕೋಡ್ ಅನ್ನು ಉಳಿಸಬಹುದು ಮತ್ತು ಅದನ್ನು ಮತ್ತೊಮ್ಮೆ ಚಾಲನೆ ಮಾಡಬಹುದು. + +ನೀವು ಫೈಲ್ ರಚಿಸಲು ಬಯಸಿದರೆ `File > New window` ಮತ್ತು ` File > Save`. ನೀವು ಬಹುಶಃ ಇದನ್ನು ನಿಮ್ಮ ಹೋಮ್ ಫೋಲ್ಡರ್ ಅಥವಾ ಹೊಸ ಪ್ರಾಜೆಕ್ಟ್ ಫೋಲ್ಡರ್ನಲ್ಲಿ ಉಳಿಸಲು ಬಯಸುತ್ತೀರಿ. + +Minecraft ಲೈಬ್ರರಿಯನ್ನು ಆಮದು ಮಾಡುವ ಮೂಲಕ ಪ್ರಾರಂಭಿಸಿ, ಆಟಕ್ಕೆ ಸಂಪರ್ಕವನ್ನು ರಚಿಸಿ ಮತ್ತು "Hello world" ("ಹಲೋ ವರ್ಲ್ಡ್") ಸಂದೇಶವನ್ನು ಪರದೆಯ ಮೇಲೆ ಪೋಸ್ಟ್ ಮಾಡುವ ಮೂಲಕ ಅದನ್ನು ಪರೀಕ್ಷಿಸಿ: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +ನೀವು ಆಜ್ಞೆಗಳನ್ನು ನೇರವಾಗಿ Python ವಿಂಡೋಗೆ ನಮೂದಿಸುತ್ತಿದ್ದರೆ, ಪ್ರತಿ ಸಾಲಿನ ನಂತರ `Enter` (ಎಂಟರ್) ಅನ್ನು ಒತ್ತಿರಿ. ಇದು ಫೈಲ್ ಆಗಿದ್ದರೆ, `Ctrl + S` ನೊಂದಿಗೆ ಉಳಿಸಿ ಮತ್ತು `F5` ನೊಂದಿಗೆ ಚಲಾಯಿಸಿ. ನಿಮ್ಮ ಕೋಡ್ ಚಾಲನೆಯಲ್ಲಿರುವಾಗ, ಆಟದಲ್ಲಿ ನಿಮ್ಮ ಸಂದೇಶವನ್ನು ಪರದೆಯ ಮೇಲೆ ನೋಡಬೇಕು. + +![](images/mcpi-idle.png) + +Minecraft ವಿಂಡೋದಲ್ಲಿ ನೀವು "Hello world" ("ಹಲೋ ವರ್ಲ್ಡ್") ಅನ್ನು ನೋಡಿದರೆ, ಮುಂದಿನ ಹಂತಕ್ಕೆ ಮುಂದುವರಿಯಬಹುದು. \ No newline at end of file diff --git a/kn-IN/step_3.md b/kn-IN/step_3.md new file mode 100644 index 0000000..1c24a2f --- /dev/null +++ b/kn-IN/step_3.md @@ -0,0 +1,5 @@ +## Minecraft Pi ನೊಂದಿಗೆ ಪ್ರಾರಂಭಿಸುವುದು + +Minecraft ಜನಪ್ರಿಯ ಸ್ಯಾಂಡ್‌ಬಾಕ್ಸ್ ಓಪನ್-ವರ್ಲ್ಡ್ ಬಿಲ್ಡಿಂಗ್ ಗೇಮ್ ಆಗಿದೆ. Raspberry Pi ಗಾಗಿ Minecraft ನ ಉಚಿತ ಆವೃತ್ತಿ ಲಭ್ಯವಿದೆ; ಇದು ಪ್ರೋಗ್ರಾಮಿಂಗ್ ಇಂಟರ್ಫೇಸ್ ನೊಂದಿಗೆ ಸಹ ಬರುತ್ತದೆ. ಇದರರ್ಥ ನೀವು ಆಟದಲ್ಲಿ ವಿಷಯಗಳನ್ನು ಸ್ವಯಂಚಾಲಿತವಾಗಿ ನಿರ್ಮಿಸಲು Python ಕೋಡ್‌ನಲ್ಲಿ ಆಜ್ಞೆಗಳನ್ನು ಮತ್ತು ಸ್ಕ್ರಿಪ್ಟ್‌ಗಳನ್ನು ಬರೆಯಬಹುದು. Python ಕಲಿಯಲು ಇದು ಉತ್ತಮ ಮಾರ್ಗವಾಗಿದೆ! + +![Minecraft Pi ಬ್ಯಾನರ್](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/kn-IN/step_4.md b/kn-IN/step_4.md new file mode 100644 index 0000000..588c66a --- /dev/null +++ b/kn-IN/step_4.md @@ -0,0 +1,35 @@ +## Minecraft ಅನ್ನು ಚಲಾಯಿಸಿ + +Minecraft Pi ಅನ್ನು ಚಲಾಯಿಸಲು, ಅದನ್ನು ಡೆಸ್ಕ್‌ಟಾಪ್ ಮೆನುವಿನಿಂದ ತೆರೆಯಿರಿ ಅಥವಾ ಟರ್ಮಿನಲ್ನಲ್ಲಿ `minecraft-pi` ಎಂದು ಟೈಪ್ ಮಾಡಿ. + +![](images/menu.png) + +Minecraft Pi ಲೋಡ್ ಮಾಡಿದಾಗ, **Start Game** (ಸ್ಟಾರ್ಟ್ ಗೇಮ್) ಕ್ಲಿಕ್ ಮಾಡಿ, ನಂತರ **Create new** (ಹೊಸದನ್ನು ರಚಿಸಿ) ಕ್ಲಿಕ್ ಮಾಡಿ. ಹೊಂದಿರುವ ವಿಂಡೋವನ್ನು ಸ್ವಲ್ಪಮಟ್ಟಿಗೆ ಸರಿದೂಗಿಸಲಾಗಿದೆ ಎಂದು ನೀವು ಗಮನಿಸಬಹುದು. ಇದರರ್ಥ ನಿಮ್ಮ ಸುತ್ತಲಿನ ವಿಂಡೋವನ್ನು ಎಳೆಯಲು Minecraft ವಿಂಡೋದ ಹಿಂದೆ ಇರುವ ಶೀರ್ಷಿಕೆ ಪಟ್ಟಿಯನ್ನು ಪಡೆದುಕೊಳ್ಳಬೇಕು. + +![](images/mcpi-game.png) + +ನೀವು ಈಗ Minecraft ಆಟದಲ್ಲಿದ್ದೀರಿ! ಸುತ್ತಲೂ ನಡೆಯಿರಿ, ವಸ್ತುಗಳನ್ನು ಹ್ಯಾಕ್ ಮಾಡಿ ಮತ್ತು ವಸ್ತುಗಳನ್ನು ನಿರ್ಮಿಸಿ! + +ಸುತ್ತಲೂ ನೋಡಲು ಮೌಸ್ ಬಳಸಿ ಮತ್ತು ಕೀಬೋರ್ಡ್‌ನಲ್ಲಿ ಈ ಕೆಳಗಿನ ಕೀಲಿಗಳನ್ನು ಬಳಸಿ: + +| Key | ಕ್ರಿಯೆ | +|:------------:|:------------------------------:| +| W | ಮುಂದೆ | +| A | ಎಡ | +| S | ಹಿಂದಕ್ಕೆ | +| D | ಬಲ | +| E | ದಾಸ್ತಾನು | +| Space | ನೆಗೆತ | +| Double Space | ಹಾರು / ಬೀಳು | +| Esc | ವಿರಾಮ / ಆಟದ ಮೆನು | +| Tab | ಮೌಸ್ ಕರ್ಸರ್ ಅನ್ನು ಬಿಡುಗಡೆ ಮಾಡಿ | + +ಮೌಸ್ ನ ಸ್ಕ್ರಾಲ್ ಚಕ್ರದೊಂದಿಗೆ ತ್ವರಿತ ಡ್ರಾ ಪ್ಯಾನೆಲ್‌ನಿಂದ ನೀವು ಐಟಂ ಅನ್ನು ಆಯ್ಕೆ ಮಾಡಬಹುದು (ಅಥವಾ ನಿಮ್ಮ ಕೀಬೋರ್ಡ್‌ನಲ್ಲಿರುವ ಸಂಖ್ಯೆಗಳನ್ನು ಬಳಸಿ), ಅಥವಾ `E` ಒತ್ತಿರಿ ಮತ್ತು ದಾಸ್ತಾನುಗಳಿಂದ ಏನನ್ನಾದರೂ ಆಯ್ಕೆಮಾಡಿ. + +![](images/mcpi-inventory.png) + +ಗಾಳಿಯಲ್ಲಿ ಹಾರಲು ನೀವು ಸ್ಪೇಸ್ ಬಾರ್ ಅನ್ನು ಎರಡು ಬಾರಿ ಟ್ಯಾಪ್ ಮಾಡಬಹುದು. ನೀವು ಸ್ಪೇಸ್ ಬಾರ್ ಅನ್ನು ಬಿಡುಗಡೆ ಮಾಡುವಾಗ ನೀವು ಹಾರಾಟವನ್ನು ನಿಲ್ಲಿಸುತ್ತೀರಿ, ಮತ್ತು ನೀವು ಅದನ್ನು ಮತ್ತೆ ಎರಡು ಬಾರಿ ಟ್ಯಾಪ್ ಮಾಡಿದರೆ ನೀವು ಮತ್ತೆ ನೆಲಕ್ಕೆ ಬೀಳುತ್ತೀರಿ. + +![](images/mcpi-flying.png) + +ನಿಮ್ಮ ಕೈಯಲ್ಲಿರುವ ಕತ್ತಿಯಿಂದ, ನಿಮ್ಮ ಮುಂದೆ ಇರುವ ಬ್ಲಾಕ್‌ಗಳನ್ನು ತೆಗೆದುಹಾಕಲು (ಅಥವಾ ಅಗೆಯಲು) ಅವುಗಳ ಮೇಲೆ ಕ್ಲಿಕ್ ಮಾಡಬಹುದು. ನಿಮ್ಮ ಕೈಯಲ್ಲಿರುವ ಬ್ಲಾಕ್ನೊಂದಿಗೆ, ಆ ಬ್ಲಾಕ್ ಅನ್ನು ನಿಮ್ಮ ಮುಂದೆ ಇರಿಸಲು ನೀವು ಬಲ ಕ್ಲಿಕ್ ಅನ್ನು ಬಳಸಬಹುದು, ಅಥವಾ ಬ್ಲಾಕ್ ಅನ್ನು ತೆಗೆದುಹಾಕಲು ಎಡ ಕ್ಲಿಕ್ ಮಾಡಿ. \ No newline at end of file diff --git a/kn-IN/step_5.md b/kn-IN/step_5.md new file mode 100644 index 0000000..ff8a282 --- /dev/null +++ b/kn-IN/step_5.md @@ -0,0 +1,162 @@ +## Python ಪ್ರೋಗ್ರಾಮಿಂಗ್ ಇಂಟರ್ಫೇಸ್ ಬಳಸಿ + +Minecraft ಚಾಲನೆಯಲ್ಲಿರುವಾಗ ಮತ್ತು ಪ್ರಪಂಚವನ್ನು ರಚಿಸಿದ ನಂತರ, `Tab` (ಟ್ಯಾಬ್) ಕೀ ಅನ್ನು ಒತ್ತುವ ಮೂಲಕ ನಿಮ್ಮ ಗಮನವನ್ನು ಆಟದಿಂದ ಬದಲಿಸಿ ದೂರವಿಡಿ, ಅದು ನಿಮ್ಮ ಮೌಸ್ ಅನ್ನು ಮುಕ್ತಗೊಳಿಸುತ್ತದೆ. ಅಪ್ಲಿಕೇಶನ್ ಮೆನುವಿನಿಂದ Python 3 ಅನ್ನು ತೆರೆಯಿರಿ ಮತ್ತು ವಿಂಡೋಗಳನ್ನು ಸರಿಸಿ. ಇದರಿಂದ ಅವು ಅಕ್ಕಪಕ್ಕದಲ್ಲಿರುತ್ತವೆ. + +ನೀವು ಆಜ್ಞೆಗಳನ್ನು ನೇರವಾಗಿ Python ವಿಂಡೋಗೆ ಟೈಪ್ ಮಾಡಬಹುದು ಅಥವಾ ಫೈಲ್ ಅನ್ನು ರಚಿಸಬಹುದು. ಇದರಿಂದ ನಿಮ್ಮ ಕೋಡ್ ಅನ್ನು ಉಳಿಸಬಹುದು ಮತ್ತು ಅದನ್ನು ಮತ್ತೊಮ್ಮೆ ಚಾಲನೆ ಮಾಡಬಹುದು. + +ನೀವು ಫೈಲ್ ರಚಿಸಲು ಬಯಸಿದರೆ `File > New window` ಮತ್ತು ` File > Save`. ನೀವು ಬಹುಶಃ ಇದನ್ನು ನಿಮ್ಮ ಹೋಮ್ ಫೋಲ್ಡರ್ ಅಥವಾ ಹೊಸ ಪ್ರಾಜೆಕ್ಟ್ ಫೋಲ್ಡರ್ನಲ್ಲಿ ಉಳಿಸಲು ಬಯಸುತ್ತೀರಿ. + +Minecraft ಲೈಬ್ರರಿಯನ್ನು ಆಮದು ಮಾಡುವ ಮೂಲಕ ಪ್ರಾರಂಭಿಸಿ, ಆಟಕ್ಕೆ ಸಂಪರ್ಕವನ್ನು ರಚಿಸಿ ಮತ್ತು "Hello world" ("ಹಲೋ ವರ್ಲ್ಡ್") ಸಂದೇಶವನ್ನು ಪರದೆಯ ಮೇಲೆ ಪೋಸ್ಟ್ ಮಾಡುವ ಮೂಲಕ ಅದನ್ನು ಪರೀಕ್ಷಿಸಿ: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +ನೀವು ಆಜ್ಞೆಗಳನ್ನು ನೇರವಾಗಿ Python ವಿಂಡೋಗೆ ನಮೂದಿಸುತ್ತಿದ್ದರೆ, ಪ್ರತಿ ಸಾಲಿನ ನಂತರ `Enter` (ಎಂಟರ್) ಅನ್ನು ಒತ್ತಿರಿ. ಇದು ಫೈಲ್ ಆಗಿದ್ದರೆ, `Ctrl + S` ನೊಂದಿಗೆ ಉಳಿಸಿ ಮತ್ತು `F5` ನೊಂದಿಗೆ ಚಲಾಯಿಸಿ. ನಿಮ್ಮ ಕೋಡ್ ಚಾಲನೆಯಲ್ಲಿರುವಾಗ, ಆಟದಲ್ಲಿ ನಿಮ್ಮ ಸಂದೇಶವನ್ನು ಪರದೆಯ ಮೇಲೆ ನೋಡಬೇಕು. + +![](images/helloworld.gif) + +### ನಿಮ್ಮ ಸ್ಥಳವನ್ನು(ಲೊಕೇಷನ್) ಹುಡುಕಿ + +ನಿಮ್ಮ ಸ್ಥಳವನ್ನು(ಲೊಕೇಷನ್) ಕಂಡುಹಿಡಿಯಲು, ಟೈಪ್ ಮಾಡಿ: + +```python +pos = mc.player.getPos() +``` + +`pos` ಈಗ ನಿಮ್ಮ ಸ್ಥಳವನ್ನು ಒಳಗೊಂಡಿದೆ; `pos.x`, `pos.y` ಮತ್ತು `pos.z` ನೊಂದಿಗೆ ನಿರ್ದೇಶಾಂಕಗಳ ಗುಂಪಿನ ಪ್ರತಿಯೊಂದು ಭಾಗವನ್ನು ಪ್ರವೇಶಿಸಿ. + +ಪರ್ಯಾಯವಾಗಿ, ನಿರ್ದೇಶಾಂಕಗಳನ್ನು ಪ್ರತ್ಯೇಕ ವೇರಿಯೇಬಲ್ಸ್ ಗಳಾಗಿ ಪಡೆಯಲು ಉತ್ತಮ ಮಾರ್ಗವೆಂದರೆ Python ನ ಅನ್ಪ್ಯಾಕ್ ಮಾಡುವ ತಂತ್ರವನ್ನು ಬಳಸುವುದು: + +```python +x, y, z = mc.player.getPos() +``` + +ಈಗ `x`, `y`, ಮತ್ತು `z` ನಿಮ್ಮ ಸ್ಥಾನದ ನಿರ್ದೇಶಾಂಕಗಳ ಪ್ರತಿಯೊಂದು ಭಾಗವನ್ನು ಒಳಗೊಂಡಿರುತ್ತದೆ. `x` ಮತ್ತು `z` ನಡೆಯುವ ನಿರ್ದೇಶನಗಳು (ಮುಂದೆ/ ಹಿಂದೆ ಮತ್ತು ಎಡ/ಬಲ) ಮತ್ತು `y` ಮೇಲೆ/ಕೆಳಗೆ ಆಗಿದೆ. + +ಗಮನಿಸಿ, `getPos ()` ಎಂಬುವುದು ಆ ಸಮಯದಲ್ಲಿ ಆಟಗಾರನ ಸ್ಥಳವನ್ನು ಹಿಂದಿರುಗಿಸುತ್ತದೆ, ಮತ್ತು ನೀವು ಸ್ಥಾನವನ್ನು ಸರಿಸಿದರೆ ನೀವು ಮತ್ತೆ ಫನ್ಕ್ಷನ್ ನ ಕರೆಯಬೇಕು ಅಥವಾ ಸಂಗ್ರಹಿಸಿದ ಸ್ಥಳವನ್ನು ಬಳಸಬೇಕು. + +### ಟೆಲಿಪೋರ್ಟ್ + +ನಿಮ್ಮ ಪ್ರಸ್ತುತ ಸ್ಥಳವನ್ನು ಕಂಡುಹಿಡಿಯುವುದರ ಜೊತೆಗೆ ಟೆಲಿಪೋರ್ಟ್ ಮಾಡಲು ನೀವು ನಿರ್ದಿಷ್ಟ ಸ್ಥಳವನ್ನು ಗೊತ್ತುಪಡಿಸಬಹುದು. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +ಇದು ನಿಮ್ಮ ಆಟಗಾರರನ್ನು ಗಾಳಿಯಲ್ಲಿ 100 ಸ್ಪೇಸ್ ಗಳಿಗೆ ಸಾಗಿಸುತ್ತದೆ. ಇದರರ್ಥ ನೀವು ಆಕಾಶದ ಮಧ್ಯಕ್ಕೆ ಟೆಲಿಪೋರ್ಟ್ ಮಾಡುತ್ತೀರಿ ಮತ್ತು ನೀವು ಪ್ರಾರಂಭಿಸಿದ ಸ್ಥಳಕ್ಕೆ ನೇರವಾಗಿ ಕೆಳಗೆ ಬೀಳುತ್ತೀರಿ. + +ಬೇರೆಡೆಗೆ ಟೆಲಿಪೋರ್ಟ್ ಮಾಡಲು ಪ್ರಯತ್ನಿಸಿ! + +### ಬ್ಲಾಕ್ ಅನ್ನು ಹೊಂದಿಸಿ + +`mc.setBlock()` ನೊಂದಿಗೆ ನಿರ್ದಿಷ್ಟ ನಿರ್ದೇಶಾಂಕಗಳಲ್ಲಿ ನೀವು ಒಂದೇ ಬ್ಲಾಕ್ ಅನ್ನು ಇರಿಸಬಹುದು: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +ಈಗ ನೀವು ನಿಂತಿರುವ ಪಕ್ಕದಲ್ಲಿ ಕಲ್ಲಿನ ಬ್ಲಾಕ್ ಕಾಣಿಸಿಕೊಳ್ಳಬೇಕು. ಅದು ತಕ್ಷಣ ನಿಮ್ಮ ಮುಂದೆ ಇಲ್ಲದಿದ್ದರೆ ಅದು ನಿಮ್ಮ ಪಕ್ಕದಲ್ಲಿ ಅಥವಾ ಹಿಂದೆ ಇರಬಹುದು. Minecraft ವಿಂಡೋಗೆ ಹಿಂತಿರುಗಿ ಮತ್ತು ನಿಮ್ಮ ಮುಂದೆ ನೇರವಾಗಿ ಬೂದುಬಣ್ಣದ ಬ್ಲಾಕ್ ಅನ್ನು ನೋಡುವ ತನಕ ಸ್ಥಳದಲ್ಲೇ ತಿರುಗಲು ಮೌಸ್ ಬಳಸಿ. + +![](images/mcpi-setblock.png) + +`set block` ಗೆ ರವಾನಿಸಿದ ವಾದಗಳು `x`, `y`, `z` ಮತ್ತು `id`. `(x, y, z)` ವಿಶ್ವದ ಸ್ಥಾನವನ್ನು ಸೂಚಿಸುತ್ತದೆ (ನಾವು ` x + 1` ನೊಂದಿಗೆ ಆಟಗಾರನು ನಿಂತಿರುವ ಸ್ಥಳದಿಂದ ಒಂದು ಬ್ಲಾಕ್ ದೂರವನ್ನು ನಿರ್ದಿಷ್ಟಪಡಿಸಿದ್ದೇವೆ) ಮತ್ತು `id` ನಾವು ಇರಿಸಲು ಬಯಸುವ ಬ್ಲಾಕ್ ಪ್ರಕಾರವನ್ನು ಸೂಚಿಸುತ್ತದೆ. `1` ಇದು ಕಲ್ಲು. + +ನೀವು ಪ್ರಯತ್ನಿಸಬಹುದಾದ ಇತರ ಬ್ಲಾಕ್‌ಗಳು: + + ಗಾಳಿ: 0 + ಹುಲ್ಲು: 2 + ಕೊಳಕು: 3 + + +ಈಗ ದೃಷ್ಟಿಯಲ್ಲಿರುವ ಬ್ಲಾಕ್ನೊಂದಿಗೆ, ಅದನ್ನು ಬೇರೆಯದಕ್ಕೆ ಬದಲಾಯಿಸಲು ಪ್ರಯತ್ನಿಸಿ: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +ನಿಮ್ಮ ಕಣ್ಣುಗಳ ಮುಂದೆ ಬೂದು ಕಲ್ಲಿನ ಬ್ಲಾಕ್ ನ ಬದಲಾವಣೆಯನ್ನು ನೀವು ನೋಡಬೇಕು! + +![](images/mcpi-setblock2.png) + +#### ಬ್ಲಾಕ್ ಸ್ಥಿರಾಂಕಗಳು + +ನಿಮ್ಮ ಬ್ಲಾಕ್ಗಳನ್ನು ಹೊಂದಿಸಲು ನೀವು ಅಂತರ್ಗತ (ಇನ್ಬಿಲ್ಟ್) ಬ್ಲಾಕ್ ಸ್ಥಿರಾಂಕಗಳನ್ನು ಬಳಸಬಹುದು, ಅವುಗಳ ಹೆಸರುಗಳು ನಿಮಗೆ ತಿಳಿದಿದ್ದರೆ. ಅದಕ್ಕಾಗಿ ನಿಮಗೆ ಮೊದಲ ಸಾಲಾಗಿ ಇನ್ನೊಂದು `import` (ಆಮದು) ನ ಅಗತ್ಯವಿದೆ. + +```python +from mcpi import block +``` + +ಬ್ಲಾಕ್ ಅನ್ನು ಇರಿಸಲು ಈಗ ನೀವು ಈ ಕೆಳಗಿನವುಗಳನ್ನು ಬರೆಯಬಹುದು: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +ಬ್ಲಾಕ್ ಐಡಿಗಳನ್ನು ಗ್ರಹಿಸಲು ತುಂಬಾ ಸುಲಭ, ಎಲ್ಲಾ ಅಕ್ಷರಗಳನ್ನು ದೊಡ್ಡಕ್ಷರ (ಕ್ಯಾಪಿಟಲ್) ಮಾಡಿ, ಆದರೆ ಅವುಗಳನ್ನು ಹೇಗೆ ಹೆಸರಿಸಬೇಕೆಂದು ನಿಮಗೆ ಪರಿಚಯಿಸಲು ಇಲ್ಲಿ ಕೆಲವು ಉದಾಹರಣೆಗಳಿವೆ. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### ಬ್ಲಾಕ್ ವೇರಿಯಬಲ್ ಆಗಿ + +ಬ್ಲಾಕ್ ನ ಐಡಿ ನಿಮಗೆ ತಿಳಿದಿದ್ದರೆ ಅದನ್ನು ವೇರಿಯಬಲ್ ಆಗಿ ಹೊಂದಿಸಲು ಇದು ಉಪಯುಕ್ತವಾಗಿರುತ್ತದೆ. ನೀವು ಹೆಸರು ಅಥವಾ ಪೂರ್ಣಾಂಕ ಐಡಿಯನ್ನು(integer id) ಬಳಸಬಹುದು. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +ಅಥವಾ + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### ವಿಶೇಷ ಬ್ಲಾಕ್ಗಳು + +ಹೆಚ್ಚುವರಿ ಗುಣಲಕ್ಷಣಗಳನ್ನು ಹೊಂದಿರುವ ಕೆಲವು ಬ್ಲಾಕ್‌ಗಳಿವೆ, ಉದಾಹರಣೆಗೆ ಉಣ್ಣೆ. ಉಣ್ಣೆಗೆ ಹೆಚ್ಚುವರಿ ಸೆಟ್ಟಿಂಗ್ ಆಗಿ, ನೀವು ಬಣ್ಣವನ್ನು ನಿರ್ದಿಷ್ಟಪಡಿಸಬಹುದು. ಇದನ್ನು ಹೊಂದಿಸಲು `setBlock` ನಲ್ಲಿ ಐಚ್ಛಿಕ ನಾಲ್ಕನೇ ನಿಯತಾಂಕವನ್ನು ಬಳಸಿ: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +ಇಲ್ಲಿ ನಾಲ್ಕನೇ ನಿಯತಾಂಕ `1` ಉಣ್ಣೆಯ ಬಣ್ಣವನ್ನು ಕಿತ್ತಳೆ ಬಣ್ಣಕ್ಕೆ ಹೊಂದಿಸುತ್ತದೆ. ನಾಲ್ಕನೇ ನಿಯತಾಂಕವಿಲ್ಲದೆ ಇದ್ದಲ್ಲಿ, ಇದನ್ನು ಡೀಫಾಲ್ಟ್ ಆಗಿ (`0`) ಗೆ ಹೊಂದಿಸಲಾಗಿದೆ. ಇದು ಬಿಳಿ ಬಣ್ಣವಾಗಿದೆ. ಇನ್ನೂ ಕೆಲವು ಬಣ್ಣಗಳು: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +ಇನ್ನೂ ಕೆಲವು ಸಂಖ್ಯೆಗಳನ್ನು ಪ್ರಯತ್ನಿಸಿ ಮತ್ತು ಬ್ಲಾಕ್ ಬದಲಾವಣೆಯನ್ನು ವೀಕ್ಷಿಸಿ! + +ಹೆಚ್ಚುವರಿ ಗುಣಲಕ್ಷಣಗಳನ್ನು ಹೊಂದಿರುವ ಇತರ ಬ್ಲಾಕ್ಗಳು ಮರ (`17`): ಓಕ್, ಸ್ಪ್ರೂಸ್, ಬರ್ಚ್, ಇತ್ಯಾದಿ; ಎತ್ತರದ ಹುಲ್ಲು (`31`): ಪೊದೆಸಸ್ಯ, ಹುಲ್ಲು, ಜರೀಗಿಡ; ಟಾರ್ಚ್ (`50`): ಪೂರ್ವ, ಪಶ್ಚಿಮ, ಉತ್ತರ, ದಕ್ಷಿಣಕ್ಕೆ ಸೂಚಿಸುತ್ತದೆ; ಮತ್ತು ಇನ್ನೂ ಅನೇಕ. ಪೂರ್ಣ ವಿವರಗಳಿಗಾಗಿ [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) (API ಉಲ್ಲೇಖವನ್ನು) ನೋಡಿ. + +### ಬಹು ಬ್ಲಾಕ್ಗಳನ್ನು ಹೊಂದಿಸಿ + +`setBlocks` ನೊಂದಿಗೆ ಒಂದೇ ಬ್ಲಾಕ್ ಅನ್ನು ರಚಿಸುವುದರ ಜೊತೆಗೆ, ನೀವು `setBlocks` ನೊಂದಿಗೆ ಒಂದೇ ಬಾರಿಗೆ ಸಾಕಷ್ಟು ಜಾಗವನ್ನು ಭರ್ತಿ ಮಾಡಬಹುದು: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +ಇದು 10 x 10 x 10 ಘನ ಘನ ಕಲ್ಲುಗಳನ್ನು ತುಂಬುತ್ತದೆ. + +![](images/mcpi-setblocks.png) + +`setBlocks` ಫಂಕ್ಷನ್ ನಿಂದ ನೀವು ದೊಡ್ಡ ಪ್ರಮಾಣದ ಬ್ಲಾಕ್‌ಗಳನ್ನು ರಚಿಸಬಹುದು. ಆದರೆ ಅವುಗಳನ್ನು ತಯಾರಿಸಲು ಹೆಚ್ಚು ಸಮಯ ತೆಗೆದುಕೊಳ್ಳಬಹುದು! \ No newline at end of file diff --git a/kn-IN/step_6.md b/kn-IN/step_6.md new file mode 100644 index 0000000..3a1b503 --- /dev/null +++ b/kn-IN/step_6.md @@ -0,0 +1,86 @@ +## ನೀವು ನಡೆಯುವಾಗ ಬ್ಲಾಕ್ ಗಳನ್ನು ಬೀಳಿಸುವುದು + +ಬ್ಲಾಕ್ಗಳನ್ನು ಹೇಗೆ ಬಿಡುವುದು ಎಂದು ಈಗ ನಿಮಗೆ ತಿಳಿದಿದೆ, ನೀವು ನಡೆಯುವಾಗ ಬ್ಲಾಕ್ಗಳನ್ನು ಬಿಡಲು ನಮ್ಮ ಚಲಿಸುವ ಸ್ಥಳವನ್ನು ಬಳಸೋಣ. + +ಈ ಕೆಳಗಿನ ಕೋಡ್ ನೀವು ಎಲ್ಲಿ ನಡೆದರೂ ನಿಮ್ಮ ಹಿಂದೆ ಒಂದು ಹೂವನ್ನು ಬಿಡುತ್ತದೆ: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +ಈಗ ಸ್ವಲ್ಪ ಸಮಯದವರೆಗೆ ನಡೆದು, ನೀವು ಹಿಂದೆ ಬಿಟ್ಟುಹೋದ ಹೂವುಗಳನ್ನು ನೋಡಲು ತಿರುಗಿ. + +![](images/mcpi-flowers.png) + +ನಾವು `while True` ಅನ್ನೋ ಲೂಪ್ ಬಳಸಿದ್ದರಿಂದ, ಇದು ಶಾಶ್ವತವಾಗಿ ಮುಂದುವರಿಯುತ್ತದೆ. ಅದನ್ನು ನಿಲ್ಲಿಸಲು, Python ವಿಂಡೋದಲ್ಲಿ`Ctrl + C` ಒತ್ತಿರಿ. + +ಗಾಳಿಯಲ್ಲಿ ಹಾರಲು ಪ್ರಯತ್ನಿಸಿ ಮತ್ತು ನೀವು ಆಕಾಶದಲ್ಲಿ ಬಿಡುವ ಹೂವುಗಳನ್ನು ನೋಡಿ: + +![](images/mcpi-flowers-sky.png) + +ಆಟಗಾರನು ಹುಲ್ಲಿನ ಮೇಲೆ ನಡೆದಾಗ ಮಾತ್ರ ನಾವು ಹೂವುಗಳನ್ನು ಬಿಡಲು ಬಯಸಿದರೆ? ನಾವು `getBlock` ಅನ್ನು ಬಳಸಿ ಬ್ಲಾಕ್ ಯಾವ ಪ್ರಕಾರವಾಗಿದೆ ಎಂದು ಕಂಡುಹಿಡಿಯಬಹುದು: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +ನೀವು ನಿಂತಿರುವ ಬ್ಲಾಕ್ನ ಸ್ಥಳವನ್ನು *ಇದು* ನಿಮಗೆ ತಿಳಿಸುತ್ತದೆ ( `0` - ಇದು ಏರ್ ಬ್ಲಾಕ್ ಆಗಿರುತ್ತದೆ). ನಾವು ಯಾವ ರೀತಿಯ ಬ್ಲಾಕ್ *ಮೇಲೆ* ನಿಂತಿದ್ದೇವೆ ಎಂದು ತಿಳಿಯಲು ನಾವು ಬಯಸುತ್ತೇವೆ. ಇದಕ್ಕಾಗಿ ನಾವು `y` ಮೌಲ್ಯದಿಂದ 1 ಅನ್ನು ಕಳೆಯುತ್ತೇವೆ ಮತ್ತು ನಾವು ಯಾವ ರೀತಿಯ ಬ್ಲಾಕ್‌ನಲ್ಲಿ ನಿಂತಿದ್ದೇವೆ ಎಂಬುದನ್ನು ನಿರ್ಧರಿಸಲು `getBlock()` ಅನ್ನು ಬಳಸುತ್ತೇವೆ: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +ಇದು ನಮಗೆ ಆಟಗಾರನು ನಿಂತಿರುವ ಬ್ಲಾಕ್ ನ ಐಡಿ ಯನ್ನು ಹೇಳುತ್ತದೆ. + +ನೀವು ಪ್ರಸ್ತುತ ನಿಂತಿರುವ ಬ್ಲಾಕ್ ಐಡಿಯನ್ನು ಮುದ್ರಿಸಲು ಲೂಪ್ ಅನ್ನು ಚಲಾಯಿಸುವ ಮೂಲಕ ಇದನ್ನು ಪರೀಕ್ಷಿಸಿ: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +ನಾವು ಹೂವನ್ನು ನೆಡಬೇಕೇ ಅಥವಾ ಬೇಡವೇ ಎಂಬುದನ್ನು ಆಯ್ಕೆ ಮಾಡಲು ನಾವು `if` (ವೇಳೆ) ಹೇಳಿಕೆಯನ್ನು ಬಳಸಬಹುದು: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +ಬಹುಶಃ ಇದರ ನಂತರ, ನಾವು ನಿಂತಿರುವ ಟೈಲ್ ಅನ್ನು ಈಗಾಗಲೇ ಹುಲ್ಲು ಇಲ್ಲದಿದ್ದರೆ ಹುಲ್ಲಿಗೆ ಬದಲಾಯಿಸಬಹುದು: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +ಈಗ ನಾವು ಮುಂದೆ ನಡೆಯಬಹುದು ಮತ್ತು ನಾವು ಹುಲ್ಲಿನ ಮೇಲೆ ನಡೆದರೆ, ನಾವು ಒಂದು ಹೂವನ್ನು ಬಿಡುತ್ತೇವೆ. ಮುಂದಿನ ಬ್ಲಾಕ್ ಹುಲ್ಲು ಅಲ್ಲದಿದ್ದರೆ, ಅದು ಹುಲ್ಲು ಆಗಿ ಬದಲಾಗುತ್ತದೆ. ನಾವು ತಿರುಗಿ ಹಿಂದಕ್ಕೆ ನಡೆದಾಗ, ನಾವು ಈಗ ನಮ್ಮ ಹಿಂದೆ ಒಂದು ಹೂವನ್ನು ಬಿಡುತ್ತೇವೆ. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/kn-IN/step_7.md b/kn-IN/step_7.md new file mode 100644 index 0000000..685c523 --- /dev/null +++ b/kn-IN/step_7.md @@ -0,0 +1,32 @@ +## TNT ಬ್ಲಾಕ್ ಗಳೊಂದಿಗೆ ಆಡುವುದು + +ಮತ್ತೊಂದು ಆಸಕ್ತಿದಾಯಕ ಬ್ಲಾಕ್ TNT! ಸಾಮಾನ್ಯ TNT ಬ್ಲಾಕ್ ಅನ್ನು ಇರಿಸಲು ಇದನ್ನು ಬಳಸಿ: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +ಆದಾಗ್ಯೂ, ಈ TNT ಬ್ಲಾಕ್ ಸಾಕಷ್ಟು ನೀರಸವಾಗಿದೆ. `data` (ಡೇಟಾ) ಅನ್ನು `1` ಆಗಿ ಅನ್ವಯಿಸಲು ಪ್ರಯತ್ನಿಸಿ: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +ಈಗ ನಿಮ್ಮ ಖಡ್ಗವನ್ನು ಬಳಸಿ ಮತ್ತು TNT ಬ್ಲಾಕ್ ಅನ್ನು ಎಡ ಕ್ಲಿಕ್ ಮಾಡಿ: ಇದು ಸಕ್ರಿಯಗೊಳ್ಳುತ್ತದೆ ಮತ್ತು ಕೆಲವೇ ಸೆಕೆಂಡುಗಳಲ್ಲಿ ಸ್ಫೋಟಗೊಳ್ಳುತ್ತದೆ! + +ಈಗ TNT ಬ್ಲಾಕ್ಗಳ ದೊಡ್ಡ ಘನವನ್ನು ತಯಾರಿಸಲು ಪ್ರಯತ್ನಿಸಿ! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +ಈಗ ನೀವು TNT ಬ್ಲಾಕ್‌ಗಳಿಂದ ತುಂಬಿದ ದೊಡ್ಡ ಘನವನ್ನು ನೋಡುತ್ತೀರಿ. ಹೋಗಿ ಒಂದು ಬ್ಲಾಕ್ ಅನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಿ ನಂತರ ಪ್ರದರ್ಶನವನ್ನು ವೀಕ್ಷಿಸಲು ಓಡಿಹೋಗಿ! ಅನೇಕ ವಿಷಯಗಳು ಏಕಕಾಲದಲ್ಲಿ ಬದಲಾಗುತ್ತಿರುವುದರಿಂದ ಗ್ರಾಫಿಕ್ಸ್ ಅನ್ನು ನಿರೂಪಿಸಲು ನಿಜವಾಗಿಯೂ ನಿಧಾನವಾಗಿರುತ್ತದೆ. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/kn-IN/step_8.md b/kn-IN/step_8.md new file mode 100644 index 0000000..bf363cd --- /dev/null +++ b/kn-IN/step_8.md @@ -0,0 +1,43 @@ +## ಹರಿಯುವ ಲಾವಾದೊಂದಿಗೆ ಮೋಜು. + +ಹರಿಯುವ ಲಾವಾ ಒಂದು ಬ್ಲಾಕ್ ಆಗಿದ್ದು ಅದು ಆಡಲು ತುಂಬಾ ಖುಷಿಯಾಗುತ್ತದೆ. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +ನೀವು ಈಗ ಇರಿಸಿರುವ ಬ್ಲಾಕ್ ಅನ್ನು ಹುಡುಕಿ, ಮತ್ತು ಆ ಬ್ಲಾಕ್ನಿಂದ ಲಾವಾ ನೆಲಕ್ಕೆ ಹರಿಯುವುದನ್ನು ನೀವು ನೋಡಬೇಕು. + +ಲಾವಾದ ಬಗ್ಗೆ ಒಂದು ವಿಶೇಷವಾದ ವಿಷಯವೆಂದರೆ, ತಣ್ಣಗಾದಾಗ ಅದು ಬಂಡೆಯಾಗುತ್ತದೆ. ಇದನ್ನು ಪ್ರಯತ್ನಿಸಲು ನಿಮ್ಮ ಜಗತ್ತಿನ ಮತ್ತೊಂದು ಸ್ಥಳಕ್ಕೆ ತೆರಳಿ: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +ಲಾವಾ ಹೆಚ್ಚು ಅಥವಾ ಕಡಿಮೆ ಹರಿಯುವಂತೆ ಮಾಡಲು ನೀವು `sleep` (ನಿದ್ರೆ) ನಿಯತಾಂಕಗಳನ್ನು ಹೊಂದಿಸಬಹುದು. + +![ಲಾವಾ](images/lava.png) \ No newline at end of file diff --git a/kn-IN/step_9.md b/kn-IN/step_9.md new file mode 100644 index 0000000..cf22f13 --- /dev/null +++ b/kn-IN/step_9.md @@ -0,0 +1,11 @@ +## ಮುಂದೆ ಏನು? + +Minecraft ಪ್ರಪಂಚದಾದ್ಯಂತ ನಿಮ್ಮ ದಾರಿ ಮತ್ತು Python ಇಂಟರ್ಫೇಸ್ ಅನ್ನು ಹೇಗೆ ಬಳಸುವುದು ಎಂದು ನಿಮಗೆ ತಿಳಿದಿರುವ ಕಾರಣ ಈಗ ನೀವು ಬಹಳಷ್ಟು ಮಾಡಬಹುದು. + +### ನೆಟ್‌ವರ್ಕ್ ಮಾಡಲಾದ ಆಟ + +ಅನೇಕ ಜನರು Raspberry Pi ಅನ್ನು ಸ್ಥಳೀಯ ನೆಟ್‌ವರ್ಕ್‌ಗೆ ಸಂಪರ್ಕಿಸಿದರೆ, ಅವರು ಒಂದೇ Minecraft ಜಗತ್ತಿನಲ್ಲಿ ಸೇರಬಹುದು ಮತ್ತು ಒಟ್ಟಿಗೆ ಆಡಬಹುದು. Minecraft ಜಗತ್ತಿನಲ್ಲಿ ಆಟಗಾರರು ಪರಸ್ಪರ ನೋಡಬಹುದು. + +### API ಉಲ್ಲೇಖ + +ಕಾರ್ಯಗಳ ಹೆಚ್ಚು ವಿಸ್ತಾರವಾದ ದಸ್ತಾವೇಜನ್ನು ಮತ್ತು ಬ್ಲಾಕ್ ಐಡಿಗಳ ಪೂರ್ಣ ಪಟ್ಟಿಗಾಗಿ [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) ನಲ್ಲಿ API ಉಲ್ಲೇಖವನ್ನು ನೋಡಿ. \ No newline at end of file diff --git a/ko-KR/images/banner.png b/ko-KR/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/ko-KR/images/banner.png differ diff --git a/ko-KR/images/blockbeneath.gif b/ko-KR/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/ko-KR/images/blockbeneath.gif differ diff --git a/ko-KR/images/helloworld.gif b/ko-KR/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/ko-KR/images/helloworld.gif differ diff --git a/ko-KR/images/lava.png b/ko-KR/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/ko-KR/images/lava.png differ diff --git a/ko-KR/images/mcpi-block-test.png b/ko-KR/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/ko-KR/images/mcpi-block-test.png differ diff --git a/ko-KR/images/mcpi-flowers-grass.png b/ko-KR/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/ko-KR/images/mcpi-flowers-grass.png differ diff --git a/ko-KR/images/mcpi-flowers-sky.png b/ko-KR/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/ko-KR/images/mcpi-flowers-sky.png differ diff --git a/ko-KR/images/mcpi-flowers.png b/ko-KR/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/ko-KR/images/mcpi-flowers.png differ diff --git a/ko-KR/images/mcpi-flying.png b/ko-KR/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/ko-KR/images/mcpi-flying.png differ diff --git a/ko-KR/images/mcpi-game.png b/ko-KR/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/ko-KR/images/mcpi-game.png differ diff --git a/ko-KR/images/mcpi-idle.png b/ko-KR/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/ko-KR/images/mcpi-idle.png differ diff --git a/ko-KR/images/mcpi-install.png b/ko-KR/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/ko-KR/images/mcpi-install.png differ diff --git a/ko-KR/images/mcpi-inventory.png b/ko-KR/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/ko-KR/images/mcpi-inventory.png differ diff --git a/ko-KR/images/mcpi-setblock.png b/ko-KR/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/ko-KR/images/mcpi-setblock.png differ diff --git a/ko-KR/images/mcpi-setblock2.png b/ko-KR/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/ko-KR/images/mcpi-setblock2.png differ diff --git a/ko-KR/images/mcpi-setblocks.png b/ko-KR/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/ko-KR/images/mcpi-setblocks.png differ diff --git a/ko-KR/images/mcpi-start.png b/ko-KR/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/ko-KR/images/mcpi-start.png differ diff --git a/ko-KR/images/mcpi-tnt-blocks.png b/ko-KR/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/ko-KR/images/mcpi-tnt-blocks.png differ diff --git a/ko-KR/images/mcpi-tnt-explode.png b/ko-KR/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/ko-KR/images/mcpi-tnt-explode.png differ diff --git a/ko-KR/images/mcpi-tnt.png b/ko-KR/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/ko-KR/images/mcpi-tnt.png differ diff --git a/ko-KR/images/menu.png b/ko-KR/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/ko-KR/images/menu.png differ diff --git a/ko-KR/images/minecraft-pi-banner.png b/ko-KR/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/ko-KR/images/minecraft-pi-banner.png differ diff --git a/ko-KR/images/minecraft-pi-shortcut.png b/ko-KR/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/ko-KR/images/minecraft-pi-shortcut.png differ diff --git a/ko-KR/meta.yml b/ko-KR/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/ko-KR/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/ko-KR/step_1.md b/ko-KR/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/ko-KR/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/ko-KR/step_2.md b/ko-KR/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/ko-KR/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/ko-KR/step_3.md b/ko-KR/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/ko-KR/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/ko-KR/step_4.md b/ko-KR/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/ko-KR/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/ko-KR/step_5.md b/ko-KR/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/ko-KR/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/ko-KR/step_6.md b/ko-KR/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/ko-KR/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/ko-KR/step_7.md b/ko-KR/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/ko-KR/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/ko-KR/step_8.md b/ko-KR/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/ko-KR/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/ko-KR/step_9.md b/ko-KR/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/ko-KR/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/mr-IN/images/banner.png b/mr-IN/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/mr-IN/images/banner.png differ diff --git a/mr-IN/images/blockbeneath.gif b/mr-IN/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/mr-IN/images/blockbeneath.gif differ diff --git a/mr-IN/images/helloworld.gif b/mr-IN/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/mr-IN/images/helloworld.gif differ diff --git a/mr-IN/images/lava.png b/mr-IN/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/mr-IN/images/lava.png differ diff --git a/mr-IN/images/mcpi-block-test.png b/mr-IN/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/mr-IN/images/mcpi-block-test.png differ diff --git a/mr-IN/images/mcpi-flowers-grass.png b/mr-IN/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/mr-IN/images/mcpi-flowers-grass.png differ diff --git a/mr-IN/images/mcpi-flowers-sky.png b/mr-IN/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/mr-IN/images/mcpi-flowers-sky.png differ diff --git a/mr-IN/images/mcpi-flowers.png b/mr-IN/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/mr-IN/images/mcpi-flowers.png differ diff --git a/mr-IN/images/mcpi-flying.png b/mr-IN/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/mr-IN/images/mcpi-flying.png differ diff --git a/mr-IN/images/mcpi-game.png b/mr-IN/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/mr-IN/images/mcpi-game.png differ diff --git a/mr-IN/images/mcpi-idle.png b/mr-IN/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/mr-IN/images/mcpi-idle.png differ diff --git a/mr-IN/images/mcpi-install.png b/mr-IN/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/mr-IN/images/mcpi-install.png differ diff --git a/mr-IN/images/mcpi-inventory.png b/mr-IN/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/mr-IN/images/mcpi-inventory.png differ diff --git a/mr-IN/images/mcpi-setblock.png b/mr-IN/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/mr-IN/images/mcpi-setblock.png differ diff --git a/mr-IN/images/mcpi-setblock2.png b/mr-IN/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/mr-IN/images/mcpi-setblock2.png differ diff --git a/mr-IN/images/mcpi-setblocks.png b/mr-IN/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/mr-IN/images/mcpi-setblocks.png differ diff --git a/mr-IN/images/mcpi-start.png b/mr-IN/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/mr-IN/images/mcpi-start.png differ diff --git a/mr-IN/images/mcpi-tnt-blocks.png b/mr-IN/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/mr-IN/images/mcpi-tnt-blocks.png differ diff --git a/mr-IN/images/mcpi-tnt-explode.png b/mr-IN/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/mr-IN/images/mcpi-tnt-explode.png differ diff --git a/mr-IN/images/mcpi-tnt.png b/mr-IN/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/mr-IN/images/mcpi-tnt.png differ diff --git a/mr-IN/images/menu.png b/mr-IN/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/mr-IN/images/menu.png differ diff --git a/mr-IN/images/minecraft-pi-banner.png b/mr-IN/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/mr-IN/images/minecraft-pi-banner.png differ diff --git a/mr-IN/images/minecraft-pi-shortcut.png b/mr-IN/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/mr-IN/images/minecraft-pi-shortcut.png differ diff --git a/mr-IN/meta.yml b/mr-IN/meta.yml new file mode 100644 index 0000000..4a8ef35 --- /dev/null +++ b/mr-IN/meta.yml @@ -0,0 +1,37 @@ +--- +title: Minecraft Pi सह प्रारंभ करणे +hero_image: images/banner.png +description: Minecraftच्या जगात प्रोग्रामिंगचा आपला पहिला अनुभव मिळवा +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: परिचय + - + title: तुम्हाला कशाची आवश्यकता असेल + - + title: Minecraft Pi सह प्रारंभ करणे + - + title: Minecraft चालवा + - + title: Python प्रोग्रामिंग इंटरफेस वापरा + - + title: आपण चालता चालता ब्लॉक टाकणे + - + title: TNT ब्लॉक्ससह खेळा + - + title: वाहत्या लावा सह मजा. + - + title: पुढे काय? diff --git a/mr-IN/step_1.md b/mr-IN/step_1.md new file mode 100644 index 0000000..0e10e11 --- /dev/null +++ b/mr-IN/step_1.md @@ -0,0 +1,19 @@ +## आपण काय तयार करणार आहोत + +या संसाधनात आपण Minecraft Pi, Rasberry Pi यासाठी Minecraft ने तयार केलेल्या विशेष आवृत्ती च्या आभासी जगाचा शोध घ्याल. + +आपण शिकूया की खेळाडूला कसे नियंत्रित करावे, ब्लॉक ला हाताने तयार कसे करावे आणि आपल्या सभोवतालच्या जगाला हाताळण्यासाठी Python इंटरफेसचा वापर कसा करावा. + +## आपण काय शिकाल + +आपल्या Raspberry Pi सह या स्त्रोताचे अनुसरण करून आपण शिकाल: + +- Minecraft Pi मध्ये कसा प्रवेश करावा आणि एक नवीन विश्व कसे तयार करावे +- Minecraft Pi ला जोडण्यासाठी Python प्रोग्रामिंग वातावरण IDLE चा वापर कसा करावा +- चॅट विंडोवर मजकूर पोस्ट करण्यासाठी, प्लेअरचे समन्वय शोधण्यासाठी, टेलिपोर्ट आणि संरचना तयार करण्यासाठी Minecraft Python API चा वापर कसा करावा +- विविध प्रकारच्या ब्लॉक्ससाठी आयडी संचयित करण्यासाठी व्हेरियबल्स कसे वापरावे +- विशेष गुणधर्मांसह विविध प्रकारचे ब्लॉक ठेवून प्रयोग करणे + +या प्रोजेक्टमध्ये [Raspberry Pi डिजिटल मेकिंग अभ्यासक्रमाचे](https://www.raspberrypi.org/curriculum/) खालील घटक समाविष्ट आहेत: + +- [सोपे प्रोग्राम तयार करण्यासाठी मूलभूत संरचना वापरा](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/mr-IN/step_2.md b/mr-IN/step_2.md new file mode 100644 index 0000000..568f817 --- /dev/null +++ b/mr-IN/step_2.md @@ -0,0 +1,54 @@ +## आपल्याला कशाची गरज असेल + +### सॉफ्टवेअर + +#### सॉफ्टवेअर इंस्टालेशन + +Minecraft सप्टेंबर 2014 पासून Raspbian मध्ये डिफॉल्ट स्वरुपात इंस्टॉल केले गेले आहे. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +जर आपण Raspbianची जुनी आवृत्ती वापरत असाल तर, टर्मिनल विंडो उघडा आणि खालील कमांड टाइप करा (आपण ऑनलाइन असणे आवश्यक आहे): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +हे संपल्यानंतर, Minecraft Pi आणि Python लाइब्ररि इंस्टॉल केली पाहिजे. + +#### Minecraft ची चाचणी घ्या + +Minecraft चालविण्यासाठी टर्मिनल मध्ये डेस्कटॉप चिन्हावर डबल क्लिक करा किंवा `minecraft-pi` प्रविष्ट करा. + +![](images/mcpi-start.png) + +जेव्हा Minecraft Pi लोड होईल, तेव्हा **Start Game** (गेम सुरू करा) वर क्लिक करा, त्यानंतर **Create new** (नविन बनवा) वर. आपल्याला दिसेल की मुख्य विंडो थोडीशी ऑफसेट आहे. याचा अर्थ आहे की विंडोला जवळ-पास ड्रॅगकरण्यासाठी आपल्या Minecraft विंडोच्या मागची title (शीर्षक) पट्टी पकडावी लागेल. + +![](images/mcpi-game.png) + +आपण आता Minecraft च्या गेममध्ये आहात! + +#### Python ची चाचणी करणे + +जेव्हा Minecraft चालू आहे, आणि जग तयार झाले आहे, तेव्हा `Tab` (टॅब) बटन दाबून आपले लक्ष खेळापासून दूर आणा, जे की आपल्या माउसला मुक्त करेल. डेस्कटॉपवर Python 3 (IDLE) उघडा आणि विंडोजला हलवा, ज्याने की दोन्ही एकमेकांच्या आजू-बाजूला येतील. + +आपण Python विंडोमध्ये थेट कमांड टाइप करू शकता किंवा फाइल तयार करू शकता जेणेकरून आपण आपला कोड सेव्ह करुन त्यास पुन्हा एकदा चालवू शकाल. + +आपल्याला नवीन फाइल तयार करवायची आसल्यास `File > New window` आणि `File > Save` चा वापर करा. आपणास हे कदाचित आपल्या होम फोल्डरमध्ये किंवा नवीन प्रोजेक्ट फोल्डरमध्ये सेव करू शकता. + +Minecraft लायब्ररी आयात करून, खेळाशी कनेक्शन तयार करुन आणि स्क्रीनवर “Hello world” संदेश पोस्ट करुन त्याची चाचणी करुन प्रारंभ करा: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +जर आपण Python विंडोमध्ये थेट कमांड टाइप करीत असाल तर प्रत्येक ओळीनंतर `Enter` (एंटर) दाबा. जर ही फाइल असेल तर `Ctrl + S` सह सेव्ह करा आणि `F5` सह चालवा. जेव्हा आपला कोड चालू असेल तेव्हा आपण आपला संदेश गेममध्ये स्क्रीनवर पहावा. + +![](images/mcpi-idle.png) + +जर आपल्याला Minecraft विंडोमध्ये "Hello world" (हॅलो वर्ल्ड) दिसत असेल तर आपण पुढील भागात प्रवेश करता. \ No newline at end of file diff --git a/mr-IN/step_3.md b/mr-IN/step_3.md new file mode 100644 index 0000000..e8181d0 --- /dev/null +++ b/mr-IN/step_3.md @@ -0,0 +1,5 @@ +## Minecraft Pi सह प्रारंभ करणे + +Minecraft हा एक लोकप्रिय सँडबॉक्स ओपन-वर्ल्ड बिल्डिंग गेम आहे. Raspberry Pi साठी Minecraft ची एक विनामूल्य आवृत्ती उपलब्ध आहे; हे प्रोग्रामिंग इंटरफेससह देखील येते. याचा अर्थ गेममध्ये गोष्टी आपोआप तयार करण्यासाठी आपण Python कोडमध्ये कमांड आणि स्क्रिप्ट लिहू शकता. Python शिकण्याचा हा एक चांगला मार्ग आहे! + +![Minecraft Pi बॅनर](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/mr-IN/step_4.md b/mr-IN/step_4.md new file mode 100644 index 0000000..0b2bda5 --- /dev/null +++ b/mr-IN/step_4.md @@ -0,0 +1,35 @@ +## Minecraft चालवा + +Minecraft चालविण्यासाठी, टर्मिनल मध्ये डेस्कटॉप चिन्हावर डबल क्लिक करा किंवा `minecraft-pi` प्रविष्ट(टाइप) करा. + +![](images/menu.png) + +जेव्हा Minecraft Pi लोड होईल, तेव्हा **Start Game** (गेम सुरू करा) वर क्लिक करा, त्यानंतर **Create new** (नविन बनवा) वर. आपल्याला दिसेल की मुख्य विंडो थोडीशी ऑफसेट आहे. याचा अर्थ आहे की विंडोला जवळ-पास ड्रॅगकरण्यासाठी आपल्या Minecraft विंडोच्या मागची title (शीर्षक) पट्टी पकडावी लागेल. + +![](images/mcpi-game.png) + +आपण आता Minecraft च्या गेममध्ये आहात! भोवती फिरा मग, गोष्टी(थिंग्ज) हॅक करा आणि गोष्टी तयार करा! + +आजू-बाजूचे दिसण्यासाठी माउस वापरा आणि कीबोर्डवरील खालील बटणे वापरा: + +| बटन | कार्य | +|:------------:|:---------------------:| +| W | पुढे | +| A | डावीकडे | +| S | मागे | +| D | उजवीकडे | +| E | यादी | +| Space | जागा | +| Double Space | दुहेरी जागा | +| Esc | विराम(pause)/गेम मेनू | +| Tab | माउस कर्सर सोडा | + +आपण माउसच्या स्क्रोल व्हीलसह त्वरित ड्रॉ पॅनेलमधून एखादी वस्तू निवडू शकता (किंवा आपल्या कीबोर्डवरील नंबर वापरा) किंवा `E` दाबा आणि यादीमधून एखादी गोष्ट निवडा. + +![](images/mcpi-inventory.png) + +हवेत उड्डाण करण्यासाठी आपण स्पेस बारवर डबल टॅप देखील करू शकता. जेव्हा आपण स्पेस बार सोडता तेव्हा आपण उड्डाण करणे थांबवाल आणि आपण त्यास पुन्हा दोनदा टॅप केल्यास आपण परत जमिनीवर याल. + +![](images/mcpi-flying.png) + +आपल्या हातात तलवार घेऊन, आपण आपल्या समोर असलेले ब्लॉक काढण्यासाठी (किंवा खोदण्यासाठी) त्या वर क्लिक करू शकता. आपल्या हातात एका ब्लॉकसह, तो ब्लॉक आपल्या समोर ठेवण्यासाठी आपण राइट क्लिक वापरू शकता किंवा ब्लॉक काढण्यासाठी डावे क्लिक करू शकता. \ No newline at end of file diff --git a/mr-IN/step_5.md b/mr-IN/step_5.md new file mode 100644 index 0000000..8caf323 --- /dev/null +++ b/mr-IN/step_5.md @@ -0,0 +1,162 @@ +## Python प्रोग्रामिंग इंटरफेसचा वापर करा + +जेव्हा Minecraft चालू आहे, आणि जग तयार झाले आहे, तेव्हा `Tab` (टॅब) बटन दाबून आपले लक्ष खेळापासून दूर न्या, ज्यामुळे आपला माउसला मुक्त होईल. अ‍ॅप्लिकेशन मेन्यूमधून Python 3 उघडा आणि विंडोज बाजूला करा जेणेकरून दोघ आजुबाजूला येतील. + +आपण Python विंडोमध्ये कमांड टाइप करू शकता किंवा फाइल तयार करू शकता जेणेकरून आपण आपला कोड सेव्ह करू शकता आणि त्यास पुन्हा एकदा चालवू शकाल. + +आपणास नवीन फाइल तयार करायची असल्यास `File > New window` आणि `File > Save` चा वापर करा. आपणास हे कदाचित आपल्या होम फोल्डरमध्ये किंवा नवीन प्रोजेक्ट फोल्डरमध्ये सेव्ह करू शकता. + +Minecraft लायब्ररी आयात करून, खेळाशी कनेक्शन तयार करुन आणि स्क्रीनवर “Hello world” संदेश पोस्ट करुन त्याची चाचणी करुन प्रारंभ करा: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +जर आपण Python विंडोमध्ये थेट कमांड टाइप करीत असाल तर प्रत्येक ओळीनंतर `Enter `(एंटर) दाबा. जर ही फाइल असेल तर, `Ctrl + S` सह सेव्ह करा आणि `F5` सह चालवा. जेव्हा आपला कोड चालू असेल, तेव्हा आपण आपला संदेश गेममध्ये स्क्रीनवर दिसला पाहिजे. + +![](images/helloworld.gif) + +### आपले लोकेशन शोधा + +आपले स्थान शोधण्यासाठी, टाइप करा: + +```python +pos = mc.player.getPos() +``` + +`pos` आता आपले स्थान आहे; `pos.x`, `pos.y` आणि `pos.z` च्या बरोबर कोऑर्डिनेट्स च्या संचाच्या प्रत्येक भागाला एक्सेस करा. + +वैकल्पिकरित्या, कोऑर्डिनेट्स (निर्देशांक) स्वतंत्र व्हेरिएबल्समध्ये आणण्याचा एक चांगला मार्ग म्हणजे Pythonचे अनपॅकिंग तंत्र वापरणे: + +```python +x, y, z = mc.player.getPos() +``` + +आता `x`, `y`, आणि `z` आपल्या स्थानाच्या कोऑर्डिनेट्सच्या प्रत्येक भागात आहे. `x` आणि `z` चालण्याचे दिशानिर्देश आहेत (पुढे / मागे आणि डावीकडे / उजवीकडे) आणि `y` वर / खाली आहे. + +लक्षात घ्या `getPos()` त्या वेळी प्लेअरचे स्थान दर्शविते आणि आपण स्थान हलविल्यास आपल्याला पुन्हा फंक्शन कॉल करावे लागेल किंवा संचयित स्थान वापरावे लागेल. + +### टेलिपोर्ट + +तसेच आपले वर्तमान स्थान शोधून काढण्यासाठी आपण टेलिपोर्टसाठी विशिष्ट स्थान निर्दिष्ट करू शकता. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +हे आपल्या प्लेअरला हवेत 100 स्पेस वर घेऊन जाईल. याचा अर्थ असा की आपण आकाशाच्या मध्यभागी टेलिपोर्ट कराल आणि आपण जिथे प्रारंभ केला तिथे सरळ खाली पडाल. + +इतर कोठेतरी टेलिपोर्टिंग करून पहा! + +### ब्लॉक सेट करा + +आपण `mc.setBlock()` सह निर्देशांकांच्या सेटवर एकच ब्लॉक ठेवू शकता: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +आता आपण जिथे उभे आहात तिथे आता दगडी ब्लॉक दिसला पाहिजे. जर ते तत्काळ आपल्या समोर नसेल तर ते आपल्या बाजूला किंवा मागे असू शकते. Minecraft विंडोवर परत जा आणि आपल्या समोर राखाडी ब्लॉक दिसत नाही तोपर्यंत जागेवर फिरण्यासाठी माउस वापरा. + +![](images/mcpi-setblock.png) + +`set block`(ब्लॉक सेट करा) ह्या साठी दिलेले तर्क आहेत`x`, `y`, `z` आणि `id`. `(x, y, z)` जगातील स्थिती संदर्भित करते (आम्ही `x + 1` प्लेयर सह जिथे उभे आहे तेथून एक ब्लॉक निर्दिष्ट केला आहे) आणि `id` आम्ही ठेऊ इच्छित असलेल्या ब्लॉकचा प्रकार दर्शवितो. `1` दगड आहे. + +आपण प्रयत्न करू शकता असे इतर ब्लॉक: + + Air: 0 + Grass: 2 + Dirt: 3 + + +आता ब्लॉक डोळ्यांसमोर ठेवून, त्यास दुसर्‍या कशामध्ये बदलण्याचा प्रयत्न करा: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +आपल्याला आपल्या डोळ्यासमोर राखाडी दगडाचा ब्लॉक बदलतांना दिसला पाहिजे! + +![](images/mcpi-setblock2.png) + +#### ब्लॉक स्थिर + +आपल्याला त्यांची नावे माहित असल्यास आपण ब्लॉक सेट करण्यासाठी इनबिल्ट ब्लॉक स्थिरांक (कॉन्टस्टेंट) वापरू शकता. आपल्याला प्रथम एक अजून `import`(आयात) ओळीची आवश्यकता आहे. + +```python +from mcpi import block +``` + +आता आपण ब्लॉक ठेवण्यासाठी पुढील गोष्टी लिहू शकता: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +ब्लॉक आयडी अंदाज करणे खूपच सोपे आहे, फक्त सर्व अक्षर कॅपिटल मध्ये लिहा, परंतु त्यांची नावे ज्या पद्धतीने वापरली जातात त्याकरिता येथे काही उदाहरणे दिली आहेत. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### ब्लॉक व्हेरिएबलच्या रूपात + +जर आपल्याला एखाद्या ब्लॉकची आयडी माहित असेल तर ती व्हेरिएबल म्हणून सेट करणे उपयुक्त ठरू शकते. आपण नाव किंवा Integer Id (पूर्ण नावाची ओळख) वापरू शकता. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +किंवा + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### विशेष ब्लॉक + +अशी काही ब्लॉक्स आहेत ज्यात अतिरिक्त गुणधर्म आहेत, जसे की ऊनची अतिरिक्त सेटिंग आहे ज्यामध्ये आपण रंग निर्दिष्ट करू शकता. हे सेट करण्यासाठी पर्यायी चौथा पॅरामीटर `setBlock` (ब्लॉक सेट करा) वापरा: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +येथे चौथा पॅरामीटर `1` ऊलचा रंग नारंगीवर सेट करतो. चौथ्या पॅरामीटरशिवाय ते डीफॉल्टवर सेट केले आहे (`0`) जे पांढरे आहे. आणखी काही रंग आहेत: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +आणखी काही संख्या वापरून पहा आणि ब्लॉकमधील बदल पहा! + +अतिरिक्त गुणधर्म असलेले इतर ब्लॉक्स म्हणजे लाकूड (`17`): ओक, स्पृस (देवदार), बर्च, इत्यादी; उंच गवत (`31`): झुडूप, गवत, फर्न; मशाल (`50`): पूर्व, पश्चिम, उत्तर, दक्षिण दर्शविणारा; आणि अधिक. संपूर्ण माहितीसाठी [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) पहा. + +### एकाधिक ब्लॉक्स सेट करा + +`setBlock` च्या सोबत एक ब्लॉक बनवता बनवता आपण `setBlocks` सह एकाच वेळी खूप जागा पण भरू शकता: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +यामुळे 10 x 10 x 10 घन भरीव दगड भरेल. + +![](images/mcpi-setblocks.png) + +आपण `setBlocks` फंक्शन सोबत मोठे परिमाण तयार करू शकता पण ते निर्माण करण्यास जास्त वेळ लागू शकेल! \ No newline at end of file diff --git a/mr-IN/step_6.md b/mr-IN/step_6.md new file mode 100644 index 0000000..0e238b0 --- /dev/null +++ b/mr-IN/step_6.md @@ -0,0 +1,86 @@ +## आपण चालता चालता blocks सोडणे + +आता आपल्याला ब्लॉक कसे सोडवायचे हे माहित झाले आहे, आता आपण चालत असताना ब्लॉक ड्रॉप करण्यासाठी आमच्या फिरत्या स्थानाचा वापर करूया. + +आपण जिथे जिथे जाल तिथे खालील कोड आपल्या मागे एक फ्लॉवर सोडेल: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +आता थोड्या वेळासाठी पुढे जा आणि आपण मागे सोडलेली फुले पाहण्यासाठी मागे वळा. + +![](images/mcpi-flowers.png) + +कारण आपण `while True` (जेव्हा हे सत्य आहे) हा लूप उपयोग केला होता म्हणून हा नेहमी चालत राहील. हे बंद करण्या साठी Python विंडो मध्ये `Ctrl + C` दाबा. + +हवेतून उड्डाण करण्याचा प्रयत्न करा आणि आपण आकाशात सोडलेली फुले पहा: + +![](images/mcpi-flowers-sky.png) + +जेव्हा जेव्हा खेळाडू गवता वर चालतात तेव्हा आम्हाला फक्त फुले टाकायची असतील तर काय करावे? कोणता ब्लॉक कश्या प्रकारचा आहे हे शोधण्यासाठी आपण `getBlock` वापरू शकता: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +हे आपल्याला त्या ब्लॉकचे स्थान दाखवतो *ज्यात* आपण उभे आहोत ( हे `0` असेल - एक हवेचा ब्लॉक). आम्ही जाणून घेऊ इच्छित आहोत की आम्ही कोणत्या प्रकारच्या ब्लॉक वर उभे आहोत *on*. यासाठी आम्ही `y` वरून 1 वजा करतोआणि `getBlock()` वापरतो, ज्यामुळे हे निर्धारित होते की आपण कोणत्या प्रकारच्या ब्लॉकवर उभे आहोत: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +हे आम्हाला प्लेअर उभा असलेल्या ब्लॉकचा आयडी सांगतात. + +आपण सध्या ज्यावर उभे आहात त्याचा ब्लॉक आयडी मुद्रित करण्यासाठी लूप चालवून याची चाचणी करा: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +आम्ही फ्लॉवर लावू की नाही हे निवडण्यासाठी आम्ही `if` चिन्ह वापरू शकतो: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +कदाचित ह्या नंतर आम्ही ज्या टाइल वर उभे आहोत त्याला आम्ही गवता मध्ये बदलू शकतो जर ते आधीच गवत नाही आहे: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +आता आपण पुढे जाऊ शकतो आणि जर आपण गवता वर चालत असू, तरआपण मागे एक फूल सोडून देऊ. जर पुढील ब्लॉक गवत नसेल, तर ते ते गवतमध्ये बदलते. जेव्हा आपण मागे वळायला लागतो आणि परत चालतो, तेव्हा आपण मागे एक फूल सोडून देतो. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/mr-IN/step_7.md b/mr-IN/step_7.md new file mode 100644 index 0000000..eda37a8 --- /dev/null +++ b/mr-IN/step_7.md @@ -0,0 +1,32 @@ +## TNT ब्लॉक्ससह खेळा + +आणखी एक मनोरंजक ब्लॉक TNT आहे! एक सामान्य TNT ब्लॉक ठेवण्यासाठी ह्याचा वापर करा: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +तथापि, हा TNT ब्लॉक बर्‍यापैकी कंटाळवाणा आहे. `data` (डेटा) ला `1` या रूपात लागू करण्याचा प्रयत्न करा: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +आता आपली तलवार वापरा आणि टीएनटी ब्लॉक वर लेफ्ट क्लिक करा: ते सक्रिय होईल आणि काही सेकंदातच त्याचा स्फोट होईल! + +आता TNT ब्लॉक्सचा एक मोठा घन बनवण्याचा प्रयत्न करा! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +आता आपल्याला TNT ब्लॉक्समध्ये भरलेला एक मोठा घन दिसेल. जा आणि त्यापैकी एक ब्लॉक सक्रिय करा आणि नंतर कार्यक्रम पाहण्यासाठी पळून जा! एकाच वेळी बर्‍याच गोष्टी बदलत असल्यामुळे ग्राफिक्स प्रस्तुत करणे खरोखरच हळू होईल. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/mr-IN/step_8.md b/mr-IN/step_8.md new file mode 100644 index 0000000..7597c60 --- /dev/null +++ b/mr-IN/step_8.md @@ -0,0 +1,43 @@ +## वाहत्या लावा सह गम्मत. + +खेळायला खूप मजा असलेला एक ब्लॉक म्हणजे वाहता लावा. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +आपण आत्ताच ठेवलेला ब्लॉक शोधा आणि आपल्याला त्या ब्लॉकवरून जमिनीवर वाहणारा लावा दिसला पाहिजे. + +लावा बद्दल छान गोष्ट अशी आहे की जेव्हा ते थंड होते तेव्हा ते खडक होते. आपल्या जगातील दुसर्‍या ठिकाणी जा आणि हे करून पहा: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +आपण लावाला कमी-अधिक प्रमाणात प्रवाहीत करण्यासाठी `sleep` (स्लीप) हे पॅरामीटर समायोजित करू शकता. + +![लावा](images/lava.png) \ No newline at end of file diff --git a/mr-IN/step_9.md b/mr-IN/step_9.md new file mode 100644 index 0000000..079f81e --- /dev/null +++ b/mr-IN/step_9.md @@ -0,0 +1,11 @@ +## पुढे काय? + +आता आपण बरेच काही करू शकतो कारण आपण Minecraft जगाच्या भोवताली आपला रस्ता आणि Python इंटरफ़ेस चा उपयोग कसा करायचा हे जाणतो. + +### नेटवर्क गेम + +जर एकापेक्षा जास्त लोक Raspberry Pi ला स्थानिक नेटवर्कशी जोडत असतील तर, ते त्याच Minecraft जगात सामील होऊ शकतात आणि एकत्र खेळू शकतात. खेळाडू Minecraft च्या जगात एकमेकांना पाहू शकतात. + +### API संदर्भ + +कार्याच्या अधिक विस्तृत दस्तऐवजीकरणासाठी आणि ब्लॉक आयडींच्या संपूर्ण यादीसाठी [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) वर एक API संदर्भ पहा. \ No newline at end of file diff --git a/nl-NL/images/banner.png b/nl-NL/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/nl-NL/images/banner.png differ diff --git a/nl-NL/images/blockbeneath.gif b/nl-NL/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/nl-NL/images/blockbeneath.gif differ diff --git a/nl-NL/images/helloworld.gif b/nl-NL/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/nl-NL/images/helloworld.gif differ diff --git a/nl-NL/images/lava.png b/nl-NL/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/nl-NL/images/lava.png differ diff --git a/nl-NL/images/mcpi-block-test.png b/nl-NL/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/nl-NL/images/mcpi-block-test.png differ diff --git a/nl-NL/images/mcpi-flowers-grass.png b/nl-NL/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/nl-NL/images/mcpi-flowers-grass.png differ diff --git a/nl-NL/images/mcpi-flowers-sky.png b/nl-NL/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/nl-NL/images/mcpi-flowers-sky.png differ diff --git a/nl-NL/images/mcpi-flowers.png b/nl-NL/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/nl-NL/images/mcpi-flowers.png differ diff --git a/nl-NL/images/mcpi-flying.png b/nl-NL/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/nl-NL/images/mcpi-flying.png differ diff --git a/nl-NL/images/mcpi-game.png b/nl-NL/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/nl-NL/images/mcpi-game.png differ diff --git a/nl-NL/images/mcpi-idle.png b/nl-NL/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/nl-NL/images/mcpi-idle.png differ diff --git a/nl-NL/images/mcpi-install.png b/nl-NL/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/nl-NL/images/mcpi-install.png differ diff --git a/nl-NL/images/mcpi-inventory.png b/nl-NL/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/nl-NL/images/mcpi-inventory.png differ diff --git a/nl-NL/images/mcpi-setblock.png b/nl-NL/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/nl-NL/images/mcpi-setblock.png differ diff --git a/nl-NL/images/mcpi-setblock2.png b/nl-NL/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/nl-NL/images/mcpi-setblock2.png differ diff --git a/nl-NL/images/mcpi-setblocks.png b/nl-NL/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/nl-NL/images/mcpi-setblocks.png differ diff --git a/nl-NL/images/mcpi-start.png b/nl-NL/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/nl-NL/images/mcpi-start.png differ diff --git a/nl-NL/images/mcpi-tnt-blocks.png b/nl-NL/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/nl-NL/images/mcpi-tnt-blocks.png differ diff --git a/nl-NL/images/mcpi-tnt-explode.png b/nl-NL/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/nl-NL/images/mcpi-tnt-explode.png differ diff --git a/nl-NL/images/mcpi-tnt.png b/nl-NL/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/nl-NL/images/mcpi-tnt.png differ diff --git a/nl-NL/images/menu.png b/nl-NL/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/nl-NL/images/menu.png differ diff --git a/nl-NL/images/minecraft-pi-banner.png b/nl-NL/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/nl-NL/images/minecraft-pi-banner.png differ diff --git a/nl-NL/images/minecraft-pi-shortcut.png b/nl-NL/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/nl-NL/images/minecraft-pi-shortcut.png differ diff --git a/nl-NL/meta.yml b/nl-NL/meta.yml new file mode 100644 index 0000000..e54459f --- /dev/null +++ b/nl-NL/meta.yml @@ -0,0 +1,37 @@ +--- +title: Aan de slag met Minecraft Pi +hero_image: images/banner.png +description: Dit is je eerste kennismaking met het programmeren van de wereld van Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: spellen +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Inleiding + - + title: Wat heb je nodig + - + title: Aan de slag met Minecraft Pi + - + title: Voer Minecraft uit + - + title: Gebruik de programmeerinterface van Python + - + title: Blokken laten vallen terwijl je loopt + - + title: Spelen met TNT-blokken + - + title: Plezier met vloeiende lava. + - + title: Wat kun je verder nog doen? diff --git a/nl-NL/step_1.md b/nl-NL/step_1.md new file mode 100644 index 0000000..957fdbf --- /dev/null +++ b/nl-NL/step_1.md @@ -0,0 +1,19 @@ +## Wat ga je maken? + +In dit project verken je de virtuele wereld van Minecraft Pi, de speciale editie van Minecraft gemaakt voor Raspberry Pi. + +Je leert hoe je de speler kunt besturen, handmatig met blokken kunt bouwen en de Python-interface kunt gebruiken om de wereld om je heen te manipuleren. + +## Wat ga je leren + +Door dit project met je Raspberry Pi te maken, leer je: + +- Hoe toegang te krijgen tot Minecraft Pi en een nieuwe wereld te creëren +- Hoe de Python-programmeeromgeving IDLE te gebruiken om verbinding te maken met Minecraft Pi +- Hoe de Minecraft Python API te gebruiken om tekst naar het chatvenster te posten, de coördinaten van de speler te vinden, structuren te teleporteren en te bouwen +- Hoe variabelen te gebruiken om ID's op te slaan voor verschillende soorten blokken +- Experimenteren met het plaatsen van verschillende soorten blokken met speciale attributen + +Dit project behandelt elementen uit de volgende onderdelen van het [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Gebruik eenvoudige programmeerconstructies om simpele programma's te maken](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/nl-NL/step_2.md b/nl-NL/step_2.md new file mode 100644 index 0000000..20a55ff --- /dev/null +++ b/nl-NL/step_2.md @@ -0,0 +1,54 @@ +## Wat heb je nodig + +### Software + +#### Software installatie + +Minecraft is standaard in Raspbian geïnstalleerd sinds september 2014. + +![Minecraft Pi-bureaubladpictogram](images/minecraft-pi-shortcut.png) + +Als je een oudere versie van Raspbian gebruikt, open je een terminalvenster en typ je de volgende opdrachten (je moet online zijn): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Zodra dat is voltooid, moeten Minecraft Pi en de Python-bibliotheek geïnstalleerd zijn. + +#### Test Minecraft + +Dubbelklik op het bureaubladpictogram om Minecraft uit te voeren of voer `minecraft-pi` in de terminal in. + +![](images/mcpi-start.png) + +Wanneer Minecraft Pi is geladen, klik je op **Start Game**, vervolgens op **Create new**. Je zult merken dat het venster enigszins is verschoven. Dit betekent dat als je het venster wilt slepen, je de titelbalk achter het Minecraft-venster moet pakken. + +![](images/mcpi-game.png) + +Je speelt nu een spelletje Minecraft! + +#### Test Python + +Terwijl Minecraft actief is en de wereld gecreëerd is, haal je je focus weg van het spel door op de `Tab` toets te drukken, waardoor je muis vrijkomt. Open Python 3 (IDLE) op het bureaublad en verplaats de vensters zodat ze naast elkaar staan. + +Je kunt opdrachten rechtstreeks in het Python-venster typen of een bestand maken zodat je jouw code kunt opslaan en deze een andere keer opnieuw kunt uitvoeren. + +Als je een nieuw bestand wilt maken, ga je naar `File > New window` en `File > Save`. Je wilt dit waarschijnlijk in je thuismap of een nieuwe projectmap opslaan. + +Begin met het importeren van de Minecraft-bibliotheek, maak een verbinding met de game en test het door het bericht "Hallo wereld" op het scherm te plaatsen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hallo wereld") +``` + +Als je opdrachten rechtstreeks in het Python-venster invoert, druk je na elke regel op `Enter`. Als het een bestand is, sla het op met `Ctrl + S` en voer het uit met `F5`. Wanneer jouw code wordt uitgevoerd, zou je jouw bericht op het scherm in het spel moeten zien. + +![](images/mcpi-idle.png) + +Als je "Hallo wereld" ziet in het Minecraft-venster, kun je doorgaan naar de volgende stap. \ No newline at end of file diff --git a/nl-NL/step_3.md b/nl-NL/step_3.md new file mode 100644 index 0000000..4f60b52 --- /dev/null +++ b/nl-NL/step_3.md @@ -0,0 +1,5 @@ +## Aan de slag met Minecraft Pi + +Minecraft is een populair sandbox-spel voor het bouwen van een open wereld. Er is een gratis versie van Minecraft beschikbaar voor de Raspberry Pi; het heeft een ingebouwde programmeerinterface. Dit betekent dat je opdrachten en scripts in Python-code kunt schrijven om automatisch dingen in het spel te bouwen. Het is een geweldige manier om Python te leren! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/nl-NL/step_4.md b/nl-NL/step_4.md new file mode 100644 index 0000000..19b682f --- /dev/null +++ b/nl-NL/step_4.md @@ -0,0 +1,35 @@ +## Voer Minecraft uit + +Om Minecraft Pi uit te voeren, open je het vanuit het bureaubladmenu of typ je `minecraft-pi` in de terminal. + +![](images/menu.png) + +Wanneer Minecraft Pi is geladen, klik je op **Start Game**, gevolgd door **Create new**. Je zult merken dat het venster enigszins is verschoven. Dit betekent dat als je het venster wilt slepen, je de titelbalk achter het Minecraft-venster moet pakken. + +![](images/mcpi-game.png) + +Je speelt nu een spelletje Minecraft! Ga rondlopen, dingen hacken en dingen bouwen! + +Gebruik de muis om rond te kijken en gebruik de volgende toetsen op het toetsenbord: + +| Toets | Actie | +|:--------------:|:----------------------:| +| W | Vooruit | +| A | Links | +| S | Achteruit | +| D | Rechts | +| E | Inventaris | +| Spatie | Springen | +| Dubbele spatie | Vliegen / Vallen | +| Esc | Pauze / Spelmenu | +| Tab | Laat de muiscursor los | + +Je kunt een item selecteren uit het paneel voor snel tekenen met het wiel van de muis (of de cijfers op je toetsenbord gebruiken) of op `E` drukken en iets uit de inventaris selecteren. + +![](images/mcpi-inventory.png) + +Je kunt ook tweemaal op de spatiebalk tikken om de lucht in te vliegen. Je stopt met vliegen wanneer je de spatiebalk loslaat en als je nogmaals dubbelklikt, val je terug op de grond. + +![](images/mcpi-flying.png) + +Met het zwaard in je hand kun je op blokken voor je klikken om ze te verwijderen (of om te graven). Met een blok in je hand kun je met de rechtermuisknop dat blok voor je plaatsen of met de linkermuisknop een blok verwijderen. \ No newline at end of file diff --git a/nl-NL/step_5.md b/nl-NL/step_5.md new file mode 100644 index 0000000..4eb4a36 --- /dev/null +++ b/nl-NL/step_5.md @@ -0,0 +1,162 @@ +## Gebruik de programmeerinterface van Python + +Terwijl Minecraft actief is en de wereld gecreëerd is, haal je je focus weg van het spel door op de `Tab` toets te drukken, waardoor je muis vrijkomt. Open Python 3 vanuit het applicatiemenu en verplaats de vensters zodat ze naast elkaar staan. + +Je kunt opdrachten rechtstreeks in het Python-venster typen of een bestand maken zodat je jouw code kunt opslaan en deze een andere keer opnieuw kunt uitvoeren. + +Als je een nieuw bestand wilt maken, ga je naar `File > New window` en `File > Save`. Je wilt dit waarschijnlijk in je thuismap of een nieuwe projectmap opslaan. + +Begin met het importeren van de Minecraft-bibliotheek, maak een verbinding met de game en test het door het bericht "Hallo wereld" op het scherm te plaatsen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hallo wereld") +``` + +Als je opdrachten rechtstreeks in het Python-venster invoert, druk je op `Enter` na elke regel. Als het een bestand is, sla het op met `Ctrl + S` en voer het uit met `F5`. Wanneer je code wordt uitgevoerd, zou je jouw bericht op het scherm in het spel moeten zien. + +![](images/helloworld.gif) + +### Vind je locatie + +Typ het volgende om je locatie te vinden: + +```python +pos = mc.player.getPos() +``` + +`pos` bevat nu je locatie; ga naar elk onderdeel van de coördinaten met `pos.x`, `pos.y` en `pos.z`. + +Een andere manier om de coördinaten in afzonderlijke variabelen te krijgen, is door de uitpaktechniek van Python te gebruiken: + +```python +x, y, z = mc.player.getPos() +``` + +Nu bevatten `x`, `y`en `z` elk onderdeel van je positiecoördinaten. `x` en `z` zijn de looprichtingen (vooruit/achteruit en links/rechts) en `y` is omhoog/omlaag. + +Merk op dat `getPos()` de locatie van de speler van dat moment geeft, als je van positie verandert, moet je de functie opnieuw oproepen of de opgeslagen locatie gebruiken. + +### Teleporteer + +Naast het vinden van je huidige locatie, kun je een specifieke locatie opgeven om naar te teleporteren. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y + 100, z) +``` + +Dit verplaatst je speler 100 plaatsen de lucht in. Dit betekent dat je naar het midden van de lucht teleporteert en meteen terugvalt naar waar je bent begonnen. + +Probeer ergens anders naartoe te teleporteren! + +### Blok instellen + +Je kunt een enkel blok op een gegeven stel coördinaten plaatsen met `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Nu zou een stenen blok naast je moeten verschijnen. Als het niet direct voor je staat, kan het zich naast of achter je bevinden. Keer terug naar het Minecraft-venster en draai met de muis ter plaatse rond totdat je een grijs blok direct voor je ziet. + +![](images/mcpi-setblock.png) + +De argumenten die zijn doorgegeven aan `set block` zijn `x`, `y`, `z` en `id`. De `(x, y, z)` verwijst naar de positie in de wereld (we hebben één blok verwijderd van waar de speler staat gespecificeerd met `x + 1`) en de `id` verwijst naar het type blok dat we willen plaatsen. `1` is steen. + +Andere blokken die je kunt proberen: + + Lucht: 0 + Gras: 2 + Grond: 3 + + +Probeer het blok nu in iets anders te veranderen: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +Je zou het grijze stenen blok voor je ogen moeten zien veranderen! + +![](images/mcpi-setblock2.png) + +#### Blokconstanten + +Je kunt ingebouwde blokconstanten gebruiken om je blokken in te stellen, als je hun namen kent. Je hebt echter eerst nog een `import` regel nodig. + +```python +from mcpi import block +``` + +Nu kun je het volgende schrijven om een blok te plaatsen: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Blok-id's zijn vrij eenvoudig te raden, gebruik gewoon ALLE HOOFDLETTERS, maar hier zijn een paar voorbeelden om je te laten wennen aan de naam die ze hebben. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Blokken als variabele + +Als je het id van een blok kent, kan het handig zijn om het als een variabele in te stellen. Je kunt de naam of het getal gebruiken. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +of + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Speciale blokken + +Er zijn enkele blokken met extra eigenschappen, zoals Wol met een extra instelling waarmee je de kleur kunt opgeven. Om dit in te stellen, gebruik je de optionele vierde parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Hier stelt de vierde parameter `1` de wolkleur in op oranje. Zonder de vierde parameter wordt deze ingesteld op de standaardwaarde (`0`) die wit is. Nog wat kleuren zijn: + + 2: Magenta + 3: Lichtblauw + 4: Geel + + +Probeer wat meer nummers en zie het blok veranderen! + +Andere blokken met extra eigenschappen zijn hout (`17`): eiken, sparren, berken, enz.; hoog gras (`31`): struik, gras, varen; fakkel (`50`): naar het oosten, westen, noorden, zuiden; en meer. Zie de [API-referentie](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) voor alle details. + +### Stel meerdere blokken in + +Naast het instellen van een enkel blok met `setBlock` kun je een volume in één keer vullen met `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +Hiermee vul je een 10 x 10 x 10 kubus van massieve steen. + +![](images/mcpi-setblocks.png) + +Je kunt grotere volumes maken met de `setBlocks` functie, maar het kan langer duren om het te genereren! \ No newline at end of file diff --git a/nl-NL/step_6.md b/nl-NL/step_6.md new file mode 100644 index 0000000..6936c23 --- /dev/null +++ b/nl-NL/step_6.md @@ -0,0 +1,86 @@ +## Blokken laten vallen terwijl je loopt + +Nu je weet hoe je blokken moet laten vallen, laten we onze bewegende locatie gebruiken om blokken te laten vallen wanneer je loopt. + +De volgende code laat een bloem achter je neer vallen, waar je ook loopt: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Loop nu een tijdje vooruit en draai je om om de bloemen te zien die je achter je hebt gelaten. + +![](images/mcpi-flowers.png) + +Omdat we een `while True` lus hebben gebruikt, zal dit voor altijd zal doorgaan. Om het te stoppen, druk je op `Ctrl + C` in het Python-venster. + +Probeer door de lucht te vliegen en zie de bloemen die je in de lucht achterlaat: + +![](images/mcpi-flowers-sky.png) + +Wat als we alleen bloemen willen laten vallen als de speler op gras loopt? We kunnen `getBlock` gebruiken om erachter te komen welk type een blok is: + +```python +x, y, z = mc.player.getPos() # spelerpositie (x, y, z) +this_block = mc.getBlock(x, y, z) # blok ID +print(this_block) +``` + +Dit vertelt je de locatie van het blok waar je *in* staat (dit zal `0` - een luchtblok zijn). We willen weten *op* welk type blok we staan. Hiervoor trekken we 1 af van de waarde `y` en gebruiken we `getBlock()` om te bepalen op welk type blok we staan: + +```python +x, y, z = mc.player.getPos() # spelerpositie (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # blok ID +print(block_beneath) +``` + +Dit vertelt ons het id van het blok waarop de speler staat. + +Test dit door een lus uit te voeren om het blok-id te tonen van waar je nu op staat: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We kunnen een `if` instructie gebruiken om te kiezen of we een bloem planten of niet: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # spelerpositie (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # blok ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Misschien kunnen we vervolgens de tegel waarop we staan in gras veranderen als het nog geen gras is: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Nu kunnen we vooruit lopen en als we op gras lopen, laten we een bloem achter. Als het volgende blok geen gras is, wordt het gras. Als we ons omdraaien en teruglopen, laten we nu een bloem achter ons. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/nl-NL/step_7.md b/nl-NL/step_7.md new file mode 100644 index 0000000..39e2841 --- /dev/null +++ b/nl-NL/step_7.md @@ -0,0 +1,32 @@ +## Spelen met TNT-blokken + +Een ander interessant blok is TNT! Om een normaal TNT-blok te plaatsen, gebruik: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +Dit TNT-blok is echter behoorlijk saai. Probeer `data` als `1` toe te passen: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Gebruik nu je zwaard en klik met de linkermuisknop op het TNT-blok: het wordt geactiveerd en zal binnen enkele seconden exploderen! + +Probeer nu een grote kubus van TNT-blokken te maken! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Nu zie je een grote kubus vol TNT-blokken. Activeer een van de blokken en ren dan weg om de show te bekijken! Het zal even duren om de afbeeldingen weer te geven, omdat zoveel dingen tegelijkertijd veranderen. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/nl-NL/step_8.md b/nl-NL/step_8.md new file mode 100644 index 0000000..425ef7c --- /dev/null +++ b/nl-NL/step_8.md @@ -0,0 +1,43 @@ +## Plezier met vloeiende lava. + +Een blok dat erg leuk is om mee te spelen is stromende lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Vind het blok dat je zojuist hebt geplaatst en je zou de lava van het blok naar de grond moeten zien stromen. + +Het leuke van lava is dat wanneer het afkoelt, het rots wordt. Ga naar een andere locatie in je wereld en probeer dit: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +Je kunt de `sleep` parameters aanpassen om meer of minder lava te laten stromen. + +![lava](images/lava.png) \ No newline at end of file diff --git a/nl-NL/step_9.md b/nl-NL/step_9.md new file mode 100644 index 0000000..6ca3bf9 --- /dev/null +++ b/nl-NL/step_9.md @@ -0,0 +1,11 @@ +## Wat kun je verder nog doen? + +Er is genoeg dat je kunt doen nu je de weg kent in de Minecraft-wereld en hoe je de Python-interface kunt gebruiken. + +### Netwerkspel + +Als meerdere mensen Raspberry Pi's verbinden met een lokaal netwerk, kunnen ze lid worden van dezelfde Minecraft-wereld en samen spelen. Spelers kunnen elkaar zien in de Minecraft-wereld. + +### API referentie + +Zie voor een uitgebreidere documentatie van functies en een volledige lijst met blok-id's de API-referentie op [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/no-NO/images/banner.png b/no-NO/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/no-NO/images/banner.png differ diff --git a/no-NO/images/blockbeneath.gif b/no-NO/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/no-NO/images/blockbeneath.gif differ diff --git a/no-NO/images/helloworld.gif b/no-NO/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/no-NO/images/helloworld.gif differ diff --git a/no-NO/images/lava.png b/no-NO/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/no-NO/images/lava.png differ diff --git a/no-NO/images/mcpi-block-test.png b/no-NO/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/no-NO/images/mcpi-block-test.png differ diff --git a/no-NO/images/mcpi-flowers-grass.png b/no-NO/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/no-NO/images/mcpi-flowers-grass.png differ diff --git a/no-NO/images/mcpi-flowers-sky.png b/no-NO/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/no-NO/images/mcpi-flowers-sky.png differ diff --git a/no-NO/images/mcpi-flowers.png b/no-NO/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/no-NO/images/mcpi-flowers.png differ diff --git a/no-NO/images/mcpi-flying.png b/no-NO/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/no-NO/images/mcpi-flying.png differ diff --git a/no-NO/images/mcpi-game.png b/no-NO/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/no-NO/images/mcpi-game.png differ diff --git a/no-NO/images/mcpi-idle.png b/no-NO/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/no-NO/images/mcpi-idle.png differ diff --git a/no-NO/images/mcpi-install.png b/no-NO/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/no-NO/images/mcpi-install.png differ diff --git a/no-NO/images/mcpi-inventory.png b/no-NO/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/no-NO/images/mcpi-inventory.png differ diff --git a/no-NO/images/mcpi-setblock.png b/no-NO/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/no-NO/images/mcpi-setblock.png differ diff --git a/no-NO/images/mcpi-setblock2.png b/no-NO/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/no-NO/images/mcpi-setblock2.png differ diff --git a/no-NO/images/mcpi-setblocks.png b/no-NO/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/no-NO/images/mcpi-setblocks.png differ diff --git a/no-NO/images/mcpi-start.png b/no-NO/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/no-NO/images/mcpi-start.png differ diff --git a/no-NO/images/mcpi-tnt-blocks.png b/no-NO/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/no-NO/images/mcpi-tnt-blocks.png differ diff --git a/no-NO/images/mcpi-tnt-explode.png b/no-NO/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/no-NO/images/mcpi-tnt-explode.png differ diff --git a/no-NO/images/mcpi-tnt.png b/no-NO/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/no-NO/images/mcpi-tnt.png differ diff --git a/no-NO/images/menu.png b/no-NO/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/no-NO/images/menu.png differ diff --git a/no-NO/images/minecraft-pi-banner.png b/no-NO/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/no-NO/images/minecraft-pi-banner.png differ diff --git a/no-NO/images/minecraft-pi-shortcut.png b/no-NO/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/no-NO/images/minecraft-pi-shortcut.png differ diff --git a/no-NO/meta.yml b/no-NO/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/no-NO/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/no-NO/step_1.md b/no-NO/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/no-NO/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/no-NO/step_2.md b/no-NO/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/no-NO/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/no-NO/step_3.md b/no-NO/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/no-NO/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/no-NO/step_4.md b/no-NO/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/no-NO/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/no-NO/step_5.md b/no-NO/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/no-NO/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/no-NO/step_6.md b/no-NO/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/no-NO/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/no-NO/step_7.md b/no-NO/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/no-NO/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/no-NO/step_8.md b/no-NO/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/no-NO/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/no-NO/step_9.md b/no-NO/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/no-NO/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/pl-PL/images/banner.png b/pl-PL/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/pl-PL/images/banner.png differ diff --git a/pl-PL/images/blockbeneath.gif b/pl-PL/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/pl-PL/images/blockbeneath.gif differ diff --git a/pl-PL/images/helloworld.gif b/pl-PL/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/pl-PL/images/helloworld.gif differ diff --git a/pl-PL/images/lava.png b/pl-PL/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/pl-PL/images/lava.png differ diff --git a/pl-PL/images/mcpi-block-test.png b/pl-PL/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/pl-PL/images/mcpi-block-test.png differ diff --git a/pl-PL/images/mcpi-flowers-grass.png b/pl-PL/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/pl-PL/images/mcpi-flowers-grass.png differ diff --git a/pl-PL/images/mcpi-flowers-sky.png b/pl-PL/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/pl-PL/images/mcpi-flowers-sky.png differ diff --git a/pl-PL/images/mcpi-flowers.png b/pl-PL/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/pl-PL/images/mcpi-flowers.png differ diff --git a/pl-PL/images/mcpi-flying.png b/pl-PL/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/pl-PL/images/mcpi-flying.png differ diff --git a/pl-PL/images/mcpi-game.png b/pl-PL/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/pl-PL/images/mcpi-game.png differ diff --git a/pl-PL/images/mcpi-idle.png b/pl-PL/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/pl-PL/images/mcpi-idle.png differ diff --git a/pl-PL/images/mcpi-install.png b/pl-PL/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/pl-PL/images/mcpi-install.png differ diff --git a/pl-PL/images/mcpi-inventory.png b/pl-PL/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/pl-PL/images/mcpi-inventory.png differ diff --git a/pl-PL/images/mcpi-setblock.png b/pl-PL/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/pl-PL/images/mcpi-setblock.png differ diff --git a/pl-PL/images/mcpi-setblock2.png b/pl-PL/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/pl-PL/images/mcpi-setblock2.png differ diff --git a/pl-PL/images/mcpi-setblocks.png b/pl-PL/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/pl-PL/images/mcpi-setblocks.png differ diff --git a/pl-PL/images/mcpi-start.png b/pl-PL/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/pl-PL/images/mcpi-start.png differ diff --git a/pl-PL/images/mcpi-tnt-blocks.png b/pl-PL/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/pl-PL/images/mcpi-tnt-blocks.png differ diff --git a/pl-PL/images/mcpi-tnt-explode.png b/pl-PL/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/pl-PL/images/mcpi-tnt-explode.png differ diff --git a/pl-PL/images/mcpi-tnt.png b/pl-PL/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/pl-PL/images/mcpi-tnt.png differ diff --git a/pl-PL/images/menu.png b/pl-PL/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/pl-PL/images/menu.png differ diff --git a/pl-PL/images/minecraft-pi-banner.png b/pl-PL/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/pl-PL/images/minecraft-pi-banner.png differ diff --git a/pl-PL/images/minecraft-pi-shortcut.png b/pl-PL/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/pl-PL/images/minecraft-pi-shortcut.png differ diff --git a/pl-PL/meta.yml b/pl-PL/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/pl-PL/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/pl-PL/step_1.md b/pl-PL/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/pl-PL/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/pl-PL/step_2.md b/pl-PL/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/pl-PL/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/pl-PL/step_3.md b/pl-PL/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/pl-PL/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/pl-PL/step_4.md b/pl-PL/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/pl-PL/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/pl-PL/step_5.md b/pl-PL/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/pl-PL/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/pl-PL/step_6.md b/pl-PL/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/pl-PL/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/pl-PL/step_7.md b/pl-PL/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/pl-PL/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/pl-PL/step_8.md b/pl-PL/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/pl-PL/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/pl-PL/step_9.md b/pl-PL/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/pl-PL/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/pt-BR/images/banner.png b/pt-BR/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/pt-BR/images/banner.png differ diff --git a/pt-BR/images/blockbeneath.gif b/pt-BR/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/pt-BR/images/blockbeneath.gif differ diff --git a/pt-BR/images/helloworld.gif b/pt-BR/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/pt-BR/images/helloworld.gif differ diff --git a/pt-BR/images/lava.png b/pt-BR/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/pt-BR/images/lava.png differ diff --git a/pt-BR/images/mcpi-block-test.png b/pt-BR/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/pt-BR/images/mcpi-block-test.png differ diff --git a/pt-BR/images/mcpi-flowers-grass.png b/pt-BR/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/pt-BR/images/mcpi-flowers-grass.png differ diff --git a/pt-BR/images/mcpi-flowers-sky.png b/pt-BR/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/pt-BR/images/mcpi-flowers-sky.png differ diff --git a/pt-BR/images/mcpi-flowers.png b/pt-BR/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/pt-BR/images/mcpi-flowers.png differ diff --git a/pt-BR/images/mcpi-flying.png b/pt-BR/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/pt-BR/images/mcpi-flying.png differ diff --git a/pt-BR/images/mcpi-game.png b/pt-BR/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/pt-BR/images/mcpi-game.png differ diff --git a/pt-BR/images/mcpi-idle.png b/pt-BR/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/pt-BR/images/mcpi-idle.png differ diff --git a/pt-BR/images/mcpi-install.png b/pt-BR/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/pt-BR/images/mcpi-install.png differ diff --git a/pt-BR/images/mcpi-inventory.png b/pt-BR/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/pt-BR/images/mcpi-inventory.png differ diff --git a/pt-BR/images/mcpi-setblock.png b/pt-BR/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/pt-BR/images/mcpi-setblock.png differ diff --git a/pt-BR/images/mcpi-setblock2.png b/pt-BR/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/pt-BR/images/mcpi-setblock2.png differ diff --git a/pt-BR/images/mcpi-setblocks.png b/pt-BR/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/pt-BR/images/mcpi-setblocks.png differ diff --git a/pt-BR/images/mcpi-start.png b/pt-BR/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/pt-BR/images/mcpi-start.png differ diff --git a/pt-BR/images/mcpi-tnt-blocks.png b/pt-BR/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/pt-BR/images/mcpi-tnt-blocks.png differ diff --git a/pt-BR/images/mcpi-tnt-explode.png b/pt-BR/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/pt-BR/images/mcpi-tnt-explode.png differ diff --git a/pt-BR/images/mcpi-tnt.png b/pt-BR/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/pt-BR/images/mcpi-tnt.png differ diff --git a/pt-BR/images/menu.png b/pt-BR/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/pt-BR/images/menu.png differ diff --git a/pt-BR/images/minecraft-pi-banner.png b/pt-BR/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/pt-BR/images/minecraft-pi-banner.png differ diff --git a/pt-BR/images/minecraft-pi-shortcut.png b/pt-BR/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/pt-BR/images/minecraft-pi-shortcut.png differ diff --git a/pt-BR/meta.yml b/pt-BR/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/pt-BR/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/pt-BR/step_1.md b/pt-BR/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/pt-BR/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/pt-BR/step_2.md b/pt-BR/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/pt-BR/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/pt-BR/step_3.md b/pt-BR/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/pt-BR/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/pt-BR/step_4.md b/pt-BR/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/pt-BR/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/pt-BR/step_5.md b/pt-BR/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/pt-BR/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/pt-BR/step_6.md b/pt-BR/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/pt-BR/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/pt-BR/step_7.md b/pt-BR/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/pt-BR/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/pt-BR/step_8.md b/pt-BR/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/pt-BR/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/pt-BR/step_9.md b/pt-BR/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/pt-BR/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/pt-PT/images/banner.png b/pt-PT/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/pt-PT/images/banner.png differ diff --git a/pt-PT/images/blockbeneath.gif b/pt-PT/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/pt-PT/images/blockbeneath.gif differ diff --git a/pt-PT/images/helloworld.gif b/pt-PT/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/pt-PT/images/helloworld.gif differ diff --git a/pt-PT/images/lava.png b/pt-PT/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/pt-PT/images/lava.png differ diff --git a/pt-PT/images/mcpi-block-test.png b/pt-PT/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/pt-PT/images/mcpi-block-test.png differ diff --git a/pt-PT/images/mcpi-flowers-grass.png b/pt-PT/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/pt-PT/images/mcpi-flowers-grass.png differ diff --git a/pt-PT/images/mcpi-flowers-sky.png b/pt-PT/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/pt-PT/images/mcpi-flowers-sky.png differ diff --git a/pt-PT/images/mcpi-flowers.png b/pt-PT/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/pt-PT/images/mcpi-flowers.png differ diff --git a/pt-PT/images/mcpi-flying.png b/pt-PT/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/pt-PT/images/mcpi-flying.png differ diff --git a/pt-PT/images/mcpi-game.png b/pt-PT/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/pt-PT/images/mcpi-game.png differ diff --git a/pt-PT/images/mcpi-idle.png b/pt-PT/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/pt-PT/images/mcpi-idle.png differ diff --git a/pt-PT/images/mcpi-install.png b/pt-PT/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/pt-PT/images/mcpi-install.png differ diff --git a/pt-PT/images/mcpi-inventory.png b/pt-PT/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/pt-PT/images/mcpi-inventory.png differ diff --git a/pt-PT/images/mcpi-setblock.png b/pt-PT/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/pt-PT/images/mcpi-setblock.png differ diff --git a/pt-PT/images/mcpi-setblock2.png b/pt-PT/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/pt-PT/images/mcpi-setblock2.png differ diff --git a/pt-PT/images/mcpi-setblocks.png b/pt-PT/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/pt-PT/images/mcpi-setblocks.png differ diff --git a/pt-PT/images/mcpi-start.png b/pt-PT/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/pt-PT/images/mcpi-start.png differ diff --git a/pt-PT/images/mcpi-tnt-blocks.png b/pt-PT/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/pt-PT/images/mcpi-tnt-blocks.png differ diff --git a/pt-PT/images/mcpi-tnt-explode.png b/pt-PT/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/pt-PT/images/mcpi-tnt-explode.png differ diff --git a/pt-PT/images/mcpi-tnt.png b/pt-PT/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/pt-PT/images/mcpi-tnt.png differ diff --git a/pt-PT/images/menu.png b/pt-PT/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/pt-PT/images/menu.png differ diff --git a/pt-PT/images/minecraft-pi-banner.png b/pt-PT/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/pt-PT/images/minecraft-pi-banner.png differ diff --git a/pt-PT/images/minecraft-pi-shortcut.png b/pt-PT/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/pt-PT/images/minecraft-pi-shortcut.png differ diff --git a/pt-PT/meta.yml b/pt-PT/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/pt-PT/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/pt-PT/step_1.md b/pt-PT/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/pt-PT/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/pt-PT/step_2.md b/pt-PT/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/pt-PT/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/pt-PT/step_3.md b/pt-PT/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/pt-PT/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/pt-PT/step_4.md b/pt-PT/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/pt-PT/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/pt-PT/step_5.md b/pt-PT/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/pt-PT/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/pt-PT/step_6.md b/pt-PT/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/pt-PT/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/pt-PT/step_7.md b/pt-PT/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/pt-PT/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/pt-PT/step_8.md b/pt-PT/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/pt-PT/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/pt-PT/step_9.md b/pt-PT/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/pt-PT/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/ro-RO/images/banner.png b/ro-RO/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/ro-RO/images/banner.png differ diff --git a/ro-RO/images/blockbeneath.gif b/ro-RO/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/ro-RO/images/blockbeneath.gif differ diff --git a/ro-RO/images/helloworld.gif b/ro-RO/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/ro-RO/images/helloworld.gif differ diff --git a/ro-RO/images/lava.png b/ro-RO/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/ro-RO/images/lava.png differ diff --git a/ro-RO/images/mcpi-block-test.png b/ro-RO/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/ro-RO/images/mcpi-block-test.png differ diff --git a/ro-RO/images/mcpi-flowers-grass.png b/ro-RO/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/ro-RO/images/mcpi-flowers-grass.png differ diff --git a/ro-RO/images/mcpi-flowers-sky.png b/ro-RO/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/ro-RO/images/mcpi-flowers-sky.png differ diff --git a/ro-RO/images/mcpi-flowers.png b/ro-RO/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/ro-RO/images/mcpi-flowers.png differ diff --git a/ro-RO/images/mcpi-flying.png b/ro-RO/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/ro-RO/images/mcpi-flying.png differ diff --git a/ro-RO/images/mcpi-game.png b/ro-RO/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/ro-RO/images/mcpi-game.png differ diff --git a/ro-RO/images/mcpi-idle.png b/ro-RO/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/ro-RO/images/mcpi-idle.png differ diff --git a/ro-RO/images/mcpi-install.png b/ro-RO/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/ro-RO/images/mcpi-install.png differ diff --git a/ro-RO/images/mcpi-inventory.png b/ro-RO/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/ro-RO/images/mcpi-inventory.png differ diff --git a/ro-RO/images/mcpi-setblock.png b/ro-RO/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/ro-RO/images/mcpi-setblock.png differ diff --git a/ro-RO/images/mcpi-setblock2.png b/ro-RO/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/ro-RO/images/mcpi-setblock2.png differ diff --git a/ro-RO/images/mcpi-setblocks.png b/ro-RO/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/ro-RO/images/mcpi-setblocks.png differ diff --git a/ro-RO/images/mcpi-start.png b/ro-RO/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/ro-RO/images/mcpi-start.png differ diff --git a/ro-RO/images/mcpi-tnt-blocks.png b/ro-RO/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/ro-RO/images/mcpi-tnt-blocks.png differ diff --git a/ro-RO/images/mcpi-tnt-explode.png b/ro-RO/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/ro-RO/images/mcpi-tnt-explode.png differ diff --git a/ro-RO/images/mcpi-tnt.png b/ro-RO/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/ro-RO/images/mcpi-tnt.png differ diff --git a/ro-RO/images/menu.png b/ro-RO/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/ro-RO/images/menu.png differ diff --git a/ro-RO/images/minecraft-pi-banner.png b/ro-RO/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/ro-RO/images/minecraft-pi-banner.png differ diff --git a/ro-RO/images/minecraft-pi-shortcut.png b/ro-RO/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/ro-RO/images/minecraft-pi-shortcut.png differ diff --git a/ro-RO/meta.yml b/ro-RO/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/ro-RO/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/ro-RO/step_1.md b/ro-RO/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/ro-RO/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/ro-RO/step_2.md b/ro-RO/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/ro-RO/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/ro-RO/step_3.md b/ro-RO/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/ro-RO/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/ro-RO/step_4.md b/ro-RO/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/ro-RO/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/ro-RO/step_5.md b/ro-RO/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/ro-RO/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/ro-RO/step_6.md b/ro-RO/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/ro-RO/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/ro-RO/step_7.md b/ro-RO/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/ro-RO/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/ro-RO/step_8.md b/ro-RO/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/ro-RO/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/ro-RO/step_9.md b/ro-RO/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/ro-RO/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/ru-RU/images/banner.png b/ru-RU/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/ru-RU/images/banner.png differ diff --git a/ru-RU/images/blockbeneath.gif b/ru-RU/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/ru-RU/images/blockbeneath.gif differ diff --git a/ru-RU/images/helloworld.gif b/ru-RU/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/ru-RU/images/helloworld.gif differ diff --git a/ru-RU/images/lava.png b/ru-RU/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/ru-RU/images/lava.png differ diff --git a/ru-RU/images/mcpi-block-test.png b/ru-RU/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/ru-RU/images/mcpi-block-test.png differ diff --git a/ru-RU/images/mcpi-flowers-grass.png b/ru-RU/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/ru-RU/images/mcpi-flowers-grass.png differ diff --git a/ru-RU/images/mcpi-flowers-sky.png b/ru-RU/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/ru-RU/images/mcpi-flowers-sky.png differ diff --git a/ru-RU/images/mcpi-flowers.png b/ru-RU/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/ru-RU/images/mcpi-flowers.png differ diff --git a/ru-RU/images/mcpi-flying.png b/ru-RU/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/ru-RU/images/mcpi-flying.png differ diff --git a/ru-RU/images/mcpi-game.png b/ru-RU/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/ru-RU/images/mcpi-game.png differ diff --git a/ru-RU/images/mcpi-idle.png b/ru-RU/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/ru-RU/images/mcpi-idle.png differ diff --git a/ru-RU/images/mcpi-install.png b/ru-RU/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/ru-RU/images/mcpi-install.png differ diff --git a/ru-RU/images/mcpi-inventory.png b/ru-RU/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/ru-RU/images/mcpi-inventory.png differ diff --git a/ru-RU/images/mcpi-setblock.png b/ru-RU/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/ru-RU/images/mcpi-setblock.png differ diff --git a/ru-RU/images/mcpi-setblock2.png b/ru-RU/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/ru-RU/images/mcpi-setblock2.png differ diff --git a/ru-RU/images/mcpi-setblocks.png b/ru-RU/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/ru-RU/images/mcpi-setblocks.png differ diff --git a/ru-RU/images/mcpi-start.png b/ru-RU/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/ru-RU/images/mcpi-start.png differ diff --git a/ru-RU/images/mcpi-tnt-blocks.png b/ru-RU/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/ru-RU/images/mcpi-tnt-blocks.png differ diff --git a/ru-RU/images/mcpi-tnt-explode.png b/ru-RU/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/ru-RU/images/mcpi-tnt-explode.png differ diff --git a/ru-RU/images/mcpi-tnt.png b/ru-RU/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/ru-RU/images/mcpi-tnt.png differ diff --git a/ru-RU/images/menu.png b/ru-RU/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/ru-RU/images/menu.png differ diff --git a/ru-RU/images/minecraft-pi-banner.png b/ru-RU/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/ru-RU/images/minecraft-pi-banner.png differ diff --git a/ru-RU/images/minecraft-pi-shortcut.png b/ru-RU/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/ru-RU/images/minecraft-pi-shortcut.png differ diff --git a/ru-RU/meta.yml b/ru-RU/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/ru-RU/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/ru-RU/step_1.md b/ru-RU/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/ru-RU/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/ru-RU/step_2.md b/ru-RU/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/ru-RU/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/ru-RU/step_3.md b/ru-RU/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/ru-RU/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/ru-RU/step_4.md b/ru-RU/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/ru-RU/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/ru-RU/step_5.md b/ru-RU/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/ru-RU/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/ru-RU/step_6.md b/ru-RU/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/ru-RU/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/ru-RU/step_7.md b/ru-RU/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/ru-RU/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/ru-RU/step_8.md b/ru-RU/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/ru-RU/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/ru-RU/step_9.md b/ru-RU/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/ru-RU/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/sk-SK/images/banner.png b/sk-SK/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/sk-SK/images/banner.png differ diff --git a/sk-SK/images/blockbeneath.gif b/sk-SK/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/sk-SK/images/blockbeneath.gif differ diff --git a/sk-SK/images/helloworld.gif b/sk-SK/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/sk-SK/images/helloworld.gif differ diff --git a/sk-SK/images/lava.png b/sk-SK/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/sk-SK/images/lava.png differ diff --git a/sk-SK/images/mcpi-block-test.png b/sk-SK/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/sk-SK/images/mcpi-block-test.png differ diff --git a/sk-SK/images/mcpi-flowers-grass.png b/sk-SK/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/sk-SK/images/mcpi-flowers-grass.png differ diff --git a/sk-SK/images/mcpi-flowers-sky.png b/sk-SK/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/sk-SK/images/mcpi-flowers-sky.png differ diff --git a/sk-SK/images/mcpi-flowers.png b/sk-SK/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/sk-SK/images/mcpi-flowers.png differ diff --git a/sk-SK/images/mcpi-flying.png b/sk-SK/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/sk-SK/images/mcpi-flying.png differ diff --git a/sk-SK/images/mcpi-game.png b/sk-SK/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/sk-SK/images/mcpi-game.png differ diff --git a/sk-SK/images/mcpi-idle.png b/sk-SK/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/sk-SK/images/mcpi-idle.png differ diff --git a/sk-SK/images/mcpi-install.png b/sk-SK/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/sk-SK/images/mcpi-install.png differ diff --git a/sk-SK/images/mcpi-inventory.png b/sk-SK/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/sk-SK/images/mcpi-inventory.png differ diff --git a/sk-SK/images/mcpi-setblock.png b/sk-SK/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/sk-SK/images/mcpi-setblock.png differ diff --git a/sk-SK/images/mcpi-setblock2.png b/sk-SK/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/sk-SK/images/mcpi-setblock2.png differ diff --git a/sk-SK/images/mcpi-setblocks.png b/sk-SK/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/sk-SK/images/mcpi-setblocks.png differ diff --git a/sk-SK/images/mcpi-start.png b/sk-SK/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/sk-SK/images/mcpi-start.png differ diff --git a/sk-SK/images/mcpi-tnt-blocks.png b/sk-SK/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/sk-SK/images/mcpi-tnt-blocks.png differ diff --git a/sk-SK/images/mcpi-tnt-explode.png b/sk-SK/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/sk-SK/images/mcpi-tnt-explode.png differ diff --git a/sk-SK/images/mcpi-tnt.png b/sk-SK/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/sk-SK/images/mcpi-tnt.png differ diff --git a/sk-SK/images/menu.png b/sk-SK/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/sk-SK/images/menu.png differ diff --git a/sk-SK/images/minecraft-pi-banner.png b/sk-SK/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/sk-SK/images/minecraft-pi-banner.png differ diff --git a/sk-SK/images/minecraft-pi-shortcut.png b/sk-SK/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/sk-SK/images/minecraft-pi-shortcut.png differ diff --git a/sk-SK/meta.yml b/sk-SK/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/sk-SK/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/sk-SK/step_1.md b/sk-SK/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/sk-SK/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/sk-SK/step_2.md b/sk-SK/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/sk-SK/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/sk-SK/step_3.md b/sk-SK/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/sk-SK/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/sk-SK/step_4.md b/sk-SK/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/sk-SK/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/sk-SK/step_5.md b/sk-SK/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/sk-SK/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/sk-SK/step_6.md b/sk-SK/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/sk-SK/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/sk-SK/step_7.md b/sk-SK/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/sk-SK/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/sk-SK/step_8.md b/sk-SK/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/sk-SK/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/sk-SK/step_9.md b/sk-SK/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/sk-SK/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/sr-SP/images/banner.png b/sr-SP/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/sr-SP/images/banner.png differ diff --git a/sr-SP/images/blockbeneath.gif b/sr-SP/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/sr-SP/images/blockbeneath.gif differ diff --git a/sr-SP/images/helloworld.gif b/sr-SP/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/sr-SP/images/helloworld.gif differ diff --git a/sr-SP/images/lava.png b/sr-SP/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/sr-SP/images/lava.png differ diff --git a/sr-SP/images/mcpi-block-test.png b/sr-SP/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/sr-SP/images/mcpi-block-test.png differ diff --git a/sr-SP/images/mcpi-flowers-grass.png b/sr-SP/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/sr-SP/images/mcpi-flowers-grass.png differ diff --git a/sr-SP/images/mcpi-flowers-sky.png b/sr-SP/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/sr-SP/images/mcpi-flowers-sky.png differ diff --git a/sr-SP/images/mcpi-flowers.png b/sr-SP/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/sr-SP/images/mcpi-flowers.png differ diff --git a/sr-SP/images/mcpi-flying.png b/sr-SP/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/sr-SP/images/mcpi-flying.png differ diff --git a/sr-SP/images/mcpi-game.png b/sr-SP/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/sr-SP/images/mcpi-game.png differ diff --git a/sr-SP/images/mcpi-idle.png b/sr-SP/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/sr-SP/images/mcpi-idle.png differ diff --git a/sr-SP/images/mcpi-install.png b/sr-SP/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/sr-SP/images/mcpi-install.png differ diff --git a/sr-SP/images/mcpi-inventory.png b/sr-SP/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/sr-SP/images/mcpi-inventory.png differ diff --git a/sr-SP/images/mcpi-setblock.png b/sr-SP/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/sr-SP/images/mcpi-setblock.png differ diff --git a/sr-SP/images/mcpi-setblock2.png b/sr-SP/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/sr-SP/images/mcpi-setblock2.png differ diff --git a/sr-SP/images/mcpi-setblocks.png b/sr-SP/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/sr-SP/images/mcpi-setblocks.png differ diff --git a/sr-SP/images/mcpi-start.png b/sr-SP/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/sr-SP/images/mcpi-start.png differ diff --git a/sr-SP/images/mcpi-tnt-blocks.png b/sr-SP/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/sr-SP/images/mcpi-tnt-blocks.png differ diff --git a/sr-SP/images/mcpi-tnt-explode.png b/sr-SP/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/sr-SP/images/mcpi-tnt-explode.png differ diff --git a/sr-SP/images/mcpi-tnt.png b/sr-SP/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/sr-SP/images/mcpi-tnt.png differ diff --git a/sr-SP/images/menu.png b/sr-SP/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/sr-SP/images/menu.png differ diff --git a/sr-SP/images/minecraft-pi-banner.png b/sr-SP/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/sr-SP/images/minecraft-pi-banner.png differ diff --git a/sr-SP/images/minecraft-pi-shortcut.png b/sr-SP/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/sr-SP/images/minecraft-pi-shortcut.png differ diff --git a/sr-SP/meta.yml b/sr-SP/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/sr-SP/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/sr-SP/step_1.md b/sr-SP/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/sr-SP/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/sr-SP/step_2.md b/sr-SP/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/sr-SP/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/sr-SP/step_3.md b/sr-SP/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/sr-SP/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/sr-SP/step_4.md b/sr-SP/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/sr-SP/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/sr-SP/step_5.md b/sr-SP/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/sr-SP/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/sr-SP/step_6.md b/sr-SP/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/sr-SP/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/sr-SP/step_7.md b/sr-SP/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/sr-SP/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/sr-SP/step_8.md b/sr-SP/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/sr-SP/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/sr-SP/step_9.md b/sr-SP/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/sr-SP/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/sv-SE/images/banner.png b/sv-SE/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/sv-SE/images/banner.png differ diff --git a/sv-SE/images/blockbeneath.gif b/sv-SE/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/sv-SE/images/blockbeneath.gif differ diff --git a/sv-SE/images/helloworld.gif b/sv-SE/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/sv-SE/images/helloworld.gif differ diff --git a/sv-SE/images/lava.png b/sv-SE/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/sv-SE/images/lava.png differ diff --git a/sv-SE/images/mcpi-block-test.png b/sv-SE/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/sv-SE/images/mcpi-block-test.png differ diff --git a/sv-SE/images/mcpi-flowers-grass.png b/sv-SE/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/sv-SE/images/mcpi-flowers-grass.png differ diff --git a/sv-SE/images/mcpi-flowers-sky.png b/sv-SE/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/sv-SE/images/mcpi-flowers-sky.png differ diff --git a/sv-SE/images/mcpi-flowers.png b/sv-SE/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/sv-SE/images/mcpi-flowers.png differ diff --git a/sv-SE/images/mcpi-flying.png b/sv-SE/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/sv-SE/images/mcpi-flying.png differ diff --git a/sv-SE/images/mcpi-game.png b/sv-SE/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/sv-SE/images/mcpi-game.png differ diff --git a/sv-SE/images/mcpi-idle.png b/sv-SE/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/sv-SE/images/mcpi-idle.png differ diff --git a/sv-SE/images/mcpi-install.png b/sv-SE/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/sv-SE/images/mcpi-install.png differ diff --git a/sv-SE/images/mcpi-inventory.png b/sv-SE/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/sv-SE/images/mcpi-inventory.png differ diff --git a/sv-SE/images/mcpi-setblock.png b/sv-SE/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/sv-SE/images/mcpi-setblock.png differ diff --git a/sv-SE/images/mcpi-setblock2.png b/sv-SE/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/sv-SE/images/mcpi-setblock2.png differ diff --git a/sv-SE/images/mcpi-setblocks.png b/sv-SE/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/sv-SE/images/mcpi-setblocks.png differ diff --git a/sv-SE/images/mcpi-start.png b/sv-SE/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/sv-SE/images/mcpi-start.png differ diff --git a/sv-SE/images/mcpi-tnt-blocks.png b/sv-SE/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/sv-SE/images/mcpi-tnt-blocks.png differ diff --git a/sv-SE/images/mcpi-tnt-explode.png b/sv-SE/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/sv-SE/images/mcpi-tnt-explode.png differ diff --git a/sv-SE/images/mcpi-tnt.png b/sv-SE/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/sv-SE/images/mcpi-tnt.png differ diff --git a/sv-SE/images/menu.png b/sv-SE/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/sv-SE/images/menu.png differ diff --git a/sv-SE/images/minecraft-pi-banner.png b/sv-SE/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/sv-SE/images/minecraft-pi-banner.png differ diff --git a/sv-SE/images/minecraft-pi-shortcut.png b/sv-SE/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/sv-SE/images/minecraft-pi-shortcut.png differ diff --git a/sv-SE/meta.yml b/sv-SE/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/sv-SE/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/sv-SE/step_1.md b/sv-SE/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/sv-SE/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/sv-SE/step_2.md b/sv-SE/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/sv-SE/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/sv-SE/step_3.md b/sv-SE/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/sv-SE/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/sv-SE/step_4.md b/sv-SE/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/sv-SE/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/sv-SE/step_5.md b/sv-SE/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/sv-SE/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/sv-SE/step_6.md b/sv-SE/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/sv-SE/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/sv-SE/step_7.md b/sv-SE/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/sv-SE/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/sv-SE/step_8.md b/sv-SE/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/sv-SE/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/sv-SE/step_9.md b/sv-SE/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/sv-SE/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/tr-TR/images/banner.png b/tr-TR/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/tr-TR/images/banner.png differ diff --git a/tr-TR/images/blockbeneath.gif b/tr-TR/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/tr-TR/images/blockbeneath.gif differ diff --git a/tr-TR/images/helloworld.gif b/tr-TR/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/tr-TR/images/helloworld.gif differ diff --git a/tr-TR/images/lava.png b/tr-TR/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/tr-TR/images/lava.png differ diff --git a/tr-TR/images/mcpi-block-test.png b/tr-TR/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/tr-TR/images/mcpi-block-test.png differ diff --git a/tr-TR/images/mcpi-flowers-grass.png b/tr-TR/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/tr-TR/images/mcpi-flowers-grass.png differ diff --git a/tr-TR/images/mcpi-flowers-sky.png b/tr-TR/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/tr-TR/images/mcpi-flowers-sky.png differ diff --git a/tr-TR/images/mcpi-flowers.png b/tr-TR/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/tr-TR/images/mcpi-flowers.png differ diff --git a/tr-TR/images/mcpi-flying.png b/tr-TR/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/tr-TR/images/mcpi-flying.png differ diff --git a/tr-TR/images/mcpi-game.png b/tr-TR/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/tr-TR/images/mcpi-game.png differ diff --git a/tr-TR/images/mcpi-idle.png b/tr-TR/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/tr-TR/images/mcpi-idle.png differ diff --git a/tr-TR/images/mcpi-install.png b/tr-TR/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/tr-TR/images/mcpi-install.png differ diff --git a/tr-TR/images/mcpi-inventory.png b/tr-TR/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/tr-TR/images/mcpi-inventory.png differ diff --git a/tr-TR/images/mcpi-setblock.png b/tr-TR/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/tr-TR/images/mcpi-setblock.png differ diff --git a/tr-TR/images/mcpi-setblock2.png b/tr-TR/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/tr-TR/images/mcpi-setblock2.png differ diff --git a/tr-TR/images/mcpi-setblocks.png b/tr-TR/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/tr-TR/images/mcpi-setblocks.png differ diff --git a/tr-TR/images/mcpi-start.png b/tr-TR/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/tr-TR/images/mcpi-start.png differ diff --git a/tr-TR/images/mcpi-tnt-blocks.png b/tr-TR/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/tr-TR/images/mcpi-tnt-blocks.png differ diff --git a/tr-TR/images/mcpi-tnt-explode.png b/tr-TR/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/tr-TR/images/mcpi-tnt-explode.png differ diff --git a/tr-TR/images/mcpi-tnt.png b/tr-TR/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/tr-TR/images/mcpi-tnt.png differ diff --git a/tr-TR/images/menu.png b/tr-TR/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/tr-TR/images/menu.png differ diff --git a/tr-TR/images/minecraft-pi-banner.png b/tr-TR/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/tr-TR/images/minecraft-pi-banner.png differ diff --git a/tr-TR/images/minecraft-pi-shortcut.png b/tr-TR/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/tr-TR/images/minecraft-pi-shortcut.png differ diff --git a/tr-TR/meta.yml b/tr-TR/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/tr-TR/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/tr-TR/step_1.md b/tr-TR/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/tr-TR/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/tr-TR/step_2.md b/tr-TR/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/tr-TR/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/tr-TR/step_3.md b/tr-TR/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/tr-TR/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/tr-TR/step_4.md b/tr-TR/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/tr-TR/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/tr-TR/step_5.md b/tr-TR/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/tr-TR/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/tr-TR/step_6.md b/tr-TR/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/tr-TR/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/tr-TR/step_7.md b/tr-TR/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/tr-TR/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/tr-TR/step_8.md b/tr-TR/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/tr-TR/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/tr-TR/step_9.md b/tr-TR/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/tr-TR/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/uk-UA/images/banner.png b/uk-UA/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/uk-UA/images/banner.png differ diff --git a/uk-UA/images/blockbeneath.gif b/uk-UA/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/uk-UA/images/blockbeneath.gif differ diff --git a/uk-UA/images/helloworld.gif b/uk-UA/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/uk-UA/images/helloworld.gif differ diff --git a/uk-UA/images/lava.png b/uk-UA/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/uk-UA/images/lava.png differ diff --git a/uk-UA/images/mcpi-block-test.png b/uk-UA/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/uk-UA/images/mcpi-block-test.png differ diff --git a/uk-UA/images/mcpi-flowers-grass.png b/uk-UA/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/uk-UA/images/mcpi-flowers-grass.png differ diff --git a/uk-UA/images/mcpi-flowers-sky.png b/uk-UA/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/uk-UA/images/mcpi-flowers-sky.png differ diff --git a/uk-UA/images/mcpi-flowers.png b/uk-UA/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/uk-UA/images/mcpi-flowers.png differ diff --git a/uk-UA/images/mcpi-flying.png b/uk-UA/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/uk-UA/images/mcpi-flying.png differ diff --git a/uk-UA/images/mcpi-game.png b/uk-UA/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/uk-UA/images/mcpi-game.png differ diff --git a/uk-UA/images/mcpi-idle.png b/uk-UA/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/uk-UA/images/mcpi-idle.png differ diff --git a/uk-UA/images/mcpi-install.png b/uk-UA/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/uk-UA/images/mcpi-install.png differ diff --git a/uk-UA/images/mcpi-inventory.png b/uk-UA/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/uk-UA/images/mcpi-inventory.png differ diff --git a/uk-UA/images/mcpi-setblock.png b/uk-UA/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/uk-UA/images/mcpi-setblock.png differ diff --git a/uk-UA/images/mcpi-setblock2.png b/uk-UA/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/uk-UA/images/mcpi-setblock2.png differ diff --git a/uk-UA/images/mcpi-setblocks.png b/uk-UA/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/uk-UA/images/mcpi-setblocks.png differ diff --git a/uk-UA/images/mcpi-start.png b/uk-UA/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/uk-UA/images/mcpi-start.png differ diff --git a/uk-UA/images/mcpi-tnt-blocks.png b/uk-UA/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/uk-UA/images/mcpi-tnt-blocks.png differ diff --git a/uk-UA/images/mcpi-tnt-explode.png b/uk-UA/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/uk-UA/images/mcpi-tnt-explode.png differ diff --git a/uk-UA/images/mcpi-tnt.png b/uk-UA/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/uk-UA/images/mcpi-tnt.png differ diff --git a/uk-UA/images/menu.png b/uk-UA/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/uk-UA/images/menu.png differ diff --git a/uk-UA/images/minecraft-pi-banner.png b/uk-UA/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/uk-UA/images/minecraft-pi-banner.png differ diff --git a/uk-UA/images/minecraft-pi-shortcut.png b/uk-UA/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/uk-UA/images/minecraft-pi-shortcut.png differ diff --git a/uk-UA/meta.yml b/uk-UA/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/uk-UA/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/uk-UA/step_1.md b/uk-UA/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/uk-UA/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/uk-UA/step_2.md b/uk-UA/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/uk-UA/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/uk-UA/step_3.md b/uk-UA/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/uk-UA/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/uk-UA/step_4.md b/uk-UA/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/uk-UA/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/uk-UA/step_5.md b/uk-UA/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/uk-UA/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/uk-UA/step_6.md b/uk-UA/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/uk-UA/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/uk-UA/step_7.md b/uk-UA/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/uk-UA/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/uk-UA/step_8.md b/uk-UA/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/uk-UA/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/uk-UA/step_9.md b/uk-UA/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/uk-UA/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/vi-VN/images/banner.png b/vi-VN/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/vi-VN/images/banner.png differ diff --git a/vi-VN/images/blockbeneath.gif b/vi-VN/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/vi-VN/images/blockbeneath.gif differ diff --git a/vi-VN/images/helloworld.gif b/vi-VN/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/vi-VN/images/helloworld.gif differ diff --git a/vi-VN/images/lava.png b/vi-VN/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/vi-VN/images/lava.png differ diff --git a/vi-VN/images/mcpi-block-test.png b/vi-VN/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/vi-VN/images/mcpi-block-test.png differ diff --git a/vi-VN/images/mcpi-flowers-grass.png b/vi-VN/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/vi-VN/images/mcpi-flowers-grass.png differ diff --git a/vi-VN/images/mcpi-flowers-sky.png b/vi-VN/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/vi-VN/images/mcpi-flowers-sky.png differ diff --git a/vi-VN/images/mcpi-flowers.png b/vi-VN/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/vi-VN/images/mcpi-flowers.png differ diff --git a/vi-VN/images/mcpi-flying.png b/vi-VN/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/vi-VN/images/mcpi-flying.png differ diff --git a/vi-VN/images/mcpi-game.png b/vi-VN/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/vi-VN/images/mcpi-game.png differ diff --git a/vi-VN/images/mcpi-idle.png b/vi-VN/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/vi-VN/images/mcpi-idle.png differ diff --git a/vi-VN/images/mcpi-install.png b/vi-VN/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/vi-VN/images/mcpi-install.png differ diff --git a/vi-VN/images/mcpi-inventory.png b/vi-VN/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/vi-VN/images/mcpi-inventory.png differ diff --git a/vi-VN/images/mcpi-setblock.png b/vi-VN/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/vi-VN/images/mcpi-setblock.png differ diff --git a/vi-VN/images/mcpi-setblock2.png b/vi-VN/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/vi-VN/images/mcpi-setblock2.png differ diff --git a/vi-VN/images/mcpi-setblocks.png b/vi-VN/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/vi-VN/images/mcpi-setblocks.png differ diff --git a/vi-VN/images/mcpi-start.png b/vi-VN/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/vi-VN/images/mcpi-start.png differ diff --git a/vi-VN/images/mcpi-tnt-blocks.png b/vi-VN/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/vi-VN/images/mcpi-tnt-blocks.png differ diff --git a/vi-VN/images/mcpi-tnt-explode.png b/vi-VN/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/vi-VN/images/mcpi-tnt-explode.png differ diff --git a/vi-VN/images/mcpi-tnt.png b/vi-VN/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/vi-VN/images/mcpi-tnt.png differ diff --git a/vi-VN/images/menu.png b/vi-VN/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/vi-VN/images/menu.png differ diff --git a/vi-VN/images/minecraft-pi-banner.png b/vi-VN/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/vi-VN/images/minecraft-pi-banner.png differ diff --git a/vi-VN/images/minecraft-pi-shortcut.png b/vi-VN/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/vi-VN/images/minecraft-pi-shortcut.png differ diff --git a/vi-VN/meta.yml b/vi-VN/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/vi-VN/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/vi-VN/step_1.md b/vi-VN/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/vi-VN/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/vi-VN/step_2.md b/vi-VN/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/vi-VN/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/vi-VN/step_3.md b/vi-VN/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/vi-VN/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/vi-VN/step_4.md b/vi-VN/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/vi-VN/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/vi-VN/step_5.md b/vi-VN/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/vi-VN/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/vi-VN/step_6.md b/vi-VN/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/vi-VN/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/vi-VN/step_7.md b/vi-VN/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/vi-VN/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/vi-VN/step_8.md b/vi-VN/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/vi-VN/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/vi-VN/step_9.md b/vi-VN/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/vi-VN/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/zh-CN/images/banner.png b/zh-CN/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/zh-CN/images/banner.png differ diff --git a/zh-CN/images/blockbeneath.gif b/zh-CN/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/zh-CN/images/blockbeneath.gif differ diff --git a/zh-CN/images/helloworld.gif b/zh-CN/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/zh-CN/images/helloworld.gif differ diff --git a/zh-CN/images/lava.png b/zh-CN/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/zh-CN/images/lava.png differ diff --git a/zh-CN/images/mcpi-block-test.png b/zh-CN/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/zh-CN/images/mcpi-block-test.png differ diff --git a/zh-CN/images/mcpi-flowers-grass.png b/zh-CN/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/zh-CN/images/mcpi-flowers-grass.png differ diff --git a/zh-CN/images/mcpi-flowers-sky.png b/zh-CN/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/zh-CN/images/mcpi-flowers-sky.png differ diff --git a/zh-CN/images/mcpi-flowers.png b/zh-CN/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/zh-CN/images/mcpi-flowers.png differ diff --git a/zh-CN/images/mcpi-flying.png b/zh-CN/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/zh-CN/images/mcpi-flying.png differ diff --git a/zh-CN/images/mcpi-game.png b/zh-CN/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/zh-CN/images/mcpi-game.png differ diff --git a/zh-CN/images/mcpi-idle.png b/zh-CN/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/zh-CN/images/mcpi-idle.png differ diff --git a/zh-CN/images/mcpi-install.png b/zh-CN/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/zh-CN/images/mcpi-install.png differ diff --git a/zh-CN/images/mcpi-inventory.png b/zh-CN/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/zh-CN/images/mcpi-inventory.png differ diff --git a/zh-CN/images/mcpi-setblock.png b/zh-CN/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/zh-CN/images/mcpi-setblock.png differ diff --git a/zh-CN/images/mcpi-setblock2.png b/zh-CN/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/zh-CN/images/mcpi-setblock2.png differ diff --git a/zh-CN/images/mcpi-setblocks.png b/zh-CN/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/zh-CN/images/mcpi-setblocks.png differ diff --git a/zh-CN/images/mcpi-start.png b/zh-CN/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/zh-CN/images/mcpi-start.png differ diff --git a/zh-CN/images/mcpi-tnt-blocks.png b/zh-CN/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/zh-CN/images/mcpi-tnt-blocks.png differ diff --git a/zh-CN/images/mcpi-tnt-explode.png b/zh-CN/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/zh-CN/images/mcpi-tnt-explode.png differ diff --git a/zh-CN/images/mcpi-tnt.png b/zh-CN/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/zh-CN/images/mcpi-tnt.png differ diff --git a/zh-CN/images/menu.png b/zh-CN/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/zh-CN/images/menu.png differ diff --git a/zh-CN/images/minecraft-pi-banner.png b/zh-CN/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/zh-CN/images/minecraft-pi-banner.png differ diff --git a/zh-CN/images/minecraft-pi-shortcut.png b/zh-CN/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/zh-CN/images/minecraft-pi-shortcut.png differ diff --git a/zh-CN/meta.yml b/zh-CN/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/zh-CN/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/zh-CN/step_1.md b/zh-CN/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/zh-CN/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/zh-CN/step_2.md b/zh-CN/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/zh-CN/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/zh-CN/step_3.md b/zh-CN/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/zh-CN/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/zh-CN/step_4.md b/zh-CN/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/zh-CN/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/zh-CN/step_5.md b/zh-CN/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/zh-CN/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/zh-CN/step_6.md b/zh-CN/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/zh-CN/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/zh-CN/step_7.md b/zh-CN/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/zh-CN/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/zh-CN/step_8.md b/zh-CN/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/zh-CN/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/zh-CN/step_9.md b/zh-CN/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/zh-CN/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file diff --git a/zh-TW/images/banner.png b/zh-TW/images/banner.png new file mode 100644 index 0000000..ca62025 Binary files /dev/null and b/zh-TW/images/banner.png differ diff --git a/zh-TW/images/blockbeneath.gif b/zh-TW/images/blockbeneath.gif new file mode 100644 index 0000000..12066f0 Binary files /dev/null and b/zh-TW/images/blockbeneath.gif differ diff --git a/zh-TW/images/helloworld.gif b/zh-TW/images/helloworld.gif new file mode 100644 index 0000000..6faff19 Binary files /dev/null and b/zh-TW/images/helloworld.gif differ diff --git a/zh-TW/images/lava.png b/zh-TW/images/lava.png new file mode 100644 index 0000000..fbec4a2 Binary files /dev/null and b/zh-TW/images/lava.png differ diff --git a/zh-TW/images/mcpi-block-test.png b/zh-TW/images/mcpi-block-test.png new file mode 100644 index 0000000..6635f3d Binary files /dev/null and b/zh-TW/images/mcpi-block-test.png differ diff --git a/zh-TW/images/mcpi-flowers-grass.png b/zh-TW/images/mcpi-flowers-grass.png new file mode 100644 index 0000000..56be007 Binary files /dev/null and b/zh-TW/images/mcpi-flowers-grass.png differ diff --git a/zh-TW/images/mcpi-flowers-sky.png b/zh-TW/images/mcpi-flowers-sky.png new file mode 100644 index 0000000..5d90ae2 Binary files /dev/null and b/zh-TW/images/mcpi-flowers-sky.png differ diff --git a/zh-TW/images/mcpi-flowers.png b/zh-TW/images/mcpi-flowers.png new file mode 100644 index 0000000..07e1451 Binary files /dev/null and b/zh-TW/images/mcpi-flowers.png differ diff --git a/zh-TW/images/mcpi-flying.png b/zh-TW/images/mcpi-flying.png new file mode 100644 index 0000000..62244d1 Binary files /dev/null and b/zh-TW/images/mcpi-flying.png differ diff --git a/zh-TW/images/mcpi-game.png b/zh-TW/images/mcpi-game.png new file mode 100644 index 0000000..5b83c61 Binary files /dev/null and b/zh-TW/images/mcpi-game.png differ diff --git a/zh-TW/images/mcpi-idle.png b/zh-TW/images/mcpi-idle.png new file mode 100644 index 0000000..847cae5 Binary files /dev/null and b/zh-TW/images/mcpi-idle.png differ diff --git a/zh-TW/images/mcpi-install.png b/zh-TW/images/mcpi-install.png new file mode 100644 index 0000000..463c8e4 Binary files /dev/null and b/zh-TW/images/mcpi-install.png differ diff --git a/zh-TW/images/mcpi-inventory.png b/zh-TW/images/mcpi-inventory.png new file mode 100644 index 0000000..6ed67b6 Binary files /dev/null and b/zh-TW/images/mcpi-inventory.png differ diff --git a/zh-TW/images/mcpi-setblock.png b/zh-TW/images/mcpi-setblock.png new file mode 100644 index 0000000..a1e8fbc Binary files /dev/null and b/zh-TW/images/mcpi-setblock.png differ diff --git a/zh-TW/images/mcpi-setblock2.png b/zh-TW/images/mcpi-setblock2.png new file mode 100644 index 0000000..aeeeabb Binary files /dev/null and b/zh-TW/images/mcpi-setblock2.png differ diff --git a/zh-TW/images/mcpi-setblocks.png b/zh-TW/images/mcpi-setblocks.png new file mode 100644 index 0000000..2329d77 Binary files /dev/null and b/zh-TW/images/mcpi-setblocks.png differ diff --git a/zh-TW/images/mcpi-start.png b/zh-TW/images/mcpi-start.png new file mode 100644 index 0000000..9c298ce Binary files /dev/null and b/zh-TW/images/mcpi-start.png differ diff --git a/zh-TW/images/mcpi-tnt-blocks.png b/zh-TW/images/mcpi-tnt-blocks.png new file mode 100644 index 0000000..88f6ef5 Binary files /dev/null and b/zh-TW/images/mcpi-tnt-blocks.png differ diff --git a/zh-TW/images/mcpi-tnt-explode.png b/zh-TW/images/mcpi-tnt-explode.png new file mode 100644 index 0000000..13f07c5 Binary files /dev/null and b/zh-TW/images/mcpi-tnt-explode.png differ diff --git a/zh-TW/images/mcpi-tnt.png b/zh-TW/images/mcpi-tnt.png new file mode 100644 index 0000000..f1841a8 Binary files /dev/null and b/zh-TW/images/mcpi-tnt.png differ diff --git a/zh-TW/images/menu.png b/zh-TW/images/menu.png new file mode 100644 index 0000000..f028ce6 Binary files /dev/null and b/zh-TW/images/menu.png differ diff --git a/zh-TW/images/minecraft-pi-banner.png b/zh-TW/images/minecraft-pi-banner.png new file mode 100644 index 0000000..4c8cf28 Binary files /dev/null and b/zh-TW/images/minecraft-pi-banner.png differ diff --git a/zh-TW/images/minecraft-pi-shortcut.png b/zh-TW/images/minecraft-pi-shortcut.png new file mode 100644 index 0000000..c647818 Binary files /dev/null and b/zh-TW/images/minecraft-pi-shortcut.png differ diff --git a/zh-TW/meta.yml b/zh-TW/meta.yml new file mode 100644 index 0000000..d569bba --- /dev/null +++ b/zh-TW/meta.yml @@ -0,0 +1,37 @@ +--- +title: Getting Started with Minecraft Pi +hero_image: images/banner.png +description: Get your first taste of programming the world of Minecraft +original_url: https://raspberrypi.org/learning/getting-started-with-minecraft-pi +theme: yellow +duration: 2 +listed: true +ingredient: false +copyedit: true +curriculum: 2, design-0, programming-2, phys-comp-0, manufacture-0, community-0 +interests: games +technologies: python +site_areas: projects +hardware: '' +software: python +version: 3 +last_tested: 2017-01-01 +steps: + - + title: Introduction + - + title: What you will need + - + title: Getting Started with Minecraft Pi + - + title: Run Minecraft + - + title: Use the Python programming interface + - + title: Dropping blocks as you walk + - + title: Playing with TNT blocks + - + title: Fun with flowing lava. + - + title: What next? diff --git a/zh-TW/step_1.md b/zh-TW/step_1.md new file mode 100644 index 0000000..6a84b23 --- /dev/null +++ b/zh-TW/step_1.md @@ -0,0 +1,19 @@ +## What you will make + +In this resource you will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi. + +You will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you. + +## What you will learn + +By following this resource with your Raspberry Pi you will learn: + +- How to access Minecraft Pi and create a new world +- How to use the Python programming environment IDLE to connect to Minecraft Pi +- How to use the Minecraft Python API to post text to the chat window, find the player's coordinates, teleport and build structures +- How to use variables to store IDs for different types of blocks +- Experimenting with placing different types of blocks with special attributes + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Use basic programming constructs to create simple programs](https://www.raspberrypi.org/curriculum/programming/creator) \ No newline at end of file diff --git a/zh-TW/step_2.md b/zh-TW/step_2.md new file mode 100644 index 0000000..e5d0457 --- /dev/null +++ b/zh-TW/step_2.md @@ -0,0 +1,54 @@ +## What you will need + +### Software + +#### Software installation + +Minecraft has been installed by default in Raspbian since September 2014. + +![Minecraft Pi desktop icon](images/minecraft-pi-shortcut.png) + +If you're using an older version of Raspbian, open a terminal window and type the following commands (you must be online): + +```bash +sudo apt-get update +sudo apt-get install minecraft-pi +``` + +Once that finishes, Minecraft Pi and the Python library should be installed. + +#### Test Minecraft + +To run Minecraft double click the desktop icon or enter `minecraft-pi` in the terminal. + +![](images/mcpi-start.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! + +#### Test Python + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 (IDLE) on the Desktop and move the windows so they're side-by-side. + +You can either type commands directly in to the Python window or create a file so you can save your code and run it again another time. + +If you want create a file go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi import minecraft + +mc = minecraft.Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly in to the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/mcpi-idle.png) + +If you see "Hello world" in the Minecraft window, you're good to proceed to the next step. \ No newline at end of file diff --git a/zh-TW/step_3.md b/zh-TW/step_3.md new file mode 100644 index 0000000..431176c --- /dev/null +++ b/zh-TW/step_3.md @@ -0,0 +1,5 @@ +## Getting Started with Minecraft Pi + +Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you can write commands and scripts in Python code to build things in the game automatically. It's a great way to learn Python! + +![Minecraft Pi banner](images/minecraft-pi-banner.png) \ No newline at end of file diff --git a/zh-TW/step_4.md b/zh-TW/step_4.md new file mode 100644 index 0000000..7d63d57 --- /dev/null +++ b/zh-TW/step_4.md @@ -0,0 +1,35 @@ +## Run Minecraft + +To run Minecraft Pi, open it from the desktop menu or type `minecraft-pi` in the terminal. + +![](images/menu.png) + +When Minecraft Pi has loaded, click on **Start Game**, followed by **Create new**. You'll notice that the containing window is offset slightly. This means to drag the window around you have to grab the title bar behind the Minecraft window. + +![](images/mcpi-game.png) + +You are now in a game of Minecraft! Go walk around, hack things, and build things! + +Use the mouse to look around and use the following keys on the keyboard: + +| Key | Action | +|:------------:|:--------------------:| +| W | Forward | +| A | Left | +| S | Backward | +| D | Right | +| E | Inventory | +| Space | Jump | +| Double Space | Fly / Fall | +| Esc | Pause / Game menu | +| Tab | Release mouse cursor | + +You can select an item from the quick draw panel with the mouse's scroll wheel (or use the numbers on your keyboard), or press `E` and select something from the inventory. + +![](images/mcpi-inventory.png) + +You can also double tap the space bar to fly into the air. You'll stop flying when you release the space bar, and if you double tap it again you'll fall back to the ground. + +![](images/mcpi-flying.png) + +With the sword in your hand, you can click on blocks in front of you to remove them (or to dig). With a block in your hand, you can use right click to place that block in front of you, or left click to remove a block. \ No newline at end of file diff --git a/zh-TW/step_5.md b/zh-TW/step_5.md new file mode 100644 index 0000000..74c4549 --- /dev/null +++ b/zh-TW/step_5.md @@ -0,0 +1,162 @@ +## Use the Python programming interface + +With Minecraft running, and the world created, bring your focus away from the game by pressing the `Tab` key, which will free your mouse. Open Python 3 from the application menu and move the windows so they're side-by-side. + +You can either type commands directly into the Python window or create a file so you can save your code and run it again another time. + +If you want create a file, go to `File > New window` and `File > Save`. You'll probably want to save this in your home folder or a new project folder. + +Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message "Hello world" to the screen: + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +mc.postToChat("Hello world") +``` + +If you're entering commands directly into the Python window, just hit `Enter` after each line. If it's a file, save with `Ctrl + S` and run with `F5`. When your code runs, you should see your message on screen in the game. + +![](images/helloworld.gif) + +### Find your location + +To find your location, type: + +```python +pos = mc.player.getPos() +``` + +`pos` now contains your location; access each part of the set of coordinates with `pos.x`, `pos.y` and `pos.z`. + +Alternatively, a nice way to get the coordinates into separate variables is to use Python's unpacking technique: + +```python +x, y, z = mc.player.getPos() +``` + +Now `x`, `y`, and `z` contain each part of your position coordinates. `x` and `z` are the walking directions (forward/back and left/right) and `y` is up/down. + +Note that `getPos()` returns the location of the player at the time, and if you move position you have to call the function again or use the stored location. + +### Teleport + +As well as finding out your current location you can specify a particular location to teleport to. + +```python +x, y, z = mc.player.getPos() +mc.player.setPos(x, y+100, z) +``` + +This will transport your player to 100 spaces in the air. This will mean you'll teleport to the middle of the sky and fall straight back down to where you started. + +Try teleporting to somewhere else! + +### Set block + +You can place a single block at a given set of coordinates with `mc.setBlock()`: + +```python +x, y, z = mc.player.getPos() +mc.setBlock(x+1, y, z, 1) +``` + +Now a stone block should appear beside where you're standing. If it's not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you. + +![](images/mcpi-setblock.png) + +The arguments passed to `set block` are `x`, `y`, `z` and `id`. The `(x, y, z)` refers to the position in the world (we specified one block away from where the player is standing with `x + 1`) and the `id` refers to the type of block we'd like to place. `1` is stone. + +Other blocks you can try: + + Air: 0 + Grass: 2 + Dirt: 3 + + +Now with the block in sight, try changing it to something else: + +```python +mc.setBlock(x+1, y, z, 2) +``` + +You should see the grey stone block change in front of your eyes! + +![](images/mcpi-setblock2.png) + +#### Block constants + +You can use a inbuilt block constants to set your blocks, if you know their names. You'll need another `import` line first though. + +```python +from mcpi import block +``` + +Now you can write the following to place a block: + +```python +mc.setBlock(x+3, y, z, block.STONE.id) +``` + +Block ids are pretty easy to guess, just use ALL CAPS, but here are a few examples to get you used to the way they are named. + + WOOD_PLANKS + WATER_STATIONARY + GOLD_ORE + GOLD_BLOCK + DIAMOND_BLOCK + NETHER_REACTOR_CORE + + +### Block as variable + +If you know the id of a block it can be useful to set it as a variable. You can use the name or the integer id. + +```python +dirt = 3 +mc.setBlock(x, y, z, dirt) +``` + +or + +```python +dirt = block.DIRT.id +mc.setBlock(x, y, z, dirt) +``` + +### Special blocks + +There are some blocks which have extra properties, such as Wool which has an extra setting you can specify the colour. To set this use the optional fourth parameter in `setBlock`: + +```python +wool = 35 +mc.setBlock(x, y, z, wool, 1) +``` + +Here the fourth parameter `1` sets the wool colour to orange. Without the fourth parameter it is set to the default (`0`) which is white. Some more colours are: + + 2: Magenta + 3: Light Blue + 4: Yellow + + +Try some more numbers and watch the block change! + +Other blocks which have extra properties are wood (`17`): oak, spruce, birch, etc; tall grass (`31`): shrub, grass, fern; torch (`50`): pointing east, west, north, south; and more. See the [API reference](http://www.stuffaboutcode.com/p/minecraft-api-reference.html) for full details. + +### Set multiple blocks + +As well as setting a single block with `setBlock` you can fill in a volume of space in one go with `setBlocks`: + +```python +stone = 1 +x, y, z = mc.player.getPos() +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, stone) +``` + +This will fill in a 10 x 10 x 10 cube of solid stone. + +![](images/mcpi-setblocks.png) + +You can create bigger volumes with the `setBlocks` function but it may take longer to generate! \ No newline at end of file diff --git a/zh-TW/step_6.md b/zh-TW/step_6.md new file mode 100644 index 0000000..e5c0b37 --- /dev/null +++ b/zh-TW/step_6.md @@ -0,0 +1,86 @@ +## Dropping blocks as you walk + +Now you know how to drop blocks, let's use our moving location to drop blocks when you walk. + +The following code will drop a flower behind you wherever you walk: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +flower = 38 + +while True: + x, y, z = mc.player.getPos() + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Now walk forward for a while and turn around to see the flowers you have left behind you. + +![](images/mcpi-flowers.png) + +Since we used a `while True` loop this will go on forever. To stop it, hit `Ctrl + C` in the Python window. + +Try flying through the air and see the flowers you leave in the sky: + +![](images/mcpi-flowers-sky.png) + +What if we only wanted to drop flowers when the player walks on grass? We can use `getBlock` to find out what type a block is: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +this_block = mc.getBlock(x, y, z) # block ID +print(this_block) +``` + +This tells you the location of the block you're standing *in* (this will be `0` - an air block). We want to know what type of block we're standing *on*. For this we subtract 1 from the `y` value and use `getBlock()` to determine what type of block we're standing on: + +```python +x, y, z = mc.player.getPos() # player position (x, y, z) +block_beneath = mc.getBlock(x, y-1, z) # block ID +print(block_beneath) +``` + +This tells us the ID of the block the player is standing on. + +Test this out by running a loop to print the block ID of whatever you're currently standing on: + +```python +while True: + x, y, z = mc.player.getPos() + block_beneath = mc.getBlock(x, y-1, z) + print(block_beneath) +``` + +![](images/blockbeneath.gif) + +We can use an `if` statement to choose whether or not we plant a flower: + +```python +grass = 2 +flower = 38 + +while True: + x, y, z = mc.player.getPos() # player position (x, y, z) + block_beneath = mc.getBlock(x, y-1, z) # block ID + + if block_beneath == grass: + mc.setBlock(x, y, z, flower) + sleep(0.1) +``` + +Perhaps next we could turn the tile we're standing on into grass if it isn't grass already: + +```python +if block_beneath == grass: + mc.setBlock(x, y, z, flower) +else: + mc.setBlock(x, y-1, z, grass) +``` + +Now we can walk forward and if we walk on grass, we'll leave a flower behind. If the next block is not grass, it turns into grass. When we turn around and walk back, we now leave a flower behind us. + +![](images/mcpi-flowers-grass.png) \ No newline at end of file diff --git a/zh-TW/step_7.md b/zh-TW/step_7.md new file mode 100644 index 0000000..5918c6c --- /dev/null +++ b/zh-TW/step_7.md @@ -0,0 +1,32 @@ +## Playing with TNT blocks + +Another interesting block is TNT! To place a normal TNT block use: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt) +``` + +![](images/mcpi-tnt.png) + +However, this TNT block is fairly boring. Try applying `data` as `1`: + +```python +tnt = 46 +mc.setBlock(x, y, z, tnt, 1) +``` + +Now use your sword and left click the TNT block: it will be activated and will explode in a matter of seconds! + +Now try making a big cube of TNT blocks! + +```python +tnt = 46 +mc.setBlocks(x+1, y+1, z+1, x+11, y+11, z+11, tnt, 1) +``` + +![](images/mcpi-tnt-blocks.png) + +Now you'll see a big cube full of TNT blocks. Go and activate one of the blocks and then run away to watch the show! It'll be really slow to render the graphics as so many things are changing at once. + +![](images/mcpi-tnt-explode.png) \ No newline at end of file diff --git a/zh-TW/step_8.md b/zh-TW/step_8.md new file mode 100644 index 0000000..31a79e7 --- /dev/null +++ b/zh-TW/step_8.md @@ -0,0 +1,43 @@ +## Fun with flowing lava. + +One block that's a lot of fun to play with is flowing lava. + +```python +from mcpi.minecraft import Minecraft + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 + +mc.setBlock(x+3, y+3, z, lava) +``` + +Find the block you've just placed, and you should see lava flowing from the block to the ground. + +The cool thing about lava is that when it cools down it becomes rock. Move to another location in your world and try this: + +```python +from mcpi.minecraft import Minecraft +from time import sleep + +mc = Minecraft.create() + +x, y, z = mc.player.getPos() + +lava = 10 +water = 8 +air = 0 + +mc.setBlock(x+3, y+3, z, lava) +sleep(20) +mc.setBlock(x+3, y+5, z, water) +sleep(4) +mc.setBlock(x+3, y+5, z, air) + +``` + +You can adjust the `sleep` parameters to allow more or less lava to flow. + +![lava](images/lava.png) \ No newline at end of file diff --git a/zh-TW/step_9.md b/zh-TW/step_9.md new file mode 100644 index 0000000..9791fdd --- /dev/null +++ b/zh-TW/step_9.md @@ -0,0 +1,11 @@ +## What next? + +There's plenty you can do now you know your way around the Minecraft world and how to use the Python interface. + +### Networked game + +If multiple people connect Raspberry Pis to a local network, they can join the same Minecraft world and play together. Players can see each other in the Minecraft world. + +### API reference + +For a more extensive documentation of functions and a full list of block IDs see an API reference at [stuffaboutcode.com](http://www.stuffaboutcode.com/p/minecraft-api-reference.html). \ No newline at end of file