Dinky OSC “Paw Game”

Phil is experimenting & learning how to control text / images on the #SSD1306 (128×64 px OLED display) attached to the #RaspberryPi #Pico – he’s ended up making a little game that involved moving a “Cat Paw” around with a slider & potentiometer and a button press “grabs” at what’s underneath the paw.

Phil is experimenting & learning how to control text / images on the #SSD1306 (128×64 px OLED display) attached to the #RaspberryPi #Pico – he’s ended up making a little game that involved moving a “Cat Paw” around with a slider & potentiometer and a button press “grabs” at what’s underneath the paw.

the code for the game is here

There are 8 “targets” to grab (you can change that by changing the line:
dots = 8 ) & the targets fly around with a random vector, each connecting to the next target with a line. The paw has a “hot spot” (the middle of the paw) and a “circle object” draws around it using the distance from it to the 1st target in the list (calculated by some simple trig in the utilities.py module, after an angle & radius has been calculated from the two objects’ positions)

Phil’s commented the main.py script as best he can, but, if you need any explanation, just holler!

Dinky OSC “image objects” drawn on SSD1306 128×64 px OLED screen controlled by GPIO pot, slider, buttons.

OOP Orbits

Phil has been learning OOP (Object Orientated Programming) in Python & applying it to his #dinkyOSC development on the raspberry pi pico. We’re aiming for two styles of GUI, a “simple” numbers / settings interface (like digital representation of a “normal” midi device, and a “visually creative” interface (what ever that develops into!)

Phil has developed an OOP system to create & manage “orbiting objects”

This “Orbit OOP” script creates an object that keeps track of a centre point, and equally spaces points around it using some simple trigonometry based on the slider & rotary Potentiometer’s values. (Slider = Length of radius to orbit, pot = angle (0-259° (converted to Radians (Degree * (Pi / 180.0)))

Button 1 & 2 “add & subtract” points (with a minimum of 1 & maximum of 9 points). When a point is added, the “orbit object” calculates the angular segments (4 objects = 90° segments, 5 object = 72° etc) and re-draws the objects accordingly. Phil also created different “image objects” that can follow the orbit points, but stuck with a simple BOX object (text box with padding) that follows the orbit point from its own centre (x,y for an object is usually top, left, so he subtracted 1/2 the width & height from the x,y orbit).

These scripts are still considered “experiments” but Phil had been asked by a few people online (when posting videos) if the code was available… so, here it is in a zip for you to play with. Remember, Phil’s still learning, so if it doesn’t “look like professional python code” do let him know where he can improve!