Facebook Twitter Instagram Pinterest YouTube
    Trending
    • Add Kodi to RetroPie Menu
    • Disable Auto-login in Raspberry Pi OS
    • Raspberry Pi Cloud Storage with MEGA
    • RetroPie Temperature Monitor from Menu
    • Pi Pico Pinout and Power Pins
    • Install Arduino IDE on Raspberry Pi
    • Raspberry Pi 400 SSD Upgrade
    • Raspberry Pi Temperature Monitoring
    Facebook Twitter Instagram Pinterest YouTube RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        May 6, 2022

        Add Kodi to RetroPie Menu

        February 26, 2022

        Disable Auto-login in Raspberry Pi OS

        February 2, 2022

        Raspberry Pi Cloud Storage with MEGA

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Hardware»Add-ons»Operation Counterstrike – A Minecraft Game For The Pi
      Minecraft Operation Counterstrike

      Operation Counterstrike – A Minecraft Game For The Pi

      3
      By Matt on July 9, 2014 Add-ons, Minecraft, Python

      After my “Building A Castle In Minecraft With Python” article I wanted to create a Minecraft game that was a bit more interactive. The “find a diamond” type game had already been done so I decided to do a slightly different version with a time limit.

      “Operation Counterstrike” was born.

      The script randomly places a number of TNT blocks around the map and the player has to find and destroy them all before the timers run out. As in my castle script you can dive in and start adjusting the Python code to change the game play or implement your own ideas.

      Initial Setup

      In order to make use of this script you will need have Minecraft installed on your Pi with the Python API ready to use. Follow these tutorials if in doubt :

      • How To Setup Minecraft On The Raspberry Pi
      • How to Setup the Minecraft Python API on a Raspberry Pi

      Download Script

      The game script needs to be placed into the directory created when setting up the API. In the API setup tutorial linked above I use /home/pi/mcpi-api. You can download the script directly to your Pi using using :

      cd ~/mcpi-api
      wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/minecraft/counterstrike.py

      Alternatively here is a link to the Python game script.

      Minecraft TNT blockRunning The Game

      Launch Minecraft on the Pi and create a new world. To free the mouse cursor you can press the TAB key.

      To run the game you will need to launch the script either from an LXTerminal window on the Pi or a command line on a remote machine that is connected to the Pi (i.e. using Putty).

      Navigate to the API folder that you copied the script into and execute it.

      cd ~/mcpi-api
      python counterstrike.py

      Adding a number after the script will set the number of devices to generate. For example :

      python counterstrike.py 7

      will generate 7. If you do not specify a number the default is 3.

      Playing The Game

      Once the script is running you should see messages appear in your Minecraft window. You will be told how many devices are out there as well as status messages.

      The devices are placed in random positions around the map. Devices on land will be buried under the surface whereas devices in water will rest on the sea-bed. Each device has a randomly generated timer ranging from 80 to 180 seconds.

      Operation Counterstrike Screenshot #2

      The status updates will report the distance (R) to the nearest device and the lowest timer count (T). The nearest device may not always have the lowest count so you may have less time than you think to find the device that is about to explode!

      When you destroy a device you will get bonus time added to all the remaining devices.

      Operation Counterstrike Screenshot #1

      Find and destroy all the bombs before you run out of time!

      PiFace Control & Display

      One of my reasons for creating this script was to test my new PiFace Control & Display add-on. This allows you to easily add a 16×2 LCD screen to the Pi with switches. Within the script you will find 5 lines that relate to configuring the PiFace and outputting messages to it.

      Operation Counterstrike PiFace

      If you want to use one then remove the # symbol from the front of the following 5 lines :

      #import pifacecad as pf
      ...
      #cad.lcd.clear()
      ...
      #cad.lcd.write(msg)
      ...
      #cad = pf.PiFaceCAD()
      #cad.lcd.backlight_on()

      Have fun and happy hunting!

      Possible Future Updates

      • Remove all TNT blocks when player fails to find them so they aren’t left in world
      • Place bonus blocks that give the player extra time or extra clues to TNT block positions
      • Limit the maximum timer value due to bonuses
      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleFarnell USB Powered Soldering Iron
      Next Article Introducing the Raspberry Pi Model B+ Single Board Computer

      Related Posts

      Gameboy Zero 6 Button Board from Aliexpress

      Kano Motion Sensor Kit for the Raspberry Pi

      Controlling Energenie Power Sockets with the Pi-mote Addon

      3 Comments

      1. Boyd Wang on July 22, 2014 5:28 am

        hmm, awesome, I just don’t understand what is the LCD used for? Just displaying the screen message? Coz we already had a screen ;P

        Reply
        • Matt on July 22, 2014 10:51 am

          The screen was just there for a bit of fun. I wanted to show beginners that you could combine hardware with your Minecraft creations and weren’t limited to the on-screen world.

          Reply
      2. Darkflame2308 on August 5, 2014 9:32 pm

        You should make the tnt explode! You might be able to trigger an explosion at those coordinates, and change the default blast size. Make the world go boom!

        Reply

      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      May 6, 2022

      Add Kodi to RetroPie Menu

      February 26, 2022

      Disable Auto-login in Raspberry Pi OS

      February 2, 2022

      Raspberry Pi Cloud Storage with MEGA

      January 7, 2022

      RetroPie Temperature Monitor from Menu

      January 24, 2021

      Pi Pico Pinout and Power Pins

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      3D Printing Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter LCD LED Linux media Minecraft Model A Model B motionEyeOS PCB photography photos Pi-Lite portable power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives
      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Recent Posts
      May 6, 2022

      Add Kodi to RetroPie Menu

      February 26, 2022

      Disable Auto-login in Raspberry Pi OS

      February 2, 2022

      Raspberry Pi Cloud Storage with MEGA

      Facebook Twitter Instagram Pinterest YouTube RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2022 - All Rights Reserved - Matt Hawkins

      Type above and press Enter to search. Press Esc to cancel.