title: Perfomance improvement by using glsl
body: <p>my game animation performance isn't fast enough so i tried looking for a way to improve speed and found <a href="https://github.com/cr8ivecodesmith/kivy-shmup/blob/master/shmup/app.py" rel="nofollow noreferrer">Shoot em up</a>  but the  game seems to use GLSL script and canvas which i really don't understand how they works. How can i rewrite my code by using the above method (glsl script and canvas) </p>
  
  <p>Here is my slow script 10-12 Fps on Mobile (android and iOS) and 48-58 Fps on desktop </p>
  
  <pre><code>from kivy.app import App
  from kivy.uix.image import Image
  from kivy.uix.widget import Widget
  from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty,ListProperty, BooleanProperty
  from kivy.vector import Vector
  from kivy.clock import Clock
  import random
  import math
  from kivy.lang import Builder
  
  Builder.load_string("""
  &lt;FT&gt;:
      canvas.before:
          PushMatrix
  
          Rotate:
              angle: self.angle
              origin: self.center
      canvas.after:
          PopMatrix
  &lt;Flame&gt;:
      canvas.before:
          PushMatrix
  
          Rotate:
              angle: self.angle
              origin: self.center
  
      canvas.after:
          PopMatrix
  &lt;FlameGun&gt;:
      tank: tank
      canvas:
          Rectangle:
              source: "wood.png"
              size: self.size
              pos: self.pos
      FT:
          id: tank
          center: (root.width/2, 70)
  """) 
  class Flame(Image):
      velocity_x = NumericProperty(0)
      active = BooleanProperty(False)
      velocity_y = NumericProperty(0)
      velocity = ReferenceListProperty(velocity_x, velocity_y)
      angle = NumericProperty(0)
      def __init__(self, **kwargs):
          super(Flame, self).__init__(**kwargs)
          self.size_hint=(None, None)
          self.source = "zn.zip" #Contain animated images of Flame
          self.anim_delay= 0.35
          self.anim_loop = 1
          rs = random.randint(70, 80)
          self.size = (rs, rs)
          self.bind(active=self.addV)
      def addV(self, *args):
          self.velocity_y += random.uniform(20.0, 25.0)
          self.velocity_x += 0
      def move(self, pa):
          self.pos = Vector(*self.velocity) + self.pos
          self.angle = random.randint(0, 360)
          self.size = (self.size[0]+1, self.size[1]+1)
          if (self.y &gt; pa.top/1.6):
              pa.removeThis(self)
              self.velocity_y = 0
              self.velocity_x = 0
  class FT(Image):
      velocity_x = NumericProperty(0)
      activated = BooleanProperty(False)
      velocity_y = NumericProperty(0)
      velocity = ReferenceListProperty(velocity_x, velocity_y)
      angle = NumericProperty(180)
      def __init__(self, **kwargs):
          super(FT, self).__init__(**kwargs)
          self.source = 'FlameThrower.png'
  class FlameGun(Widget):
      tank = ObjectProperty(None)
      angle = NumericProperty(180)
      pr = NumericProperty(0.0)
      flames = []
      def update(self, dt):
          self.addFlame()
          if len(self.flames) != 0:
              for tank in self.flames:
                  if tank.active:
                      tank.move(self)
  
      def removeThis(self, bl):
          self.flames.remove(bl)
          self.remove_widget(bl)
          bl = None
      def startFlame(self, *args):
          for tank in self.flames:
              if not tank.active:
                  tank.active = True
      def addFlame(self, *args):
          self.fl = Flame()
          self.add_widget(self.fl)
          self.fl.center = self.tank.center
          self.flames.append(self.fl)
          self.fl.velocity = 0, 0
          if len(self.flames) != 0:
              self.startFlame()
      def on_touch_down(self, touch):
          self.tank.activated = True
  
  class FlameApp(App):
      def build(self):
          game = FlameGun()
          Clock.schedule_interval(game.update, 1.0 / 60.0)
          return game
  
  if __name__ == '__main__':
      FlameApp().run()
  </code></pre>
  
  <p>how can i rewrite the above code  using glsl for the fastest performance? </p>