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: 17
Joined: Sun Jul 02, 2017 9:41 am

Hlp - collection of useful libraries for game development

Post 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
User avatar
yintercept
Citizen
Posts: 64
Joined: Mon Apr 02, 2018 3:31 pm

Re: Hlp - collection of useful libraries for game development

Post 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.
Back in the saddle again.
egorcod
Prole
Posts: 17
Joined: Sun Jul 02, 2017 9:41 am

Post by egorcod »

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

Re: Hlp - collection of useful libraries for game development

Post by unek »

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
User avatar
yintercept
Citizen
Posts: 64
Joined: Mon Apr 02, 2018 3:31 pm

Re: Hlp - collection of useful libraries for game development

Post by yintercept »

I was literally going to implement an async asset loader this week until I saw this post for the second time lol.
Back in the saddle again.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests