Search found 155 matches

by monolifed
Tue Mar 30, 2021 7:38 pm
Forum: Libraries and Tools
Topic: A Simple Resource Library
Replies: 0
Views: 307

A Simple Resource Library

local function cache_invalidate(cache) for k, v in pairs(cache) do v.unused = true end end local function cache_cleanup(cache) for k, v in pairs(cache) do if v.unused then cache_remove(cache, k) end end end local function cache_remove(cache, k) local cached = cache[k] if cached.release then cached:...
by monolifed
Mon Mar 29, 2021 11:18 am
Forum: Libraries and Tools
Topic: A Simple Class Library
Replies: 0
Views: 436

A Simple Class Library

local M local noop = function() end local _deepcopy _deepcopy = function(t, mem) if type(t) ~= 'table' then return t end if mem[t] then return mem[t] end local copy = {} mem[t] = copy local meta = getmetatable(t) for k, v in pairs(t) do copy[_deepcopy(k, mem)] = _deepcopy(v, mem) end setmetatable(c...
by monolifed
Sun Mar 21, 2021 7:06 pm
Forum: Games and Creations
Topic: Platformer Template
Replies: 0
Views: 1224

Platformer Template

Purpose:
- Use as a base for platformer
- Create most of the game in Tiled map editor
- With minimal code changes

https://github.com/monolifed/platformer
Work in progress
Unfinished
by monolifed
Sun Mar 21, 2021 1:05 pm
Forum: Support and Development
Topic: Enforce just one instance?
Replies: 21
Views: 2966

Re: Enforce just one instance?

You can also run a local server with a fixed port. Then the other instance can't use the same port. (The code is just proof of concept) local socket = require"socket" local s, err = socket.bind("0.0.0.0", "8329") local role = err == "address already in use" an...
by monolifed
Thu Mar 18, 2021 3:00 pm
Forum: Games and Creations
Topic: Point In Polygon algorithm
Replies: 11
Views: 1687

Re: Point In Polygon algorithm

Thanks, changed it accordingly
Anyway sorry devdev
by monolifed
Thu Mar 18, 2021 1:39 pm
Forum: Games and Creations
Topic: Point In Polygon algorithm
Replies: 11
Views: 1687

Re: Point In Polygon algorithm

There is no possibility of NaN, (y1 > y) ~= (y2 > y) is false for y1 = y2

Your other points are right
by monolifed
Thu Mar 18, 2021 11:40 am
Forum: Libraries and Tools
Topic: Fast 2D point-in-polygon test
Replies: 5
Views: 3586

Re: Fast 2D point-in-polygon test

Since you use +1 and -1, wouldn't "return wn ~= 0" be sufficient.
by monolifed
Thu Mar 18, 2021 11:36 am
Forum: Games and Creations
Topic: Point In Polygon algorithm
Replies: 11
Views: 1687

Re: Point In Polygon algorithm

pgimeno's code after further simplification -- By Pedro Gimeno, donated to the public domain function isPointInPolygon(x, y, poly) local x1, y1, x2, y2 local len = #poly x2, y2 = poly[len - 1], poly[len] local wn = 0 for idx = 1, len, 2 do x1, y1 = x2, y2 x2, y2 = poly[idx], poly[idx + 1] if (y1 > y...
by monolifed
Tue Mar 16, 2021 9:11 pm
Forum: Support and Development
Topic: Avoiding moving objects going into walls in bump.lua
Replies: 22
Views: 2250

Re: Avoiding moving objects going into walls in bump.lua

I recently tried something similar local function shoveItemTo(self, other, x, y) map.world:update(other, x, y) local newx, newy = map.world:check(other, x, y) if newx ~= x or newy ~= y then map.world:update(other, other.x, other.y) else other.x, other.y = x, y end end basically I check if the new po...
by monolifed
Tue Mar 09, 2021 7:50 pm
Forum: Libraries and Tools
Topic: Simple Tiled Implementation - STI v1.2.3.0
Replies: 851
Views: 371224

Re: Simple Tiled Implementation - STI v1.2.3.0

Why do every function in graphics.lua check for graphics.isCreated before the actual love.graphics function call? Wouldn't something like this be more optimal? (I mean not this particular code but calling love.graphics functions directly) local lg = _G.love.graphics local graphics = { isCreated = lg...