Thursday, February 16, 2017

Making Games with Scratch and Sense Hat on Raspberry Pi

I'm a big fan of the Raspberry Pi Sense Hat and Scratch for doing interesting things and learning to code.
Previously I made a Sense Hat Cave Game using Python where you tilt the Sense Hat to move around as well as a Crane controller programmed in Scratch.
This time the goal was to create game that uses the Sense Hat as the display while programmed in Scratch.  The best of both world.  The goal for me was to lean to control the pixels a bit better in Scratch.

The result is Collect the Dots a simple game where you're a blue dot collecting red dots.  It's kind of like snake without the tail.

You control your dot using either the small joystick on the Sense Hat or use the keyboard on the computer.  Press Down to start the game.  You'll see in the video it tells you this on the Sense Hat, but if no Sense hat is attached and you're running on screen there is no prompt.

As can be seen in the video the on screen display mirrors on the Sense Hat dots, so either can be used.
Strangely even though the screen display is bigger I found it easier to play if I only looked at the Sense Hat display.
The game can also be played without the Sense Hat. Uploaded to Scratch website

Embedded from the Scratch Website

You can download the code from GitHub

TIP: As the wonderful Cat Lamin points out in her blog post about using doing an animation on the Sense Hat using Scratch you have to run the code once to enable the sensors and capability of the Sense Hat.  So, the first time you run the program on a Raspberry Pi with a Sense Hat it may not work correctly.  Just stop it and start again and all will be perfect

A thought for an enhancement would be to control your dot by tilting the Sense Hat rather than using the joystick or keys.

1 comment:

  1. Purefit Keto Diet Plan

    Take a gander on the prescribed measurements! each jug of Purefit Keto Diet Plan enhancement is pressed with 60 nutritional capsules and Purefit Keto Diet Plan is suggested to admission 2 tablets always like 1 pill early in the day after your morning meal and 1 pill at the night after your supper with a pitcher of water. at the off chance that you really need to come across lengthy haul weight reduction and medical benefits then you definitely are advocated to take this equation in any event for ninety days daily with a legitimate eating ordinary. alongside those traces, you'll honestly encounter its beneficial effects in handiest fourteen days of its day by day make use of.