Skip to main content

Raspberry Pi geste contrôlé Minecraft X -Wing (revisited )


Translated using Google Translate from http://robotsandphysicalcomputing.blogspot.co.uk/2016/01/gesture-controlled-minecraft-x-wing.html I apologise if there are any translation issues.


Ce poste se fonde sur deux postes précédents et tente de répondre à certains des commentaires très utiles de personnes qui ont essayé cela. J'espère que cela aide.

Globalement, le projet se fonde sur un projet antérieur pour obtenir d'un simple X -Wing dans Minecraft sur ​​un Raspberry Pi . Le but était obtenir Python pour construire et déplacer le X -Wing . Les détails de ce projet peuvent être trouvés ici .


Révision Principale: Dans ce projet, et le précédent est basé autour de Python 3 exécutant le Raspbian ' Jessie ' Novembre version de l'OS . Aussi les bibliothèques supplémentaires peuvent devoir être ajouter pour obtenir le minecraftstuff (comme ShapeBlock ( ) et MinecraftShape ( ) ) . Détails sur la façon d' obtenir et d'installer ceux-ci peuvent être trouvés à


Dans ce post, la supplémentaire de Skywriter de Pirmoroni est inclus pour permettre les mouvements d'une main ou un doigt pour permettre à la X -Wing pour le décollage , la terre , aller de l'avant ou vers l'arrière .


Il se fonde sur des idées du livre Adventures in Minecraft sur ​​l'utilisation de Python et Minecraft utilisant un Raspberry Pi .


Le Skywriter  est une HAT Raspberry Pi (voir figure 2 ) qui permet à l'information de position de la main juste au-dessus du bord. Dans ce projet, il détecte films de la main , vers le bas, ou à travers le conseil d'administration afin de déterminer la direction du mouvement



Avant de commencer , utilisez le Skywriter dans le terminal que vous devez ajouter
 curl -sSL get.pimoroni.com/skywriter | bash


Pour commencer nous avons juste placé le X -Wing au-dessus du lecteur en plaçant des blocs en forme ( à peu près ) de la X -Wing basée autour de la méthode MinecraftShape ( voir le chapitre 8 de Adventures in Minecraft ) .







• Pour éviter de construire sur le joueur la position de départ de la X -Wing est défini par:• Trouver la position du joueur ;

o    ajouter 5 à la position x du joueur ;
o    ajouter 10 à la position y du joueur ( Le bit je dois me rappeler est l'axe y est vertical. ) ;
o    ajouter 5 à la position z du joueur;
• L'utilisation de ces valeurs construire en utilisant des blocs de laine , le X -Wing - 0 pour le blanc , et 14 pour les blocs rouges ;
• Si un film commence au sommet de la planche (ou «nord» ) cela déplace le X -Wing vers le sol ;
• Si un film commence au bas de la carte (ou " sud " ) cela déplace le X -Wing verticalement vers le haut ;
• Si un film commence sur la droite de la carte (ou «est» ), le X -Wing se déplace vers l'arrière horizontalement ;
• si un film commence sur la gauche de la carte ( ou « ouest »), le X -Wing se déplace vers l'avant .
 
from mcpi.minecraft import Minecraft
from mcpi import block
import mcpi.minecraftstuff as minecraftstuff
import time
import skywriter
import signal

mc=Minecraft.create()
xPos=mc.player.getTilePos()
xPos.x=xPos.x+5
xPos.y=xPos.y+5
xPos.z=xPos.z+5

xWingBlocks=[
minecraftstuff.ShapeBlock(0,0,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(-1,0,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(-2,0,0,block.WOOL.id,14),
minecraftstuff.ShapeBlock(-3,0,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(1,0,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(0,1,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(1,1,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(2,0,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(2,1,0,block.WOOL.id,0),
minecraftstuff.ShapeBlock(1,2,-1,block.WOOL.id,14),
minecraftstuff.ShapeBlock(1,2,1,block.WOOL.id,14),
minecraftstuff.ShapeBlock(1,-1,-1,block.WOOL.id,14),
minecraftstuff.ShapeBlock(1,-1,1,block.WOOL.id,14),
minecraftstuff.ShapeBlock(1,3,-2,block.WOOL.id,0),
minecraftstuff.ShapeBlock(1,3,2,block.WOOL.id,0),
minecraftstuff.ShapeBlock(1,-2,-2,block.WOOL.id,0),
minecraftstuff.ShapeBlock(1,-2,2,block.WOOL.id,0)]

xWingShape=minecraftstuff.MinecraftShape(mc,xPos,xWingBlocks)

@skywriter.flick()
def flick(start,finish):
  if start=="south":
    for count in range(1,10):
      time.sleep(0.1)
      xWingShape.moveBy(0,1,0)
  if start=="west":
    for count in range(1,10):
      time.sleep(0.1)
      xWingShape.moveBy(-1,0,0)
  if start=="east":
    for count in range(1,10):
      time.sleep(0.1)
      xWingShape.moveBy(1,0,0)
  if start=="north":
    for count in range(1,10):
      time.sleep(0.1)
      xWingShape.moveBy(0,-1,0)
signal.pause()





Pour plus de détails sur Minecraft et Python je suggère d'aller à http://www.stuffaboutcode.com/2013/11/coding-shapes-in-minecraft.html~~V en particulier sur la façon de télécharger le logiciel à mettre en œuvre MinecraftShape . Si vous n'utilisez ou modifiez cette s'il vous plaît laisser un commentaire, je serais ravi de voir ce que les autres faire.









All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Translation was done with Google Translate – sorry if it causes any offence this was not intentional.

Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular posts from this blog

Robot Software

In the previous blog posts for this 'series' "It is a good time...."  Post 1  looked at the hardware unpinning some of this positive rise in robots; Post 2  looked at social robots; Post 3  looked at a collection of small robots; Post 4 looked at further examples of small robots Robots, such as the forthcoming Buddy and JIBO, will be based some established open sourceand other technologies. Jibo will be based around various technologies including Electron and JavaScript (for more details see:  http://blog.jibo.com/2015/07/29/jibo-making-development-readily-accessible-to-all-developers/ ). Buddy is expected to be developed around tools for Unity3d, Arduino and OpenCV, and support Python, C++, C#, Java and JavaScript (for more details see http://www.roboticstrends.com/article/customize_your_buddy_companion_robot_with_this_software_development_kit ).  This post contin ues with some of the software being used with the smaller robots.  A number ...

Speech Recognition in Scratch 3 - turning Hello into Bonjour!

The Raspberry Pi Foundation recently released a programming activity Alien Language , with support Dale from Machine Learning for Kids , that is a brilliant use of Scratch 3 - Speech Recognition to control a sprite in an alien language. Do the activity, and it is very much worth doing, and it will make sense! I  would also recommend going to the  machinelearningforkids.co.uk   site anyway it is full of exciting things to do (for example loads of activities  https://machinelearningforkids.co.uk/#!/worksheets  ) . Scratch 3 has lots of extensions that are accessible through the Extension button in the Scratch 3 editor (see below) which add new fun new blocks to play with. The critical thing for this post is  Machine Learning for Kids  have created a Scratch 3 template with their own extensions for Scratch 3 within it  https://machinelearningforkids.co.uk/scratch3/ . One of which is a Speech to Text extension (see below). You must use this one ...

Scratch and web-cams in Scratch 3

Scratch 3 was launched on 2nd January 2019, so I wanted to know would Webcams still work with Scratch 3 as it did with Scratch 2. For example, in a previous post  Scratch, webcams, cats and explosions  the cat (Scratch) moved across the screen and a button burst when the object moved in the camera onto it.  Can the same thing be done in Scratch 3? The short answer is yes, but it is done slightly differently. The first change the video capture is not there in the blocks automatically; but is an extension that needs to be added. First, you need to add the extension blocks for video sensing. Go to the little icon at the bottom left of the screen (as shown below) this takes you to the extensions menu. Next, find the Video Sensing option and selected. The webcam, if enabled, with start automatically. A video sensing set of blocks is now in the list of block options.  The rest is very similar to doing this in Scratch 2. Moving ...