ZmijaV2

function collision(x1, y1, w1, h1, x2, y2, w2, h2)
  if (x1 < x2 + w2 and
   x1 + w1 > x2 and
   y1 < y2 + h2 and
   y1 + h1 > y2) then
    return true
  end
  return false
end

function love.load()
  love.graphics.setDefaultFilter("nearest", "nearest")
  x = 250
  y = 10
  snake = love.graphics.newImage("snake.png")
  jabuka = love.graphics.newImage("apple.png")
  
  bodovi = 0
  velicina = 1
  
  bod = {}
  bod.x = math.random() * 250
  bod.y = math.random() * 250
  
end

function love.update()
  if love.keyboard.isDown('s') then
    y = y + 5
  end
  if love.keyboard.isDown('w') then
    y = y - 5
  end
  if love.keyboard.isDown('d') then
    x = x + 5
  end
  if love.keyboard.isDown('a') then
    x = x - 5
  end
  
  if collision( x, y, 16*velicina, 16*velicina, bod.x, bod.y, 16, 16) then
    bodovi = bodovi + 1
    bod.x = math.random() * 250
    bod.y = math.random() * 250
    velicina = velicina + 0.5
  end
  
end

function love.draw()
  love.graphics.print(bodovi, 250, 0)
  love.graphics.draw(snake, x, y, 0, velicina, velicina)
  love.graphics.draw(jabuka, bod.x, bod.y)
end