def renderAction()

in jsuarez/extra/embyr_deprecated/embyr2d/render.py [0:0]


def renderAction(screen, sprite, offs, tex, fonts, txSz, iso):
   rAnim, cAnim = sprite.posAnim
   rTarg, cTarg = sprite.targ.pos
   rTrans, cTrans= offs
   frame = sprite.frame

   rOff, cOff = rTarg - rAnim, cTarg - cAnim
   r = rAnim + frame * rOff 
   c = cAnim + frame * cOff 

   e = sprite.ent
   W, H = screen.W, screen.H
   if e.entID != sprite.targ.entID:
      attk = e.attack.action
      w, h = embyr.tileCoords(c-cTrans, r-rTrans, W, H, txSz, iso)
      if attk is v2.Melee:
         angle = np.arctan2(rAnim-rTarg, cTarg-cAnim) * 180 / np.pi - 90
         tex = tex.action[txSz]['melee']
         tex = pygame.transform.rotate(tex, angle + 360*frame)
      elif attk is v2.Range:
         angle = np.arctan2(rAnim-rTarg, cTarg-cAnim) * 180 / np.pi - 90
         tex = tex.action[txSz]['range']
         tex = pygame.transform.rotate(tex, angle)
      elif attk is v2.Mage:
         tex = tex.action[txSz]['mage']
         sz = int(txSz * frame)
         tex = pygame.transform.scale(tex, (sz, sz))
      else:
         print('invalid attack texture in render.py')
         exit(0)

      screen.blit(tex, (w, h))
      #w, h = embyr.tileCoords(cAnim-cOff, rAnim-rOff, W, H, txSz, iso)
      #screen.rect(Neon.BLUE.rgb, (w, h, txSz, txSz), 2)

      #w, h = embyr.tileCoords(cTarg-cOff, rTarg-rOff, W, H, txSz, iso)
      #screen.rect(Neon.ORANGE.rgb, (w, h, txSz, txSz), 4)

   damage = e.damage
   if damage is not None:
      w, h = embyr.tileCoords(cAnim-cTrans, rAnim-rTrans, W, H, txSz, iso)
      if damage == 0:
         text = fonts.huge.render(str(damage), 1, Neon.BLUE.rgb)
      else:
         text = fonts.huge.render(str(damage), 1, Neon.RED.rgb)
      screen.blit(text, (w, h-16))