The following code creates a rectangular grid of 64 cells (8*8) with different colors. If you touch a cell, it changes the color. I hope this gives you an idea of how to solve your problem with shader. The following online book explains how to create such shaders.
http://patriciogonzalezvivo.com/2015/thebookofshaders/
import scene, ui
shader_text = '''
precision highp float;
varying vec2 v_tex_coord;
uniform sampler2D u_texture;
uniform float u_time;
uniform vec2 u_sprite_size;
uniform float u_scale;
uniform vec2 u_offset;
void main(void) {
vec2 uv = mod(v_tex_coord, .125);
vec2 invuv = uv*8.;
vec2 pq = floor(v_tex_coord*8.0)/8.;
//vec4 color = texture2D(u_texture, invuv);
vec2 t = floor(u_offset*8.0/(u_sprite_size))/8.;
float r = 0.;
if ((pq.x == t.x) && (pq.y == t.y)) r = 1.0;
vec4 color = vec4(pq.x, pq.y, r, 1.);
gl_FragColor = color;
}
'''
class MyScene (scene.Scene):
def setup(self):
tile_texture = scene.Texture(ui.Image.named('Snake'))
self.sprite = scene.SpriteNode(
tile_texture,
size=(600, 600),
anchor_point=(0,0),
parent=self)
self.sprite.shader = scene.Shader(shader_text)
self.sprite.position = (100, 100)
def touch_began(self, touch):
self.set_touch_position(touch)
print (self.sprite.shader.get_uniform('u_offset'))
def set_touch_position(self, touch):
dx, dy = touch.location -self.sprite.position
self.sprite.shader.set_uniform('u_offset', (dx, dy))
scene.run(MyScene(), show_fps=True)