Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
some smaller folders
  • Loading branch information
RokonShimo authored Sep 21, 2018
1 parent c7a58a1 commit b6020d6
Show file tree
Hide file tree
Showing 81 changed files with 2,936 additions and 0 deletions.
669 changes: 669 additions & 0 deletions netplayinc/LUBE.lua

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions netplayinc/MiddleClass.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
-----------------------------------------------------------------------------------
-- MiddleClass.lua
-- Enrique García ( enrique.garcia.cota [AT] gmail [DOT] com ) - 19 Oct 2009
-- Based on YaciCode, from Julien Patte and LuaObject, from Sébastien Rocca-Serra
-----------------------------------------------------------------------------------

local _classes = setmetatable({}, {__mode = "k"}) -- weak table storing references to all declared _classes

-- The 'Object' class
Object = { name = "Object" }

_classes[Object]=Object -- adds Object to the list of _classes

-- creates a new instance
Object.new = function(theClass, ...)
assert(_classes[theClass]~=nil, "Use class:new instead of class.new")

local instance = setmetatable({ class = theClass }, theClass.__classDict) -- the class dictionary is the instance's metatable
instance:initialize(...)
return instance
end

-- creates a subclass
Object.subclass = function(theClass, name)
assert(_classes[theClass]~=nil, "Use class:subclass instead of class.subclass")
if type(name)~="string" then name = "Unnamed" end

local theSubclass = { name = name, superclass = theClass, __classDict = {} }
local classDict = theSubclass.__classDict

-- This one is weird. Since:
-- a) the class dict is the instances' metatable (so it must have an __index for looking up the methods) and
-- b) The instance methods are in the class dict itself, then ...
classDict.__index = classDict
-- if a method isn't found on the class dict, look on its super class
setmetatable(classDict, {__index = theClass.__classDict} )

setmetatable(theSubclass, { -- theSubclass' metamethods
__index = function(_,methodName)
local localMethod = classDict[methodName] -- this allows using classDic as a class method AND instance method dict
if localMethod ~= nil then return localMethod end
return theClass[methodName]
end,
-- FIXME add support for __index method here
__newindex = function(_, methodName, method) -- when adding new methods, include a "super" function
if type(method) == 'function' then
local fenv = getfenv(method)
local newenv = setmetatable( {super = theClass.__classDict}, {__index = fenv, __newindex = fenv} )
setfenv( method, newenv )
end
rawset(classDict, methodName, method)
end,
__tostring = function() return ("class ".. name) end,
__call = function(_, ...) return theSubclass:new(...) end
})
-- instance methods go after the setmetatable, so we can use "super"
theSubclass.initialize = function(instance,...) super.initialize(instance) end

_classes[theSubclass]=theSubclass --registers the new class on the list of _classes

return theSubclass
end

-- Mixin extension function - simulates very basically ruby's include(module)
-- module is a lua table of functions. The functions will be copied to the class
-- if present in the module, the included() method will be called
Object.includes = function(theClass, module, ... )
assert(_classes[theClass]~=nil, "Use class:includes instead of class.includes")
for methodName,method in pairs(module) do
if methodName ~="included" then theClass[methodName] = method end
end
if type(module.included)=="function" then module:included(theClass, ... ) end
end

-- root of initialize and __tostring methods
Object.__classDict = {
initialize = function(instance, ...) end, -- end of the initialize() call chain
__tostring = function(instance) return ("instance of ".. instance.class.name) end
}

-- This allows doing tostring(obj) and Object() instead of Object:new()
setmetatable(Object, { __index = Object.__classDict, __newindex = Object.__classDict,
__tostring = function() return ("class Object") end,
__call = Object.new
})

-- Getter/Setter related methods
function Object.getterFor(theClass, attr) return 'get' .. attr:gsub("^%l", string.upper) end
function Object.setterFor(theClass, attr) return 'set' .. attr:gsub("^%l", string.upper) end
function Object.getter(theClass, attributeName, defaultValue)
theClass[theClass:getterFor(attributeName)] = function(self)
if(self[attributeName]~=nil) then return self[attributeName] end
return defaultValue
end
end
function Object.setter(theClass, attributeName)
theClass[theClass:setterFor(attributeName)] = function(self, value) self[attributeName] = value end
end
function Object.getterSetter(theClass, attributeName, defaultValue)
theClass:getter(attributeName, defaultValue)
theClass:setter(attributeName)
end

-- Returns true if aClass is a subclass of other, false otherwise
function subclassOf(other, aClass)
if aClass == nil or other==nil then return false end
if aClass.superclass==nil then return false end -- aClass is Object, or a non-class
return aClass.superclass == other or subclassOf(other, aClass.superclass)
end

-- Returns true if obj is an instance of aClass (or one of its subclasses) false otherwise
function instanceOf(aClass, obj)
if obj==nil or _classes[aClass]==nil or _classes[obj.class]==nil then return false end
if obj.class==aClass then return true end
return subclassOf(aClass, obj.class)
end

-- Creates a new class named 'name'. It uses baseClass as the parent (Object if none specified)
function class(name, baseClass)
baseClass = baseClass or Object
return baseClass:subclass(name)
end
77 changes: 77 additions & 0 deletions netplayinc/umsg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
umsg = {}
umsg.hooknames = {}
umsg.hookfuncs = {}
usermessage = class("usermessage")
function usermessage:initialize(name,message)
self.sender = nil
self.name = name
self.message = (message or nil)
end

function usermessage:send(id)
local lid
if id then
lid = id - 1
end
if(SERVER) then
if self.message == nil then
MyServer:send("#UMSG#"..self.name, lid)
else
MyServer:send("#UMSG#"..self.name.."~"..self.message, lid)
end
end
if(CLIENT) then
if self.message == nil then
MyClient:send("#UMSG#"..self.name)
else
MyClient:send("#UMSG#"..self.name.."~"..self.message)
end
end
end

function umsg.hook(hookname,hookfunction)
table.insert(umsg.hooknames, #umsg.hooknames + 1, hookname)
table.insert(umsg.hookfuncs, #umsg.hookfuncs + 1, hookfunction)
end

function umsg.recv(data, id)
clienttimeouttimer = 0

if lagtime == 0 then
umsg.recv2(data, id)
else
table.insert(lagtable, 1, {0, data, id})
end
end

function umsg.recv2(data, id)
if(string.sub(data,1,6) == "#UMSG#") then
data = string.sub(data,7)
if string.find(data, "~") == nil then
um = usermessage:new(data)
um.message = ""
else
local des = deserialize(data)
um = usermessage:new(des[1])
um.message = des[2]
for i = 3, #des do
um.message = um.message .. "~" .. des[i]
end
end
if(SERVER) then
um.sender = id+1
end
if (CLIENT) then
um.sender = 1
end
for i,v in pairs(umsg.hooknames) do
if v == um.name then
umsg.hookfuncs[i](um.message, um.sender)
return
end
end
if not (um.name == nil) then
message("UMSG ERROR: Unknown Hookname: "..um.name)
end
end
end
173 changes: 173 additions & 0 deletions shaders/4xBR.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
4xBR shader
Copyright (C) 2011 Hyllian.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
(justification for applying the GPLv2:
http://board.byuu.org/viewtopic.php?p=32616#p32616
)
modified by slime73 for use with love2d and mari0
*/


extern vec2 textureSize;

const vec3 dtt = vec3(65536.0, 255.0, 1.0);

float reduce(vec3 color)
{
return dot(color, dtt);
}

vec4 effect(vec4 vcolor, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
vec2 ps = 1.0 / textureSize;
vec2 dx = vec2(ps.x, 0.0);
vec2 dy = vec2(0.0, ps.y);

vec2 pixcoord = texture_coords/ps;
vec2 fp = fract(pixcoord);
vec2 d11 = texture_coords - fp * ps;

// Reading the texels

vec3 A = Texel(texture, d11-dx-dy).xyz;
vec3 B = Texel(texture, d11 -dy).xyz;
vec3 C = Texel(texture, d11+dx-dy).xyz;
vec3 D = Texel(texture, d11-dx ).xyz;
vec3 E = Texel(texture, d11 ).xyz;
vec3 F = Texel(texture, d11+dx ).xyz;
vec3 G = Texel(texture, d11-dx+dy).xyz;
vec3 H = Texel(texture, d11+dy ).xyz;
vec3 I = Texel(texture, d11+dx+dy).xyz;

vec3 E0 = E;
vec3 E1 = E;
vec3 E2 = E;
vec3 E3 = E;
vec3 E4 = E;
vec3 E5 = E;
vec3 E6 = E;
vec3 E7 = E;
vec3 E8 = E;
vec3 E9 = E;
vec3 E10 = E;
vec3 E11 = E;
vec3 E12 = E;
vec3 E13 = E;
vec3 E14 = E;
vec3 E15 = E;

float a = reduce(A);
float b = reduce(B);
float c = reduce(C);
float d = reduce(D);
float e = reduce(E);
float f = reduce(F);
float g = reduce(G);
float h = reduce(H);
float i = reduce(I);


if ((h == f)&&(h != e))
{
if (
((e == g) && ((i == h) || (e == d)))
||
((e == c) && ((i == h) || (e == b)))
)
{
E11 = mix(E11, F, 0.5);
E14 = E11;
E15 = F;
}
}

if ((f == b)&&(f != e))
{
if (
((e == i) && ((f == c) || (e == h)))
||
((e == a) && ((f == c) || (e == d)))
)
{
E2 = mix(E2, B, 0.5);
E7 = E2;
E3 = B;
}
}

if ((b == d)&&(b != e))
{
if (
((e == c) && ((b == a) || (e == f)))
||
((e == g) && ((b == a) || (e == h)))
)
{
E1 = mix(E1, D, 0.5);
E4 = E1;
E0 = D;
}
}

if ((d == h)&&(d != e))
{
if (
((e == a) && ((d == g) || (e == b)))
||
((e == i) && ((d == g) || (e == f)))
)
{
E8 = mix(E8, H, 0.5);
E13 = E8;
E12 = H;
}
}

vec3 res;

if (fp.x < 0.25)
{
if (fp.y < 0.25) res = E0;
else if ((fp.y > 0.25) && (fp.y < 0.50)) res = E4;
else if ((fp.y > 0.50) && (fp.y < 0.75)) res = E8;
else res = E12;
}
else if ((fp.x > 0.25) && (fp.x < 0.50))
{
if (fp.y < 0.25) res = E1;
else if ((fp.y > 0.25) && (fp.y < 0.50)) res = E5;
else if ((fp.y > 0.50) && (fp.y < 0.75)) res = E9;
else res = E13;
}
else if ((fp.x > 0.50) && (fp.x < 0.75))
{
if (fp.y < 0.25) res = E2;
else if ((fp.y > 0.25) && (fp.y < 0.50)) res = E6;
else if ((fp.y > 0.50) && (fp.y < 0.75)) res = E10;
else res = E14;
}
else
{
if (fp.y < 0.25) res = E3;
else if ((fp.y > 0.25) && (fp.y < 0.50)) res = E7;
else if ((fp.y > 0.50) && (fp.y < 0.75)) res = E11;
else res = E15;
}

return vec4(res, 1.0);
}
Loading

0 comments on commit b6020d6

Please sign in to comment.