Page 1 of 1

Hlp - collection of useful libraries for game development

Posted: Sun Apr 15, 2018 3:13 pm
by egorcod
Hello!

I created a collection of some useful libraries. They are:

1. Finder
This library can find game servers in local network through UDP broadcast.

Example:

Code: Select all

local finder = require('finder')

love.window.close()

print('1 - server, other - client')

if tonumber(io.read(1)) == 1 then
  print('server')

  local srv = finder.Server({
    port = 8080,
    handshake = '93203'
  })

  srv:on('connect', function(address)
    return print(address .. " connected to server!")
  end)

  srv:on('disconnect', function(address)
    return print(address .. " disconnected from server!")
  end)

  love.update = function(dt)
    return srv:update()
  end

else

  print('client')

  local cl = finder.Client({
    port = 8080,
    handshake = '93203'
  })

  cl:on('connect', function(address)
    return print("Found server " .. address .. "!")
  end)

  cl:on('disconnect', function(address)
    return print(address .. " disconnected!")
  end)

  love.update = function(dt)
    return cl:update()
  end
end
2. Locale
Localization library. The killer feature: it can get system locale!

Example:

main.lua:

Code: Select all

local locale = require('locale')

local lc = locale.new('en', 'ru')

-- get system locale, wow!
lc.current = locale.get()

-- more locales can be loaded later
-- lc:load('*')

-- export data from locale
local data = lc.values

local time = 0

local font = love.graphics.newFont('font.ttf', 50)


love.update = function(dt)
  -- switch locales every second
  time = time + dt
  if time >= 1 then
    time = 0
    if lc.current == 'en' then
      lc.current = 'ru'
    else
      lc.current = 'en'
    end
  end
end

love.draw = function()
  love.graphics.setFont(font)
  return love.graphics.print(data.hello, 100, 100)
end
en.lua:

Code: Select all

return {
  language = 'en',
  values = {
    hello = 'Hello!'
  }
}
ru.lua:

Code: Select all

return {
  language = 'ru',
  values = {
    hello = 'Привет!'
  }
}

3. Asset
Async asset loader.

Example:

Code: Select all

local asset = require('asset')
local assets = {}


love.update = function()
	assets = {
		font = asset.font('font.ttf', 26),
		shader = asset('shader.glsl'),
		image = asset('image.jpg')
	}
end

love.draw = function()
	if assets.font then
		love.graphics.setFont(assets.font)
		love.graphics.print('SUPPORTS FONTS, SHADERS, IMAGES, AUDIOS AND VIDEOS')
	end

	if assets.shader then
		love.graphics.setShader(assets.shader)
	end

	if assets.image then
		love.graphics.draw(assets.image, 0, 55, nil, 0.14, 0.14)
	end

	if assets.shader then
		love.graphics.setShader()
	end
end
Thanks for reading! You can download library at GitHub repo: https://github.com/malyutinegor/hlp

Re: Hlp - collection of useful libraries for game development

Posted: Mon Apr 16, 2018 3:51 am
by yintercept
This is a really useful asset. Gonna save some time for sure.

egorcod thanks for this library, I appreciate what you've done here.

Posted: Mon Apr 16, 2018 2:23 pm
by egorcod
Thanks :)

Re: Hlp - collection of useful libraries for game development

Posted: Mon Apr 23, 2018 6:51 pm
by unek
https://github.com/malyutinegor/hlp/blo ... le.lua#L71
I think what you want is 'AppleLocale' not AppleLocal

Re: Hlp - collection of useful libraries for game development

Posted: Mon May 20, 2019 4:47 pm
by yintercept
I was literally going to implement an async asset loader this week until I saw this post for the second time lol.