Hlp - collection of useful libraries for game development

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
egorcod
Prole
Posts: 16
Joined: Sun Jul 02, 2017 9:41 am

Hlp - collection of useful libraries for game development

Post by egorcod » Sun Apr 15, 2018 3:13 pm

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

User avatar
yintercept
Prole
Posts: 27
Joined: Mon Apr 02, 2018 3:31 pm

Re: Hlp - collection of useful libraries for game development

Post by yintercept » Mon Apr 16, 2018 3:51 am

This is a really useful asset. Gonna save some time for sure.

egorcod thanks for this library, I appreciate what you've done here.
Currently working on something Love2D could really use. Shhh.

egorcod
Prole
Posts: 16
Joined: Sun Jul 02, 2017 9:41 am

Post by egorcod » Mon Apr 16, 2018 2:23 pm

Thanks :)

User avatar
unek
Citizen
Posts: 85
Joined: Fri Oct 12, 2012 8:43 pm
Location: Poland
Contact:

Re: Hlp - collection of useful libraries for game development

Post by unek » Mon Apr 23, 2018 6:51 pm

https://github.com/malyutinegor/hlp/blo ... le.lua#L71
I think what you want is 'AppleLocale' not AppleLocal
DRAW DRAW - online painting app CLICK NUMBERS - cool game with numbers THEME LOVEFRAMES - a collection of my themes HOST FOR FREE - free hosting for online LOVE games STALK PEOPLE - a map of LOVE users

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests