APC Australia

Build a world with Minecraft Pi

Jonni Bidwell Minecraft on

-

Besides empowering a new generation of makers, the Raspberry Pi has also establishe­d its merits as a gaming platform. Projects such as RetroPie, combined with the Pi’s cheapness, mean that it’s great for playing old classics. And even some new ones. Such as Minecraft.

In case you’ve been living under a rock since 2011, Minecraft is the best-selling computer game of all time. It’s an openworld sandbox affair, in which our hero, Steve, roams around a landscape made of voxels (blocks). Resources can be mined and crafted into other resources, so that Steve can build houses, farm crops, cook food, and fight enemies (all rendered in low-res splendor).

A special version, Minecraft: Pi Edition, was released in 2013, and has been bundled with Raspbian since 2014. This version is in some ways cut down, in the sense that there isn’t any crafting or baddies, and nor is there any limit on the available resources. But it does have some features that aren’t present in the full game, most notably a Python API for manipulati­ng the world while a game is being played. Not having to worry about creatures trying to kill you or where your next meal is coming from makes it great for younger players, emphasisin­g the creative aspects of the game, and the Python API makes it an ideal platform for aspiring coders, young and old.

FIRST STEPS

To get started, head to the menu, then ‘Games > Minecraft Pi’. Choose ‘Single Player’, then ‘New Game’. The game window is offset from the app window behind it — ensure your cursor is parallel with the top of the app window, and hold down to reposition it.

Click ‘Start Game’, followed by ‘Create New’. Your new world now loads. Feel free to explore and build. The controls for the game are pretty simple, and are shown in the table to the right.

Use the mouse to look around you. It can also be used to select items from the inventory. By default, you’re holding a sword. Click blocks to destroy them. The sword can also be used to dig. If you select a block from your inventory, you can begin building. Use the right mouse button to place the block, or the left button to destroy it. With time, patience, and some coding to automate block placement, you can have your very own castle [Image A].

CODING BLOCKS

To start coding in Minecraft: Pi Edition, press the Tab key while it’s running. Go to ‘Menu > Programing’. Click ‘Python 3’. Try to place the text boxes so they’re next to one another.

You can type commands here to change the in-game world. Over time, you can also write scripts to automate tasks for you — for example, a script that places a stone block wherever you walk. Let’s reprogram the game to display a simple message. Type in the following commands, pressing Return after each one:

from mcpi.minecraft import Minecraft mc = Minecraft.create() mc.postToChat(“Hello world, I’m playing Minecraft Pi!!!”)

Press Return to display your first in-game message. Next, look at the top-left of the screen. You can see your X, Y and Z co-ordinates. This is an excellent way to work out your location, as well as place blocks precisely. You can use Python to summon any number of blocks

 ??  ?? Image A
Image A

Newspapers in English

Newspapers from Australia