LINUX.ORG.RU

История изменений

Исправление LINUX-ORG-RU, (текущая версия) :

Вроде работает, скомпилять программу, внутри сделать файлик main.lua запустить love .

local image = nil;
local anima = nil;
local anicount = 1;
local center = 150;
local typecount = 1;
local atypes =
{
      "insine",    "inquad",    "incubic",    "inquart",      "inquint",
      "inexpo",    "incirc",    "inback",     "inelastic",    "inbounce",
      "outsine",   "outquad",   "outcubic",   "outquart",     "outquint",
      "outexpo",   "outcirc",   "outback",    "outelastic",   "outbounce",
      "inoutsine", "inoutquad", "inoutcubic", "inoutquart",   "inoutquint",
      "inoutexpo", "inoutcirc", "inoutback",  "inoutelastic", "inoutbounce"
}

function lerp (a, b, t)
    return a + (b - a) * t
end


function gentable(atype)
    local animation = io.popen('./doner -m table -e '..atype..' -k 200  -c "%f,"'):read('*a');
    return load("return {"..animation.."};")();
end

function love.load()
    love.window.setTitle("LOR")
    local penguin = "https://www.linux.org.ru/img/good-penguin.png";
    os.execute('wget '..penguin..' -O img.png');
    image = love.graphics.newImage('img.png');
end

function draw_good(x,y,s)
    if image then
       love.graphics.draw(image,x,y);
    end
end
local ty ='';
function love.update(dt)
    if not anima then
       ty = atypes[typecount];
       typecount = typecount + 1;
       if typecount >= #atypes then typecount = 1; end
       anima = gentable(ty);
       anicount = 1;
       posx=center+anima[1];
    end

    if anicount+1 < #anima then
       posx = lerp(posx,center+anima[anicount+1],1)
       if posx >= center+anima[anicount+1] then
           anicount=anicount+1;
           posx=center+anima[anicount];
       end
   else
       anima = nil;
   end
end

function love.draw()
    love.graphics.setBackgroundColor(39/255,44/255,45/255,1)
    draw_good(posx,200);

    love.graphics.setColor(posx/255,posx/255,45/255,1)
    love.graphics.circle('line',100,150+posx,50)
    love.graphics.circle('fill',100,150+300-posx,50)

    love.graphics.setColor(1,1,1,1)
    love.graphics.print(typecount..' '..ty,300,150);

    love.graphics.setColor(posx/200,30*posx/200,posx/200,1)
    love.graphics.rectangle('fill',600,50,posx*0.5,posx*0.5,50,50)
end

Говнокод, но зато наглядно.

Исправление LINUX-ORG-RU, :

Вроде работает, скомпилять программу, внутри сделать файлик main.lua запустить love .

local image = nil;
local anima = nil;
local anicount = 1;
local center = 150;
local typecount = 1;
local atypes =
{
      "insine",    "inquad",    "incubic",    "inquart",      "inquint",
      "inexpo",    "incirc",    "inback",     "inelastic",    "inbounce",
      "outsine",   "outquad",   "outcubic",   "outquart",     "outquint",
      "outexpo",   "outcirc",   "outback",    "outelastic",   "outbounce",
      "inoutsine", "inoutquad", "inoutcubic", "inoutquart",   "inoutquint",
      "inoutexpo", "inoutcirc", "inoutback",  "inoutelastic", "inoutbounce"
}

function lerp (a, b, t)
    return a + (b - a) * t
end


function gentable(atype)
    local animation = io.popen('./doner -m table -e '..atype..' -k 200  -c "%f,"'):read('*a');
    return load("return {"..animation.."};")();
end

function love.load()
    love.window.setTitle("LOR")
    local penguin = "https://www.linux.org.ru/img/good-penguin.png";
    os.execute('wget '..penguin..' -O img.png');
    image = love.graphics.newImage('img.png');
end

function draw_good(x,y,s)
    if image then
       love.graphics.draw(image,x,y);
    end
end
local ty ='';
function love.update(dt)
    if not anima then
       ty = atypes[typecount];
       typecount = typecount + 1;
       if typecount >= #atypes then typecount = 1; end
       anima = gentable(ty);
       anicount = 1;
       posx=center+anima[1];
    end

    if anicount+1 < #anima then
       posx = lerp(posx,center+anima[anicount+1],1)
       if posx >= center+anima[anicount+1] then
           anicount=anicount+1;
           posx=center+anima[anicount];
       end
   else
       anima = nil;
   end
end

function love.draw()
    love.graphics.setBackgroundColor(39/255,44/255,45/255,1)
    draw_good(posx,200);

    love.graphics.setColor(posx/255,posx/255,45/255,1)
    love.graphics.circle('line',100,150+posx,50)
    love.graphics.circle('fill',100,150+300-posx,50)

    love.graphics.setColor(1,1,1,1)
    love.graphics.print(typecount..' '..ty,300,150);

    love.graphics.setColor(posx/200,30*posx/200,posx/200,1)
    love.graphics.rectangle('fill',600,50,posx*0.5,posx*0.5,50,50)
end

Исходная версия LINUX-ORG-RU, :

Вроде работает, скомпилять программу, внутри сделать файлик main.lua запустить love .

local image = nil;
local anima = nil;
local anicount = 1;
local center = 150;
local typecount = 1;
local atypes =
{
      "insine",    "inquad",    "incubic",    "inquart",      "inquint",
      "inexpo",    "incirc",    "inback",     "inelastic",    "inbounce",
      "outsine",   "outquad",   "outcubic",   "outquart",     "outquint",
      "outexpo",   "outcirc",   "outback",    "outelastic",   "outbounce",
      "inoutsine", "inoutquad", "inoutcubic", "inoutquart",   "inoutquint",
      "inoutexpo", "inoutcirc", "inoutback",  "inoutelastic", "inoutbounce"
}

function lerp (a, b, t)
    return a + (b - a) * t
end


function gentable(atype)
    local animation = io.popen('./doner -m table -e '..atype..' -k 200  -c "%f,"'):read('*a');
    return load("return {"..animation.."};")();
end

function love.load()
    love.window.setTitle("LOR")
    local penguin = "https://www.linux.org.ru/img/good-penguin.png";
    os.execute('wget '..penguin..' -O img.png');
    image = love.graphics.newImage('img.png');
end

function draw_good(x,y,s)
    if image then
       love.graphics.draw(image,x,y);
    end
end
local ty ='';
function love.update(dt)
    if not anima then
       ty = atypes[typecount];
       typecount = typecount + 1;
       if typecount >= #atypes then typecount = 1; end
       anima = gentable(ty);
       anicount = 1;
       posx=center+anima[1];
    end

    if anicount+1 < #anima then
       posx = lerp(posx,center+anima[anicount+1],1)
       if posx >= center+anima[anicount+1] then
           anicount=anicount+1;
           posx=center+anima[anicount];
       end
   else
       anima = nil;
   end
end

function love.draw()
    love.graphics.setBackgroundColor(39/255,44/255,45/255,1)
    draw_good(posx,200);

    love.graphics.setColor(posx/255,posx/255,45/255,1)
    love.graphics.circle('line',100,150+posx,50)
    love.graphics.circle('fill',100,150+300-posx,50)

    love.graphics.setColor(1,1,1,1)
    love.graphics.print(typecount..' '..ty,300,150);

    love.graphics.setColor(posx/200,30*posx/200,posx/200,1)
    love.graphics.rectangle('fill',600,50,posx*0.5,posx*0.5,50,50)
end