Advertisement
Guest User

Untitled

a guest
Sep 13th, 2019
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. --sprite draw on angle
  2. function spra(angle,n,x,y,w,h,f_x,f_y)
  3.   if w==nil or h==nil then
  4.    w,h=8,8
  5.   else
  6.    w=w*8
  7.    h=h*8
  8.   end
  9.   local diag,w,h=flr(sqrt(w*w+h*h))/2,w/2,h/2
  10.   f_x,f_y=f_x and -1 or 1,f_y and -1 or 1
  11.   local cosa,sina,nx,ny=cos(angle),sin(angle),n%16*8,flr(n/16)*8
  12.   for i=-diag,diag do
  13.    for j=-diag,diag do
  14.     local ox,oy=(cosa*i + sina*j),(cosa*j - sina*i)
  15.     if ox==mid(-w,ox,w) and oy==mid(-h,oy,h) then
  16.      local col=sget(ox+w+nx,oy+h+ny)
  17.      if col!=14 then
  18.       --if(f_x*i+w>5) then col = darken[col]; end --shading and light hack
  19.       pset(x+f_x*i+w,y+f_y*j+h,col)
  20.      end
  21.     end
  22.    end
  23.   end
  24.  end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement