Charging battery animation over time I have the following method that is working perfectly. Main problem I see is that I think it can be done just in one line, but I don't know how:

def _animate_display(self, display):
    self._timer += 1 / bge.logic.getAverageFrameRate()

    symbolic_level = self.battery.get_symbolic_level()

    if self._timer &gt;= 5.0:
        self._timer = symbolic_level / 25
    elif (self._timer &gt;= 4.0) and (symbolic_level &lt;= 100):
        utils.change_texture(display, 'DisplayMat', 'icons/battery_100.png')
    elif (self._timer &gt;= 3.0) and (symbolic_level &lt;= 75):
        utils.change_texture(display, 'DisplayMat', 'icons/battery_75.png')
    elif (self._timer &gt;= 2.0) and (symbolic_level &lt;= 50):
        utils.change_texture(display, 'DisplayMat', 'icons/battery_50.png')
    elif (self._timer &gt;= 1.0) and (symbolic_level &lt;= 25):
        utils.change_texture(display, 'DisplayMat', 'icons/battery_25.png')
    elif (self._timer &gt;= 0.0) and (symbolic_level &lt;= 0):
        utils.change_texture(display, 'DisplayMat', 'icons/battery_0.png')


It models a simple animation of a charging battery in steps of 1 second. Something like: [....] --1s--> [=...] --1s--> [==..] --1s--> [===.] --1s--> [====] --1s--> [....] ...

Symbolic level is a variable that keep a value of [0, 25, 50, 75, 100], one of these, so animation loops from that symbolic value so it doesn't start from 0.
I took it to 6 to make it a little more readable:

def _animate_display(self, display):
    self._timer += 1 / bge.logic.getAverageFrameRate()
    symbolic_level = self.battery.get_symbolic_level()
    if self._timer &gt;= 5.0:
        self._timer = symbolic_level / 25
    else:
        utils.change_texture(display, 'DisplayMat', 'icons/battery_{}.png'.format(next((x,y) for x,y in zip(xrange(100, -1, -25), xrange(4, -1, -1)) if symbolic_level &lt;= x and self._timer &gt;= y)))