Day 1
commit
28e24736f3
|
@ -0,0 +1,42 @@
|
||||||
|
Arena = Object:extend()
|
||||||
|
Arena:implement(State)
|
||||||
|
Arena:implement(GameObject)
|
||||||
|
function Arena:init(name)
|
||||||
|
self:init_state(name)
|
||||||
|
self:init_game_object()
|
||||||
|
self.main = Group():set_as_physics_world(32, 0, 0, {'player', 'enemy', 'projectile', 'enemy_projectile'})
|
||||||
|
self.effects = Group()
|
||||||
|
self.ui = Group():no_camera()
|
||||||
|
self.main:disable_collision_between('player', 'player')
|
||||||
|
|
||||||
|
self.x1, self.y1 = gw/2 - 0.8*gw/2, gh/2 - 0.8*gh/2
|
||||||
|
self.x2, self.y2 = gw/2 + 0.8*gw/2, gh/2 + 0.8*gh/2
|
||||||
|
|
||||||
|
Wall{group = self.main, vertices = math.to_rectangle_vertices(-40, -40, self.x1, gh + 40), color = bg[-1]}
|
||||||
|
Wall{group = self.main, vertices = math.to_rectangle_vertices(self.x2, -40, gw + 40, gh + 40), color = bg[-1]}
|
||||||
|
Wall{group = self.main, vertices = math.to_rectangle_vertices(self.x1, -40, self.x2, self.y1), color = bg[-1]}
|
||||||
|
Wall{group = self.main, vertices = math.to_rectangle_vertices(self.x1, self.y2, self.x2, gh + 40), color = bg[-1]}
|
||||||
|
|
||||||
|
self.player = Unit{group = self.main, x = gw/2, y = gh/2, player = true, leader = true, character = 'vagrant'}
|
||||||
|
-- self.player:add_follower(Unit{group = self.main, player = true, color = red[0]})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Arena:on_enter(from)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Arena:update(dt)
|
||||||
|
self:update_game_object(dt*slow_amount)
|
||||||
|
self.main:update(dt*slow_amount)
|
||||||
|
self.effects:update(dt*slow_amount)
|
||||||
|
self.ui:update(dt*slow_amount)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Arena:draw()
|
||||||
|
self.main:draw()
|
||||||
|
self.effects:draw()
|
||||||
|
self.ui:draw()
|
||||||
|
end
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,4 @@
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) {
|
||||||
|
vec4 tex_color = Texel(texture, tc);
|
||||||
|
return vec4(vcolor.rgb*tex_color.rgb, tex_color.a);
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
vec4 position(mat4 transform_projection, vec4 vertex_position) {
|
||||||
|
return transform_projection * vertex_position;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
extern Image displacement_map;
|
||||||
|
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc) {
|
||||||
|
vec4 dp = Texel(displacement_map, tc);
|
||||||
|
vec2 p = tc;
|
||||||
|
p.x += (dp.r*2.0 - 1.0)*0.025*dp.a;
|
||||||
|
p.y += (dp.g*2.0 - 1.0)*0.025*dp.a;
|
||||||
|
return color*Texel(texture, p);
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) {
|
||||||
|
vec4 tex_color = Texel(texture, tc);
|
||||||
|
return vec4(vcolor.rgb + tex_color.rgb, tex_color.a);
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) {
|
||||||
|
vec4 tex_color = Texel(texture, tc);
|
||||||
|
return vec4(vcolor.rgb, tex_color.a);
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
vec4 effect(vec4 vcolor, Image texture, vec2 tc, vec2 pc) {
|
||||||
|
return vec4(0.1, 0.1, 0.1, Texel(texture, tc).a*0.5);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
function love.conf(t)
|
||||||
|
t.version = "11.3"
|
||||||
|
t.window.width = 960
|
||||||
|
t.window.height = 540
|
||||||
|
t.window.vsync = 1
|
||||||
|
t.window.msaa = 0
|
||||||
|
end
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Day 1 - 17/02/21
|
||||||
|
|
||||||
|
Ideaguyed the basics of the game's classes and mechanics, and implemented basic movement and setting of all the stats it will have. Here are the initial characters, synergies and stats I want to have:
|
||||||
|
|
||||||
|
### Characters
|
||||||
|
|
||||||
|
* Vagrant: shoots a projectile at any nearby enemy, medium range
|
||||||
|
* Scout: throws a knife at any nearby enemy that chains, small range
|
||||||
|
* Cleric: heals every unit when any one drops below 50% HP
|
||||||
|
* Swordsman: deals damage in an area around the unit, small range
|
||||||
|
* Archer: shoots an arrow at any nearby enemy in front of the unit, long range
|
||||||
|
* Wizard: shoots a projectile at any nearby enemy and deals AoE damage on contact, small range
|
||||||
|
|
||||||
|
### Synergies
|
||||||
|
|
||||||
|
* Ranger: yellow, buff attack speed
|
||||||
|
* Warrior: orange, buff attack damage
|
||||||
|
* Healer: green, buff healing effectiveness
|
||||||
|
* Mage: blue, debuff enemy defense
|
||||||
|
* Cycler: purple, buff cycle speed
|
||||||
|
|
||||||
|
### Stats
|
||||||
|
|
||||||
|
* HP
|
||||||
|
* Damage
|
||||||
|
* Attack speed: stacks additively, starts at 1 and capped at minimum 0.125s or +300%
|
||||||
|
* Defense: if defense >= 0 then dmg_m = 100/(100+defense) else dmg_m = 2-100/(100-defense)
|
||||||
|
* Cycle speed: stacks additively, starts at 2 and capped at minimum 0.5s or +300%
|
||||||
|
|
||||||
|
Perhaps I'm overengineering it already with the stats but I wanna see where this goes. From SHOOTRX it seems like figuring out stats earlier is better than later, and these seem like they have enough flexibility.
|
|
@ -0,0 +1,283 @@
|
||||||
|
Graph = Object:extend()
|
||||||
|
function Graph:init()
|
||||||
|
self.adjacency_list = {}
|
||||||
|
self.nodes = {}
|
||||||
|
self.edges = {}
|
||||||
|
self.floyd_dists = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Nodes can be of any type but must be unique
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
function Graph:add_node(node)
|
||||||
|
self.adjacency_list[node] = {}
|
||||||
|
self:_set_nodes()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a node after searching for it by property, the property value must be unique among all nodes
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node({id = 1})
|
||||||
|
-- graph:add_node({id = 2})
|
||||||
|
-- graph:get_node_by_property('id', 1) -> original {id = 1} table
|
||||||
|
function Graph:get_node_by_property(key, value)
|
||||||
|
for node, _ in pairs(self.adjacency_list) do
|
||||||
|
if node[key] == value then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Runs function f for all nodes in the graph
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
-- graph:for_all_nodes(function(node) print(node) end) -> prints 1, 'node_2'
|
||||||
|
function Graph:for_all_nodes(f)
|
||||||
|
for _, node in ipairs(self.nodes) do
|
||||||
|
f(node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Runs function f for all edges in the graph
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
-- graph:add_node(3)
|
||||||
|
-- graph:add_edge(1, 'node_2')
|
||||||
|
-- graph:add_edge('node_2', 3)
|
||||||
|
-- graph:for_all_edges(function(node1, node2) print(node1, node2) end) -> prints 1, 'node_2'; prints 'node_2', 3
|
||||||
|
function Graph:for_all_edges(f)
|
||||||
|
for _, edge in ipairs(self.edges) do
|
||||||
|
f(edge[1], edge[2])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a table containing all neighbors of the given node.
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
-- graph:add_node(3)
|
||||||
|
-- graph:add_edge(1, 'node_2')
|
||||||
|
-- graph:add_edge('node_2', 3)
|
||||||
|
-- graph:get_node_neighbors('node_2') -> {1, 3}
|
||||||
|
function Graph:get_node_neighbors(node)
|
||||||
|
return self.adjacency_list[node]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:remove_node(1)
|
||||||
|
function Graph:remove_node(node)
|
||||||
|
for _node, list in pairs(self.adjacency_list) do
|
||||||
|
self:remove_edge(node, _node)
|
||||||
|
end
|
||||||
|
self.adjacency_list[node] = nil
|
||||||
|
self:_set_nodes()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function contains_edge(table, edge)
|
||||||
|
for _, v in ipairs(table) do
|
||||||
|
if (v[1] == edge[1] and v[2] == edge[2]) or (v[1] == edge[2] and v[2] == edge[1]) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
-- graph:add_edge(1, 'node_2')
|
||||||
|
function Graph:add_edge(node1, node2)
|
||||||
|
if table.any(self.adjacency_list[node1], function(v) return v == node2 end) then return end
|
||||||
|
table.insert(self.adjacency_list[node1], node2)
|
||||||
|
table.insert(self.adjacency_list[node2], node1)
|
||||||
|
self:_set_edges()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
-- graph:add_edge(1, 'node_2')
|
||||||
|
-- graph:remove_edge(1, 'node_2')
|
||||||
|
function Graph:remove_edge(node1, node2)
|
||||||
|
for i, node in ipairs(self.adjacency_list[node1]) do
|
||||||
|
if node == node2 then
|
||||||
|
table.remove(self.adjacency_list[node1], i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i, node in ipairs(self.adjacency_list[node2]) do
|
||||||
|
if node == node1 then
|
||||||
|
table.remove(self.adjacency_list[node2], i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:_set_edges()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
-- graph:add_node('node_3')
|
||||||
|
-- graph:add_edge(1, 'node_2')
|
||||||
|
-- graph:add_edge('node_2', 'node_3')
|
||||||
|
-- path = graph:shortest_path_bfs(1, 'node_3')
|
||||||
|
-- print(path) -> {1, 'node_2', 'node_3'}
|
||||||
|
function Graph:shortest_path_bfs(node1, node2)
|
||||||
|
local path = {}
|
||||||
|
local visited = {}
|
||||||
|
local queue = {}
|
||||||
|
table.insert(queue, node1)
|
||||||
|
visited[node1] = true
|
||||||
|
|
||||||
|
while #queue > 0 do
|
||||||
|
local node = table.remove(queue, 1)
|
||||||
|
if node == node2 then
|
||||||
|
local linear_path = {}
|
||||||
|
local current_node = node2
|
||||||
|
table.insert(linear_path, 1, current_node)
|
||||||
|
while current_node ~= node1 do
|
||||||
|
current_node = path[current_node]
|
||||||
|
table.insert(linear_path, 1, current_node)
|
||||||
|
end
|
||||||
|
return linear_path
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, neighbor in ipairs(self.adjacency_list[node]) do
|
||||||
|
if not visited[neighbor] then
|
||||||
|
path[neighbor] = node
|
||||||
|
visited[neighbor] = true
|
||||||
|
table.insert(queue, neighbor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Graph:get_distance_between_nodes(node1, node2)
|
||||||
|
return self.floyd_dists[node1][node2]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Comments follow pseudocode from http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm.
|
||||||
|
-- graph = Graph()
|
||||||
|
-- graph:add_node(1)
|
||||||
|
-- graph:add_node('node_2')
|
||||||
|
-- graph:add_edge(1, 'node_2')
|
||||||
|
-- graph:floyd_warshall()
|
||||||
|
-- print(graph.floyd_dists[1]['node_2']) -> 1
|
||||||
|
function Graph:floyd_warshall()
|
||||||
|
self:_set_nodes()
|
||||||
|
self:_set_edges()
|
||||||
|
|
||||||
|
-- initialize multidimensional to be array
|
||||||
|
for _, node in ipairs(self.nodes) do
|
||||||
|
self.floyd_dists[node] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- let floyd_dist be a |V|x|V| array of minimun distance initialized to infinity
|
||||||
|
for _, node in ipairs(self.nodes) do
|
||||||
|
for _, _node in ipairs(self.nodes) do
|
||||||
|
self.floyd_dists[node][_node] = 10000 -- 10000 is big enough for an unweighted graph
|
||||||
|
self.floyd_dists[_node][node] = 10000
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- set dist[v][v] to 0
|
||||||
|
for _, node in ipairs(self.nodes) do
|
||||||
|
self.floyd_dists[node][node] = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- set dist[u][v] to w(u, v) which is always 1 in the case of an unweighted graph
|
||||||
|
for _, edge in ipairs(self.edges) do
|
||||||
|
self.floyd_dists[edge[1]][edge[2]] = 1
|
||||||
|
self.floyd_dists[edge[2]][edge[1]] = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- main triple loop
|
||||||
|
for _, nodek in ipairs(self.nodes) do
|
||||||
|
for _, nodei in ipairs(self.nodes) do
|
||||||
|
for _, nodej in ipairs(self.nodes) do
|
||||||
|
if self.floyd_dists[nodei][nodek] + self.floyd_dists[nodek][nodej] < self.floyd_dists[nodei][nodej] then
|
||||||
|
self.floyd_dists[nodei][nodej] = self.floyd_dists[nodei][nodek] + self.floyd_dists[nodek][nodej]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Graph:_get_edge(node1, node2)
|
||||||
|
for _, node in ipairs(self.adjacency_list[node1]) do
|
||||||
|
if node == node2 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Graph:_set_nodes()
|
||||||
|
self.nodes = {}
|
||||||
|
for node, _ in pairs(self.adjacency_list) do
|
||||||
|
table.insert(self.nodes, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Graph:_set_edges()
|
||||||
|
self.edges = {}
|
||||||
|
for node, list in pairs(self.adjacency_list) do
|
||||||
|
for _, _node in ipairs(list) do
|
||||||
|
if not contains_edge(self.edges, {node, _node}) then
|
||||||
|
table.insert(self.edges, {node, _node})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Graph:__tostring()
|
||||||
|
local str = "----\nAdjacency List: \n"
|
||||||
|
for node, list in pairs(self.adjacency_list) do
|
||||||
|
str = str .. node .. " -> "
|
||||||
|
for _, adj in ipairs(list) do
|
||||||
|
str = str .. adj .. ", "
|
||||||
|
end
|
||||||
|
str = string.sub(str, 0, -3)
|
||||||
|
str = str .. "\n"
|
||||||
|
end
|
||||||
|
str = str .. "\n"
|
||||||
|
str = str .. "Nodes: \n"
|
||||||
|
for _, node in ipairs(self.nodes) do
|
||||||
|
str = str .. node .. "\n"
|
||||||
|
end
|
||||||
|
str = str .. "\n"
|
||||||
|
str = str .. "Edges: \n"
|
||||||
|
for _, edge in ipairs(self.edges) do
|
||||||
|
str = str .. edge[1] .. ", " .. edge[2]
|
||||||
|
str = str .. "\n"
|
||||||
|
end
|
||||||
|
str = str .. "\n"
|
||||||
|
str = str .. "Floyd Warshall Distances: \n"
|
||||||
|
for node, _ in pairs(self.floyd_dists) do
|
||||||
|
for _node, _ in pairs(self.floyd_dists[node]) do
|
||||||
|
str = str .. "(" .. node .. ", " .. _node .. ") = " .. self.floyd_dists[node][_node]
|
||||||
|
str = str .. "\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str = str .. "----\n"
|
||||||
|
return str
|
||||||
|
end
|
|
@ -0,0 +1,260 @@
|
||||||
|
-- Starts a new grid with 10 width, 5 height and all values 0ed
|
||||||
|
-- grid = Grid(10, 5, 0)
|
||||||
|
-- Starts a new grid with 3 width, 2 height and values 1, 2, 3 in the first row and 3, 4, 5 in the second row.
|
||||||
|
-- grid = Grid(3, 2, {1, 2, 3, 4, 5, 6})
|
||||||
|
Grid = Object:extend()
|
||||||
|
function Grid:init(w, h, v)
|
||||||
|
self.grid = {}
|
||||||
|
self.w, self.h = w, h
|
||||||
|
if type(v) ~= 'table' then
|
||||||
|
for j = 1, h do
|
||||||
|
for i = 1, w do
|
||||||
|
self.grid[w*(j-1) + i] = v or 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for j = 1, h do
|
||||||
|
for i = 1, w do
|
||||||
|
self.grid[w*(j-1) + i] = v[w*(j-1) + i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Creates a copy of a grid instance
|
||||||
|
-- grid = Grid(10, 5, 0)
|
||||||
|
-- grid_clone = grid:clone()
|
||||||
|
function Grid:clone()
|
||||||
|
local new_grid = Grid(self.w, self.h, 0)
|
||||||
|
new_grid.grid = table.deep_copy(self.grid)
|
||||||
|
return new_grid
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- grid = Grid(10, 5, 0)
|
||||||
|
-- grid:get(2, 2) -> 0
|
||||||
|
-- grid:set(2, 2, 1)
|
||||||
|
-- grid:get(2, 2) -> 1
|
||||||
|
-- grid:set(11, 1, 1) -> doesn't actually set because out of bounds, fails silently
|
||||||
|
function Grid:set(x, y, v)
|
||||||
|
if not self:_is_outside_bounds(x, y) then
|
||||||
|
self.grid[self.w*(y-1) + x] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies function f to all grid elements
|
||||||
|
-- If i1,j1 and i2,j2 are passed then it applies only to the subgrid defined by those values.
|
||||||
|
-- grid:apply(function(grid, i, j) grid:set(i, j, 0) end) -> sets all elements in the grid to 0
|
||||||
|
-- grid:apply(function(grid, i, j) grid:set(i, j, 0) end, 2, 2, 4, 4) -> sets all elements in the subgrid 2,2x4,4 to 0
|
||||||
|
function Grid:apply(f, i1, j1, i2, j2)
|
||||||
|
if i1 and j1 and i2 and j2 then
|
||||||
|
for i = i1, i2 do
|
||||||
|
for j = j1, j2 do
|
||||||
|
f(self, i, j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i = 1, self.w do
|
||||||
|
for j = 1, self.h do
|
||||||
|
f(self, i, j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- grid = Grid(10, 5, 0)
|
||||||
|
-- print(grid:get(2, 2)) -> 0
|
||||||
|
-- grid:set(2, 2, 1)
|
||||||
|
-- grid:get(2, 2) -> 1
|
||||||
|
-- grid:get(11, 1) -> nil, out of bounds, fails silently
|
||||||
|
function Grid:get(x, y)
|
||||||
|
if not self:_is_outside_bounds(x, y) then
|
||||||
|
return self.grid[self.w*(y-1) + x]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Converts the 2D grid to a 1D array
|
||||||
|
-- If i1,j1 and i2,j2 are passed then it applies only to the subgrid defined by those values.
|
||||||
|
-- grid = Grid(3, 2, 1)
|
||||||
|
-- grid:to_table() -> {1, 1, 1, 1, 1, 1}
|
||||||
|
-- grid:to_table(1, 1, 2, 2) -> {1, 1, 1, 1}
|
||||||
|
function Grid:to_table(i1, j1, i2, j2)
|
||||||
|
local t = {}
|
||||||
|
if i1 and j1 and i2 and j2 then
|
||||||
|
for j = j1, j2 do
|
||||||
|
for i = i1, i2 do
|
||||||
|
if self:get(i, j) then
|
||||||
|
table.insert(t, self:get(i, j))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for j = 1, self.h do
|
||||||
|
for i = 1, self.w do
|
||||||
|
table.insert(t, self:get(i, j))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return t, self.w
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rotates the grid in an anti-clockwise direction
|
||||||
|
-- grid = Grid(3, 2, {1, 2, 3, 4, 5, 6}) -> the grid looks like this:
|
||||||
|
-- [1, 2, 3]
|
||||||
|
-- [4, 5, 6]
|
||||||
|
-- grid:rotate_anticlockwise() -> now the grid looks like this:
|
||||||
|
-- [3, 6]
|
||||||
|
-- [2, 5]
|
||||||
|
-- [1, 4]
|
||||||
|
-- grid:rotate_anticlockwise() -> now the grid looks like this:
|
||||||
|
-- [6, 5, 4]
|
||||||
|
-- [3, 2, 1]
|
||||||
|
function Grid:rotate_anticlockwise()
|
||||||
|
local new_grid = Grid(self.h, self.w, 0)
|
||||||
|
for i = 1, self.w do
|
||||||
|
for j = 1, self.h do
|
||||||
|
new_grid:set(j, i, self:get(i, j))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, new_grid.w do
|
||||||
|
for k = 0, math.floor(new_grid.h/2) do
|
||||||
|
local v1, v2 = new_grid:get(i, 1+k), new_grid:get(i, new_grid.h-k)
|
||||||
|
new_grid:set(i, 1+k, v2)
|
||||||
|
new_grid:set(i, new_grid.h-k, v1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return new_grid
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rotates the grid in a clockwise direction
|
||||||
|
-- grid = Grid(3, 2, {1, 2, 3, 4, 5, 6}) -> the grid looks like this:
|
||||||
|
-- [1, 2, 3]
|
||||||
|
-- [4, 5, 6]
|
||||||
|
-- grid:rotate_clockwise() -> now the grid looks like this:
|
||||||
|
-- [4, 1]
|
||||||
|
-- [5, 2]
|
||||||
|
-- [6, 3]
|
||||||
|
-- grid:rotate_clockwise() -> now the grid looks like this:
|
||||||
|
-- [6, 5, 4]
|
||||||
|
-- [3, 2, 1]
|
||||||
|
function Grid:rotate_clockwise()
|
||||||
|
local new_grid = Grid(self.h, self.w, 0)
|
||||||
|
for i = 1, self.w do
|
||||||
|
for j = 1, self.h do
|
||||||
|
new_grid:set(j, i, self:get(i, j))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for j = 1, new_grid.h do
|
||||||
|
for k = 0, math.floor(new_grid.w/2) do
|
||||||
|
local v1, v2 = new_grid:get(1+k, j), new_grid:get(new_grid.w-k, j)
|
||||||
|
new_grid:set(1+k, j, v2)
|
||||||
|
new_grid:set(new_grid.w-k, j, v1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return new_grid
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Assume the following grid:
|
||||||
|
-- grid = Grid(10, 10, {
|
||||||
|
-- 1, 1, 1, 0, 0, 0, 0, 1, 1, 0,
|
||||||
|
-- 1, 1, 0, 0, 0, 0, 1, 1, 1, 1,
|
||||||
|
-- 1, 0, 0, 0, 1, 0, 1, 0, 1, 0,
|
||||||
|
-- 0, 0, 0, 1, 1, 1, 0, 0, 1, 0,
|
||||||
|
-- 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
|
||||||
|
-- 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
|
||||||
|
-- 1, 1, 0, 0, 0, 0, 1, 1, 0, 0,
|
||||||
|
-- 1, 1, 0, 1, 1, 0, 0, 1, 1, 1,
|
||||||
|
-- 1, 1, 0, 1, 1, 0, 0, 0, 0, 1,
|
||||||
|
-- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
-- })
|
||||||
|
-- In this grid you can see that there are multiple islands of solid positions formed.
|
||||||
|
-- This function will go over the entire grid and find all the islands of solid values, mark them with different numbers, and return them.
|
||||||
|
-- Essentially, it would do this: {
|
||||||
|
-- 1, 1, 1, 0, 0, 0, 0, 2, 2, 0,
|
||||||
|
-- 1, 1, 0, 0, 0, 0, 2, 2, 2, 2,
|
||||||
|
-- 1, 0, 0, 0, 3, 0, 2, 0, 2, 0,
|
||||||
|
-- 0, 0, 0, 3, 3, 3, 0, 0, 2, 0,
|
||||||
|
-- 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
|
||||||
|
-- 4, 0, 0, 0, 0, 0, 0, 5, 0, 0,
|
||||||
|
-- 4, 4, 0, 0, 0, 0, 5, 5, 0, 0,
|
||||||
|
-- 4, 4, 0, 6, 6, 0, 0, 5, 5, 5,
|
||||||
|
-- 4, 4, 0, 6, 6, 0, 0, 0, 0, 5,
|
||||||
|
-- 0, 0, 7, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
-- }
|
||||||
|
-- All values form islands that are connected, and each of those islands is identified by a different number.
|
||||||
|
-- The function returns this information in two formats: an array of positions per island number, and the marked grid as shown above.
|
||||||
|
-- islands, marked_grid = grid:flood_fill(1) -> (the value passed in is what the solid value should be, in the case of the array we're using as an example 1 is the proper value)
|
||||||
|
-- islands is an array that looks like this: {
|
||||||
|
-- [1] = {{1, 1}, {2, 1}, {3, 1}, {1, 2}, {2, 2}, {1, 3}},
|
||||||
|
-- [2] = {{8, 1}, {9, 1}, {7, 2}, {8, 2}, {9, 2}, {10, 2}, {7, 3}, {9, 3}, {9, 4}},
|
||||||
|
-- ...
|
||||||
|
-- [7] = {{3, 10}}
|
||||||
|
-- }
|
||||||
|
-- It contains all the positions in each island, indexed by island number.
|
||||||
|
-- And marked_grid is simply a Grid instance that looks exactly like the one shown above right after I said "Essentially, it would do this:"
|
||||||
|
function Grid:flood_fill(v)
|
||||||
|
local islands = {}
|
||||||
|
local marked_grid = Grid(self.w, self.h, 0)
|
||||||
|
|
||||||
|
local flood_fill = function(i, j, color)
|
||||||
|
local queue = {}
|
||||||
|
table.insert(queue, {i, j})
|
||||||
|
while #queue > 0 do
|
||||||
|
local x, y = unpack(table.remove(queue, 1))
|
||||||
|
marked_grid:set(x, y, color)
|
||||||
|
table.insert(islands[color], {x, y})
|
||||||
|
|
||||||
|
if self:get(x, y-1) == v and marked_grid:get(x, y-1) == 0 then table.insert(queue, {x, y-1}) end
|
||||||
|
if self:get(x, y+1) == v and marked_grid:get(x, y+1) == 0 then table.insert(queue, {x, y+1}) end
|
||||||
|
if self:get(x-1, y) == v and marked_grid:get(x-1, y) == 0 then table.insert(queue, {x-1, y}) end
|
||||||
|
if self:get(x+1, y) == v and marked_grid:get(x+1, y) == 0 then table.insert(queue, {x+1, y}) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local color = 1
|
||||||
|
islands[color] = {}
|
||||||
|
for i = 1, self.w do
|
||||||
|
for j = 1, self.h do
|
||||||
|
if self:get(i, j) == v and marked_grid:get(i, j) == 0 then
|
||||||
|
flood_fill(i, j, color)
|
||||||
|
color = color + 1
|
||||||
|
islands[color] = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
islands[color] = nil
|
||||||
|
return islands, marked_grid
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Grid:_is_outside_bounds(x, y)
|
||||||
|
if x > self.w then return true end
|
||||||
|
if x < 1 then return true end
|
||||||
|
if y > self.h then return true end
|
||||||
|
if y < 1 then return true end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Grid:__tostring()
|
||||||
|
local str = ''
|
||||||
|
for j = 1, self.h do
|
||||||
|
str = str .. '['
|
||||||
|
for i = 1, self.w do
|
||||||
|
str = str .. self:get(i, j) .. ', '
|
||||||
|
end
|
||||||
|
str = str:sub(1, -3) .. ']\n'
|
||||||
|
end
|
||||||
|
return str
|
||||||
|
end
|
|
@ -0,0 +1,45 @@
|
||||||
|
-- Returns the substring to the left of the first instance of the pattern passed in
|
||||||
|
-- a = 'assets/images/player_32.png'
|
||||||
|
-- a:left('/') -> 'assets'
|
||||||
|
function string:left(p)
|
||||||
|
local i = self:find(p)
|
||||||
|
if i then
|
||||||
|
local out = self:sub(1, i-1)
|
||||||
|
return out ~= "" and out
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the substring to the right of the first instance of the pattern passed in
|
||||||
|
-- a = 'assets/images/player_32.png'
|
||||||
|
-- a:right('/') -> 'images/player_32.png'
|
||||||
|
function string:right(p)
|
||||||
|
local _, j = self:find(p)
|
||||||
|
if j then
|
||||||
|
local out = self:sub(j+1)
|
||||||
|
return out ~= "" and out
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Splits the string into words in a table according to the separator pattern passed in
|
||||||
|
-- paid_comment = 'This engine is really great!'
|
||||||
|
-- paid_comment:split('%s') -> {'This', 'engine', 'is', 'really', 'great!'}
|
||||||
|
function string:split(s)
|
||||||
|
if not s then s = "%s" end
|
||||||
|
local out = {}
|
||||||
|
for str in self:gmatch("([^" .. s .. "]+)") do
|
||||||
|
table.insert(out, str)
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the character at a particular index
|
||||||
|
-- a = 'engine'
|
||||||
|
-- a:index(2) -> 'n'
|
||||||
|
-- a:index(3) -> 'g'
|
||||||
|
-- a:index(-1) -> 'e'
|
||||||
|
function string:index(i)
|
||||||
|
return self:sub(i, i)
|
||||||
|
end
|
|
@ -0,0 +1,480 @@
|
||||||
|
-- Copies the table deeply, including metatables
|
||||||
|
function table.copy(t)
|
||||||
|
local t_type = type(t)
|
||||||
|
local copy
|
||||||
|
if t_type == "table" then
|
||||||
|
copy = {}
|
||||||
|
for k, v in next, t, nil do
|
||||||
|
copy[table.copy(k)] = table.copy(v)
|
||||||
|
end
|
||||||
|
setmetatable(copy, table.copy(getmetatable(t)))
|
||||||
|
else
|
||||||
|
copy = t
|
||||||
|
end
|
||||||
|
return copy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Copies the table shallowly, meaning that tables inside the table will not be created anew, and only be referenced in the copy
|
||||||
|
function table.shallow_copy(t)
|
||||||
|
local copy = {}
|
||||||
|
for k, v in pairs(t) do
|
||||||
|
copy[k] = v
|
||||||
|
end
|
||||||
|
return copy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- t = {}
|
||||||
|
-- table.array(t, 5) -> {1, 2, 3, 4, 5}
|
||||||
|
function table.array(t, n)
|
||||||
|
for i = 1, n do
|
||||||
|
table.push(t, i)
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
-- t = {"a", "b", "c", "d"}
|
||||||
|
-- table.get(t, 1) -> "a"
|
||||||
|
-- table.get(t, 1, 3) -> {"a", "b", "c"}
|
||||||
|
-- table.get(t, 2, -1) -> {"b", "c", "d"}
|
||||||
|
function table.get(t, i, j)
|
||||||
|
if i < 0 then i = #t + i + 1 end
|
||||||
|
if not j then return t[i] end
|
||||||
|
if j < 0 then j = #t + j + 1 end
|
||||||
|
if i == j then return t[i] end
|
||||||
|
local out = {}
|
||||||
|
for k = i, j, math.sign(j-i) do
|
||||||
|
table.push(out, t[k])
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- t = {"a", "b", "c", "d"}
|
||||||
|
-- table.set(t, 1, 1) -> {1, "b", "c", "d"}
|
||||||
|
-- table.set(t, 1, 3, 2) -> {2, 2, 2, "d"}
|
||||||
|
-- table.set(t, 2, -1, 3) -> {"a", 3, 3, 3}
|
||||||
|
function table.set(t, i, j, v)
|
||||||
|
if i < 0 then i = #t + i + 1 end
|
||||||
|
if not v then t[i] = j; return t end
|
||||||
|
if j < 0 then j = #t + j + 1 end
|
||||||
|
if i == j then t[i] = v; return t end
|
||||||
|
for k = i, j, math.sign(j-i) do
|
||||||
|
t[k] = v
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the index of the first instance of value v
|
||||||
|
-- t = {4, 3, 2, 4, "a", 1, "a"}
|
||||||
|
-- table.index(t, 4) -> 1
|
||||||
|
-- table.index(t, "a") -> 5
|
||||||
|
function table.index(t, v)
|
||||||
|
for i, u in ipairs(t) do
|
||||||
|
if u == v then
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the last value of the table
|
||||||
|
-- t = {1, 2, 3, 4}
|
||||||
|
-- table.back(t) -> 4
|
||||||
|
function table.back(t)
|
||||||
|
return t[#t]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the first n values
|
||||||
|
-- t = {4, 3, 2, 1}
|
||||||
|
-- table.head(t) -> 4
|
||||||
|
-- table.head(t, 2) -> {4, 3}
|
||||||
|
function table.head(t, n)
|
||||||
|
local out = {}
|
||||||
|
for i = 1, (n or 1) do
|
||||||
|
table.push(out, t[i])
|
||||||
|
end
|
||||||
|
if #out == 1 then return out[1]
|
||||||
|
else return out end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the last n values
|
||||||
|
-- t = {5, 4, 3, 2, 1}
|
||||||
|
-- table.tail(t) -> 1
|
||||||
|
-- table.tail(t, 2) -> {2, 1}
|
||||||
|
function table.tail(t, n)
|
||||||
|
local out = {}
|
||||||
|
for i = #t-(n or #t-1)+1, #t do
|
||||||
|
table.push(out, t[i])
|
||||||
|
end
|
||||||
|
if #out == 1 then return out[1]
|
||||||
|
else return out end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Inserts value at the end of the table
|
||||||
|
-- t = {1, 2}
|
||||||
|
-- table.push(t, "a") -> {1, 2, "a"}
|
||||||
|
function table.push(t, v)
|
||||||
|
table.insert(t, v)
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Removes the first n values and returns them as well as the modified table
|
||||||
|
-- t = {4, 3, 2, 1}
|
||||||
|
-- table.shift(t) -> 4, {3, 2, 1}
|
||||||
|
-- table.shift(t, 3) -> {4, 3, 2}, {1}
|
||||||
|
function table.shift(t, n)
|
||||||
|
local out = {}
|
||||||
|
for i = 1, (n or 1) do
|
||||||
|
table.insert(out, table.remove(t, 1))
|
||||||
|
end
|
||||||
|
if #out == 1 then return out[1], t
|
||||||
|
else return out, t end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Inserts values at the start of the table
|
||||||
|
-- t = {3, 4}
|
||||||
|
-- table.unshift(t, 1, 2) -> {1, 2, 3, 4}
|
||||||
|
function table.unshift(t, ...)
|
||||||
|
for j, v in ipairs({...}) do
|
||||||
|
table.insert(t, 1+j-1, v)
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Removes the last value and returns it as well as the modified table
|
||||||
|
-- t = {1, 2, 3, 4}
|
||||||
|
-- table.pop(t) -> 4, {1, 2, 3}
|
||||||
|
function table.pop(t)
|
||||||
|
return table.remove(t, #t), t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Deletes all instances of value v
|
||||||
|
-- t = {1, 1, 2, 3, 2, 3, 4, 4}
|
||||||
|
-- table.delete(t, 1) -> {2, 3, 2, 3, 4, 4}
|
||||||
|
-- t = {{id = 1}, {id = 1}, {id = 2}}
|
||||||
|
-- table.delete(t, function(v) return v.id == 1 end) -> {{id = 2}}
|
||||||
|
function table.delete(t, v)
|
||||||
|
if type(v) == 'function' then
|
||||||
|
for i = #t, 1, -1 do
|
||||||
|
if v(t[i]) then
|
||||||
|
table.remove(t, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i = #t, 1, -1 do
|
||||||
|
if v == t[i] then
|
||||||
|
table.remove(t, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Deletes the elements in the given range and returns them as well as the modified table
|
||||||
|
-- t = {1, 2, 3}
|
||||||
|
-- table.slice(t, 1) -> 1, {2, 3}
|
||||||
|
-- table.slice(t, 2, -1) -> {2, 3}, 1
|
||||||
|
function table.slice(t, i, j)
|
||||||
|
if i < 0 then i = #t + i + 1 end
|
||||||
|
if not j then return t[i] end
|
||||||
|
if j < 0 then j = #t + j + 1 end
|
||||||
|
if i == j then return t[i] end
|
||||||
|
local out = {}
|
||||||
|
for k = j, i, -math.sign(j-i) do
|
||||||
|
table.insert(out, table.remove(t, k))
|
||||||
|
end
|
||||||
|
if #out == 1 then return out[1], t
|
||||||
|
else return table.reverse(out), t end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Removes duplicates
|
||||||
|
-- t = {1, 1, 2, 2, 3, 3}
|
||||||
|
-- table.unify(t) -> {1, 2, 3}
|
||||||
|
-- t = {{id = 1}, {id = 1}, {id = 2}}
|
||||||
|
-- table.unify(t, function(v) return v.id end) -> {{id = 1}, {id = 2}}
|
||||||
|
function table.unify(t, f)
|
||||||
|
if not f then f = function(v) return v end end
|
||||||
|
local seen = {}
|
||||||
|
for i = #t, 1, -1 do
|
||||||
|
if not seen[f(t[i])] then
|
||||||
|
seen[f(t[i])] = true
|
||||||
|
else
|
||||||
|
table.remove(t, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Counts the number of elements in the table
|
||||||
|
-- t = {1, 1, 5, 5, 4, 1, 3, 2, 0, 9, 8, 5, 1, 5, 5, 4, 6}
|
||||||
|
-- table.count(t, 1) -> 4
|
||||||
|
-- table.count(t, 5) -> 5
|
||||||
|
-- table.count(t, 6) -> 1
|
||||||
|
-- table.count(t, 4) -> 2
|
||||||
|
function table.count(t, v)
|
||||||
|
local n = 0
|
||||||
|
for i = 1, #t do
|
||||||
|
if t[i] == v then
|
||||||
|
n = n + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies function f to all table elements and replaces each element for the value returned by f
|
||||||
|
function table.map(t, f, ...)
|
||||||
|
for k, v in ipairs(t) do
|
||||||
|
t[k] = f(v, k, ...)
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies function f to all table elements resulting in a single output value
|
||||||
|
-- t = {1, 2, 3}
|
||||||
|
-- table.reduce(t, function(memo, v) return memo + v end) -> 6
|
||||||
|
-- t = {'a', 'b', 'c'}
|
||||||
|
-- table.reduce(t, function(memo, v) return memo .. v end) -> 'abc'
|
||||||
|
-- t = {{id = 1}, {id = 2}, {id = 3}}
|
||||||
|
-- table.reduce(t, function(memo, v) return memo + v.id end, 0) -> 6
|
||||||
|
-- The memo variable starts as the first argument in the array, but sometimes, as in the last example, that's not the desired functionality.
|
||||||
|
-- For those cases the third argument comes in handy and can be used to set the initial value of memo directly.
|
||||||
|
function table.reduce(t, f, dv, ...)
|
||||||
|
local memo = t[1] or dv
|
||||||
|
for i = 2, #t do
|
||||||
|
memo = f(memo, t[i], i, ...)
|
||||||
|
end
|
||||||
|
return memo
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies function f to all array elements without changing the array
|
||||||
|
function table.foreach(t, f, ...)
|
||||||
|
for k, v in ipairs(t) do
|
||||||
|
f(v, k, ...)
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies function f to all array elements and adds the results to a new array
|
||||||
|
function table.foreachn(t, f, ...)
|
||||||
|
local out = {}
|
||||||
|
for k, v in ipairs(t) do
|
||||||
|
table.insert(out, f(v, k, ...))
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies filter function f which removes all elements that pass the filter and returns them as well as the modified table
|
||||||
|
-- t = {1, 2, 3, 4}
|
||||||
|
-- table.reject(t, function(v) return v >= 3 end) -> {3, 4}, {1, 2}
|
||||||
|
-- table.reject(t, function(v) return v == 1 end) -> 1, {2, 3, 4}
|
||||||
|
function table.reject(t, f, ...)
|
||||||
|
local out = {}
|
||||||
|
for i = #t, 1, -1 do
|
||||||
|
if f(t[i], i, ...) then
|
||||||
|
table.insert(out, table.remove(t, i))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #out == 1 then return out[1], t
|
||||||
|
else return table.reverse(out), t end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies filter function f which collects all elements that pass the filter and returns them; the original table is not modified
|
||||||
|
-- t = {1, 2, 3, 4}
|
||||||
|
-- table.select(t, function(v) return v >= 3 end) -> {3, 4}
|
||||||
|
-- table.select(t, function(v) return v == 1 end) -> 1
|
||||||
|
function table.select(t, f, ...)
|
||||||
|
local out = {}
|
||||||
|
for i = 1, #t do
|
||||||
|
if f(t[i], i, ...) then
|
||||||
|
table.insert(out, t[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if any values in the table pass the test
|
||||||
|
function table.any(t, f, ...)
|
||||||
|
for i, v in ipairs(t) do
|
||||||
|
if f(v, i, ...) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if all values in the table pass the test
|
||||||
|
function table.all(t, f, ...)
|
||||||
|
for i, v in ipairs(t) do
|
||||||
|
if not f(v, i, ...) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Check if table contains value v and return its index
|
||||||
|
-- If value v is a function instead then it checks according to the check performed by that function
|
||||||
|
-- t = {4, 3, 2, 1}
|
||||||
|
-- table.contains(t, 4) -> 1
|
||||||
|
-- t = {{id = 4}, {id = 3}, {id = 2}, {id = 1}}
|
||||||
|
-- table.contains(t, function(v) return v.id == 3 end) -> 2
|
||||||
|
function table.contains(t, v)
|
||||||
|
if type(v) == "function" then
|
||||||
|
for i, u in ipairs(t) do
|
||||||
|
if v(u) then return i end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i, u in ipairs(t) do
|
||||||
|
if u == v then return i end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- t = {{1, 2}, {3, {4, 5}}, {6, 7}, 8}
|
||||||
|
-- table.flatten(t) -> {1, 2, 3, 4, 5, 6, 7, 8}
|
||||||
|
-- table.flatten(t, true) -> {1, 2, 3, {4, 5}, 6, 7, 8}
|
||||||
|
function table.flatten(t, shallow)
|
||||||
|
local out = {}
|
||||||
|
local u
|
||||||
|
for k, v in ipairs(t) do
|
||||||
|
if type(v) == "table" and getmetatable(t) == nil then
|
||||||
|
u = shallow and v or table.flatten(v)
|
||||||
|
for _, x in ipairs(u) do
|
||||||
|
table.insert(out, x)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(out, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- t = {1, 2, 3, 4}
|
||||||
|
-- table.tostring(t) -> '{[1] = 1, [2] = 2, [3] = 3, [4] = 4}'
|
||||||
|
function table.tostring(t)
|
||||||
|
if type(t) == "table" then
|
||||||
|
local str = "{"
|
||||||
|
for k, v in ipairs(t) do
|
||||||
|
if type(k) ~= "number" then k = '"' .. k .. '"' end
|
||||||
|
str = str .. "[" .. k .. "] = " .. table.tostring(v) .. ", "
|
||||||
|
end
|
||||||
|
return str:sub(1, -3) .. "}"
|
||||||
|
else return tostring(t) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the first n values, same as head
|
||||||
|
-- t = {4, 3, 2, 1}
|
||||||
|
-- table.first(t) -> 4
|
||||||
|
-- table.first(t, 2) -> {4, 3}
|
||||||
|
function table.first(t, n)
|
||||||
|
if n == 1 then return t[1] end
|
||||||
|
local out = {}
|
||||||
|
for i = 1, (n or 1) do
|
||||||
|
table.push(out, t[i])
|
||||||
|
end
|
||||||
|
if #out == 1 then return out[1]
|
||||||
|
else return out end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the last n values, same as tail
|
||||||
|
-- t = {4, 3, 2, 1}
|
||||||
|
-- table.last(t) -> 1
|
||||||
|
-- table.last(t, 2) -> {2, 1}
|
||||||
|
function table.last(t, n)
|
||||||
|
if n == 1 then return t[#t] end
|
||||||
|
local out = {}
|
||||||
|
for i = #t-n+1, #t do
|
||||||
|
table.push(out, t[i])
|
||||||
|
end
|
||||||
|
if #out == 1 then return out[1]
|
||||||
|
else return out end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- t = {"a", "b", "c", "d"}
|
||||||
|
-- table.reverse(t) -> {"d", "c", "b", "a"}
|
||||||
|
-- table.reverse(t, 2, 3) -> {"a", "c", "b", "d"}
|
||||||
|
-- table.reverse(t, 2, -1) -> {"a", "d", "c", "b"}
|
||||||
|
function table.reverse(t, i, j)
|
||||||
|
if not i then i = 1 end
|
||||||
|
if i < 0 then i = #t + i + 1 end
|
||||||
|
if not j then j = #t end
|
||||||
|
if j < 0 then j = #t + j + 1 end
|
||||||
|
if i == j then return t end
|
||||||
|
for k = 0, (j-i+1)/2-1, math.sign(j-i) do
|
||||||
|
t[i+k], t[j-k] = t[j-k], t[i+k]
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Shifts the table to the right n times, the last value is warped over to become the first value
|
||||||
|
-- t = {1, 2, 3, 4}
|
||||||
|
-- table.rotate(t) -> {4, 1, 2, 3}
|
||||||
|
-- table.rotate(t, 2) -> {3, 4, 1, 2}
|
||||||
|
function table.rotate(t, n)
|
||||||
|
if not n then n = 1 end
|
||||||
|
if n < 0 then n = #t + n end
|
||||||
|
t = table.reverse(t, 1, #t)
|
||||||
|
t = table.reverse(t, 1, #t-n)
|
||||||
|
t = table.reverse(t, #t-n+1, #t)
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a random value from the table
|
||||||
|
-- t = {1, 2, 3}
|
||||||
|
-- table.random(t) -> 1 or 2 or 3 randomly
|
||||||
|
function table.random(t)
|
||||||
|
return t[love.math.random(1, #t)]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- t = {1, 2, 3, 4, 5}
|
||||||
|
-- table.shuffle(t) -> {3, 4, 1, 2, 5}
|
||||||
|
-- table.shuttle(t) -> {2, 5, 1, 4, 3}
|
||||||
|
-- table.shuffle(t) -> {5, 4, 1, 3, 2}
|
||||||
|
function table.shuffle(t)
|
||||||
|
for i = #t, 2, -1 do
|
||||||
|
local j = love.math.random(i)
|
||||||
|
t[i], t[j] = t[j], t[i]
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Merges both tables based on their indexes, if the second table has values in the same indexes as the first table then those will overwrite the first values.
|
||||||
|
-- t1 = {1, 2, ['a'] = 3, ['b'] = function() end}
|
||||||
|
-- t2 = {nil, 8, 4, 5, ['a'] = 8}
|
||||||
|
-- table.merge(t1, t2) -> {1, 2, 8, 4, 5, ['a'] = 8, ['b'] = function() end}
|
||||||
|
function table.merge(t1, t2)
|
||||||
|
local out = {}
|
||||||
|
for k, v in pairs(t1) do out[k] = v end
|
||||||
|
for k, v in pairs(t2) do out[k] = v end
|
||||||
|
return out
|
||||||
|
end
|
|
@ -0,0 +1,747 @@
|
||||||
|
-- binser.lua
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Copyright (c) 2016-2019 Calvin Rose
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
]]
|
||||||
|
|
||||||
|
local assert = assert
|
||||||
|
local error = error
|
||||||
|
local select = select
|
||||||
|
local pairs = pairs
|
||||||
|
local getmetatable = getmetatable
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local type = type
|
||||||
|
local loadstring = loadstring or load
|
||||||
|
local concat = table.concat
|
||||||
|
local char = string.char
|
||||||
|
local byte = string.byte
|
||||||
|
local format = string.format
|
||||||
|
local sub = string.sub
|
||||||
|
local dump = string.dump
|
||||||
|
local floor = math.floor
|
||||||
|
local frexp = math.frexp
|
||||||
|
local unpack = unpack or table.unpack
|
||||||
|
|
||||||
|
-- Lua 5.3 frexp polyfill
|
||||||
|
-- From https://github.com/excessive/cpml/blob/master/modules/utils.lua
|
||||||
|
if not frexp then
|
||||||
|
local log, abs, floor = math.log, math.abs, math.floor
|
||||||
|
local log2 = log(2)
|
||||||
|
frexp = function(x)
|
||||||
|
if x == 0 then return 0, 0 end
|
||||||
|
local e = floor(log(abs(x)) / log2 + 1)
|
||||||
|
return x / 2 ^ e, e
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function pack(...)
|
||||||
|
return {...}, select("#", ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function not_array_index(x, len)
|
||||||
|
return type(x) ~= "number" or x < 1 or x > len or x ~= floor(x)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function type_check(x, tp, name)
|
||||||
|
assert(type(x) == tp,
|
||||||
|
format("Expected parameter %q to be of type %q.", name, tp))
|
||||||
|
end
|
||||||
|
|
||||||
|
local bigIntSupport = false
|
||||||
|
local isInteger
|
||||||
|
if math.type then -- Detect Lua 5.3
|
||||||
|
local mtype = math.type
|
||||||
|
bigIntSupport = loadstring[[
|
||||||
|
local char = string.char
|
||||||
|
return function(n)
|
||||||
|
local nn = n < 0 and -(n + 1) or n
|
||||||
|
local b1 = nn // 0x100000000000000
|
||||||
|
local b2 = nn // 0x1000000000000 % 0x100
|
||||||
|
local b3 = nn // 0x10000000000 % 0x100
|
||||||
|
local b4 = nn // 0x100000000 % 0x100
|
||||||
|
local b5 = nn // 0x1000000 % 0x100
|
||||||
|
local b6 = nn // 0x10000 % 0x100
|
||||||
|
local b7 = nn // 0x100 % 0x100
|
||||||
|
local b8 = nn % 0x100
|
||||||
|
if n < 0 then
|
||||||
|
b1, b2, b3, b4 = 0xFF - b1, 0xFF - b2, 0xFF - b3, 0xFF - b4
|
||||||
|
b5, b6, b7, b8 = 0xFF - b5, 0xFF - b6, 0xFF - b7, 0xFF - b8
|
||||||
|
end
|
||||||
|
return char(212, b1, b2, b3, b4, b5, b6, b7, b8)
|
||||||
|
end]]()
|
||||||
|
isInteger = function(x)
|
||||||
|
return mtype(x) == 'integer'
|
||||||
|
end
|
||||||
|
else
|
||||||
|
isInteger = function(x)
|
||||||
|
return floor(x) == x
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Copyright (C) 2012-2015 Francois Perrad.
|
||||||
|
-- number serialization code modified from https://github.com/fperrad/lua-MessagePack
|
||||||
|
-- Encode a number as a big-endian ieee-754 double, big-endian signed 64 bit integer, or a small integer
|
||||||
|
local function number_to_str(n)
|
||||||
|
if isInteger(n) then -- int
|
||||||
|
if n <= 100 and n >= -27 then -- 1 byte, 7 bits of data
|
||||||
|
return char(n + 27)
|
||||||
|
elseif n <= 8191 and n >= -8192 then -- 2 bytes, 14 bits of data
|
||||||
|
n = n + 8192
|
||||||
|
return char(128 + (floor(n / 0x100) % 0x100), n % 0x100)
|
||||||
|
elseif bigIntSupport then
|
||||||
|
return bigIntSupport(n)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local sign = 0
|
||||||
|
if n < 0.0 then
|
||||||
|
sign = 0x80
|
||||||
|
n = -n
|
||||||
|
end
|
||||||
|
local m, e = frexp(n) -- mantissa, exponent
|
||||||
|
if m ~= m then
|
||||||
|
return char(203, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
||||||
|
elseif m == 1/0 then
|
||||||
|
if sign == 0 then
|
||||||
|
return char(203, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
||||||
|
else
|
||||||
|
return char(203, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
e = e + 0x3FE
|
||||||
|
if e < 1 then -- denormalized numbers
|
||||||
|
m = m * 2 ^ (52 + e)
|
||||||
|
e = 0
|
||||||
|
else
|
||||||
|
m = (m * 2 - 1) * 2 ^ 52
|
||||||
|
end
|
||||||
|
return char(203,
|
||||||
|
sign + floor(e / 0x10),
|
||||||
|
(e % 0x10) * 0x10 + floor(m / 0x1000000000000),
|
||||||
|
floor(m / 0x10000000000) % 0x100,
|
||||||
|
floor(m / 0x100000000) % 0x100,
|
||||||
|
floor(m / 0x1000000) % 0x100,
|
||||||
|
floor(m / 0x10000) % 0x100,
|
||||||
|
floor(m / 0x100) % 0x100,
|
||||||
|
m % 0x100)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Copyright (C) 2012-2015 Francois Perrad.
|
||||||
|
-- number deserialization code also modified from https://github.com/fperrad/lua-MessagePack
|
||||||
|
local function number_from_str(str, index)
|
||||||
|
local b = byte(str, index)
|
||||||
|
if not b then error("Expected more bytes of input.") end
|
||||||
|
if b < 128 then
|
||||||
|
return b - 27, index + 1
|
||||||
|
elseif b < 192 then
|
||||||
|
local b2 = byte(str, index + 1)
|
||||||
|
if not b2 then error("Expected more bytes of input.") end
|
||||||
|
return b2 + 0x100 * (b - 128) - 8192, index + 2
|
||||||
|
end
|
||||||
|
local b1, b2, b3, b4, b5, b6, b7, b8 = byte(str, index + 1, index + 8)
|
||||||
|
if (not b1) or (not b2) or (not b3) or (not b4) or
|
||||||
|
(not b5) or (not b6) or (not b7) or (not b8) then
|
||||||
|
error("Expected more bytes of input.")
|
||||||
|
end
|
||||||
|
if b == 212 then
|
||||||
|
local flip = b1 >= 128
|
||||||
|
if flip then -- negative
|
||||||
|
b1, b2, b3, b4 = 0xFF - b1, 0xFF - b2, 0xFF - b3, 0xFF - b4
|
||||||
|
b5, b6, b7, b8 = 0xFF - b5, 0xFF - b6, 0xFF - b7, 0xFF - b8
|
||||||
|
end
|
||||||
|
local n = ((((((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4) *
|
||||||
|
0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8
|
||||||
|
if flip then
|
||||||
|
return (-n) - 1, index + 9
|
||||||
|
else
|
||||||
|
return n, index + 9
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if b ~= 203 then
|
||||||
|
error("Expected number")
|
||||||
|
end
|
||||||
|
local sign = b1 > 0x7F and -1 or 1
|
||||||
|
local e = (b1 % 0x80) * 0x10 + floor(b2 / 0x10)
|
||||||
|
local m = ((((((b2 % 0x10) * 0x100 + b3) * 0x100 + b4) * 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8
|
||||||
|
local n
|
||||||
|
if e == 0 then
|
||||||
|
if m == 0 then
|
||||||
|
n = sign * 0.0
|
||||||
|
else
|
||||||
|
n = sign * (m / 2 ^ 52) * 2 ^ -1022
|
||||||
|
end
|
||||||
|
elseif e == 0x7FF then
|
||||||
|
if m == 0 then
|
||||||
|
n = sign * (1/0)
|
||||||
|
else
|
||||||
|
n = 0.0/0.0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
n = sign * (1.0 + m / 2 ^ 52) * 2 ^ (e - 0x3FF)
|
||||||
|
end
|
||||||
|
return n, index + 9
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function newbinser()
|
||||||
|
|
||||||
|
-- unique table key for getting next value
|
||||||
|
local NEXT = {}
|
||||||
|
local CTORSTACK = {}
|
||||||
|
|
||||||
|
-- NIL = 202
|
||||||
|
-- FLOAT = 203
|
||||||
|
-- TRUE = 204
|
||||||
|
-- FALSE = 205
|
||||||
|
-- STRING = 206
|
||||||
|
-- TABLE = 207
|
||||||
|
-- REFERENCE = 208
|
||||||
|
-- CONSTRUCTOR = 209
|
||||||
|
-- FUNCTION = 210
|
||||||
|
-- RESOURCE = 211
|
||||||
|
-- INT64 = 212
|
||||||
|
-- TABLE WITH META = 213
|
||||||
|
|
||||||
|
local mts = {}
|
||||||
|
local ids = {}
|
||||||
|
local serializers = {}
|
||||||
|
local deserializers = {}
|
||||||
|
local resources = {}
|
||||||
|
local resources_by_name = {}
|
||||||
|
local types = {}
|
||||||
|
|
||||||
|
types["nil"] = function(x, visited, accum)
|
||||||
|
accum[#accum + 1] = "\202"
|
||||||
|
end
|
||||||
|
|
||||||
|
function types.number(x, visited, accum)
|
||||||
|
accum[#accum + 1] = number_to_str(x)
|
||||||
|
end
|
||||||
|
|
||||||
|
function types.boolean(x, visited, accum)
|
||||||
|
accum[#accum + 1] = x and "\204" or "\205"
|
||||||
|
end
|
||||||
|
|
||||||
|
function types.string(x, visited, accum)
|
||||||
|
local alen = #accum
|
||||||
|
if visited[x] then
|
||||||
|
accum[alen + 1] = "\208"
|
||||||
|
accum[alen + 2] = number_to_str(visited[x])
|
||||||
|
else
|
||||||
|
visited[x] = visited[NEXT]
|
||||||
|
visited[NEXT] = visited[NEXT] + 1
|
||||||
|
accum[alen + 1] = "\206"
|
||||||
|
accum[alen + 2] = number_to_str(#x)
|
||||||
|
accum[alen + 3] = x
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function check_custom_type(x, visited, accum)
|
||||||
|
local res = resources[x]
|
||||||
|
if res then
|
||||||
|
accum[#accum + 1] = "\211"
|
||||||
|
types[type(res)](res, visited, accum)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local mt = getmetatable(x)
|
||||||
|
local id = mt and ids[mt]
|
||||||
|
if id then
|
||||||
|
local constructing = visited[CTORSTACK]
|
||||||
|
if constructing[x] then
|
||||||
|
error("Infinite loop in constructor.")
|
||||||
|
end
|
||||||
|
constructing[x] = true
|
||||||
|
accum[#accum + 1] = "\209"
|
||||||
|
types[type(id)](id, visited, accum)
|
||||||
|
local args, len = pack(serializers[id](x))
|
||||||
|
accum[#accum + 1] = number_to_str(len)
|
||||||
|
for i = 1, len do
|
||||||
|
local arg = args[i]
|
||||||
|
types[type(arg)](arg, visited, accum)
|
||||||
|
end
|
||||||
|
visited[x] = visited[NEXT]
|
||||||
|
visited[NEXT] = visited[NEXT] + 1
|
||||||
|
-- We finished constructing
|
||||||
|
constructing[x] = nil
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function types.userdata(x, visited, accum)
|
||||||
|
if visited[x] then
|
||||||
|
accum[#accum + 1] = "\208"
|
||||||
|
accum[#accum + 1] = number_to_str(visited[x])
|
||||||
|
else
|
||||||
|
if check_custom_type(x, visited, accum) then return end
|
||||||
|
error("Cannot serialize this userdata.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function types.table(x, visited, accum)
|
||||||
|
if visited[x] then
|
||||||
|
accum[#accum + 1] = "\208"
|
||||||
|
accum[#accum + 1] = number_to_str(visited[x])
|
||||||
|
else
|
||||||
|
if check_custom_type(x, visited, accum) then return end
|
||||||
|
visited[x] = visited[NEXT]
|
||||||
|
visited[NEXT] = visited[NEXT] + 1
|
||||||
|
local xlen = #x
|
||||||
|
local mt = getmetatable(x)
|
||||||
|
if mt then
|
||||||
|
accum[#accum + 1] = "\213"
|
||||||
|
types.table(mt, visited, accum)
|
||||||
|
else
|
||||||
|
accum[#accum + 1] = "\207"
|
||||||
|
end
|
||||||
|
accum[#accum + 1] = number_to_str(xlen)
|
||||||
|
for i = 1, xlen do
|
||||||
|
local v = x[i]
|
||||||
|
types[type(v)](v, visited, accum)
|
||||||
|
end
|
||||||
|
local key_count = 0
|
||||||
|
for k in pairs(x) do
|
||||||
|
if not_array_index(k, xlen) then
|
||||||
|
key_count = key_count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
accum[#accum + 1] = number_to_str(key_count)
|
||||||
|
for k, v in pairs(x) do
|
||||||
|
if not_array_index(k, xlen) then
|
||||||
|
types[type(k)](k, visited, accum)
|
||||||
|
types[type(v)](v, visited, accum)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
types["function"] = function(x, visited, accum)
|
||||||
|
if visited[x] then
|
||||||
|
accum[#accum + 1] = "\208"
|
||||||
|
accum[#accum + 1] = number_to_str(visited[x])
|
||||||
|
else
|
||||||
|
if check_custom_type(x, visited, accum) then return end
|
||||||
|
visited[x] = visited[NEXT]
|
||||||
|
visited[NEXT] = visited[NEXT] + 1
|
||||||
|
local str = dump(x)
|
||||||
|
accum[#accum + 1] = "\210"
|
||||||
|
accum[#accum + 1] = number_to_str(#str)
|
||||||
|
accum[#accum + 1] = str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
types.cdata = function(x, visited, accum)
|
||||||
|
if visited[x] then
|
||||||
|
accum[#accum + 1] = "\208"
|
||||||
|
accum[#accum + 1] = number_to_str(visited[x])
|
||||||
|
else
|
||||||
|
if check_custom_type(x, visited, #accum) then return end
|
||||||
|
error("Cannot serialize this cdata.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
types.thread = function() error("Cannot serialize threads.") end
|
||||||
|
|
||||||
|
local function deserialize_value(str, index, visited)
|
||||||
|
local t = byte(str, index)
|
||||||
|
if not t then return nil, index end
|
||||||
|
if t < 128 then
|
||||||
|
return t - 27, index + 1
|
||||||
|
elseif t < 192 then
|
||||||
|
local b2 = byte(str, index + 1)
|
||||||
|
if not b2 then error("Expected more bytes of input.") end
|
||||||
|
return b2 + 0x100 * (t - 128) - 8192, index + 2
|
||||||
|
elseif t == 202 then
|
||||||
|
return nil, index + 1
|
||||||
|
elseif t == 203 or t == 212 then
|
||||||
|
return number_from_str(str, index)
|
||||||
|
elseif t == 204 then
|
||||||
|
return true, index + 1
|
||||||
|
elseif t == 205 then
|
||||||
|
return false, index + 1
|
||||||
|
elseif t == 206 then
|
||||||
|
local length, dataindex = number_from_str(str, index + 1)
|
||||||
|
local nextindex = dataindex + length
|
||||||
|
if not (length >= 0) then error("Bad string length") end
|
||||||
|
if #str < nextindex - 1 then error("Expected more bytes of string") end
|
||||||
|
local substr = sub(str, dataindex, nextindex - 1)
|
||||||
|
visited[#visited + 1] = substr
|
||||||
|
return substr, nextindex
|
||||||
|
elseif t == 207 or t == 213 then
|
||||||
|
local mt, count, nextindex
|
||||||
|
local ret = {}
|
||||||
|
visited[#visited + 1] = ret
|
||||||
|
nextindex = index + 1
|
||||||
|
if t == 213 then
|
||||||
|
mt, nextindex = deserialize_value(str, nextindex, visited)
|
||||||
|
if type(mt) ~= "table" then error("Expected table metatable") end
|
||||||
|
end
|
||||||
|
count, nextindex = number_from_str(str, nextindex)
|
||||||
|
for i = 1, count do
|
||||||
|
local oldindex = nextindex
|
||||||
|
ret[i], nextindex = deserialize_value(str, nextindex, visited)
|
||||||
|
if nextindex == oldindex then error("Expected more bytes of input.") end
|
||||||
|
end
|
||||||
|
count, nextindex = number_from_str(str, nextindex)
|
||||||
|
for i = 1, count do
|
||||||
|
local k, v
|
||||||
|
local oldindex = nextindex
|
||||||
|
k, nextindex = deserialize_value(str, nextindex, visited)
|
||||||
|
if nextindex == oldindex then error("Expected more bytes of input.") end
|
||||||
|
oldindex = nextindex
|
||||||
|
v, nextindex = deserialize_value(str, nextindex, visited)
|
||||||
|
if nextindex == oldindex then error("Expected more bytes of input.") end
|
||||||
|
if k == nil then error("Can't have nil table keys") end
|
||||||
|
ret[k] = v
|
||||||
|
end
|
||||||
|
if mt then setmetatable(ret, mt) end
|
||||||
|
return ret, nextindex
|
||||||
|
elseif t == 208 then
|
||||||
|
local ref, nextindex = number_from_str(str, index + 1)
|
||||||
|
return visited[ref], nextindex
|
||||||
|
elseif t == 209 then
|
||||||
|
local count
|
||||||
|
local name, nextindex = deserialize_value(str, index + 1, visited)
|
||||||
|
count, nextindex = number_from_str(str, nextindex)
|
||||||
|
local args = {}
|
||||||
|
for i = 1, count do
|
||||||
|
local oldindex = nextindex
|
||||||
|
args[i], nextindex = deserialize_value(str, nextindex, visited)
|
||||||
|
if nextindex == oldindex then error("Expected more bytes of input.") end
|
||||||
|
end
|
||||||
|
if not name or not deserializers[name] then
|
||||||
|
error(("Cannot deserialize class '%s'"):format(tostring(name)))
|
||||||
|
end
|
||||||
|
local ret = deserializers[name](unpack(args))
|
||||||
|
visited[#visited + 1] = ret
|
||||||
|
return ret, nextindex
|
||||||
|
elseif t == 210 then
|
||||||
|
local length, dataindex = number_from_str(str, index + 1)
|
||||||
|
local nextindex = dataindex + length
|
||||||
|
if not (length >= 0) then error("Bad string length") end
|
||||||
|
if #str < nextindex - 1 then error("Expected more bytes of string") end
|
||||||
|
local ret = loadstring(sub(str, dataindex, nextindex - 1))
|
||||||
|
visited[#visited + 1] = ret
|
||||||
|
return ret, nextindex
|
||||||
|
elseif t == 211 then
|
||||||
|
local resname, nextindex = deserialize_value(str, index + 1, visited)
|
||||||
|
if resname == nil then error("Got nil resource name") end
|
||||||
|
local res = resources_by_name[resname]
|
||||||
|
if res == nil then
|
||||||
|
error(("No resources found for name '%s'"):format(tostring(resname)))
|
||||||
|
end
|
||||||
|
return res, nextindex
|
||||||
|
else
|
||||||
|
error("Could not deserialize type byte " .. t .. ".")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function serialize(...)
|
||||||
|
local visited = {[NEXT] = 1, [CTORSTACK] = {}}
|
||||||
|
local accum = {}
|
||||||
|
for i = 1, select("#", ...) do
|
||||||
|
local x = select(i, ...)
|
||||||
|
types[type(x)](x, visited, accum)
|
||||||
|
end
|
||||||
|
return concat(accum)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function make_file_writer(file)
|
||||||
|
return setmetatable({}, {
|
||||||
|
__newindex = function(_, _, v)
|
||||||
|
file:write(v)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function serialize_to_file(path, mode, ...)
|
||||||
|
local file, err = io.open(path, mode)
|
||||||
|
assert(file, err)
|
||||||
|
local visited = {[NEXT] = 1, [CTORSTACK] = {}}
|
||||||
|
local accum = make_file_writer(file)
|
||||||
|
for i = 1, select("#", ...) do
|
||||||
|
local x = select(i, ...)
|
||||||
|
types[type(x)](x, visited, accum)
|
||||||
|
end
|
||||||
|
-- flush the writer
|
||||||
|
file:flush()
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function writeFile(path, ...)
|
||||||
|
return serialize_to_file(path, "wb", ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function appendFile(path, ...)
|
||||||
|
return serialize_to_file(path, "ab", ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function deserialize(str, index)
|
||||||
|
assert(type(str) == "string", "Expected string to deserialize.")
|
||||||
|
local vals = {}
|
||||||
|
index = index or 1
|
||||||
|
local visited = {}
|
||||||
|
local len = 0
|
||||||
|
local val
|
||||||
|
while true do
|
||||||
|
local nextindex
|
||||||
|
val, nextindex = deserialize_value(str, index, visited)
|
||||||
|
if nextindex > index then
|
||||||
|
len = len + 1
|
||||||
|
vals[len] = val
|
||||||
|
index = nextindex
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return vals, len
|
||||||
|
end
|
||||||
|
|
||||||
|
local function deserializeN(str, n, index)
|
||||||
|
assert(type(str) == "string", "Expected string to deserialize.")
|
||||||
|
n = n or 1
|
||||||
|
assert(type(n) == "number", "Expected a number for parameter n.")
|
||||||
|
assert(n > 0 and floor(n) == n, "N must be a poitive integer.")
|
||||||
|
local vals = {}
|
||||||
|
index = index or 1
|
||||||
|
local visited = {}
|
||||||
|
local len = 0
|
||||||
|
local val
|
||||||
|
while len < n do
|
||||||
|
local nextindex
|
||||||
|
val, nextindex = deserialize_value(str, index, visited)
|
||||||
|
if nextindex > index then
|
||||||
|
len = len + 1
|
||||||
|
vals[len] = val
|
||||||
|
index = nextindex
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vals[len + 1] = index
|
||||||
|
return unpack(vals, 1, n + 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function readFile(path)
|
||||||
|
local file, err = io.open(path, "rb")
|
||||||
|
assert(file, err)
|
||||||
|
local str = file:read("*all")
|
||||||
|
file:close()
|
||||||
|
return deserialize(str)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Resources
|
||||||
|
|
||||||
|
local function registerResource(resource, name)
|
||||||
|
type_check(name, "string", "name")
|
||||||
|
assert(not resources[resource],
|
||||||
|
"Resource already registered.")
|
||||||
|
assert(not resources_by_name[name],
|
||||||
|
format("Resource %q already exists.", name))
|
||||||
|
resources_by_name[name] = resource
|
||||||
|
resources[resource] = name
|
||||||
|
return resource
|
||||||
|
end
|
||||||
|
|
||||||
|
local function unregisterResource(name)
|
||||||
|
type_check(name, "string", "name")
|
||||||
|
assert(resources_by_name[name], format("Resource %q does not exist.", name))
|
||||||
|
local resource = resources_by_name[name]
|
||||||
|
resources_by_name[name] = nil
|
||||||
|
resources[resource] = nil
|
||||||
|
return resource
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Templating
|
||||||
|
|
||||||
|
local function normalize_template(template)
|
||||||
|
local ret = {}
|
||||||
|
for i = 1, #template do
|
||||||
|
ret[i] = template[i]
|
||||||
|
end
|
||||||
|
local non_array_part = {}
|
||||||
|
-- The non-array part of the template (nested templates) have to be deterministic, so they are sorted.
|
||||||
|
-- This means that inherently non deterministicly sortable keys (tables, functions) should NOT be used
|
||||||
|
-- in templates. Looking for way around this.
|
||||||
|
for k in pairs(template) do
|
||||||
|
if not_array_index(k, #template) then
|
||||||
|
non_array_part[#non_array_part + 1] = k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.sort(non_array_part)
|
||||||
|
for i = 1, #non_array_part do
|
||||||
|
local name = non_array_part[i]
|
||||||
|
ret[#ret + 1] = {name, normalize_template(template[name])}
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
local function templatepart_serialize(part, argaccum, x, len)
|
||||||
|
local extras = {}
|
||||||
|
local extracount = 0
|
||||||
|
for k, v in pairs(x) do
|
||||||
|
extras[k] = v
|
||||||
|
extracount = extracount + 1
|
||||||
|
end
|
||||||
|
for i = 1, #part do
|
||||||
|
local name
|
||||||
|
if type(part[i]) == "table" then
|
||||||
|
name = part[i][1]
|
||||||
|
len = templatepart_serialize(part[i][2], argaccum, x[name], len)
|
||||||
|
else
|
||||||
|
name = part[i]
|
||||||
|
len = len + 1
|
||||||
|
argaccum[len] = x[part[i]]
|
||||||
|
end
|
||||||
|
if extras[name] ~= nil then
|
||||||
|
extracount = extracount - 1
|
||||||
|
extras[name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if extracount > 0 then
|
||||||
|
argaccum[len + 1] = extras
|
||||||
|
else
|
||||||
|
argaccum[len + 1] = nil
|
||||||
|
end
|
||||||
|
return len + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function templatepart_deserialize(ret, part, values, vindex)
|
||||||
|
for i = 1, #part do
|
||||||
|
local name = part[i]
|
||||||
|
if type(name) == "table" then
|
||||||
|
local newret = {}
|
||||||
|
ret[name[1]] = newret
|
||||||
|
vindex = templatepart_deserialize(newret, name[2], values, vindex)
|
||||||
|
else
|
||||||
|
ret[name] = values[vindex]
|
||||||
|
vindex = vindex + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local extras = values[vindex]
|
||||||
|
if extras then
|
||||||
|
for k, v in pairs(extras) do
|
||||||
|
ret[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return vindex + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function template_serializer_and_deserializer(metatable, template)
|
||||||
|
return function(x)
|
||||||
|
local argaccum = {}
|
||||||
|
local len = templatepart_serialize(template, argaccum, x, 0)
|
||||||
|
return unpack(argaccum, 1, len)
|
||||||
|
end, function(...)
|
||||||
|
local ret = {}
|
||||||
|
local args = {...}
|
||||||
|
templatepart_deserialize(ret, template, args, 1)
|
||||||
|
return setmetatable(ret, metatable)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Used to serialize classes withh custom serializers and deserializers.
|
||||||
|
-- If no _serialize or _deserialize (or no _template) value is found in the
|
||||||
|
-- metatable, then the metatable is registered as a resources.
|
||||||
|
local function register(metatable, name, serialize, deserialize)
|
||||||
|
if type(metatable) == "table" then
|
||||||
|
name = name or metatable.name
|
||||||
|
serialize = serialize or metatable._serialize
|
||||||
|
deserialize = deserialize or metatable._deserialize
|
||||||
|
if (not serialize) or (not deserialize) then
|
||||||
|
if metatable._template then
|
||||||
|
-- Register as template
|
||||||
|
local t = normalize_template(metatable._template)
|
||||||
|
serialize, deserialize = template_serializer_and_deserializer(metatable, t)
|
||||||
|
else
|
||||||
|
-- Register the metatable as a resource. This is semantically
|
||||||
|
-- similar and more flexible (handles cycles).
|
||||||
|
registerResource(metatable, name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif type(metatable) == "string" then
|
||||||
|
name = name or metatable
|
||||||
|
end
|
||||||
|
type_check(name, "string", "name")
|
||||||
|
type_check(serialize, "function", "serialize")
|
||||||
|
type_check(deserialize, "function", "deserialize")
|
||||||
|
assert((not ids[metatable]) and (not resources[metatable]),
|
||||||
|
"Metatable already registered.")
|
||||||
|
assert((not mts[name]) and (not resources_by_name[name]),
|
||||||
|
("Name %q already registered."):format(name))
|
||||||
|
mts[name] = metatable
|
||||||
|
ids[metatable] = name
|
||||||
|
serializers[name] = serialize
|
||||||
|
deserializers[name] = deserialize
|
||||||
|
return metatable
|
||||||
|
end
|
||||||
|
|
||||||
|
local function unregister(item)
|
||||||
|
local name, metatable
|
||||||
|
if type(item) == "string" then -- assume name
|
||||||
|
name, metatable = item, mts[item]
|
||||||
|
else -- assume metatable
|
||||||
|
name, metatable = ids[item], item
|
||||||
|
end
|
||||||
|
type_check(name, "string", "name")
|
||||||
|
mts[name] = nil
|
||||||
|
if (metatable) then
|
||||||
|
resources[metatable] = nil
|
||||||
|
ids[metatable] = nil
|
||||||
|
end
|
||||||
|
serializers[name] = nil
|
||||||
|
deserializers[name] = nil
|
||||||
|
resources_by_name[name] = nil;
|
||||||
|
return metatable
|
||||||
|
end
|
||||||
|
|
||||||
|
local function registerClass(class, name)
|
||||||
|
name = name or class.name
|
||||||
|
if class.__instanceDict then -- middleclass
|
||||||
|
register(class.__instanceDict, name)
|
||||||
|
else -- assume 30log or similar library
|
||||||
|
register(class, name)
|
||||||
|
end
|
||||||
|
return class
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
VERSION = "0.0-8",
|
||||||
|
-- aliases
|
||||||
|
s = serialize,
|
||||||
|
d = deserialize,
|
||||||
|
dn = deserializeN,
|
||||||
|
r = readFile,
|
||||||
|
w = writeFile,
|
||||||
|
a = appendFile,
|
||||||
|
|
||||||
|
serialize = serialize,
|
||||||
|
deserialize = deserialize,
|
||||||
|
deserializeN = deserializeN,
|
||||||
|
readFile = readFile,
|
||||||
|
writeFile = writeFile,
|
||||||
|
appendFile = appendFile,
|
||||||
|
register = register,
|
||||||
|
unregister = unregister,
|
||||||
|
registerResource = registerResource,
|
||||||
|
unregisterResource = unregisterResource,
|
||||||
|
registerClass = registerClass,
|
||||||
|
|
||||||
|
newbinser = newbinser
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return newbinser()
|
|
@ -0,0 +1,274 @@
|
||||||
|
-- Copyright (c) 2017 Laurent Zubiaur
|
||||||
|
--
|
||||||
|
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
-- of this software and associated documentation files (the "Software"), to deal
|
||||||
|
-- in the Software without restriction, including without limitation the rights
|
||||||
|
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
-- copies of the Software, and to permit persons to whom the Software is
|
||||||
|
-- furnished to do so, subject to the following conditions:
|
||||||
|
--
|
||||||
|
-- The above copyright notice and this permission notice shall be included in all
|
||||||
|
-- copies or substantial portions of the Software.
|
||||||
|
--
|
||||||
|
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
-- SOFTWARE.
|
||||||
|
|
||||||
|
local ffi = require 'ffi'
|
||||||
|
-- NOTE ffi.load doesn't use package.cpath to search for libraries but rather the
|
||||||
|
-- default OS default search path (e.g. LD_LIBRARY_PATH).
|
||||||
|
|
||||||
|
-- Load Clipper from a shared library...
|
||||||
|
local C = ffi.load 'polyclipping'
|
||||||
|
-- or use the default namespace if Clipper's been compiled within the executable
|
||||||
|
-- local C = ffi.C
|
||||||
|
|
||||||
|
ffi.cdef[[
|
||||||
|
|
||||||
|
// Replace `int64_t` with `int32_t` if Clipper has been compiled with `use_int32`
|
||||||
|
typedef struct __cl_int_point { int64_t x, y; } cl_int_point;
|
||||||
|
typedef struct __cl_int_rect { int64_t left; int64_t top; int64_t right; int64_t bottom; } cl_int_rect;
|
||||||
|
// Replace `long long` with `int` if compiled with `use_int32`
|
||||||
|
typedef signed long long cInt;
|
||||||
|
|
||||||
|
typedef struct __cl_path cl_path;
|
||||||
|
typedef struct __cl_paths cl_paths;
|
||||||
|
typedef struct __cl_offset cl_offset;
|
||||||
|
typedef struct __cl_clipper cl_clipper;
|
||||||
|
|
||||||
|
const char* cl_err_msg();
|
||||||
|
|
||||||
|
// Path
|
||||||
|
cl_path* cl_path_new();
|
||||||
|
void cl_path_free(cl_path *self);
|
||||||
|
cl_int_point* cl_path_get(cl_path *self, int i);
|
||||||
|
bool cl_path_add(cl_path *self, cInt x, cInt y);
|
||||||
|
int cl_path_size(cl_path *self);
|
||||||
|
double cl_path_area(const cl_path *self);
|
||||||
|
bool cl_path_orientation(const cl_path *self);
|
||||||
|
void cl_path_reverse(cl_path *self);
|
||||||
|
int cl_path_point_in_polygon(cl_path *self,cInt x, cInt y);
|
||||||
|
cl_paths* cl_path_simplify(cl_path *self,int fillType);
|
||||||
|
cl_path* cl_path_clean_polygon(const cl_path *in, double distance);
|
||||||
|
|
||||||
|
// Paths
|
||||||
|
cl_paths* cl_paths_new();
|
||||||
|
void cl_paths_free(cl_paths *self);
|
||||||
|
cl_path* cl_paths_get(cl_paths *self, int i);
|
||||||
|
bool cl_paths_add(cl_paths *self, cl_path *path);
|
||||||
|
int cl_paths_size(cl_paths *self);
|
||||||
|
|
||||||
|
// ClipperOffset
|
||||||
|
cl_offset* cl_offset_new(double miterLimit,double roundPrecision);
|
||||||
|
void cl_offset_free(cl_offset *self);
|
||||||
|
cl_paths* cl_offset_path(cl_offset *self, cl_path *subj, double delta, int jointType, int endType);
|
||||||
|
cl_paths* cl_offset_paths(cl_offset *self, cl_paths *subj, double delta, int jointType, int endType);
|
||||||
|
void cl_offset_clear(cl_offset *self);
|
||||||
|
|
||||||
|
// Clipper
|
||||||
|
cl_clipper* cl_clipper_new();
|
||||||
|
void cl_clipper_free(cl_clipper *cl);
|
||||||
|
void cl_clipper_clear(cl_clipper *cl);
|
||||||
|
bool cl_clipper_add_path(cl_clipper *cl,cl_path *path, int pt, bool closed,const char *err);
|
||||||
|
bool cl_clipper_add_paths(cl_clipper *cl,cl_paths *paths, int pt, bool closed,const char *err);
|
||||||
|
void cl_clipper_reverse_solution(cl_clipper *cl, bool value);
|
||||||
|
void cl_clipper_preserve_collinear(cl_clipper *cl, bool value);
|
||||||
|
void cl_clipper_strictly_simple(cl_clipper *cl, bool value);
|
||||||
|
cl_paths* cl_clipper_execute(cl_clipper *cl,int clipType,int subjFillType,int clipFillType);
|
||||||
|
cl_int_rect cl_clipper_get_bounds(cl_clipper *cl);
|
||||||
|
]]
|
||||||
|
|
||||||
|
local ClipType = {
|
||||||
|
intersection = 0, union = 1, difference = 2, xor = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
local JoinType = {
|
||||||
|
square = 0, round = 1, miter = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
local EndType = {
|
||||||
|
closedPolygon = 0, closedLine = 1, openButt = 2, openSquare = 3, openRound = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Clipper constructor options
|
||||||
|
local InitOptions = {
|
||||||
|
reverseSolution = 1, strictlySimple = 2, preserveCollinear = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
local PolyType = {
|
||||||
|
subject = 0, clip = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local PolyFillType = {
|
||||||
|
evenOdd = 1, nonZero = 2, positive = 2, negative = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
local Path = {}
|
||||||
|
|
||||||
|
function Path.new()
|
||||||
|
return ffi.gc(C.cl_path_new(), C.cl_path_free)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:add(x,y)
|
||||||
|
return C.cl_path_add(self,x,y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:get(i)
|
||||||
|
return C.cl_path_get(self,i-1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:size()
|
||||||
|
return C.cl_path_size(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:area()
|
||||||
|
return C.cl_path_area(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:reverse()
|
||||||
|
return C.cl_path_reverse(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:orientation()
|
||||||
|
return C.cl_path_orientation(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:contains(x,y)
|
||||||
|
return C.cl_path_point_in_polygon(self,x,y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:simplify(fillType)
|
||||||
|
fillType = fillType or 'evenOdd'
|
||||||
|
fillType = assert(PolyFillType[fillType],'unknown fill type')
|
||||||
|
return C.cl_path_simplify(self,fillType)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Path:cleanPolygon(distance)
|
||||||
|
distance = distance or 1.415
|
||||||
|
return C.cl_path_clean_polygon(self,distance)
|
||||||
|
end
|
||||||
|
|
||||||
|
local Paths = {}
|
||||||
|
|
||||||
|
function Paths.new()
|
||||||
|
return ffi.gc(C.cl_paths_new(), C.cl_paths_free)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Paths:add(path)
|
||||||
|
return C.cl_paths_add(self,path)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Paths:get(i)
|
||||||
|
return C.cl_paths_get(self,i-1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Paths:size()
|
||||||
|
return C.cl_paths_size(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ClipperOffset = {}
|
||||||
|
|
||||||
|
function ClipperOffset.new(miterLimit,roundPrecision)
|
||||||
|
local co = C.cl_offset_new(miterLimit or 2,roundPrecision or 0.25)
|
||||||
|
return ffi.gc(co, C.cl_offset_free)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ClipperOffset:offsetPath(path,delta,jt,et)
|
||||||
|
jt,et = jt or 'square', et or 'openButt'
|
||||||
|
assert(JoinType[jt])
|
||||||
|
assert(EndType[et])
|
||||||
|
local out = C.cl_offset_path(self,path,delta,JoinType[jt],EndType[et])
|
||||||
|
if out == nil then
|
||||||
|
error(ffi.string(C.cl_err_msg()))
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
function ClipperOffset:offsetPaths(paths,delta,jt,et)
|
||||||
|
jt,et = jt or 'square', et or 'openButt'
|
||||||
|
assert(JoinType[jt])
|
||||||
|
assert(EndType[et])
|
||||||
|
local out = C.cl_offset_paths(self,paths,delta,JoinType[jt],EndType[et])
|
||||||
|
if out == nil then
|
||||||
|
error(ffi.string(C.cl_err_msg()))
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
function ClipperOffset:clear()
|
||||||
|
C.cl_offset_clear(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clipper
|
||||||
|
|
||||||
|
local Clipper = {}
|
||||||
|
|
||||||
|
function Clipper.new(...)
|
||||||
|
local cl = C.cl_clipper_new()
|
||||||
|
for _,opt in ipairs {...} do
|
||||||
|
assert(InitOptions[opt])
|
||||||
|
if opt == 'strictlySimple' then
|
||||||
|
C.cl_clipper_strictly_simple(true)
|
||||||
|
elseif opt == 'reverseSolution' then
|
||||||
|
C.cl_clipper_reverse_solution(true)
|
||||||
|
else
|
||||||
|
C.cl_clipper_preserve_collinear(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ffi.gc(cl, C.cl_clipper_free)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Clipper:clear()
|
||||||
|
C.cl_clipper_clear(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Clipper:addPath(path,pt,closed)
|
||||||
|
assert(path,'path is nil')
|
||||||
|
assert(PolyType[pt],'unknown polygon type')
|
||||||
|
if closed == nil then closed = true end
|
||||||
|
C.cl_clipper_add_path(self,path,PolyType[pt],closed,err);
|
||||||
|
end
|
||||||
|
|
||||||
|
function Clipper:addPaths(paths,pt,closed)
|
||||||
|
assert(paths,'paths is nil')
|
||||||
|
assert(PolyType[pt],'unknown polygon type')
|
||||||
|
if closed == nil then closed = true end
|
||||||
|
if not C.cl_clipper_add_paths(self,paths,PolyType[pt],closed,err) then
|
||||||
|
error(ffi.string(C.cl_err_msg()))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Clipper:execute(clipType,subjFillType,clipFillType)
|
||||||
|
subjFillType = subjFillType or 'evenOdd'
|
||||||
|
clipFillType = clipFillType or 'evenOdd'
|
||||||
|
clipType = assert(ClipType[clipType],'unknown clip type')
|
||||||
|
subjFillType = assert(PolyFillType[subjFillType],'unknown fill type')
|
||||||
|
clipFillType = assert(PolyFillType[clipFillType],'unknown fill type')
|
||||||
|
local out = C.cl_clipper_execute(self,clipType,subjFillType,clipFillType)
|
||||||
|
-- XXX test `not nil` return false ?!
|
||||||
|
if out == nil then
|
||||||
|
error(ffi.string(C.cl_err_msg()))
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
function Clipper:getBounds()
|
||||||
|
local r = C.cl_clipper_get_bounds(self)
|
||||||
|
return tonumber(r.left),tonumber(r.top),tonumber(r.right),tonumber(r.bottom)
|
||||||
|
end
|
||||||
|
|
||||||
|
ffi.metatype('cl_path', {__index = Path})
|
||||||
|
ffi.metatype('cl_paths', {__index = Paths})
|
||||||
|
ffi.metatype('cl_offset', {__index = ClipperOffset})
|
||||||
|
ffi.metatype('cl_clipper', {__index = Clipper})
|
||||||
|
|
||||||
|
return {
|
||||||
|
Path = Path.new,
|
||||||
|
Paths = Paths.new,
|
||||||
|
ClipperOffset = ClipperOffset.new,
|
||||||
|
Clipper = Clipper.new,
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
local path = ...
|
||||||
|
if not path:find("init") then
|
||||||
|
binser = require(path .. ".binser")
|
||||||
|
mlib = require(path .. ".mlib")
|
||||||
|
if not web then clipper = require(path .. ".clipper") end
|
||||||
|
ripple = require(path .. ".ripple")
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,518 @@
|
||||||
|
local ripple = {
|
||||||
|
_VERSION = 'Ripple',
|
||||||
|
_DESCRIPTION = 'Audio helpers for LÖVE.',
|
||||||
|
_URL = 'https://github.com/tesselode/ripple',
|
||||||
|
_LICENSE = [[
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Andrew Minnich
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
]]
|
||||||
|
}
|
||||||
|
|
||||||
|
local unpack = unpack or table.unpack -- luacheck: ignore
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Represents an object that:
|
||||||
|
- can have tags applied
|
||||||
|
- has a volume
|
||||||
|
- can have effects applied
|
||||||
|
|
||||||
|
Tags, instances, and sounds are all taggable.
|
||||||
|
|
||||||
|
Note that not all taggable objects have children - tags and sounds
|
||||||
|
do, but instances do not.
|
||||||
|
]]
|
||||||
|
local Taggable = {}
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Gets the total volume of this object given its own volume
|
||||||
|
and the volume of each of its tags.
|
||||||
|
]]
|
||||||
|
function Taggable:_getTotalVolume()
|
||||||
|
local volume = self.volume
|
||||||
|
for tag, _ in pairs(self._tags) do
|
||||||
|
volume = volume * tag:_getTotalVolume()
|
||||||
|
end
|
||||||
|
return volume
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Gets all the effects that should be applied to this object given
|
||||||
|
its own effects and the effects of each of its tags. The object's
|
||||||
|
own effects will override tag effects.
|
||||||
|
|
||||||
|
Note: currently, if multiple tags define settings for the same effect,
|
||||||
|
the final result is undefined, as taggable objects use pairs to iterate
|
||||||
|
through the tags, which iterates in an undefined order.
|
||||||
|
]]
|
||||||
|
function Taggable:_getAllEffects()
|
||||||
|
local effects = {}
|
||||||
|
for tag, _ in pairs(self._tags) do
|
||||||
|
for name, filterSettings in pairs(tag:_getAllEffects()) do
|
||||||
|
effects[name] = filterSettings
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for name, filterSettings in pairs(self._effects) do
|
||||||
|
effects[name] = filterSettings
|
||||||
|
end
|
||||||
|
return effects
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
A callback that is called when anything happens that could
|
||||||
|
lead to a change in the object's total volume.
|
||||||
|
]]
|
||||||
|
function Taggable:_onChangeVolume() end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
A callback that is called when anything happens that could
|
||||||
|
change which effects are applied to the object.
|
||||||
|
]]
|
||||||
|
function Taggable:_onChangeEffects() end
|
||||||
|
|
||||||
|
function Taggable:_setVolume(volume)
|
||||||
|
self._volume = volume
|
||||||
|
self:_onChangeVolume()
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
_tag, _untag, and _setEffect are analogous to the
|
||||||
|
similarly named public API functions (see below), but
|
||||||
|
they don't call the _onChangeVolume and _onChangeEffects
|
||||||
|
callbacks. This allows me to have finer control over when
|
||||||
|
to call those callbacks, so I can set multiple tags and
|
||||||
|
effects without needlessly calling the callbacks for each
|
||||||
|
one.
|
||||||
|
]]
|
||||||
|
|
||||||
|
function Taggable:_tag(tag)
|
||||||
|
self._tags[tag] = true
|
||||||
|
tag._children[self] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:_untag(tag)
|
||||||
|
self._tags[tag] = nil
|
||||||
|
tag._children[self] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:_setEffect(name, filterSettings)
|
||||||
|
if filterSettings == nil then filterSettings = true end
|
||||||
|
self._effects[name] = filterSettings
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Given an options table, initializes the object's volume,
|
||||||
|
tags, and effects.
|
||||||
|
]]
|
||||||
|
function Taggable:_setOptions(options)
|
||||||
|
self.volume = options and options.volume or 1
|
||||||
|
-- reset tags
|
||||||
|
for tag in pairs(self._tags) do
|
||||||
|
self:_untag(tag)
|
||||||
|
end
|
||||||
|
-- apply new tags
|
||||||
|
if options and options.tags then
|
||||||
|
for _, tag in ipairs(options.tags) do
|
||||||
|
self:_tag(tag)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- reset effects
|
||||||
|
for name in pairs(self._effects) do
|
||||||
|
self._effects[name] = nil
|
||||||
|
end
|
||||||
|
-- apply new effects
|
||||||
|
if options and options.effects then
|
||||||
|
for name, filterSettings in pairs(options.effects) do
|
||||||
|
self:_setEffect(name, filterSettings)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- update final volume and effects
|
||||||
|
self:_onChangeVolume()
|
||||||
|
self:_onChangeEffects()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:tag(...)
|
||||||
|
for i = 1, select('#', ...) do
|
||||||
|
local tag = select(i, ...)
|
||||||
|
self:_tag(tag)
|
||||||
|
end
|
||||||
|
self:_onChangeVolume()
|
||||||
|
self:_onChangeEffects()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:untag(...)
|
||||||
|
for i = 1, select('#', ...) do
|
||||||
|
local tag = select(i, ...)
|
||||||
|
self:_untag(tag)
|
||||||
|
end
|
||||||
|
self:_onChangeVolume()
|
||||||
|
self:_onChangeEffects()
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Sets an effect for this object. filterSettings can be the following types:
|
||||||
|
- table - the effect will be enabled with the filter settings given in the table
|
||||||
|
- true/nil - the effect will be enabled with no filter
|
||||||
|
- false - the effect will be explicitly disabled, overriding effect settings
|
||||||
|
from a parent sound or tag
|
||||||
|
]]
|
||||||
|
function Taggable:setEffect(name, filterSettings)
|
||||||
|
self:_setEffect(name, filterSettings)
|
||||||
|
self:_onChangeEffects()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:removeEffect(name)
|
||||||
|
self._effects[name] = nil
|
||||||
|
self:_onChangeEffects()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:getEffect(name)
|
||||||
|
return self._effects[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:__index(key)
|
||||||
|
if key == 'volume' then
|
||||||
|
return self._volume
|
||||||
|
end
|
||||||
|
return Taggable[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
function Taggable:__newindex(key, value)
|
||||||
|
if key == 'volume' then
|
||||||
|
self:_setVolume(value)
|
||||||
|
else
|
||||||
|
rawset(self, key, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Represents a tag that can be applied to sounds,
|
||||||
|
instances of sounds, or other tags.
|
||||||
|
]]
|
||||||
|
local Tag = {__newindex = Taggable.__newindex}
|
||||||
|
|
||||||
|
function Tag:__index(key)
|
||||||
|
if Tag[key] then return Tag[key] end
|
||||||
|
return Taggable.__index(self, key)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Tag:_onChangeVolume()
|
||||||
|
-- tell objects using this tag about a potential
|
||||||
|
-- volume change
|
||||||
|
for child, _ in pairs(self._children) do
|
||||||
|
child:_onChangeVolume()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Tag:_onChangeEffect()
|
||||||
|
-- tell objects using this tag about a potential
|
||||||
|
-- effect change
|
||||||
|
for child, _ in pairs(self._children) do
|
||||||
|
child:_onChangeEffect()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Pauses all the sounds and instances tagged with this tag.
|
||||||
|
function Tag:pause(fadeDuration)
|
||||||
|
for child, _ in pairs(self._children) do
|
||||||
|
child:pause(fadeDuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Resumes all the sounds and instances tagged with this tag.
|
||||||
|
function Tag:resume(fadeDuration)
|
||||||
|
for child, _ in pairs(self._children) do
|
||||||
|
child:resume(fadeDuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Stops all the sounds and instances tagged with this tag.
|
||||||
|
function Tag:stop(fadeDuration)
|
||||||
|
for child, _ in pairs(self._children) do
|
||||||
|
child:stop(fadeDuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ripple.newTag(options)
|
||||||
|
local tag = setmetatable({
|
||||||
|
_effects = {},
|
||||||
|
_tags = {},
|
||||||
|
_children = {},
|
||||||
|
}, Tag)
|
||||||
|
tag:_setOptions(options)
|
||||||
|
return tag
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Represents a specific occurrence of a sound.
|
||||||
|
local Instance = {}
|
||||||
|
|
||||||
|
function Instance:__index(key)
|
||||||
|
if key == 'pitch' then
|
||||||
|
return self._source:getPitch()
|
||||||
|
elseif key == 'loop' then
|
||||||
|
return self._source:isLooping()
|
||||||
|
elseif Instance[key] then
|
||||||
|
return Instance[key]
|
||||||
|
end
|
||||||
|
return Taggable.__index(self, key)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:__newindex(key, value)
|
||||||
|
if key == 'pitch' then
|
||||||
|
self._source:setPitch(value)
|
||||||
|
elseif key == 'loop' then
|
||||||
|
self._source:setLooping(value)
|
||||||
|
else
|
||||||
|
Taggable.__newindex(self, key, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:_getTotalVolume()
|
||||||
|
local volume = Taggable._getTotalVolume(self)
|
||||||
|
-- apply sound volume as well as tag/self volumes
|
||||||
|
volume = volume * self._sound:_getTotalVolume()
|
||||||
|
-- apply fade volume
|
||||||
|
volume = volume * self._fadeVolume
|
||||||
|
return volume
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:_getAllEffects()
|
||||||
|
local effects = {}
|
||||||
|
for tag, _ in pairs(self._tags) do
|
||||||
|
for name, filterSettings in pairs(tag:_getAllEffects()) do
|
||||||
|
effects[name] = filterSettings
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- apply sound effects as well as tag/self effects
|
||||||
|
for name, filterSettings in pairs(self._sound:_getAllEffects()) do
|
||||||
|
effects[name] = filterSettings
|
||||||
|
end
|
||||||
|
for name, filterSettings in pairs(self._effects) do
|
||||||
|
effects[name] = filterSettings
|
||||||
|
end
|
||||||
|
return effects
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:_onChangeVolume()
|
||||||
|
-- update the source's volume
|
||||||
|
self._source:setVolume(self:_getTotalVolume())
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:_onChangeEffects()
|
||||||
|
-- get the list of effects that should be applied
|
||||||
|
local effects = self:_getAllEffects()
|
||||||
|
for name, filterSettings in pairs(effects) do
|
||||||
|
-- remember which effects are currently applied to the source
|
||||||
|
if filterSettings == false then
|
||||||
|
self._appliedEffects[name] = nil
|
||||||
|
else
|
||||||
|
self._appliedEffects[name] = true
|
||||||
|
end
|
||||||
|
if filterSettings == true then
|
||||||
|
self._source:setEffect(name)
|
||||||
|
else
|
||||||
|
self._source:setEffect(name, filterSettings)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- remove effects that are currently applied but shouldn't be anymore
|
||||||
|
for name in pairs(self._appliedEffects) do
|
||||||
|
if not effects[name] then
|
||||||
|
self._source:setEffect(name, false)
|
||||||
|
self._appliedEffects[name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:_play(options)
|
||||||
|
if options and options.fadeDuration then
|
||||||
|
self._fadeVolume = 0
|
||||||
|
self._fadeSpeed = 1 / options.fadeDuration
|
||||||
|
else
|
||||||
|
self._fadeVolume = 1
|
||||||
|
end
|
||||||
|
self._fadeDirection = 1
|
||||||
|
self._afterFadingOut = false
|
||||||
|
self._paused = false
|
||||||
|
self:_setOptions(options)
|
||||||
|
self.pitch = options and options.pitch or 1
|
||||||
|
if options and options.loop ~= nil then
|
||||||
|
self.loop = options.loop
|
||||||
|
end
|
||||||
|
if not web then self._source:seek(options and options.seek or 0) end
|
||||||
|
self._source:play()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:_update(dt)
|
||||||
|
-- fade in
|
||||||
|
if self._fadeDirection == 1 and self._fadeVolume < 1 then
|
||||||
|
self._fadeVolume = self._fadeVolume + self._fadeSpeed * dt
|
||||||
|
if self._fadeVolume > 1 then self._fadeVolume = 1 end
|
||||||
|
self:_onChangeVolume()
|
||||||
|
-- fade out
|
||||||
|
elseif self._fadeDirection == -1 and self._fadeVolume > 0 then
|
||||||
|
self._fadeVolume = self._fadeVolume - self._fadeSpeed * dt
|
||||||
|
if self._fadeVolume < 0 then
|
||||||
|
self._fadeVolume = 0
|
||||||
|
-- pause or stop after fading out
|
||||||
|
if self._afterFadingOut == 'pause' then
|
||||||
|
self:pause()
|
||||||
|
elseif self._afterFadingOut == 'stop' then
|
||||||
|
self:stop()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:_onChangeVolume()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:isStopped()
|
||||||
|
return (not self._source:isPlaying()) and (not self._paused)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:pause(fadeDuration)
|
||||||
|
if fadeDuration and not self._paused then
|
||||||
|
self._fadeDirection = -1
|
||||||
|
self._fadeSpeed = 1 / fadeDuration
|
||||||
|
self._afterFadingOut = 'pause'
|
||||||
|
else
|
||||||
|
self._source:pause()
|
||||||
|
self._paused = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:resume(fadeDuration)
|
||||||
|
if fadeDuration then
|
||||||
|
if self._paused then
|
||||||
|
self._fadeVolume = 0
|
||||||
|
self:_onChangeVolume()
|
||||||
|
end
|
||||||
|
self._fadeDirection = 1
|
||||||
|
self._fadeSpeed = 1 / fadeDuration
|
||||||
|
end
|
||||||
|
self._source:play()
|
||||||
|
self._paused = false
|
||||||
|
end
|
||||||
|
|
||||||
|
function Instance:stop(fadeDuration)
|
||||||
|
if fadeDuration and not self._paused then
|
||||||
|
self._fadeDirection = -1
|
||||||
|
self._fadeSpeed = 1 / fadeDuration
|
||||||
|
self._afterFadingOut = 'stop'
|
||||||
|
else
|
||||||
|
self._source:stop()
|
||||||
|
self._paused = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Represents a sound that can be played.
|
||||||
|
local Sound = {}
|
||||||
|
|
||||||
|
function Sound:__index(key)
|
||||||
|
if key == 'loop' then
|
||||||
|
return self._source:isLooping()
|
||||||
|
elseif Sound[key] then
|
||||||
|
return Sound[key]
|
||||||
|
end
|
||||||
|
return Taggable.__index(self, key)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:__newindex(key, value)
|
||||||
|
if key == 'loop' then
|
||||||
|
self._source:setLooping(value)
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
instance.loop = value
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Taggable.__newindex(self, key, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:_onChangeVolume()
|
||||||
|
-- tell instances about potential volume changes
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
instance:_onChangeVolume()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:_onChangeEffects()
|
||||||
|
-- tell instances about potential effect changes
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
instance:_onChangeEffects()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:play(options)
|
||||||
|
-- reuse a stopped instance if one is available
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
if instance:isStopped() then
|
||||||
|
instance:_play(options)
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- otherwise, create a brand new one
|
||||||
|
local instance = setmetatable({
|
||||||
|
_sound = self,
|
||||||
|
_source = self._source:clone(),
|
||||||
|
_effects = {},
|
||||||
|
_tags = {},
|
||||||
|
_appliedEffects = {},
|
||||||
|
}, Instance)
|
||||||
|
table.insert(self._instances, instance)
|
||||||
|
instance:_play(options)
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:pause(fadeDuration)
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
instance:pause(fadeDuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:resume(fadeDuration)
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
instance:resume(fadeDuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:stop(fadeDuration)
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
instance:stop(fadeDuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Sound:update(dt)
|
||||||
|
for _, instance in ipairs(self._instances) do
|
||||||
|
instance:_update(dt)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ripple.newSound(source, options)
|
||||||
|
local sound = setmetatable({
|
||||||
|
_source = source,
|
||||||
|
_effects = {},
|
||||||
|
_tags = {},
|
||||||
|
_instances = {},
|
||||||
|
}, Sound)
|
||||||
|
sound:_setOptions(options)
|
||||||
|
if options and options.loop then sound.loop = true end
|
||||||
|
return sound
|
||||||
|
end
|
||||||
|
|
||||||
|
return ripple
|
|
@ -0,0 +1,30 @@
|
||||||
|
-- The base Flashes class.
|
||||||
|
-- This class is used to manage all flashes in an object.
|
||||||
|
-- Add a new flash:
|
||||||
|
-- self.flashes:add('hit', 0.15)
|
||||||
|
-- Use it:
|
||||||
|
-- self.flashes.hit:flash(0.1)
|
||||||
|
-- self.flashes.hit.f -- a boolean that says if it's currently flashing or not
|
||||||
|
-- Every GameObject has a .flashes attribute with a Flashes instance attached to it.
|
||||||
|
Flashes = Object:extend()
|
||||||
|
function Flashes:init()
|
||||||
|
self.trigger = Trigger()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Flashes:update(dt)
|
||||||
|
self.trigger:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Adds a new flash to the object. The name must be unique and the second argument is the default duration for the flash.
|
||||||
|
-- self.flashes:add('hit', 0.15)
|
||||||
|
function Flashes:add(name, default_duration)
|
||||||
|
if name == 'parent' or name == 'names' or name == 'trigger' or name == 'add' or name == 'use' or name == 'update' or name == 'init' or name == 'pull' or name == 'flash' then
|
||||||
|
error("Invalid name to be added to the Flashes object. 'add', 'flash', 'init', 'names', 'parent', 'pull', 'trigger', 'update' and 'use' are reserved names, choose another.")
|
||||||
|
end
|
||||||
|
self[name] = {f = false, default_duration = default_duration or 0.15, flash = function(_, duration)
|
||||||
|
self[name].f = true
|
||||||
|
self.trigger:after(duration or self[name].default_duration, function() self[name].f = false end, name)
|
||||||
|
end}
|
||||||
|
end
|
|
@ -0,0 +1,78 @@
|
||||||
|
-- The base GameObject class.
|
||||||
|
-- The general way of creating an object that implements these functions goes like this:
|
||||||
|
--[[
|
||||||
|
MyGameObject = Object:extend()
|
||||||
|
MyGameObject:implement(GameObject)
|
||||||
|
function MyGameObject:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MyGameObject:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- This simply implements the GameObject class as a mixin into your own class, giving it the functions defined in this file as well as the attributes set from init_game_object.
|
||||||
|
-- In general you'd create your own game object like this, for instance:
|
||||||
|
-- group = Group()
|
||||||
|
-- MyGameObject{group = group, x = 100, y = 100, v = 100, r = math.pi/4}
|
||||||
|
-- And then this object would be automatically updated and drawn by the group.
|
||||||
|
-- Alternatively you could add the object to the group manually:
|
||||||
|
-- my_object = MyGameObject{x = 100, y = 100, v = 100, r = math.pi/4}
|
||||||
|
-- group:add(my_object)
|
||||||
|
-- One of the nice patterns I've found was a passing arguments as a key + value table.
|
||||||
|
-- So in the case above, the object would automatically have its .x, .y and .v attributes set to 100 and its .r attribute set to math.pi/4.
|
||||||
|
GameObject = Object:extend()
|
||||||
|
function GameObject:init_game_object(args)
|
||||||
|
for k, v in pairs(args or {}) do self[k] = v end
|
||||||
|
if self.group then self.group:add(self) end
|
||||||
|
self.x, self.y = self.x or 0, self.y or 0
|
||||||
|
self.r = self.r or 0
|
||||||
|
self.sx, self.sy = self.sx or 1, self.sy or 1
|
||||||
|
self.id = self.id or random:uid()
|
||||||
|
self.t = Trigger()
|
||||||
|
self.springs = Springs()
|
||||||
|
self.flashes = Flashes()
|
||||||
|
self.hfx = HitFX(self)
|
||||||
|
self.spring = Spring(1)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function GameObject:update_game_object(dt)
|
||||||
|
self.t:update(dt)
|
||||||
|
self.springs:update(dt)
|
||||||
|
self.flashes:update(dt)
|
||||||
|
self.hfx:update(dt)
|
||||||
|
self.spring:update(dt)
|
||||||
|
if self.body then self:update_physics(dt) end
|
||||||
|
|
||||||
|
if self.shape then
|
||||||
|
if self.shape.vertices and self.body then
|
||||||
|
self.shape.vertices = {self.body:getWorldPoints(self.fixture:getShape():getPoints())}
|
||||||
|
self.shape:get_centroid()
|
||||||
|
end
|
||||||
|
if self.body then
|
||||||
|
self.shape:move_to(self:get_position())
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.interact_with_mouse then
|
||||||
|
local colliding_with_mouse = self.shape:is_colliding_with_point(self.group:get_mouse_position())
|
||||||
|
if colliding_with_mouse and not self.colliding_with_mouse then
|
||||||
|
self.colliding_with_mouse = true
|
||||||
|
if self.on_mouse_enter then self:on_mouse_enter() end
|
||||||
|
elseif not colliding_with_mouse and self.colliding_with_mouse then
|
||||||
|
self.colliding_with_mouse = false
|
||||||
|
if self.on_mouse_exit then self:on_mouse_exit() end
|
||||||
|
end
|
||||||
|
if self.colliding_with_mouse then
|
||||||
|
if self.on_mouse_stay then self:on_mouse_stay() end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function GameObject:draw_game_object()
|
||||||
|
if self.body then self:draw_physics() end
|
||||||
|
end
|
|
@ -0,0 +1,410 @@
|
||||||
|
-- The Group class is responsible for object management.
|
||||||
|
-- A common usage is to create different groups for different "layers" of behavior in the game:
|
||||||
|
--[[
|
||||||
|
Game = Object:extend()
|
||||||
|
Game:implement(State)
|
||||||
|
function Game:on_enter()
|
||||||
|
self.main = Group():set_as_physics_world(192)
|
||||||
|
self.effects = Group()
|
||||||
|
self.floor = Group()
|
||||||
|
self.ui = Group():no_camera()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Game:update(dt)
|
||||||
|
self.main:update(dt)
|
||||||
|
self.floor:update(dt)
|
||||||
|
self.effects:update(dt)
|
||||||
|
self.ui:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Game:draw()
|
||||||
|
self.floor:draw()
|
||||||
|
self.main:sort_by_y()
|
||||||
|
self.main:draw()
|
||||||
|
self.effects:draw()
|
||||||
|
self.ui:draw()
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- This is a simple example where you have four groups, each for a different purpose.
|
||||||
|
-- The main group is where all gameplay objects are and thus the only one that's using the physics world (box2d).
|
||||||
|
-- If you need an object to collide with another physically then they have to use the same physics world, and thus also the same group.
|
||||||
|
-- The effects and floor groups are purely visual, one for drawing things on the floor (it's a top-down-ish 2.5D game), like shadows, and the other for drawing visual effects on top of everything else.
|
||||||
|
-- As you can see in the draw function, floor is drawn first and effects is drawn after all gameplay objects.
|
||||||
|
-- These three groups above also all use the game's main camera instance as their targets since we want gameplay objects, floor and visual effects to be drawn according to the camera's transform.
|
||||||
|
-- Finally, the UI group is the one that doesn't have a camera attached to it because we want its objects to be drawn in fixed locations on the screen.
|
||||||
|
-- And this group is also drawn last because generally UI elements go on top of literally everything else.
|
||||||
|
Group = Object:extend()
|
||||||
|
function Group:init()
|
||||||
|
self.t = Trigger()
|
||||||
|
self.camera = camera
|
||||||
|
self.objects = {}
|
||||||
|
self.objects.by_id = {}
|
||||||
|
self.objects.by_class = {}
|
||||||
|
self.cells = {}
|
||||||
|
self.cell_size = 128
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Group:update(dt)
|
||||||
|
self.t:update(dt)
|
||||||
|
for _, object in ipairs(self.objects) do object:update(dt) end
|
||||||
|
if self.world then self.world:update(dt) end
|
||||||
|
|
||||||
|
self.cells = {}
|
||||||
|
for _, object in ipairs(self.objects) do
|
||||||
|
local cx, cy = math.floor(object.x/self.cell_size), math.floor(object.y/self.cell_size)
|
||||||
|
if not self.cells[cx] then self.cells[cx] = {} end
|
||||||
|
if not self.cells[cx][cy] then self.cells[cx][cy] = {} end
|
||||||
|
table.insert(self.cells[cx][cy], object)
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = #self.objects, 1, -1 do
|
||||||
|
if self.objects[i].dead then
|
||||||
|
if self.objects[i].destroy then self.objects[i]:destroy() end
|
||||||
|
self.objects.by_id[self.objects[i].id] = nil
|
||||||
|
table.delete(self.objects.by_class[getmetatable(self.objects[i])], function(v) return v.id == self.objects[i].id end)
|
||||||
|
table.remove(self.objects, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- scroll_factor_x and scroll_factor_y can be used for parallaxing, they should be values between 0 and 1
|
||||||
|
-- The closer to 0, the more of a parallaxing effect there will be.
|
||||||
|
function Group:draw(scroll_factor_x, scroll_factor_y)
|
||||||
|
if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end
|
||||||
|
for _, object in ipairs(self.objects) do object:draw() end
|
||||||
|
if self.camera then self.camera:detach() end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws only objects within the indexed range
|
||||||
|
-- group:draw_range(1, 3) -> draws only 1st, 2nd and 3rd objects in this group
|
||||||
|
function Group:draw_range(i, j, scroll_factor_x, scroll_factor_y)
|
||||||
|
if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end
|
||||||
|
for k = i, j do self.objects[k]:draw() end
|
||||||
|
if self.camera then self.camera:detach() end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws only objects of a certain class
|
||||||
|
-- group:draw_class(Solid) -> draws only objects of the Solid class
|
||||||
|
function Group:draw_class(class, scroll_factor_x, scroll_factor_y)
|
||||||
|
if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end
|
||||||
|
for _, object in ipairs(self.objects) do
|
||||||
|
if object:is(class) then
|
||||||
|
object:draw()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if self.camera then self.camera:detach() end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws all objects except those of specified classes
|
||||||
|
-- group:draw_all_except({Solid, SolidGeometry}) -> draws all objects except those of the Solid and SolidGeometry classes
|
||||||
|
function Group:draw_all_except(classes, scroll_factor_x, scroll_factor_y)
|
||||||
|
if self.camera then self.camera:attach(scroll_factor_x, scroll_factor_y) end
|
||||||
|
for _, object in ipairs(self.objects) do
|
||||||
|
if not table.any(classes, function(v) return object:is(v) end) then
|
||||||
|
object:draw()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if self.camera then self.camera:detach() end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this group as one without a camera, useful for things like UIs
|
||||||
|
function Group:no_camera()
|
||||||
|
self.camera = nil
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sorts all objects in this group by their y position
|
||||||
|
-- This is useful for top-down 2.5D games so that objects further up on the screen are drawn first and look like they're further away from the camera
|
||||||
|
-- Objects can additionally have a .y_sort_offset attribute which gets added to this function's calculations
|
||||||
|
-- This attribute is useful for objects that are longer vertically and need some adjusting otherwise the point at which they get drawn behind looks off
|
||||||
|
function Group:sort_by_y()
|
||||||
|
table.sort(self.objects, function(a, b) return (a.y + (a.y_sort_offset or 0)) < (b.y + (b.y_sort_offset or 0)) end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the mouse position based on the camera used by this group
|
||||||
|
-- mx, my = group:get_mouse_position()
|
||||||
|
function Group:get_mouse_position()
|
||||||
|
if self.camera then
|
||||||
|
return self.camera.mouse.x, self.camera.mouse.y
|
||||||
|
else
|
||||||
|
local mx, my = love.mouse.getPosition()
|
||||||
|
return mx/sx, my/sy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Group:destroy()
|
||||||
|
for _, object in ipairs(self.objects) do object:destroy() end
|
||||||
|
self.objects = {}
|
||||||
|
self.objects.by_id = {}
|
||||||
|
self.objects.by_class = {}
|
||||||
|
if self.world then
|
||||||
|
self.world:destroy()
|
||||||
|
self.world = nil
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Adds an existing object to the group
|
||||||
|
-- player = Player{x = 160, y = 80}
|
||||||
|
-- group:add(player)
|
||||||
|
-- Creates an object and automatically add it to the group
|
||||||
|
-- player = Player{group = group, x = 160, y = 80}
|
||||||
|
-- The object has its .group attribute set to this group, and has a random .id set if it doesn't already have one
|
||||||
|
function Group:add(object)
|
||||||
|
local class = getmetatable(object)
|
||||||
|
object.group = self
|
||||||
|
if not object.id then object.id = random:uid() end
|
||||||
|
self.objects.by_id[object.id] = object
|
||||||
|
if not self.objects.by_class[class] then self.objects.by_class[class] = {} end
|
||||||
|
table.insert(self.objects.by_class[class], object)
|
||||||
|
table.insert(self.objects, object)
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns an object by its unique id
|
||||||
|
-- group:get_object_by_id(id) -> the object
|
||||||
|
function Group:get_object_by_id(id)
|
||||||
|
return self.objects.by_id[id]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the first object found after searching for it by property, the property value must be unique among all objects
|
||||||
|
-- group:get_object_by_property('special_id', 347762) -> the object
|
||||||
|
function Group:get_object_by_property(key, value)
|
||||||
|
for _, object in ipairs(self.objects) do
|
||||||
|
if object[key] == value then
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns an object after searching for it by properties with all of them matching, the property value match must be unique among all objects
|
||||||
|
-- group:get_object_by_properties({'special_id_1', 'special_id_2'}, {347762, 32452}) -> the object
|
||||||
|
function Group:get_object_by_properties(keys, values)
|
||||||
|
for _, object in ipairs(self.objects) do
|
||||||
|
local this_is_the_object = true
|
||||||
|
for i = 1, #keys do
|
||||||
|
if object[keys[i]] ~= values[i] then
|
||||||
|
this_is_the_object = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if this_is_the_object then
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns all objects of a specific class
|
||||||
|
-- group:get_objects_by_class(Star) -> all objects of class Star in a table
|
||||||
|
function Group:get_objects_by_class(class)
|
||||||
|
if not self.objects.by_class[class] then return {}
|
||||||
|
else return table.shallow_copy(self.objects.by_class[class]) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns all objects of the specified classes
|
||||||
|
-- group:get_objects_by_classes({Star, Enemy, Projectile}) -> all objects of class Star, Enemy or Projectile in a table
|
||||||
|
function Group:get_objects_by_classes(class_list)
|
||||||
|
local objects = {}
|
||||||
|
for _, class in ipairs(class_list) do table.insert(objects, self:get_objects_by_class(class)) end
|
||||||
|
return table.flatten(objects, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns all objects inside the shape, using its .x, .y attributes as the center and its .w, .h attributes as its bounding size.
|
||||||
|
-- If object_types is passed in then it only returns object of those classes.
|
||||||
|
-- The bounding size is used to select objects quickly and roughly, and then more specific and expensive collision methods are run on the objects returned from that selection.
|
||||||
|
-- group:get_objects_in_shape(Rectangle(player.x, player.y, 100, 100, player.r), {Enemy1, Enemy2}) -> all Enemy1 and Enemy2 instances in a 100x100 rotated rectangle around the player
|
||||||
|
-- group:get_objects_in_shape(Rectangle(player.x, player.y, 100, 100, player.r), {Enemy1, Enemy2}, {object_1, object_2}) -> same as above except excluding object instances object_1 and object_2
|
||||||
|
function Group:get_objects_in_shape(shape, object_types, exclude_list)
|
||||||
|
local out = {}
|
||||||
|
local exclude_list = exclude_list or {}
|
||||||
|
local cx1, cy1 = math.floor((shape.x-shape.w)/self.cell_size), math.floor((shape.y-shape.h)/self.cell_size)
|
||||||
|
local cx2, cy2 = math.floor((shape.x+shape.w)/self.cell_size), math.floor((shape.y+shape.h)/self.cell_size)
|
||||||
|
for i = cx1, cx2 do
|
||||||
|
for j = cy1, cy2 do
|
||||||
|
local cx, cy = i, j
|
||||||
|
if self.cells[cx] then
|
||||||
|
local cell_objects = self.cells[cx][cy]
|
||||||
|
if cell_objects then
|
||||||
|
for _, object in ipairs(cell_objects) do
|
||||||
|
if object_types then
|
||||||
|
if not table.any(exclude_list, function(v) return v.id == object.id end) then
|
||||||
|
if table.any(object_types, function(v) return object:is(v) end) and object.shape and object.shape:is_colliding_with_shape(shape) then
|
||||||
|
table.insert(out, object)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if object.shape and object:is_colliding_with_shape(shape) then
|
||||||
|
table.insert(out, object)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the closest object in this group to the object passed in
|
||||||
|
-- Optionally also pass in a function which will only allow objects that pass its test to be considered in the calculations
|
||||||
|
-- group:get_closest_object(player) -> closest object to the player, if the player is in this group then this object will be the player itself
|
||||||
|
-- group:get_closest_object(player, function(o) return o.id ~= player.id end) -> closest object to the player that isn't the player
|
||||||
|
function Group:get_closest_object(object, select_function)
|
||||||
|
if not select_function then select_function = function(o) return true end end
|
||||||
|
local min_distance, min_index = 100000, 0
|
||||||
|
for i, o in ipairs(self.objects) do
|
||||||
|
if select_function(o) then
|
||||||
|
local d = math.distance(o.x, o.y, object.x, object.y)
|
||||||
|
if d < min_distance then
|
||||||
|
min_distance = d
|
||||||
|
min_index = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self.objects[min_index]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this group as a physics box2d world
|
||||||
|
-- This means that objects inserted here can also be initialized as physics objects (see the gameobject file for more on this)
|
||||||
|
-- group:set_as_physics_world(192, 0, 400) -> a common platformer setup with vertical downward gravity
|
||||||
|
-- group:set_as_physics_world(192) -> a common setup for most non-platformer games
|
||||||
|
-- If your game takes place in smaller world coordinates (i.e. you set game_width and game_height to 320x240 or something) then you'll want smaller meter values, like 32 instead of 192
|
||||||
|
-- Read more on meter values for box2d worlds here: https://love2d.org/wiki/love.physics.setMeter
|
||||||
|
-- The last argument, tags, is a list of strings corresponding to collision tags that will be assigned to different objects, for instance:
|
||||||
|
-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost'})
|
||||||
|
-- As different physics objects have different collision behaviors in regards to one another, the tags created here will facilitate the delineation of those differences.
|
||||||
|
function Group:set_as_physics_world(meter, xg, yg, tags)
|
||||||
|
love.physics.setMeter(meter or 192)
|
||||||
|
self.tags = table.unify(table.push(tags, 'solid'))
|
||||||
|
self.collision_tags = {}
|
||||||
|
self.trigger_tags = {}
|
||||||
|
for i, tag in ipairs(self.tags) do
|
||||||
|
self.collision_tags[tag] = {category = i, masks = {}}
|
||||||
|
self.trigger_tags[tag] = {category = i, triggers = {}}
|
||||||
|
end
|
||||||
|
|
||||||
|
self.world = love.physics.newWorld(xg or 0, yg or 0)
|
||||||
|
self.world:setCallbacks(
|
||||||
|
function(fa, fb, c)
|
||||||
|
local oa, ob = self:get_object_by_id(fa:getUserData()), self:get_object_by_id(fb:getUserData())
|
||||||
|
if fa:isSensor() or fb:isSensor() then
|
||||||
|
if fa:isSensor() then if oa.on_trigger_enter then oa:on_trigger_enter(ob, c) end end
|
||||||
|
if fb:isSensor() then if ob.on_trigger_enter then ob:on_trigger_enter(oa, c) end end
|
||||||
|
else
|
||||||
|
if oa.on_collision_enter then oa:on_collision_enter(ob, c) end
|
||||||
|
if ob.on_collision_enter then ob:on_collision_enter(oa, c) end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
function(fa, fb, c)
|
||||||
|
local oa, ob = self:get_object_by_id(fa:getUserData()), self:get_object_by_id(fb:getUserData())
|
||||||
|
if fa:isSensor() or fb:isSensor() then
|
||||||
|
if fa:isSensor() then if oa.on_trigger_exit then oa:on_trigger_exit(ob, c) end end
|
||||||
|
if fb:isSensor() then if ob.on_trigger_exit then ob:on_trigger_exit(oa, c) end end
|
||||||
|
else
|
||||||
|
if oa.on_collision_exit then oa:on_collision_exit(ob, c) end
|
||||||
|
if ob.on_collision_exit then ob:on_collision_exit(oa, c) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Enables physical collision between objects of two tags
|
||||||
|
-- on_collision_enter and on_collision_exit callbacks will be called when objects of these two tags physically collide
|
||||||
|
-- By default, every object physically collides with every other object
|
||||||
|
-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost', 'solid'})
|
||||||
|
-- group:enable_collision_between('player', 'enemy')
|
||||||
|
function Group:enable_collision_between(tag1, tag2)
|
||||||
|
table.delete(self.collision_tags[tag1].masks, self.collision_tags[tag2].category)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Disables physical collision between objects of two tags
|
||||||
|
-- on_collision_enter and on_collision_exit callbacks will NOT be called when objects of these two tags pass through each other
|
||||||
|
-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost', 'solid'})
|
||||||
|
-- group:disable_collision_between('ghost', 'solid')
|
||||||
|
-- group:disable_collision_between('player', 'projectile')
|
||||||
|
function Group:disable_collision_between(tag1, tag2)
|
||||||
|
table.insert(self.collision_tags[tag1].masks, self.collision_tags[tag2].category)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Enables trigger collision between objects of two tags
|
||||||
|
-- When objects have physical collision disabled between one another, you might still want to have the engine generate enter and exit events when they start/stop overlapping
|
||||||
|
-- This is the function that makes that happen
|
||||||
|
-- group:set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'ghost', 'solid'})
|
||||||
|
-- group:disable_collision_between('ghost', 'solid')
|
||||||
|
-- group:enable_trigger_between('ghost', 'solid') -> now when a ghost passes through a solid, on_trigger_enter and on_trigger_exit will be called
|
||||||
|
function Group:enable_trigger_between(tag1, tag2)
|
||||||
|
table.insert(self.trigger_tags[tag1].triggers, self.trigger_tags[tag2].category)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Disables trigger collision between objects of two tags
|
||||||
|
-- This will only work if enable_trigger_between has been called for a pair of tags
|
||||||
|
-- In general you shouldn't use this, as trigger collisions are disabled by default for all objects
|
||||||
|
function Group:disable_trigger_between(tag1, tag2)
|
||||||
|
table.delete(self.trigger_tags[tag1].triggers, self.trigger_tags[tag2].category)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a table of all physics objects that collide with the segment passed in
|
||||||
|
-- This requires that the group is set as a physics world first and only works on objects initialized as physics objects (see gameobject file)
|
||||||
|
-- This function returns a table of hits, each hit is of the following format: {
|
||||||
|
-- x = hit's x position, y = hit's y position,
|
||||||
|
-- nx = hit's x normal, ny = hit's y normal,
|
||||||
|
-- fraction = a number from 0 to 1 representing the fraction of the segment where the hit happened,
|
||||||
|
-- other = the object hit by the segment
|
||||||
|
-- }
|
||||||
|
-- So if the following call group:raycast(100, 100, 800 800) hits 3 objects, it will return something like this: {
|
||||||
|
-- [1] = {x = ..., y = ..., nx = ..., ny = ..., fraction = ..., other = the 1st object hit},
|
||||||
|
-- [2] = {x = ..., y = ..., nx = ..., ny = ..., fraction = ..., other = the 2nd object hit},
|
||||||
|
-- [3] = {x = ..., y = ..., nx = ..., ny = ..., fraction = ..., other = the 3rd object hit},
|
||||||
|
-- }
|
||||||
|
-- Where ... just stands for some number.
|
||||||
|
function Group:raycast(x1, y1, x2, y2)
|
||||||
|
if not self.world then return end
|
||||||
|
|
||||||
|
self.raycast_hitlist = {}
|
||||||
|
self.world:rayCast(x1, y1, x2, y2, function(fixture, x, y, nx, ny, fraction)
|
||||||
|
local hit = {}
|
||||||
|
hit.fixture = fixture
|
||||||
|
hit.x, hit.y = x, y
|
||||||
|
hit.nx, hit.ny = nx, ny
|
||||||
|
hit.fraction = fraction
|
||||||
|
table.insert(self.raycast_hitlist, hit)
|
||||||
|
return 1
|
||||||
|
end)
|
||||||
|
|
||||||
|
local hits = {}
|
||||||
|
for _, hit in ipairs(self.raycast_hitlist) do
|
||||||
|
local obj = self:get_object_by_id(hit.fixture:getUserData())
|
||||||
|
hit.fixture = nil
|
||||||
|
hit.other = obj
|
||||||
|
table.insert(hits, hit)
|
||||||
|
end
|
||||||
|
|
||||||
|
return hits
|
||||||
|
end
|
|
@ -0,0 +1,58 @@
|
||||||
|
-- The base HitFX class.
|
||||||
|
-- Whenever an object is interacted with it's a good idea to either pull on a spring attached to its scale, or to flash it to signal that the interaction went through.
|
||||||
|
-- This is a combination of both Springs and Flashes put together to create that effect.
|
||||||
|
-- An instance of this called .hfx is added automatically to every game object.
|
||||||
|
-- Add a new effect:
|
||||||
|
-- self.hfx:add('hit')
|
||||||
|
-- Subsequent arguments are defaults for flashes and springs respectively, so:
|
||||||
|
-- self.hfx:add('hit', 0.15, 1, 200, 20)
|
||||||
|
-- Will add a flash with default duration of 0.15 and a spring with parameters 1, 200, 20.
|
||||||
|
-- Use the effect:
|
||||||
|
-- self.hfx:use('hit')
|
||||||
|
-- Subsequent arguments are the same as for the add function. This will call flash on the flash and pull on the spring.
|
||||||
|
-- Access its values:
|
||||||
|
-- self.hfx.hit.x -- the spring value
|
||||||
|
-- self.hfx.hit.f -- the flash boolean
|
||||||
|
HitFX = Object:extend()
|
||||||
|
function HitFX:init(parent)
|
||||||
|
self.parent = parent
|
||||||
|
self.names = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitFX:update(dt)
|
||||||
|
if not self.parent then return end
|
||||||
|
if self.parent and self.parent.dead then self.parent = nil; return end
|
||||||
|
|
||||||
|
for _, name in ipairs(self.names) do
|
||||||
|
self[name].x = self.parent.springs[name].x
|
||||||
|
self[name].f = self.parent.flashes[name].f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitFX:add(name, x, k, d, default_flash_duration)
|
||||||
|
if name == 'parent' or name == 'names' or name == 'trigger' or name == 'add' or name == 'use' or name == 'update' or name == 'init' or name == 'pull' or name == 'flash' then
|
||||||
|
error("Invalid name to be added to the HitFX object. 'add', 'flash', 'init', 'names', 'parent', 'pull', 'trigger', 'update' and 'use' are reserved names, choose another.")
|
||||||
|
end
|
||||||
|
self.parent.flashes:add(name, default_flash_duration)
|
||||||
|
self.parent.springs:add(name, x, k, d)
|
||||||
|
table.insert(self.names, name)
|
||||||
|
self[name] = {x = self.parent.springs[name].x, f = self.parent.flashes[name].f}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitFX:use(name, x, k, d, flash_duration)
|
||||||
|
self.parent.flashes[name]:flash(flash_duration)
|
||||||
|
self.parent.springs[name]:pull(x, k, d)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitFX:pull(name, ...)
|
||||||
|
self.parent.springs[name]:pull(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitFX:flash(name, ...)
|
||||||
|
self.parent.flashes[name]:flash(...)
|
||||||
|
end
|
|
@ -0,0 +1,109 @@
|
||||||
|
Input = Object:extend()
|
||||||
|
function Input:init(joystick_index)
|
||||||
|
self.mouse_buttons = {"m1", "m2", "m3", "m4", "m5", "wheel_up", "wheel_down"}
|
||||||
|
self.gamepad_buttons = {"fdown", "fup", "fleft", "fright", "dpdown", "dpup", "dpleft", "dpright", "start", "back", "guide", "leftstick", "rightstick", "rb", "lb"}
|
||||||
|
self.index_to_gamepad_button = {["a"] = "fdown", ["b"] = "fright", ["x"] = "fleft", ["y"] = "fup", ["back"] = "back", ["start"] = "start", ["guide"] = "guide", ["leftstick"] = "leftstick",
|
||||||
|
["rightstick"] = "rightstick", ["leftshoulder"] = "lb", ["rightshoulder"] = "rb", ["dpdown"] = "dpdown", ["dpup"] = "dpup", ["dpleft"] = "dpleft", ["dpright"] = "dpright",
|
||||||
|
}
|
||||||
|
self.index_to_gamepad_axis = {["leftx"] = "leftx", ["rightx"] = "rightx", ["lefty"] = "lefty", ["righty"] = "righty", ["triggerleft"] = "lt", ["triggerright"] = "rt"}
|
||||||
|
self.gamepad_axis = {}
|
||||||
|
self.joystick_index = joystick_index or 1
|
||||||
|
self.joystick = love.joystick.getJoysticks()[self.joystick_index]
|
||||||
|
self.keyboard_state = {}
|
||||||
|
self.previous_keyboard_state = {}
|
||||||
|
self.mouse_state = {}
|
||||||
|
self.previous_mouse_state = {}
|
||||||
|
self.gamepad_state = {}
|
||||||
|
self.previous_gamepad_state = {}
|
||||||
|
self.actions = {}
|
||||||
|
self.textinput_buffer = ''
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:update(dt)
|
||||||
|
for _, action in ipairs(self.actions) do
|
||||||
|
self[action].pressed = false
|
||||||
|
self[action].down = false
|
||||||
|
self[action].released = false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, action in ipairs(self.actions) do
|
||||||
|
for _, key in ipairs(self[action].keys) do
|
||||||
|
if table.contains(self.mouse_buttons, key) then
|
||||||
|
self[action].pressed = self[action].pressed or (self.mouse_state[key] and not self.previous_mouse_state[key])
|
||||||
|
self[action].down = self[action].down or self.mouse_state[key]
|
||||||
|
self[action].released = self[action].released or (not self.mouse_state[key] and self.previous_mouse_state[key])
|
||||||
|
elseif table.contains(self.gamepad_buttons, key) then
|
||||||
|
self[action].pressed = self[action].pressed or (self.gamepad_state[key] and not self.previous_gamepad_state[key])
|
||||||
|
self[action].down = self[action].down or self.gamepad_state[key]
|
||||||
|
self[action].released = self[action].released or (not self.gamepad_state[key] and self.previous_gamepad_state[key])
|
||||||
|
else
|
||||||
|
self[action].pressed = self[action].pressed or (self.keyboard_state[key] and not self.previous_keyboard_state[key])
|
||||||
|
self[action].down = self[action].down or self.keyboard_state[key]
|
||||||
|
self[action].released = self[action].released or (not self.keyboard_state[key] and self.previous_keyboard_state[key])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.previous_mouse_state = table.copy(self.mouse_state)
|
||||||
|
self.previous_gamepad_state = table.copy(self.gamepad_state)
|
||||||
|
self.previous_keyboard_state = table.copy(self.keyboard_state)
|
||||||
|
self.mouse_state.wheel_up = false
|
||||||
|
self.mouse_state.wheel_down = false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:set_mouse_grabbed(v)
|
||||||
|
love.mouse.setGrabbed(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:set_mouse_visible(v)
|
||||||
|
love.mouse.setVisible(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:bind(action, keys)
|
||||||
|
if not self[action] then self[action] = {} end
|
||||||
|
if type(keys) == "string" then self[action].keys = {keys}
|
||||||
|
elseif type(keys) == "table" then self[action].keys = keys end
|
||||||
|
table.insert(self.actions, action)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:unbind(action)
|
||||||
|
self[action] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:axis(key)
|
||||||
|
return self.gamepad_axis[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:textinput(text)
|
||||||
|
self.textinput_buffer = self.textinput_buffer .. text
|
||||||
|
return self.textinput_buffer
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:get_and_clear_textinput_buffer()
|
||||||
|
local buffer = self.textinput_buffer
|
||||||
|
self.textinput_buffer = ""
|
||||||
|
return buffer
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Input:bind_all()
|
||||||
|
-- Set direct input binds for every keyboard and mouse key
|
||||||
|
-- Mostly to be used if you want to skip the action system and refer to keys directly (i.e. for internal tools or menus that don't need their keys changed ever)
|
||||||
|
local keyboard_binds = {['a'] = {'a'}, ['b'] = {'b'}, ['c'] = {'c'}, ['d'] = {'d'}, ['e'] = {'e'}, ['f'] = {'f'}, ['g'] = {'g'}, ['h'] = {'h'}, ['i'] = {'i'}, ['j'] = {'j'}, ['k'] = {'k'}, ['l'] = {'l'}, ['m'] = {'m'}, ['n'] = {'n'}, ['o'] = {'o'}, ['p'] = {'p'}, ['q'] = {'q'}, ['r'] = {'r'}, ['s'] = {'s'}, ['t'] = {'t'}, ['u'] = {'u'}, ['v'] = {'v'}, ['w'] = {'w'}, ['x'] = {'x'}, ['y'] = {'y'}, ['z'] = {'z'}, ['0'] = {'0'}, ['1'] = {'1'}, ['2'] = {'2'}, ['3'] = {'3'}, ['4'] = {'4'}, ['5'] = {'5'}, ['6'] = {'6'}, ['7'] = {'7'}, ['8'] = {'8'}, ['9'] = {'9'}, ['space'] = {'space'}, ['!'] = {'!'}, ['"'] = {'"'}, ['#'] = {'#'}, ['$'] = {'$'}, ['&'] = {'&'}, ["'"] = {"'"}, ['('] = {'('}, [')'] = {')'}, ['*'] = {'*'}, ['+'] = {'+'}, [','] = {','}, ['-'] = {'-'}, ['.'] = {'.'}, ['/'] = {'/'}, [':'] = {':'}, [';'] = {';'}, ['kp0'] = {'kp0'}, ['kp1'] = {'kp1'}, ['kp2'] = {'kp2'}, ['kp3'] = {'kp3'}, ['kp4'] = {'kp4'}, ['kp5'] = {'kp5'}, ['kp6'] = {'kp6'}, ['kp7'] = {'kp7'}, ['kp8'] = {'kp8'}, ['kp9'] = {'kp9'}, ['kp.'] = {'kp.'}, ['kp,'] = {'kp,'}, ['kp/'] = {'kp/'}, ['kp*'] = {'kp*'}, ['kp-'] = {'kp-'}, ['kp+'] = {'kp+'}, ['kpenter'] = {'kpenter'}, ['kp='] = {'kp='}, ['up'] = {'up'}, ['down'] = {'down'}, ['right'] = {'right'}, ['left'] = {'left'}, ['home'] = {'home'}, ['pageup'] = {'pageup'}, ['pagedown'] = {'pagedown'}, ['insert'] = {'insert'}, ['backspace'] = {'backspace'}, ['tab'] = {'tab'}, ['clear'] = {'clear'}, ['return'] = {'return'}, ['delete'] = {'delete'}, ['f1'] = {'f1'}, ['f2'] = {'f2'}, ['f3'] = {'f3'}, ['f4'] = {'f4'}, ['f5'] = {'f5'}, ['f6'] = {'f6'}, ['f7'] = {'f7'}, ['f8'] = {'f8'}, ['f9'] = {'f9'}, ['f10'] = {'f10'}, ['f11'] = {'f11'}, ['f12'] = {'f12'}, ['f13'] = {'f13'}, ['f14'] = {'f14'}, ['f15'] = {'f15'}, ['f16'] = {'f16'}, ['f17'] = {'f17'}, ['f18'] = {'f18'}, ['numlock'] = {'numlock'}, ['capslock'] = {'capslock'}, ['scrolllock'] = {'scrolllock'}, ['rshift'] = {'rshift'}, ['lshift'] = {'lshift'}, ['rctrl'] = {'rctrl'}, ['lctrl'] = {'lctrl'}, ['ralt'] = {'ralt'}, ['lalt'] = {'lalt'}, ['rgui'] = {'rgui'}, ['lgui'] = {'lgui'}, ['mode'] = {'mode'}, ['escape'] = {'escape'}}
|
||||||
|
for k, v in pairs(keyboard_binds) do self:bind(k, v) end
|
||||||
|
self:bind('m1', {'m1'})
|
||||||
|
self:bind('m2', {'m2'})
|
||||||
|
self:bind('m3', {'m3'})
|
||||||
|
self:bind('m4', {'m4'})
|
||||||
|
self:bind('m5', {'m5'})
|
||||||
|
self:bind('wheel_up', {'wheel_up'})
|
||||||
|
self:bind('wheel_down', {'wheel_down'})
|
||||||
|
end
|
|
@ -0,0 +1,53 @@
|
||||||
|
Object = {}
|
||||||
|
Object.__index = Object
|
||||||
|
function Object:init()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Object:extend()
|
||||||
|
local cls = {}
|
||||||
|
for k, v in pairs(self) do
|
||||||
|
if k:find("__") == 1 then
|
||||||
|
cls[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cls.__index = cls
|
||||||
|
cls.super = self
|
||||||
|
setmetatable(cls, self)
|
||||||
|
return cls
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Object:implement(...)
|
||||||
|
for _, cls in pairs({...}) do
|
||||||
|
for k, v in pairs(cls) do
|
||||||
|
if self[k] == nil and type(v) == "function" then
|
||||||
|
self[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Object:is(T)
|
||||||
|
local mt = getmetatable(self)
|
||||||
|
while mt do
|
||||||
|
if mt == T then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
mt = getmetatable(mt)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Object:__tostring()
|
||||||
|
return "Object"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Object:__call(...)
|
||||||
|
local obj = setmetatable({}, self)
|
||||||
|
obj:init(...)
|
||||||
|
return obj
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
-- This useful to add to objects that need to have some kind of relationship with their parents.
|
||||||
|
-- Call the appropriate function in the object's update function every frame.
|
||||||
|
-- The game object must have a .parent attribute defined and pointing to another game object.
|
||||||
|
Parent = Object:extend()
|
||||||
|
|
||||||
|
|
||||||
|
-- Follows the parent's transform exclusively.
|
||||||
|
-- This means that if the parent dies the entity also dies.
|
||||||
|
-- The .parent attribute is niled on death.
|
||||||
|
function Parent:follow_parent_exclusively()
|
||||||
|
if self.parent and self.parent.dead then
|
||||||
|
self.parent = nil
|
||||||
|
self.dead = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.x, self.y = self.parent.x, self.parent.y
|
||||||
|
self.r = self.parent.r
|
||||||
|
self.sx, self.sy = self.parent.sx, self.parent.sy
|
||||||
|
end
|
|
@ -0,0 +1,662 @@
|
||||||
|
-- A physics mixin. Responsible for turning the game object it's attached to into a full fledged physics object.
|
||||||
|
-- Currently the only default way to add collision to objects is via this mixin.
|
||||||
|
-- In the future I want to create a way that doesn't make use of box2d for simpler games, but that also uses roughly the same API so that gameplay code doesn't have to be different regardless of which one you're using.
|
||||||
|
-- Using any of the "set_as" init functions requires the game object to have a group attached to it.
|
||||||
|
Physics = Object:extend()
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this object as a physics rectangle.
|
||||||
|
-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world.
|
||||||
|
-- Its .shape variable is set to a Rectangle instance and this instance is updated to be in sync with the physics body every frame.
|
||||||
|
function Physics:set_as_rectangle(w, h, body_type, tag)
|
||||||
|
if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end
|
||||||
|
self.tag = tag
|
||||||
|
self.shape = Rectangle(self.x, self.y, w, h)
|
||||||
|
self.body = love.physics.newBody(self.group.world, self.x, self.y, body_type or "dynamic")
|
||||||
|
local shape = love.physics.newRectangleShape(self.shape.w, self.shape.h)
|
||||||
|
self.fixture = love.physics.newFixture(self.body, shape)
|
||||||
|
self.fixture:setUserData(self.id)
|
||||||
|
self.fixture:setCategory(self.group.collision_tags[tag].category)
|
||||||
|
self.fixture:setMask(unpack(self.group.collision_tags[tag].masks))
|
||||||
|
if #self.group.trigger_tags[tag].triggers > 0 then
|
||||||
|
self.sensor = love.physics.newFixture(self.body, shape)
|
||||||
|
self.sensor:setUserData(self.id)
|
||||||
|
self.sensor:setSensor(true)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this object as a physics line.
|
||||||
|
-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world.
|
||||||
|
-- Its .shape variable is set to a Line instance and this instance is updated to be in sync with the physics body every frame.
|
||||||
|
function Physics:set_as_line(x1, y1, x2, y2, body_type, tag)
|
||||||
|
if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end
|
||||||
|
self.tag = tag
|
||||||
|
self.shape = Line(x1, y1, x2, y2)
|
||||||
|
self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic")
|
||||||
|
local shape = love.physics.newEdgeShape(self.shape.x1, self.shape.y1, self.shape.x2, self.shape.y2)
|
||||||
|
self.fixture = love.physics.newFixture(self.body, shape)
|
||||||
|
self.fixture:setUserData(self.id)
|
||||||
|
self.fixture:setCategory(self.group.collision_tags[tag].category)
|
||||||
|
self.fixture:setMask(unpack(self.group.collision_tags[tag].masks))
|
||||||
|
if #self.group.trigger_tags[tag].triggers > 0 then
|
||||||
|
self.sensor = love.physics.newFixture(self.body, shape)
|
||||||
|
self.sensor:setUserData(self.id)
|
||||||
|
self.sensor:setSensor(true)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this object as a physics chain (a collection of edges)
|
||||||
|
-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world.
|
||||||
|
-- If loop is set to true, then the collection of edges will be closed, forming a polygon. Otherwise it will be open.
|
||||||
|
-- Its .shape variable is set to a Chain instance and this instance is updated to be in sync with the physics body every frame.
|
||||||
|
function Physics:set_as_chain(loop, vertices, body_type, tag)
|
||||||
|
if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end
|
||||||
|
self.tag = tag
|
||||||
|
self.shape = Chain(loop, vertices)
|
||||||
|
self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic")
|
||||||
|
local shape = love.physics.newChainShape(self.shape.loop, self.shape.vertices)
|
||||||
|
self.fixture = love.physics.newFixture(self.body, shape)
|
||||||
|
self.fixture:setUserData(self.id)
|
||||||
|
self.fixture:setCategory(self.group.collision_tags[tag].category)
|
||||||
|
self.fixture:setMask(unpack(self.group.collision_tags[tag].masks))
|
||||||
|
if #self.group.trigger_tags[tag].triggers > 0 then
|
||||||
|
self.sensor = love.physics.newFixture(self.body, shape)
|
||||||
|
self.sensor:setUserData(self.id)
|
||||||
|
self.sensor:setSensor(true)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this object as a physics polygon.
|
||||||
|
-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world.
|
||||||
|
-- Its .shape variable is set to a Polygon instance and this instance is updated to be in sync with the physics body every frame.
|
||||||
|
function Physics:set_as_polygon(vertices, body_type, tag)
|
||||||
|
if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end
|
||||||
|
self.tag = tag
|
||||||
|
self.shape = Polygon(vertices)
|
||||||
|
self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic")
|
||||||
|
self.body:setPosition(self.x, self.y)
|
||||||
|
local shape = love.physics.newPolygonShape(self.shape.vertices)
|
||||||
|
self.fixture = love.physics.newFixture(self.body, shape)
|
||||||
|
self.fixture:setUserData(self.id)
|
||||||
|
self.fixture:setCategory(self.group.collision_tags[tag].category)
|
||||||
|
self.fixture:setMask(unpack(self.group.collision_tags[tag].masks))
|
||||||
|
if #self.group.trigger_tags[tag].triggers > 0 then
|
||||||
|
self.sensor = love.physics.newFixture(self.body, shape)
|
||||||
|
self.sensor:setUserData(self.id)
|
||||||
|
self.sensor:setSensor(true)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this object as a physics circle.
|
||||||
|
-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world.
|
||||||
|
-- Its .shape variable is set to a Circle instance and this instance is updated to be in sync with the physics body every frame.
|
||||||
|
function Physics:set_as_circle(rs, body_type, tag)
|
||||||
|
if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end
|
||||||
|
self.tag = tag
|
||||||
|
self.shape = Circle(self.x, self.y, rs)
|
||||||
|
self.body = love.physics.newBody(self.group.world, self.x, self.y, body_type or "dynamic")
|
||||||
|
local shape = love.physics.newCircleShape(self.shape.rs)
|
||||||
|
self.fixture = love.physics.newFixture(self.body, shape)
|
||||||
|
self.fixture:setUserData(self.id)
|
||||||
|
self.fixture:setCategory(self.group.collision_tags[tag].category)
|
||||||
|
self.fixture:setMask(unpack(self.group.collision_tags[tag].masks))
|
||||||
|
if #self.group.trigger_tags[tag].triggers > 0 then
|
||||||
|
self.sensor = love.physics.newFixture(self.body, shape)
|
||||||
|
self.sensor:setUserData(self.id)
|
||||||
|
self.sensor:setSensor(true)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this object as a physics triangle.
|
||||||
|
-- Its body_type can be either 'static', 'dynamic' or 'kinematic' (see box2d for more info) and its tag has to have been created in group:set_as_physics_world.
|
||||||
|
-- Its .shape variable is set to a Triangle instance and this instance is updated to be in sync with the physics body every frame.
|
||||||
|
function Physics:set_as_triangle(w, h, body_type, tag)
|
||||||
|
if not self.group then error("The GameObject must have a group defined for the Physics mixin to function") end
|
||||||
|
self.tag = tag
|
||||||
|
self.shape = Triangle(self.x, self.y, w, h)
|
||||||
|
self.body = love.physics.newBody(self.group.world, 0, 0, body_type or "dynamic")
|
||||||
|
self.body:setPosition(self.x, self.y)
|
||||||
|
local x1, y1 = h/2, 0
|
||||||
|
local x2, y2 = -h/2, -w/2
|
||||||
|
local x3, y3 = -h/2, w/2
|
||||||
|
local shape = love.physics.newPolygonShape({x1, y1, x2, y2, x3, y3})
|
||||||
|
self.fixture = love.physics.newFixture(self.body, shape)
|
||||||
|
self.fixture:setUserData(self.id)
|
||||||
|
self.fixture:setCategory(self.group.collision_tags[tag].category)
|
||||||
|
self.fixture:setMask(unpack(self.group.collision_tags[tag].masks))
|
||||||
|
if #self.group.trigger_tags[tag].triggers > 0 then
|
||||||
|
self.sensor = love.physics.newFixture(self.body, shape)
|
||||||
|
self.sensor:setUserData(self.id)
|
||||||
|
self.sensor:setSensor(true)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Automatically called by the group instance this game object belongs to whenever it dies.
|
||||||
|
function Physics:destroy()
|
||||||
|
if self.body then
|
||||||
|
if self.fixtures then for _, fixture in ipairs(self.fixtures) do fixture:destroy() end end
|
||||||
|
if self.sensors then for _, sensor in ipairs(self.sensors) do sensor:destroy() end end
|
||||||
|
if self.sensor and (self.sensor.type and self.sensor:type() == 'Fixture') then
|
||||||
|
self.sensor:destroy()
|
||||||
|
self.sensor = nil
|
||||||
|
end
|
||||||
|
self.fixture:destroy()
|
||||||
|
self.body:destroy()
|
||||||
|
self.fixture, self.body = nil, nil
|
||||||
|
if self.fixtures then self.fixtures = nil end
|
||||||
|
if self.sensors then self.sensors = nil end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Physics:draw_physics(color, line_width)
|
||||||
|
if self.shape then self.shape:draw(color, line_width or 4) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the angle from a point to this object
|
||||||
|
-- r = self:angle_from_point(player.x, player.y) -> angle from the player to this object
|
||||||
|
function Physics:angle_from_point(x, y)
|
||||||
|
return math.atan2(self.y - y, self.x - x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the angle from this object to another object
|
||||||
|
-- r = self:angle_to_object(player) -> angle from this object to the player
|
||||||
|
function Physics:angle_to_object(object)
|
||||||
|
return self:angle_to_point(object.x, object.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the angle from an object to this object
|
||||||
|
-- r = self:angle_from_object(player) -> angle from the player to this object
|
||||||
|
function Physics:angle_from_object(object)
|
||||||
|
return self:angle_from_point(object.x, object.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the angle from this object to the mouse
|
||||||
|
-- r = self:angle_to_mouse()
|
||||||
|
function Physics:angle_to_mouse()
|
||||||
|
local mx, my = self.group.camera:get_mouse_position()
|
||||||
|
return math.atan2(my - self.y, mx - self.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the distance from this object to a point
|
||||||
|
-- d = self:distance_to_point(player.x, player.y)
|
||||||
|
function Physics:distance_to_point(x, y)
|
||||||
|
return math.distance(self.x, self.y, x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the distance from an object to this object
|
||||||
|
-- d = self:distance_to_object(player)
|
||||||
|
function Physics:distance_to_object(object)
|
||||||
|
return math.distance(self.x, self.y, object.x, object.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the distance from this object to the mouse
|
||||||
|
-- d = self:angle_to_mouse()
|
||||||
|
function Physics:distance_to_mouse()
|
||||||
|
local mx, my = self.group.camera:get_mouse_position()
|
||||||
|
return math.distance(self.x, self.y, mx, my)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if this GameObject is colliding with the given point.
|
||||||
|
-- colliding = self:is_colliding_with_point(x, y)
|
||||||
|
function Physics:is_colliding_with_point(x, y)
|
||||||
|
return self:is_colliding_with_point(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if this GameObject is colliding with the mouse.
|
||||||
|
-- colliding = self:is_colliding_with_mouse()
|
||||||
|
function Physics:is_colliding_with_mouse()
|
||||||
|
return self:is_colliding_with_point(self.group.camera:get_mouse_position())
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if this GameObject is colliding with another GameObject.
|
||||||
|
-- Both must be physics objects set with one of the set_as_shape functions.
|
||||||
|
-- colliding = self:is_colliding_with_object(other)
|
||||||
|
function Physics:is_colliding_with_object(object)
|
||||||
|
return self:is_colliding_with_shape(object.shape)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if this GameObject is colliding with the given shape.
|
||||||
|
-- colliding = self:is_colliding_with_shape(shape)
|
||||||
|
function Physics:is_colliding_with_shape(shape)
|
||||||
|
return self.shape:is_colliding_with_shape(shape)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Exactly the same as group:get_objects_in_shape, except additionally it automatically removes this object from the results.
|
||||||
|
-- self:get_objects_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}) -> all objects of class Enemy1, Enemy2 and Enemy3 in a circle of radius 100 around this object
|
||||||
|
function Physics:get_objects_in_shape(shape, object_types)
|
||||||
|
return table.select(self.group:get_objects_in_shape(shape, object_types), function(v) return v.id ~= self.id end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the closest object to this object in the given shape, optionally excluding objects in the exclude list passed in.
|
||||||
|
-- self:get_closest_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}) -> closest object of class Enemy1, Enemy2 or Enemy3 in a circle of radius 100 around this object
|
||||||
|
-- self:get_closest_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}, {object_1, object_2}) -> same as above except excluding object instances object_1 and object_2
|
||||||
|
function Physics:get_closest_object_in_shape(shape, object_types, exclude_list)
|
||||||
|
local objects = self:get_objects_in_shape(shape, object_types)
|
||||||
|
local min_d, min_i = 1000000, 0
|
||||||
|
local exclude_list = exclude_list or {}
|
||||||
|
for i, object in ipairs(objects) do
|
||||||
|
if not table.any(exclude_list, function(v) return v.id == object.id end) then
|
||||||
|
local d = math.distance(self.x, self.y, object.x, object.y)
|
||||||
|
if d < min_d then
|
||||||
|
min_d = d
|
||||||
|
min_i = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if i ~= 0 then return objects[min_i] end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a random object in the given shape, excluding this object and also optionally excluding objects in the exclude list passed in.
|
||||||
|
-- self:get_random_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}) -> random object of class Enemy1, Enemy2 or Enemy3 in a circle of radius 100 around this object
|
||||||
|
-- self:get_random_object_in_shape(Circle(self.x, self.y, 100), {Enemy1, Enemy2, Enemy3}, {object_1, object_2}) -> same as above except excluding object instances object_1 and object_2
|
||||||
|
function Physics:get_random_object_in_shape(shape, object_types, exclude_list)
|
||||||
|
local objects = self:get_objects_in_shape(shape, object_types)
|
||||||
|
local exclude_list = exclude_list or {}
|
||||||
|
local random_object = random:table(objects)
|
||||||
|
local tries = 0
|
||||||
|
if random_object then
|
||||||
|
while table.any(exclude_list, function(v) return v.id == random_object.id end) and tries < 20 do
|
||||||
|
random_object = random:table(objects)
|
||||||
|
tries = tries + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return random_object
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Physics:update_physics(dt)
|
||||||
|
self:update_position()
|
||||||
|
self:steering_update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Updates the .x, .y attributes of this object, useful to call before drawing something if you need its position as recent as position
|
||||||
|
-- self:update_position()
|
||||||
|
function Physics:update_position()
|
||||||
|
if self.body then self.x, self.y = self.body:getPosition() end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's position directly, avoid using if you need velocity/acceleration calculations to make sense and be accurate, as teleporting the object around messes up its physics
|
||||||
|
-- self:set_position(100, 100)
|
||||||
|
function Physics:set_position(x, y)
|
||||||
|
if self.body then self.body:setPosition(x, y) end
|
||||||
|
return self:update_position()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the object's position as two values
|
||||||
|
-- x, y = self:get_position()
|
||||||
|
function Physics:get_position()
|
||||||
|
self:update_position()
|
||||||
|
if self.body then return self.body:getPosition() end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object as a bullet
|
||||||
|
-- Bullets will collide and generate proper collision responses regardless of their velocity, despite being more expensive to calculate
|
||||||
|
-- self:set_bullet(true)
|
||||||
|
function Physics:set_bullet(v)
|
||||||
|
if self.body then self.body:setBullet(v) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object to have fixed rotation
|
||||||
|
-- When box2d objects don't have fixed rotation, whenever they collide with other objects they will rotate around depending on where the collision happened
|
||||||
|
-- Setting this to true prevents that from happening, useful for every type of game where you don't need accurate physics responses in terms of the characters rotation
|
||||||
|
-- self:set_fixed_rotation(true)
|
||||||
|
function Physics:set_fixed_rotation(v)
|
||||||
|
self.fixed_rotation = v
|
||||||
|
if self.body then self.body:setFixedRotation(v) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's velocity
|
||||||
|
-- self:set_velocity(100, 100)
|
||||||
|
function Physics:set_velocity(vx, vy)
|
||||||
|
if self.body then self.body:setLinearVelocity(vx, vy) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the object's velocity as two values
|
||||||
|
-- vx, vy = self:get_velocity()
|
||||||
|
function Physics:get_velocity()
|
||||||
|
if self.body then return self.body:getLinearVelocity() end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's damping
|
||||||
|
-- The higher this value, the more the object will resist movement and the faster it will stop moving after forces are applied to it
|
||||||
|
-- self:set_damping(10)
|
||||||
|
function Physics:set_damping(v)
|
||||||
|
if self.body then self.body:setLinearDamping(v) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's angular velocity
|
||||||
|
-- If set_fixed_rotation is set to true then this will do nothing
|
||||||
|
-- self:set_angular_velocity(math.pi/4)
|
||||||
|
function Physics:set_angular_velocity(v)
|
||||||
|
if self.body then self.body:setAngularVelocity(v) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's angular damping
|
||||||
|
-- The higher this value, the more the object will resist rotation and the faster it will stop rotating after angular forces are applied to it
|
||||||
|
-- self:set_angular_damping(10)
|
||||||
|
function Physics:set_angular_damping(v)
|
||||||
|
if self.body then self.body:setAngularDamping(v) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the object's angle
|
||||||
|
-- r = self:get_angle()
|
||||||
|
function Physics:get_angle()
|
||||||
|
if self.body then return self.body:getAngle() end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's angle
|
||||||
|
-- If set_fixed_rotation is set to true then this will do nothing
|
||||||
|
-- self:set_angle(math.pi/8)
|
||||||
|
function Physics:set_angle(v)
|
||||||
|
if self.body then self.body:setAngle(v) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's restitution
|
||||||
|
-- This is a value from 0 to 1 and the higher it is the more energy the object will conserve when bouncing off other objects
|
||||||
|
-- At 1, it will bounce perfectly and not lose any velocity
|
||||||
|
-- At 0, it will not bounce at all
|
||||||
|
-- self:set_restitution(0.75)
|
||||||
|
function Physics:set_restitution(v)
|
||||||
|
if self.fixture then
|
||||||
|
self.fixture:setRestitution(v)
|
||||||
|
elseif self.fixtures then
|
||||||
|
for _, fixture in ipairs(self.fixtures) do
|
||||||
|
fixture:setRestitution(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's friction
|
||||||
|
-- This is a value from 0 to infinity, but generally between 0 and 1, the higher it is the more friction there will be when this object slides with another
|
||||||
|
-- At 0 friction is turned off and the object will slide with no resistance
|
||||||
|
-- The friction calculation takes into account the friction of both objects sliding on one another, so if one object has friction set to 0 then it will treat the interaction as if there's no friction
|
||||||
|
-- self:set_friction(1)
|
||||||
|
function Physics:set_friction(v)
|
||||||
|
if self.fixture then
|
||||||
|
self.fixture:setFriction(v)
|
||||||
|
elseif self.fixtures then
|
||||||
|
for _, fixture in ipairs(self.fixtures) do
|
||||||
|
fixture:setFriction(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies an instantaneous amount of force to the object
|
||||||
|
-- self:apply_impulse(100*math.cos(angle), 100*math.sin(angle))
|
||||||
|
function Physics:apply_impulse(fx, fy)
|
||||||
|
if self.body then self.body:applyLinearImpulse(fx, fy) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies an instantaneous amount of angular force to the object
|
||||||
|
-- self:apply_angular_impulse(8*math.pi)
|
||||||
|
function Physics:apply_angular_impulse(f)
|
||||||
|
if self.body then self.body:applyAngularImpulse(f) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies a continuous amount of force to the object
|
||||||
|
-- self:apply_force(100*math.cos(angle), 100*math.sin(angle))
|
||||||
|
function Physics:apply_force(fx, fy, x, y)
|
||||||
|
if self.body then self.body:applyForce(fx, fy, x, y) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Applies torque to the object
|
||||||
|
-- self:apply_torque(math.pi)
|
||||||
|
function Physics:apply_torque(t)
|
||||||
|
if self.body then self.body:applyTorque(t) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's mass
|
||||||
|
-- self:set_mass(1000)
|
||||||
|
function Physics:set_mass(mass)
|
||||||
|
if self.body then self.body:setMass(mass) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object's gravity scale
|
||||||
|
-- This is a simple multiplier on the world's gravity, but applied only to this object
|
||||||
|
function Physics:set_gravity_scale(v)
|
||||||
|
if self.body then self.body:setGravityScale(v) end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Locks the object horizontally, meaning it can never move up or down.
|
||||||
|
-- self:lock_horizontally()
|
||||||
|
function Physics:lock_horizontally()
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
self:set_velocity(vx, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Locks the object vertically, meaning it can never move left or right.
|
||||||
|
-- self:lock_vertically()
|
||||||
|
function Physics:lock_vertically()
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
self:set_velocity(0, vy)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Moves this object towards another object
|
||||||
|
-- You can either do this by using the speed argument directly, or by using the max_time argument
|
||||||
|
-- max_time will override speed since it will make it so that the object reaches the target in a given time
|
||||||
|
-- self:move_towards_object(player, 40) -> moves towards the player with 40 speed
|
||||||
|
-- self:move_towards_object(player, nil, 2) -> moves towards the player with speed such that it would reach him in 2 seconds if he never moved
|
||||||
|
function Physics:move_towards_object(object, speed, max_time)
|
||||||
|
if max_time then speed = self:distance_to_point(object.x, object.y)/max_time end
|
||||||
|
local r = self:angle_to_point(object.x, object.y)
|
||||||
|
self:set_velocity(speed*math.cos(r), speed*math.sin(r))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as move_towards_object except towards a point
|
||||||
|
-- self:move_towards_point(player.x, player.y, 40)
|
||||||
|
function Physics:move_towards_point(x, y, speed, max_time)
|
||||||
|
if max_time then speed = self:distance_to_point(x, y)/max_time end
|
||||||
|
local r = self:angle_to_point(x, y)
|
||||||
|
self:set_velocity(speed*math.cos(r), speed*math.sin(r))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as move_towards_object and move_towards_point except towards the mouse
|
||||||
|
-- self:move_towards_mouse(nil, 1)
|
||||||
|
function Physics:move_towards_mouse(speed, max_time)
|
||||||
|
if max_time then speed = self:distance_to_mouse()/max_time end
|
||||||
|
local r = self:angle_to_mouse()
|
||||||
|
self:set_velocity(speed*math.cos(r), speed*math.sin(r))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as move_towards_mouse but does so only on the x axis
|
||||||
|
-- self:move_towards_mouse_horizontally(nil, 1)
|
||||||
|
function Physics:move_towards_mouse_horizontally(speed, max_time)
|
||||||
|
if max_time then speed = self:distance_to_mouse()/max_time end
|
||||||
|
local r = self:angle_to_mouse()
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
self:set_velocity(speed*math.cos(r), vy)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as move_towards_mouse but does so only on the y axis
|
||||||
|
-- self:move_towards_mouse_vertically(nil, 1)
|
||||||
|
function Physics:move_towards_mouse_vertically(speed, max_time)
|
||||||
|
if max_time then speed = self:distance_to_mouse()/max_time end
|
||||||
|
local r = self:angle_to_mouse()
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
self:set_velocity(vx, speed*math.sin(r))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Moves the object along an angle, most useful for simple projectiles that don't need any complex movements
|
||||||
|
-- self:move_along_angle(100, math.pi/4)
|
||||||
|
function Physics:move_along_angle(speed, r)
|
||||||
|
self:set_velocity(speed*math.cos(r), speed*math.sin(r))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rotates the object towards another object using a rotational lerp, which is a value from 0 to 1
|
||||||
|
-- Higher values will rotate the object faster, lower values will make the turn have a smooth delay to it
|
||||||
|
-- self:rotate_towards_object(player, 0.2)
|
||||||
|
function Physics:rotate_towards_object(object, lerp_value)
|
||||||
|
self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_point(object.x, object.y)))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as rotate_towards_object except towards a point
|
||||||
|
-- self:rotate_towards_point(player.x, player.y, 0.2)
|
||||||
|
function Physics:rotate_towards_point(x, y, lerp_value)
|
||||||
|
self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_point(x, y)))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as rotate_towards_object and rotate_towards_point except towards the mouse
|
||||||
|
-- self:rotate_towards_mouse(0.2)
|
||||||
|
function Physics:rotate_towards_mouse(lerp_value)
|
||||||
|
self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_mouse()))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rotates the object towards its own velocity vector using a rotational lerp, which is a value from 0 to 1
|
||||||
|
-- Higher values will rotate the object faster, lower values will make the turn have a smooth delay to it
|
||||||
|
-- self:rotate_towards_velocity(0.2)
|
||||||
|
function Physics:rotate_towards_velocity(lerp_value)
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
self:set_angle(math.lerp_angle(lerp_value, self:get_angle(), self:angle_to_point(self.x + vx, self.y + vy)))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as accelerate_towards_object except towards a point
|
||||||
|
-- self:accelerate_towards_object(player.x, player.y, 100, 10, 2)
|
||||||
|
function Physics:accelerate_towards_point(x, y, max_speed, deceleration, turn_coefficient)
|
||||||
|
local tx, ty = x - self.x, y - self.y
|
||||||
|
local d = math.length(tx, ty)
|
||||||
|
if d > 0 then
|
||||||
|
local speed = d/((deceleration or 1)*0.08)
|
||||||
|
speed = math.min(speed, max_speed)
|
||||||
|
local current_vx, current_vy = speed*tx/d, speed*ty/d
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
self:apply_force((current_vx - vx)*(turn_coefficient or 1), (current_vy - vy)*(turn_coefficient or 1))
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Accelerates the object towards another object
|
||||||
|
-- Other than the object, the 3 arguments available are:
|
||||||
|
-- max_speed - the maximum speed the object can have in this acceleration
|
||||||
|
-- deceleration - how fast the object will decelerate once it gets closer to the target, higher values will make the deceleration more abrupt, do not make this value 0
|
||||||
|
-- turn_coefficient - how strong is the turning force for this object, higher values will make it turn faster
|
||||||
|
-- self:accelerate_towards_object(player, 100, 10, 2)
|
||||||
|
function Physics:accelerate_towards_object(object, max_speed, deceleration, turn_coefficient)
|
||||||
|
return self:accelerate_towards_point(object.x, object.y, max_speed, deceleration, turn_coefficient)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as accelerate_towards_object and accelerate_towards_point but towards the mouse
|
||||||
|
-- self:accelerate_towards_mouse(100, 10, 2)
|
||||||
|
function Physics:accelerate_towards_mouse(max_speed, deceleration, turn_coefficient)
|
||||||
|
local mx, my = self.group.camera:get_mouse_position()
|
||||||
|
return self:accelerate_towards_point(mx, my, max_speed, deceleration, turn_coefficient)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Keeps this object separated from other objects of specific classes according to the radius passed in
|
||||||
|
-- What this function does is simply look at all nearby objects and apply forces to this object such that it remains separated from them
|
||||||
|
-- self:separate(40, {Enemy}) -> when this is called every frame, this applies forces to this object to keep it separated from other Enemy instances by 40 units at all times
|
||||||
|
function Physics:separate(rs, class_avoid_list)
|
||||||
|
local fx, fy = 0, 0
|
||||||
|
local objects = table.flatten(table.foreachn(class_avoid_list, function(v) return self.group:get_objects_by_class(v) end), true)
|
||||||
|
for _, object in ipairs(objects) do
|
||||||
|
if object.id ~= self.id and math.distance(object.x, object.y, self.x, self.y) < 2*rs then
|
||||||
|
local tx, ty = self.x - object.x, self.y - object.y
|
||||||
|
local n = Vector(tx, ty):normalize()
|
||||||
|
local l = n:length()
|
||||||
|
fx = fx + rs*(n.x/l)
|
||||||
|
fy = fy + rs*(n.y/l)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:apply_force(fx, fy)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the angle from this object to a point
|
||||||
|
-- r = self:angle_to_point(player.x, player.y) -> angle from this object to the player
|
||||||
|
function Physics:angle_to_point(x, y)
|
||||||
|
return math.atan2(y - self.y, x - self.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the object as a steerable object.
|
||||||
|
-- The implementation of steering behaviors here mostly follows the one from chapter 3 of the book "Programming Game AI by Example"
|
||||||
|
-- https://github.com/wangchen/Programming-Game-AI-by-Example-src
|
|
@ -0,0 +1,32 @@
|
||||||
|
-- The base Springs class.
|
||||||
|
-- This class is used to manage all springs in an object.
|
||||||
|
-- Add a new spring:
|
||||||
|
-- self.springs:add('hit', 1)
|
||||||
|
-- Use it:
|
||||||
|
-- self.springs.hit:pull(0.2)
|
||||||
|
-- self.springs.hit.x
|
||||||
|
-- Every GameObject has a .springs attribute with a Springs instance attached to it.
|
||||||
|
-- See engine/game/hit
|
||||||
|
Springs = Object:extend()
|
||||||
|
function Springs:init()
|
||||||
|
self.names = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Springs:update(dt)
|
||||||
|
for _, name in ipairs(self.names) do
|
||||||
|
self[name]:update(dt)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Adds a new spring to the object. The name must be unique and the next arguments are the same
|
||||||
|
-- as the arguments for creating a spring, see engine/math/spring.lua.
|
||||||
|
-- self.springs:add('hit', 1)
|
||||||
|
function Springs:add(name, x, k, d)
|
||||||
|
if name == 'parent' or name == 'names' or name == 'trigger' or name == 'add' or name == 'use' or name == 'update' or name == 'init' or name == 'pull' or name == 'flash' then
|
||||||
|
error("Invalid name to be added to the Springs object. 'add', 'flash', 'init', 'names', 'parent', 'pull', 'trigger', 'update' and 'use' are reserved names, choose another.")
|
||||||
|
end
|
||||||
|
self[name] = Spring(x, k, d)
|
||||||
|
table.insert(self.names, name)
|
||||||
|
end
|
|
@ -0,0 +1,114 @@
|
||||||
|
-- The base State class.
|
||||||
|
-- The general way of creating an object that implements these functions goes like this:
|
||||||
|
--[[
|
||||||
|
MyState = Object:extend()
|
||||||
|
MyState:implement(State)
|
||||||
|
function MyState:init(name)
|
||||||
|
self:init_state(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MyState:on_enter(from)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function MyState:update(dt)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function MyState:draw()
|
||||||
|
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- This creates a new MyState class which you can then use to start writing your code.
|
||||||
|
-- Use the init function for things you need to do when the state object is created.
|
||||||
|
-- Use the on_enter function for things you need to do whenever the state gets activated.
|
||||||
|
-- By default, whenever a state gets deactivated it's not deleted from memory, so if you want to restart a level, for instance, whenever you switch states,
|
||||||
|
-- then you need to destroy everything that needs to be destroyed in an on_exit function and then recreate it again in the on_enter function.
|
||||||
|
--
|
||||||
|
-- You'd add a state to the game like this:
|
||||||
|
-- state.add(MyState'level_1')
|
||||||
|
-- You'd move to that state like so:
|
||||||
|
-- state.go_to'level_1'
|
||||||
|
-- state.go_to automatically calls on_exit for the currently active state and on_enter for the new one.
|
||||||
|
-- You can access the currently active state with state.current.
|
||||||
|
State = Object:extend()
|
||||||
|
function State:init_state(name)
|
||||||
|
self.name = name or random:uid()
|
||||||
|
self.active = false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function State:enter(from)
|
||||||
|
self.active = true
|
||||||
|
if self.on_enter then self:on_enter(from) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function State:exit(to)
|
||||||
|
self.active = false
|
||||||
|
if self.on_exit then self:on_exit(to) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- The main state. This is a global state that is always active and contains all other states.
|
||||||
|
Main = Object:extend()
|
||||||
|
Main:implement(State)
|
||||||
|
function Main:init(name)
|
||||||
|
self:init_state(name)
|
||||||
|
self.states = {}
|
||||||
|
self.transitions = Group():no_camera()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Main:update(dt)
|
||||||
|
for _, state in pairs(self.states) do
|
||||||
|
if state.active or state.persistent_update then
|
||||||
|
state:update(dt)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.transitions:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Main:draw()
|
||||||
|
for _, state in pairs(self.states) do
|
||||||
|
if state.active or state.persistent_draw then
|
||||||
|
state:draw()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.transitions:draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Main:add(state)
|
||||||
|
self.states[state.name] = state
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Main:get(state_name)
|
||||||
|
return self.states[state_name]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Deactivates the current active state and activates the target one.
|
||||||
|
-- Calls on_exit for the deactivated state and on_enter for the activated one.
|
||||||
|
-- If on_exit returns true then the deactivated state will be removed from memory.
|
||||||
|
-- You must handle the destruction of it yourself in its on_exit function.
|
||||||
|
function Main:go_to(state, ...)
|
||||||
|
if type(state) == 'string' then state = self:get(state) end
|
||||||
|
|
||||||
|
if self.current then
|
||||||
|
if self.current.active then
|
||||||
|
if self.current:exit(state) then
|
||||||
|
self.states[state.name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local last_state = self.current
|
||||||
|
self.current = state
|
||||||
|
state:enter(last_state, ...)
|
||||||
|
end
|
|
@ -0,0 +1,260 @@
|
||||||
|
-- Sets the object as a steerable object.
|
||||||
|
-- This is implemented in the Physics mixin because it plays well with the rest of it, thus, to make a game object steerable it needs to implement the Physics mixin.
|
||||||
|
-- The implementation of steering behaviors here mostly follows the one from chapter 3 of the book "Programming Game AI by Example"
|
||||||
|
-- https://github.com/wangchen/Programming-Game-AI-by-Example-src
|
||||||
|
-- self:set_as_steerable(100, 1000)
|
||||||
|
function Physics:set_as_steerable(max_v, max_f, max_turn_rate, turn_multiplier)
|
||||||
|
self.steerable = true
|
||||||
|
self.heading = Vector()
|
||||||
|
self.side = Vector()
|
||||||
|
self.mass = 1
|
||||||
|
self.max_v = max_v or 100
|
||||||
|
self.max_f = max_f or 2000
|
||||||
|
self.max_turn_rate = max_turn_rate or 2*math.pi
|
||||||
|
self.turn_multiplier = turn_multiplier or 2
|
||||||
|
self.seek_f = Vector()
|
||||||
|
self.flee_f = Vector()
|
||||||
|
self.pursuit_f = Vector()
|
||||||
|
self.evade_f = Vector()
|
||||||
|
self.wander_f = Vector()
|
||||||
|
local r = random:float(0, 2*math.pi)
|
||||||
|
self.wander_target = Vector(40*math.cos(r), 40*math.sin(r))
|
||||||
|
self.path_follow_f = Vector()
|
||||||
|
self.separation_f = Vector()
|
||||||
|
self.alignment_f = Vector()
|
||||||
|
self.cohesion_f = Vector()
|
||||||
|
self.apply_force_f = Vector()
|
||||||
|
self.apply_impulse_f = Vector()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Physics:steering_update(dt)
|
||||||
|
if self.steerable then
|
||||||
|
local steering_force = self:calculate_steering_force(dt):div(self.mass)
|
||||||
|
self:apply_force(steering_force.x, steering_force.y)
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
local v = Vector(vx, vy):truncate(self.max_v)
|
||||||
|
self:set_velocity(v.x, v.y)
|
||||||
|
if v:length_squared() > 0.00001 then
|
||||||
|
self.heading = self.v:clone():normalize()
|
||||||
|
self.side = self.heading:perpendicular()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Physics:calculate_steering_force(dt)
|
||||||
|
local steering_force = Vector(0, 0)
|
||||||
|
if self.seeking then steering_force:add(self.seek_f) end
|
||||||
|
if self.fleeing then steering_force:add(self.flee_f) end
|
||||||
|
if self.pursuing then steering_force:add(self.pursuit_f) end
|
||||||
|
if self.evading then steering_force:add(self.evade_f) end
|
||||||
|
if self.wandering then steering_force:add(self.wander_f) end
|
||||||
|
if self.path_following then steering_force:add(self.path_follow_f) end
|
||||||
|
if self.separating then steering_force:add(self.separation_f) end
|
||||||
|
if self.aligning then steering_force:add(self.alignment_f) end
|
||||||
|
if self.cohesing then steering_force:add(self.cohesion_f) end
|
||||||
|
self.seeking = false
|
||||||
|
self.fleeing = false
|
||||||
|
self.pursuing = false
|
||||||
|
self.evading = false
|
||||||
|
self.wandering = false
|
||||||
|
self.path_following = false
|
||||||
|
self.separating = false
|
||||||
|
self.aligning = false
|
||||||
|
self.cohesing = false
|
||||||
|
return steering_force:truncate(self.max_f)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Arrive steering behavior
|
||||||
|
-- Makes this object accelerate towards a destination, slowing down the closer it gets to it
|
||||||
|
-- deceleration - how fast the object will decelerate once it gets closer to the target, higher values will make the deceleration more abrupt, do not make this value 0
|
||||||
|
-- weight - how much the force of this behavior affects this object compared to others
|
||||||
|
-- self:seek_point(player.x, player.y)
|
||||||
|
function Physics:seek_point(x, y, deceleration, weight)
|
||||||
|
self.seeking = true
|
||||||
|
local tx, ty = x - self.x, y - self.y
|
||||||
|
local d = math.length(tx, ty)
|
||||||
|
if d > 0 then
|
||||||
|
local v = d/((deceleration or 1)*0.08)
|
||||||
|
v = math.min(v, self.max_v)
|
||||||
|
local dvx, dvy = v*tx/d, v*ty/d
|
||||||
|
self.seek_f:set((dvx - self.v.x)*self.turn_multiplier*(weight or 1), (dvy - self.v.y)*self.turn_multiplier*(weight or 1))
|
||||||
|
else self.seek_f:set(0, 0) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as self:seek_point but for objects instead.
|
||||||
|
-- self:seek_object(player)
|
||||||
|
function Physics:seek_object(object, deceleration, weight)
|
||||||
|
return self:seek_point(object.x, object.y, deceleration, weight)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as self:seek_point and self:seek_object but for the mouse instead.
|
||||||
|
-- self:seek_mouse()
|
||||||
|
function Physics:seek_mouse(deceleration, weight)
|
||||||
|
local mx, my = self.group.camera:get_mouse_position()
|
||||||
|
return self:seek_point(mx, my, deceleration, weight)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Separation steering behavior
|
||||||
|
-- Keeps this object separated from other objects of specific classes according to the radius passed in
|
||||||
|
-- What this function does is simply look at all nearby objects and apply forces to this object such that it remains separated from them
|
||||||
|
-- self:separate(40, {Enemy}) -> when this is called every frame, this applies forces to this object to keep it separated from other Enemy instances by 40 units at all times
|
||||||
|
function Physics:steering_separate(rs, class_avoid_list, weight)
|
||||||
|
self.separating = true
|
||||||
|
local fx, fy = 0, 0
|
||||||
|
local objects = table.flatten(table.foreachn(class_avoid_list, function(v) return self.group:get_objects_by_class(v) end), true)
|
||||||
|
for _, object in ipairs(objects) do
|
||||||
|
if object.id ~= self.id and math.distance(object.x, object.y, self.x, self.y) < 2*rs then
|
||||||
|
local tx, ty = self.x - object.x, self.y - object.y
|
||||||
|
local nx, ny = math.normalize(tx, ty)
|
||||||
|
local l = math.length(nx, ny)
|
||||||
|
fx = fx + rs*(nx/l)
|
||||||
|
fy = fy + rs*(ny/l)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.separation_f:set(fx*(weight or 1), fy*(weight or 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Wander steering behavior
|
||||||
|
-- Makes the object move in a jittery manner, adding some randomness to its movement while keeping the overall direction
|
||||||
|
-- What this function does is project a circle in front of the entity and then choose a point randomly inside that circle for the entity to move towards and it does that every frame
|
||||||
|
-- rs - the radius of the circle
|
||||||
|
-- distance - the distance of the circle from this object, the further away the smoother the changes to movement will be
|
||||||
|
-- jitter - the amount of jitter to the movement, the higher it is the more abrupt the changes will be
|
||||||
|
-- self:wander(50, 100, 20)
|
||||||
|
function Physics:wander(rs, distance, jitter, weight)
|
||||||
|
self.wandering = true
|
||||||
|
self.wander_target:add(random:float(-1, 1)*(jitter or 20), random:float(-1, 1)*(jitter or 20))
|
||||||
|
self.wander_target:normalize()
|
||||||
|
self.wander_target:mul(rs or 40)
|
||||||
|
local target_local = self.wander_target:clone():add(distance or 40, 0)
|
||||||
|
local target_world = steering.point_to_world_space(target_local, self.heading, self.side, Vector(self.x, self.y))
|
||||||
|
self.wander_f:set((target_world.x - self.x)*(weight or 1), (target_world.y - self.y)*(weight or 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Steering behavior specific auxiliary functions, shouldn't really be used elsewhere
|
||||||
|
C2DMatrix = Object:extend()
|
||||||
|
function C2DMatrix:init()
|
||||||
|
self._11, self._12, self._13 = 0, 0, 0
|
||||||
|
self._21, self._22, self._23 = 0, 0, 0
|
||||||
|
self._31, self._32, self._33 = 0, 0, 0
|
||||||
|
self:identity()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function C2DMatrix:multiply(other)
|
||||||
|
local mat_temp = C2DMatrix()
|
||||||
|
mat_temp._11 = (self._11 * other._11) + (self._12 * other._21) + (self._13 * other._31);
|
||||||
|
mat_temp._12 = (self._11 * other._12) + (self._12 * other._22) + (self._13 * other._32);
|
||||||
|
mat_temp._13 = (self._11 * other._13) + (self._12 * other._23) + (self._13 * other._33);
|
||||||
|
mat_temp._21 = (self._21 * other._11) + (self._22 * other._21) + (self._23 * other._31);
|
||||||
|
mat_temp._22 = (self._21 * other._12) + (self._22 * other._22) + (self._23 * other._32);
|
||||||
|
mat_temp._23 = (self._21 * other._13) + (self._22 * other._23) + (self._23 * other._33);
|
||||||
|
mat_temp._31 = (self._31 * other._11) + (self._32 * other._21) + (self._33 * other._31);
|
||||||
|
mat_temp._32 = (self._31 * other._12) + (self._32 * other._22) + (self._33 * other._32);
|
||||||
|
mat_temp._33 = (self._31 * other._13) + (self._32 * other._23) + (self._33 * other._33);
|
||||||
|
self._11 = mat_temp._11; self._12 = mat_temp._12; self._13 = mat_temp._13
|
||||||
|
self._21 = mat_temp._21; self._22 = mat_temp._22; self._23 = mat_temp._23
|
||||||
|
self._31 = mat_temp._31; self._32 = mat_temp._32; self._33 = mat_temp._33
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function C2DMatrix:identity()
|
||||||
|
self._11, self._12, self._13 = 1, 0, 0
|
||||||
|
self._21, self._22, self._23 = 0, 1, 0
|
||||||
|
self._31, self._32, self._33 = 0, 0, 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function C2DMatrix:transform_vector(point)
|
||||||
|
local temp_x = (self._11 * point.x) + (self._21 * point.y) + (self._31)
|
||||||
|
local temp_y = (self._12 * point.x) + (self._22 * point.y) + (self._32)
|
||||||
|
point.x, point.y = temp_x, temp_y
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function C2DMatrix:translate(x, y)
|
||||||
|
local mat = C2DMatrix()
|
||||||
|
mat._11 = 1; mat._12 = 0; mat._13 = 0;
|
||||||
|
mat._21 = 0; mat._22 = 1; mat._23 = 0;
|
||||||
|
mat._31 = x; mat._32 = y; mat._33 = 1;
|
||||||
|
self:multiply(mat)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function C2DMatrix:scale(sx, sy)
|
||||||
|
local mat = C2DMatrix()
|
||||||
|
mat._11 = sx; mat._12 = 0; mat._13 = 0;
|
||||||
|
mat._21 = 0; mat._22 = sy; mat._23 = 0;
|
||||||
|
mat._31 = 0; mat._32 = 0; mat._33 = 1;
|
||||||
|
self:multiply(mat)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function C2DMatrix:rotate(fwd, side)
|
||||||
|
local mat = C2DMatrix()
|
||||||
|
mat._11 = fwd.x; mat._12 = fwd.y; mat._13 = 0;
|
||||||
|
mat._21 = side.x; mat._22 = side.y; mat._23 = 0;
|
||||||
|
mat._31 = 0; mat._32 = 0; mat._33 = 1;
|
||||||
|
self:multiply(mat)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function C2DMatrix:rotater(r)
|
||||||
|
local mat = C2DMatrix()
|
||||||
|
local sin = math.sin(r)
|
||||||
|
local cos = math.cos(r)
|
||||||
|
mat._11 = cos; mat._12 = sin; mat._13 = 0;
|
||||||
|
mat._21 = -sin; mat._22 = cos; mat._23 = 0;
|
||||||
|
mat._31 = 0; mat._32 = 0; mat._33 = 1;
|
||||||
|
self:multiply(mat)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
steering = {}
|
||||||
|
function steering.point_to_world_space(point, heading, side, position)
|
||||||
|
local trans_point = Vector(point.x, point.y)
|
||||||
|
local mat_transform = C2DMatrix()
|
||||||
|
mat_transform:rotate(heading, side)
|
||||||
|
mat_transform:translate(position.x, position.y)
|
||||||
|
mat_transform:transform_vector(trans_point)
|
||||||
|
return trans_point
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function steering.point_to_local_space(point, heading, side, position)
|
||||||
|
local trans_point = Vector(point.x, point.y)
|
||||||
|
local mat_transform = C2DMatrix()
|
||||||
|
local tx, ty = -position:dot(heading), -position:dot(side)
|
||||||
|
mat_transform._11 = heading.x; mat_transform._12 = side.x;
|
||||||
|
mat_transform._21 = heading.y; mat_transform._22 = side.y;
|
||||||
|
mat_transform._31 = tx; mat_transform._32 = ty;
|
||||||
|
mat_transform:transform_vector(trans_point)
|
||||||
|
return trans_point
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function steering.vector_to_world_space(v, heading, side)
|
||||||
|
local trans_v = Vector(v.x, v.y)
|
||||||
|
local mat_transform = C2DMatrix()
|
||||||
|
mat_transform:rotate(heading, side)
|
||||||
|
mat_transform:transform_vector(trans_v)
|
||||||
|
return trans_v
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function steering.rotate_vector_around_origin(v, r)
|
||||||
|
local mat = C2DMatrix()
|
||||||
|
mat:rotater(r)
|
||||||
|
mat:transform_vector(v)
|
||||||
|
return v
|
||||||
|
end
|
|
@ -0,0 +1,231 @@
|
||||||
|
-- The base Trigger class.
|
||||||
|
-- A global instance of this called "trigger" is available by default.
|
||||||
|
Trigger = Object:extend()
|
||||||
|
function Trigger:init()
|
||||||
|
self.triggers = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Calls the action every frame until it's cancelled via trigger:cancel.
|
||||||
|
-- The tag must be passed in otherwise there will be no way to stop this from running.
|
||||||
|
-- If after is passed in then it is called after the run is cancelled.
|
||||||
|
function Trigger:run(action, after, tag)
|
||||||
|
local tag = tag or random:uid()
|
||||||
|
local after = after or function() end
|
||||||
|
self.triggers[tag] = {type = "run", timer = 0, after = after, action = action}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Calls the action after delay seconds.
|
||||||
|
-- Or calls the action after the condition is true.
|
||||||
|
-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled.
|
||||||
|
-- trigger:after(2, function() print(1) end) -> prints 1 after 2 seconds
|
||||||
|
-- trigger:after(function() return self.should_print_1 end, function() print(1) end) -> prints 1 after self.should_print_1 is set to true
|
||||||
|
function Trigger:after(delay, action, tag)
|
||||||
|
local tag = tag or random:uid()
|
||||||
|
if type(delay) == "number" or type(delay) == "table" then
|
||||||
|
self.triggers[tag] = {type = "after", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action}
|
||||||
|
else
|
||||||
|
self.triggers[tag] = {type = "conditional_after", condition = delay, action = action}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Calls the action every delay seconds.
|
||||||
|
-- Or calls the action once every time the condition becomes true.
|
||||||
|
-- If times is passed in then it only calls action for that amount of times.
|
||||||
|
-- If after is passed in then it is called after the last time action is called.
|
||||||
|
-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled.
|
||||||
|
-- trigger:every(2, function() print(1) end) -> prints 1 every 2 seconds
|
||||||
|
-- trigger:every(2, function() print(1) end, 5, function() print(2) end) -> prints 1 every 2 seconds 5 times, and then prints 2
|
||||||
|
-- trigger:every(function() return player.hit end, function() print(1) end) -> prints 1 every time the player is hit
|
||||||
|
-- trigger:every(function() return player.grounded end, function() print(1), 5, function() print(2) end) -> prints 1 every time the player becomes grounded 5 times, and then prints 2
|
||||||
|
-- Note that if using this as a condition, the action will only be triggered when the condition jumps from being false to true.
|
||||||
|
-- If the condition remains true for multiple frames then the action won't be triggered further, unless it becomes false and then becomes true again.
|
||||||
|
function Trigger:every(delay, action, times, after, tag)
|
||||||
|
local times = times or 0
|
||||||
|
local after = after or function() end
|
||||||
|
local tag = tag or random:uid()
|
||||||
|
if type(delay) == "number" or type(delay) == "table" then
|
||||||
|
self.triggers[tag] = {type = "every", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action, times = times, max_times = times, after = after, multiplier = 1}
|
||||||
|
else
|
||||||
|
self.triggers[tag] = {type = "conditional_every", condition = delay, last_condition = false, action = action, times = times, max_times = times, after = after}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as every except the action is called immediately when this function is called, and then every delay seconds.
|
||||||
|
function Trigger:every_immediate(delay, action, times, after, tag)
|
||||||
|
local times = times or 0
|
||||||
|
local after = after or function() end
|
||||||
|
local tag = tag or random:uid()
|
||||||
|
self.triggers[tag] = {type = "every", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action, times = times, max_times = times, after = after, multiplier = 1}
|
||||||
|
action()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Calls the action every frame for delay seconds.
|
||||||
|
-- Or calls the action every frame the condition is true.
|
||||||
|
-- If after is passed in then it is called after the duration ends or after the condition becomes false.
|
||||||
|
-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled.
|
||||||
|
-- trigger:during(5, function() print(random:float(0, 100)) end)
|
||||||
|
-- trigger:during(function() return self.should_print_random_float end, function() print(random:float(0, 100)) end) -> prints the random float as long as self.should_print_random_float is true
|
||||||
|
function Trigger:during(delay, action, after, tag)
|
||||||
|
local after = after or function() end
|
||||||
|
local tag = tag or random:uid()
|
||||||
|
if type(delay) == "number" or type(delay) == "table" then
|
||||||
|
self.triggers[tag] = {type = "during", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), action = action, after = after}
|
||||||
|
elseif type(delay) == "function" then
|
||||||
|
self.triggers[tag] = {type = "conditional_during", condition = delay, last_condition = false, action = action, after = after}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Tweens the target's values specified by the source table for delay seconds using the given tweening method.
|
||||||
|
-- All tween methods can be found in the math/math file.
|
||||||
|
-- If after is passed in then it is called after the duration ends.
|
||||||
|
-- If tag is passed in then any other trigger actions with the same tag are automatically cancelled.
|
||||||
|
-- trigger:tween(0.2, self, {sx = 0, sy = 0}, math.linear) -> tweens this object's scale variables to 0 linearly over 0.2 seconds
|
||||||
|
-- trigger:tween(0.2, self, {sx = 0, sy = 0}, math.linear, function() self.dead = true end) -> tweens this object's scale variables to 0 linearly over 0.2 seconds and then kills it
|
||||||
|
function Trigger:tween(delay, target, source, method, after, tag)
|
||||||
|
local method = method or math.linear
|
||||||
|
local after = after or function() end
|
||||||
|
local tag = tag or random:uid()
|
||||||
|
local initial_values = {}
|
||||||
|
for k, _ in pairs(source) do initial_values[k] = target[k] end
|
||||||
|
self.triggers[tag] = {type = "tween", timer = 0, unresolved_delay = delay, delay = self:resolve_delay(delay), target = target, initial_values = initial_values, source = source, method = method, after = after}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Cancels a trigger action based on its tag.
|
||||||
|
-- This is automatically called if repeated tags are given to trigger actions.
|
||||||
|
function Trigger:cancel(tag)
|
||||||
|
if self.triggers[tag] and self.triggers[tag].type == "run" then
|
||||||
|
self.triggers[tag].after()
|
||||||
|
end
|
||||||
|
self.triggers[tag] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Resets the timer for a tag.
|
||||||
|
-- Useful when you need to start counting that tag from 0 after an event happens.
|
||||||
|
function Trigger:reset(tag)
|
||||||
|
self.triggers[tag].timer = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the delay of a given tag.
|
||||||
|
-- This is useful when delays are set randomly (trigger:every({2, 4}, ...) would set the delay at a random number between 2 and 4) and you need to know what the value chosen was.
|
||||||
|
function Trigger:get_delay(tag)
|
||||||
|
return self.triggers[tag].delay
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the current iteration of an every trigger action with the given tag.
|
||||||
|
-- Useful if you need to know that its the nth time an every action has been called.
|
||||||
|
function Trigger:get_every_iteration(tag)
|
||||||
|
return self.triggers[tag].max_times - self.triggers[tag].times
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets a multiplier for an every tag.
|
||||||
|
-- This is useful when you need the event to happen in a varying interval, like based on the player's attack speed, which might change every frame based on buffs.
|
||||||
|
-- Call this on the update function with the appropriate multiplier.
|
||||||
|
function Trigger:set_every_multiplier(tag, multiplier)
|
||||||
|
self.triggers[tag].multiplier = multiplier or 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the elapsed time of a given trigger as a number between 0 and 1.
|
||||||
|
-- Useful if you need to know where you currently are in the duration of a during call.
|
||||||
|
function Trigger:get_during_elapsed_time(tag)
|
||||||
|
return self.triggers[tag].trigger/self.triggers[tag].delay
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Trigger:resolve_delay(delay)
|
||||||
|
if type(delay) == "table" then
|
||||||
|
return random:float(delay[1], delay[2])
|
||||||
|
else
|
||||||
|
return delay
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Trigger:update(dt)
|
||||||
|
for tag, trigger in pairs(self.triggers) do
|
||||||
|
if trigger.timer then
|
||||||
|
trigger.timer = trigger.timer + dt
|
||||||
|
end
|
||||||
|
|
||||||
|
if trigger.type == "run" then
|
||||||
|
trigger.action()
|
||||||
|
|
||||||
|
elseif trigger.type == "after" then
|
||||||
|
if trigger.timer > trigger.delay then
|
||||||
|
trigger.action()
|
||||||
|
self.triggers[tag] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif trigger.type == "conditional_after" then
|
||||||
|
if trigger.condition() then
|
||||||
|
trigger.action()
|
||||||
|
self.triggers[tag] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif trigger.type == "every" then
|
||||||
|
if trigger.timer > trigger.delay*trigger.multiplier then
|
||||||
|
trigger.action()
|
||||||
|
trigger.timer = trigger.timer - trigger.delay*trigger.multiplier
|
||||||
|
trigger.delay = self:resolve_delay(trigger.unresolved_delay)
|
||||||
|
if trigger.times > 0 then
|
||||||
|
trigger.times = trigger.times - 1
|
||||||
|
if trigger.times <= 0 then
|
||||||
|
trigger.after()
|
||||||
|
self.triggers[tag] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif trigger.type == "conditional_every" then
|
||||||
|
local condition = trigger.condition()
|
||||||
|
if condition and not trigger.last_condition then
|
||||||
|
trigger.action()
|
||||||
|
if trigger.times > 0 then
|
||||||
|
trigger.times = trigger.times - 1
|
||||||
|
if trigger.times <= 0 then
|
||||||
|
trigger.after()
|
||||||
|
self.triggers[tag] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
trigger.last_condition = condition
|
||||||
|
|
||||||
|
elseif trigger.type == "during" then
|
||||||
|
trigger.action()
|
||||||
|
if trigger.timer > trigger.delay then
|
||||||
|
self.triggers[tag] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif trigger.type == "conditional_during" then
|
||||||
|
local condition = trigger.condition()
|
||||||
|
if condition then
|
||||||
|
trigger.action()
|
||||||
|
end
|
||||||
|
if trigger.last_condition and not condition then
|
||||||
|
trigger.after()
|
||||||
|
end
|
||||||
|
trigger.last_condition = condition
|
||||||
|
|
||||||
|
elseif trigger.type == "tween" then
|
||||||
|
local t = trigger.method(trigger.timer/trigger.delay)
|
||||||
|
for k, v in pairs(trigger.source) do
|
||||||
|
trigger.target[k] = math.lerp(t, trigger.initial_values[k], v)
|
||||||
|
end
|
||||||
|
if trigger.timer > trigger.delay then
|
||||||
|
trigger.after()
|
||||||
|
self.triggers[tag] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,751 @@
|
||||||
|
# Game Controller DB for SDL in 2.0.10 format
|
||||||
|
# Source: https://github.com/gabomdq/SDL_GameControllerDB
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,
|
||||||
|
03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00001038000000000000,8BitDo F30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000090000000000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000650000000000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:a4,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000c82d00000310000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000c82d00002028000000000000,8BitDo N30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00008010000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00015900000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00065280000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000130000000000000,8BitDo SF30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d000021ab000000000000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00003028000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000030000000000000,8BitDo SN30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000351000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d000020ab000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00004028000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00006228000000000000,8BitDo SN30 GP,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000260000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000261000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000c82d00000031000000000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
|
||||||
|
03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000006f0e00001413000000000000,Afterglow,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00000263000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00001101000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00001401000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00001402000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00001901000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00001a01000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000d62000001d57000000000000,Airflo PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000869800002400000000007801,Astro C40 TR,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000d6200000e557000000000000,Batarang,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,platform:Windows,
|
||||||
|
030000006f0e00003201000000000000,Battlefield 4 PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000bc2000006012000000000000,Betop 2126F,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000bc2000000055000000000000,Betop BFM Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000bc2000006312000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000bc2000006321000000000000,BETOP CONTROLLER,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000bc2000006412000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000c01100000555000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000c01100000655000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000790000000700000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,
|
||||||
|
0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows,
|
||||||
|
03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000457500000401000000000000,Cobra,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000005e0400008e02000000000000,Controller (XBOX 360 For Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
030000005e040000a102000000000000,Controller (Xbox 360 Wireless Receiver for Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
030000005e040000ff02000000000000,Controller (Xbox One For Windows) - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
030000005e040000ea02000000000000,Controller (Xbox One For Windows) - Wireless,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000451300000830000000000000,Defender Game Racer X7,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,
|
||||||
|
030000006f0e00003001000000000000,EA SPORTS PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000b80500000410000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000120c0000f61c000000000000,Elite,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000008f0e00000f31000000000000,EXEQ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,
|
||||||
|
03000000341a00000108000000000000,EXEQ RF USB Gamepad 8206,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00008500000000000000,Fighting Commander 2016 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00008400000000000000,Fighting Commander 5,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
0300000066f700000100000000000000,Game VIB Joystick,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000ac0500003d03000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000006f0e00000102000000007801,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000008305000031b0000000000000,Genius Maxfire Blaze 3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000451300000010000000000000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000005c1a00003330000000000000,Genius MaxFire Grandias 12V,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000f0250000c283000000000000,Gioteck,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000f025000021c1000000000000,Gioteck PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000f0250000c383000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000f0250000c483000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000007d0400000540000000000000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000341a00000302000000000000,Hama Scorpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00004900000000000000,Hatsune Miku Sho Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000d81400000862000000000000,HitBox Edition Cthulhu+,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000632500002605000000000000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
030000000d0f00002d00000000000000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00005f00000000000000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00005e00000000000000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00004000000000000000,Hori Fighting Stick Mini 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00005400000000000000,Hori Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00000900000000000000,Hori Pad 3 Turbo,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00004d00000000000000,Hori Pad A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00009200000000000000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00001600000000007803,HORI Real Arcade Pro EX-SE (Xbox 360),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
030000000d0f00009c00000000000000,Hori TAC Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f0000c100000000000000,Horipad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00005500000000000000,Horipad 4 FPS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000250900000017000000000000,HRAP2 on PS/SS/N64 Joypad to USB BOX,a:b2,b:b1,back:b9,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b8,x:b3,y:b0,platform:Windows,
|
||||||
|
030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000830500006020000000000000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Windows,
|
||||||
|
03000000b50700001403000000000000,Impact Black,a:b2,b:b3,back:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
030000006f0e00002401000000000000,INJUSTICE FightStick PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000ac0500002c02000000000000,IPEGA,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000491900000204000000000000,Ipega PG-9023,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000491900000304000000000000,Ipega PG-9087 - Bluetooth Gamepad,+righty:+a5,-righty:-a4,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
030000006e0500000a20000000000000,JC-DUX60 ELECOM MMO Gamepad,a:b2,b:b3,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b14,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b15,righttrigger:b13,rightx:a3,righty:a4,start:b20,x:b0,y:b1,platform:Windows,
|
||||||
|
030000006e0500000520000000000000,JC-P301U,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,
|
||||||
|
030000006e0500000320000000000000,JC-U3613M (DInput),a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,
|
||||||
|
030000006e0500000720000000000000,JC-W01U,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
030000007e0500000620000000000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,
|
||||||
|
030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,
|
||||||
|
030000007e0500000720000000000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000bd12000003c0000000000000,JY-P70UR,a:b1,b:b0,back:b5,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b11,righttrigger:b9,rightx:a3,righty:a2,start:b4,x:b3,y:b2,platform:Windows,
|
||||||
|
03000000790000000200000000000000,King PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006d040000d2ca000000000000,Logitech Cordless Precision,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006d04000011c2000000000000,Logitech Cordless Wingman,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b5,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b2,righttrigger:b7,rightx:a3,righty:a4,x:b4,platform:Windows,
|
||||||
|
030000006d04000016c2000000000000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700006652000000000000,Mad Catz C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700005032000000000000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700005082000000000000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700008433000000000000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700008483000000000000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700008134000000000000,Mad Catz FightStick TE2+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700008184000000000000,Mad Catz FightStick TE2+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,leftstick:b10,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700006252000000000000,Mad Catz Micro C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700008034000000000000,Mad Catz TE2 PS3 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700008084000000000000,Mad Catz TE2 PS4 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700008532000000000000,Madcatz Arcade Fightstick TE S PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700003888000000000000,Madcatz Arcade Fightstick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000002a0600001024000000000000,Matricom,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,platform:Windows,
|
||||||
|
03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000242f00007300000000000000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,
|
||||||
|
0300000079000000d218000000000000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000d620000010a7000000000000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000008f0e00001030000000000000,Mayflash USB Adapter for original Sega Saturn controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,rightshoulder:b2,righttrigger:b7,start:b9,x:b3,y:b4,platform:Windows,
|
||||||
|
0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,
|
||||||
|
03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000790000002418000000000000,Mega Drive,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b2,start:b9,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000380700006382000000000000,MLG GamePad PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000efbe0000edfe000000000000,Monect Virtual Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000250900006688000000000000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,
|
||||||
|
030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000152000000182000000000000,NGDS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000000d0500000308000000000000,Nostromo N45,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000550900001472000000000000,NVIDIA Controller v01.04,a:b11,b:b10,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b5,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b4,righttrigger:a5,rightx:a3,righty:a6,start:b3,x:b9,y:b8,platform:Windows,
|
||||||
|
030000004b120000014d000000000000,NYKO AIRFLO,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a3,leftstick:a0,lefttrigger:b6,rightshoulder:b5,rightstick:a2,righttrigger:b7,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000782300000a10000000000000,Onlive Wireless Controller,a:b15,b:b14,back:b7,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b11,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b13,y:b12,platform:Windows,
|
||||||
|
03000000d62000006d57000000000000,OPP PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006b14000001a1000000000000,Orange Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000362800000100000000000000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a3,righty:a4,x:b1,y:b2,platform:Windows,
|
||||||
|
03000000120c0000f60e000000000000,P4 Wired Gamepad,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000004c050000da0c000000000000,PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000d62000009557000000000000,Pro Elite PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000d62000009f31000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000d6200000c757000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000632500002306000000000000,PS Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000e30500009605000000000000,PS to USB convert cable,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000100800000100000000000000,PS1 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000008f0e00007530000000000000,PS1 Controller,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b1,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000100800000300000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000250900008888000000000000,PS2 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000666600006706000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Windows,
|
||||||
|
030000006b1400000303000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000009d0d00001330000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000250900000500000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004c0500006802000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b10,lefttrigger:a3~,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:a4~,rightx:a2,righty:a5,start:b8,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000632500007505000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,
|
||||||
|
030000008f0e00001431000000000000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000003807000056a8000000000000,PS3 RF pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000100000008200000000000000,PS360+ v1.66,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:h0.4,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004c050000a00b000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000300f00001210000000000000,QanBa Joystick Plus,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000341a00000104000000000000,QanBa Joystick Q4RAF,a:b5,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b1,y:b2,platform:Windows,
|
||||||
|
03000000222c00000223000000000000,Qanba Obsidian Arcade Joystick PS3 Mode,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000222c00000023000000000000,Qanba Obsidian Arcade Joystick PS4 Mode,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000321500000204000000000000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000321500000104000000000000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000321500000507000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000321500000707000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
030000000d0f00001100000000000000,REAL ARCADE PRO.3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00006a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00006b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00008a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00008b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00007000000000000000,REAL ARCADE PRO.4 VLX,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00002200000000000000,REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00005b00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000000d0f00005c00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000790000001100000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
0300000000f000000300000000000000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,
|
||||||
|
0300000000f00000f100000000000000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,
|
||||||
|
030000006b140000010d000000000000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006b140000020d000000000000,Revolution Pro Controller 2(1/2),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00001e01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00002801000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000a30600001af5000000000000,Saitek Cyborg,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000a306000023f6000000000000,Saitek Cyborg V.1 Game pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000300f00001201000000000000,Saitek Dual Analog Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000a30600000701000000000000,Saitek P220,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b5,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000a30600000cff000000000000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000a30600000c04000000000000,Saitek P2900,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000300f00001001000000000000,Saitek P480 Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000a30600000b04000000000000,Saitek P990,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000a30600002106000000000000,Saitek PS1000,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000a306000020f6000000000000,Saitek PS2700,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000300f00001101000000000000,Saitek Rumble Pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000730700000401000000000000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Windows,
|
||||||
|
0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000005e0400008e02000000007801,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000d11800000094000000000000,Stadia Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b11,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000110100001914000000000000,SteelSeries,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000381000001214000000000000,SteelSeries Free,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,platform:Windows,
|
||||||
|
03000000d620000011a7000000000000,Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004f04000007d0000000000000,T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004f0400000ab1000000000000,T.16000M,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b10,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000fa1900000706000000000000,Team 5,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,
|
||||||
|
030000004f04000015b3000000000000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,
|
||||||
|
030000004f04000023b3000000000000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Windows,
|
||||||
|
030000004f04000004b3000000000000,Thrustmaster Firestorm Dual Power 3,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,
|
||||||
|
03000000666600000488000000000000,TigerGame PS/PS2 Game Controller Adapter,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000d62000006000000000000000,Tournament PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000005f140000c501000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000b80500000210000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000004f04000087b6000000000000,TWCS Throttle,dpdown:b8,dpleft:b9,dpright:b7,dpup:b6,leftstick:b5,lefttrigger:-a5,leftx:a0,lefty:a1,righttrigger:+a5,platform:Windows,
|
||||||
|
03000000d90400000200000000000000,TwinShock PS2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
030000006e0500001320000000000000,U4113,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000101c0000171c000000000000,uRage Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000300f00000701000000000000,USB 4-Axis 12-Button Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000341a00002308000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
030000005509000000b4000000000000,USB gamepad,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,platform:Windows,
|
||||||
|
030000006b1400000203000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000790000000a00000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000f0250000c183000000000000,USB gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000ff1100004133000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000632500002305000000000000,USB Vibration Joystick (BM),a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||||
|
03000000790000001a18000000000000,Venom,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000006f0e00000302000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||||
|
030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||||
|
03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||||
|
|
||||||
|
# Mac OS X
|
||||||
|
030000008f0e00000300000009010000,2In1 USB Joystick,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
03000000c82d00000650000001000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||||
|
03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
03000000c82d00000190000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
03000000c82d00000260000001000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
03000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
03000000c82d00000031000001000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||||
|
03000000a00500003232000009010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||||
|
03000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000006f0e00000102000000000000,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000007d0400000540000001010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00002d00000000100000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00009200000000010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00006600000000010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f00006600000000000000,HORIPAD FPS PLUS 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000000d0f0000ee00000000010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000008f0e00001330000011010000,HuiJia SNES Controller,a:b4,b:b2,back:b16,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b12,rightshoulder:b14,start:b18,x:b6,y:b0,platform:Mac OS X,
|
||||||
|
03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,
|
||||||
|
03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,
|
||||||
|
030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000019c2000005030000,Logitech F710,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000018c2000000010000,Logitech RumblePad 2 USB,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3~,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000380700005032000000010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000380700008433000000010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000380700008483000000010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000242f00007300000000020000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
0300000079000000d218000026010000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
03000000d620000010a7000003010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Mac OS X,
|
||||||
|
03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X,
|
||||||
|
03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000632500007505000000020000,NEOGEO mini PAD Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
030000004c050000da0c000000010000,Playstation Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
03000000d62000006dca000000010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,
|
||||||
|
030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,
|
||||||
|
030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000008916000000fd000000000000,Razer Onza TE,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000321500000204000000010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000321500000104000000010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000321500000010000000010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000321500000507000001010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||||
|
03000000321500000009000000020000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
0300000032150000030a000000000000,Razer Wildcat,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000790000001100000000000000,Retrolink Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a3,lefty:a4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000c6240000fefa000000000000,Rock Candy Gamepad for PS3,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000730700000401000000010000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Mac OS X,
|
||||||
|
03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,platform:Mac OS X,
|
||||||
|
03000000b40400000a01000000000000,Sega Saturn USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Mac OS X,
|
||||||
|
030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||||
|
0300000000f00000f100000000000000,SNES RetroPort,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,rightshoulder:b7,start:b6,x:b0,y:b1,platform:Mac OS X,
|
||||||
|
030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000110100001714000000000000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000110100001714000020010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000004f04000015b3000000000000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Mac OS X,
|
||||||
|
030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Mac OS X,
|
||||||
|
03000000bd12000015d0000000000000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
03000000100800000100000000000000,Twin USB Joystick,a:b4,b:b2,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b12,leftstick:b20,lefttrigger:b8,leftx:a0,lefty:a2,rightshoulder:b14,rightstick:b22,righttrigger:b10,rightx:a6,righty:a4,start:b18,x:b6,y:b0,platform:Mac OS X,
|
||||||
|
030000006f0e00000302000025040000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
03000000791d00000103000009010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||||
|
050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,platform:Mac OS X,
|
||||||
|
050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,platform:Mac OS X,
|
||||||
|
030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e040000e002000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e040000ea02000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||||
|
030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||||
|
03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||||
|
03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||||
|
|
||||||
|
# Linux
|
||||||
|
05000000c82d00001038000000010000,8Bitdo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00005106000000010000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
03000000c82d00001590000011010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d00000310000011010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
05000000c82d00008010000000010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00000060000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00000061000000010000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d000021ab000010010000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
030000003512000012ab000010010000,8Bitdo SFC30 GamePad,a:b2,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b0,platform:Linux,
|
||||||
|
05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00003028000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d00000160000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d00001290000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00006228000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
03000000c82d00000260000011010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
030000005e0400008e02000020010000,8BitDo Wireless Adapter,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000c82d00000031000011010000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
|
||||||
|
05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006f0e00003901000020060000,Afterglow Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006f0e00003901000000430000,Afterglow Prismatic Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006f0e00003901000013020000,Afterglow Prismatic Wired Controller 048-007-NA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000050b00000045000040000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000120c00000500000010010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux,
|
||||||
|
03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000ffff0000ffff000000010000,Chinese-made Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,
|
||||||
|
03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000000b0400003365000000010000,Competition Pro,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Linux,
|
||||||
|
03000000260900008888000000010000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000a306000022f6000011010000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000b40400000a01000000010000,CYPRESS USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,
|
||||||
|
03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000004f04000004b3000010010000,Dual Power 2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
|
||||||
|
030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000bc2000000055000011010000,GameSir G3w,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006f0e00000104000000010000,Gamestop Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000008f0e00000800000010010000,Gasia Co. Ltd PS(R) Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
0300000079000000d418000000010000,GPD Win 2 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000007d0400000540000000010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000280400000140000000010000,Gravis GamePad Pro USB ,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000008f0e00000610000000010000,GreenAsia Electronics 4Axes 12Keys GamePad ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Linux,
|
||||||
|
030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
0500000047532067616d657061640000,GS gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000f0250000c383000010010000,GT VX2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,platform:Linux,
|
||||||
|
030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00006a00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00006b00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00002200000011010000,HORI CO. LTD. REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00005f00000011010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00005e00000011010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000000d0f00009200000011010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00001600000000010000,Hori Real Arcade Pro.EX-SE (Xbox 360),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00006600000011010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f0000ee00000011010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000000d0f00006700000001010000,HORIPAD ONE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000008f0e00001330000010010000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,
|
||||||
|
050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,
|
||||||
|
03000000d80400008200000003000000,IMS PCU#0 Gamepad Interface,a:b1,b:b0,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b5,x:b3,y:b2,platform:Linux,
|
||||||
|
03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,platform:Linux,
|
||||||
|
0500000049190000020400001b010000,Ipega PG-9069 - Bluetooth Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b161,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Linux,
|
||||||
|
03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,
|
||||||
|
03000000300f00000b01000010010000,Jess Tech GGE909 PC Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,
|
||||||
|
050000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,
|
||||||
|
030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
050000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006d0400000ac2000010010000,Logitech Inc. WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Linux,
|
||||||
|
030000006d04000015c2000010010000,Logitech Logitech Extreme 3D,a:b0,b:b4,back:b6,guide:b8,leftshoulder:b9,leftstick:h0.8,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:h0.2,start:b7,x:b2,y:b5,platform:Linux,
|
||||||
|
030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b6,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b10,rightx:a3,righty:a4,start:b8,x:b3,y:b4,platform:Linux,
|
||||||
|
05000000380700006652000025010000,Mad Catz C.T.R.L.R ,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000380700005032000011010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000380700005082000011010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000ad1b00002ef0000090040000,Mad Catz Fightpad SFxT,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000380700008034000011010000,Mad Catz fightstick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000380700008084000011010000,Mad Catz fightstick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000380700008433000011010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000380700008483000011010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000380700003847000090040000,Mad Catz Wired Xbox 360 Controller (SFIV),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000120c00000500000000010000,Manta Dualshock 2,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000790000004318000010010000,Mayflash GameCube Controller Adapter,a:b1,b:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000242f00007300000011010000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,
|
||||||
|
0300000079000000d218000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000d620000010a7000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
0300000025090000e803000001010000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:a5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000005e0400000e00000000010000,Microsoft SideWinder,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,
|
||||||
|
030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e040000e302000003020000,Microsoft X-Box One Elite pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
050000005e040000050b000003090000,Microsoft X-Box One Elite 2 pad,a:b0,b:b1,y:b4,x:b3,start:b11,guide:b12,back:b17,leftstick:b13,rightstick:b14,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,platform:Linux,
|
||||||
|
030000005e040000dd02000003020000,Microsoft X-Box One pad (Firmware 2015),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,
|
||||||
|
030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,
|
||||||
|
03000000c62400001a53000000010000,Mini PE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000030000000300000002000000,Miroof,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,
|
||||||
|
05000000d6200000e589000001000000,Moga 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,
|
||||||
|
030000000d0f00000900000010010000,Natec Genesis P44,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux,
|
||||||
|
050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000550900001472000011010000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000550900001472000001000000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,
|
||||||
|
05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,
|
||||||
|
05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,
|
||||||
|
03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006f0e0000a802000023020000,PDP Wired Controller for Xbox One,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000d62000006dca000011010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006d040000d2ca000011010000,Precision Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004c0500006802000010010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||||
|
030000004c0500006802000010810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||||
|
030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
030000006f0e00001402000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000008f0e00000300000010010000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||||
|
050000004c0500006802000000800000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
05000000504c415953544154494f4e00,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||||
|
060000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||||
|
030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004c050000cc09000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
03000000c01100000140000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
050000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
050000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux,
|
||||||
|
030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux,
|
||||||
|
030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000008916000000fd000024010000,Razer Onza Tournament Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000321500000204000011010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000321500000104000011010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000321500000010000011010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000321500000507000000010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
030000008916000000fe000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000c6240000045d000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000c6240000045d000025010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
0300000081170000990a000001010000,Retronic Adapter,a:b0,leftx:a0,lefty:a1,platform:Linux,
|
||||||
|
0300000000f000000300000000010000,RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,
|
||||||
|
030000006b140000010d000011010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006f0e00001f01000000010000,Rock Candy,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000006f0e00001e01000011010000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000006f0e00004601000001010000,Rock Candy Xbox One Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,
|
||||||
|
03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000300f00001201000010010000,Saitek P380,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a1,righty:a2,start:b9,x:b0,y:b1,platform:Linux,
|
||||||
|
03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,
|
||||||
|
03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
03000000d81d00000e00000010010000,Savior,a:b0,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b11,righttrigger:b3,start:b9,x:b4,y:b5,platform:Linux,
|
||||||
|
03000000c01600008704000011010000,Serial/Keyboard/Mouse/Joystick,a:b12,b:b10,back:b4,dpdown:b2,dpleft:b3,dpright:b1,dpup:b0,leftshoulder:b9,leftstick:b14,lefttrigger:b6,leftx:a1,lefty:a0,rightshoulder:b8,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b5,x:b13,y:b11,platform:Linux,
|
||||||
|
03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000632500007505000010010000,SHANWAN PS3/PC Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000bc2000000055000010010000,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000341a00000908000010010000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,
|
||||||
|
030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000381000003014000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000381000003114000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,
|
||||||
|
0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,
|
||||||
|
030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
|
||||||
|
030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
|
||||||
|
030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Linux,
|
||||||
|
030000004f04000026b3000002040000,Thrustmaster Gamepad GP XID,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000c6240000025b000002020000,Thrustmaster GPX Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
030000004f04000012b3000010010000,Thrustmaster vibrating gamepad,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
|
||||||
|
03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,platform:Linux,
|
||||||
|
030000005e0400008e02000070050000,Torid,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000c01100000591000011010000,Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000100800000300000010010000,USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000790000000600000007010000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
03000000790000001100000000010000,USB Gamepad1,a:b2,b:b1,back:b8,dpdown:a0,dpleft:a1,dpright:a2,dpup:a4,start:b9,platform:Linux,
|
||||||
|
030000006f0e00000302000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
05000000ac0500003232000001000000,VR-BOX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000791d00000103000010010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||||
|
030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
030000005e040000d102000002010000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
050000005e040000fd02000030110000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
030000005e040000ea02000001030000,Xbox One Wireless Controller (Model 1708),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||||
|
05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux,
|
||||||
|
03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,
|
||||||
|
xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||||
|
03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||||
|
|
||||||
|
# Android
|
||||||
|
05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
05000000d6020000e5890000dfff3f00,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
64633436313965656664373634323364,Microsoft X-Box 360 pad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,
|
||||||
|
050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,platform:Android,
|
||||||
|
37336435666338653565313731303834,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
61363931656135336130663561616264,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
050000005509000003720000cf7f3f00,NVIDIA Controller v01.01,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
050000005509000010720000ffff3f00,NVIDIA Controller v01.03,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,
|
||||||
|
050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,
|
||||||
|
35643031303033326130316330353564,PS4 Controller,a:b1,b:b17,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,
|
||||||
|
050000003215000005070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
050000003215000007070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
050000003215000000090000bf7f3f00,Razer Serval,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,
|
||||||
|
05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,
|
||||||
|
05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,
|
||||||
|
5477696e20555342204a6f7973746963,Twin USB Joystick,a:b22,b:b21,back:b28,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b26,leftstick:b30,lefttrigger:b24,leftx:a0,lefty:a1,rightshoulder:b27,rightstick:b31,righttrigger:b25,rightx:a3,righty:a2,start:b29,x:b23,y:b20,platform:Android,
|
||||||
|
050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,platform:Android,
|
||||||
|
050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
050000005e04000091020000ff073f00,Xbox Wireless Controller,a:b0,b:b1,back:b4,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android,
|
||||||
|
34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,platform:Android,
|
||||||
|
|
||||||
|
# iOS
|
||||||
|
05000000ac0500000100000000006d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,
|
||||||
|
05000000ac050000010000004f066d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,
|
||||||
|
05000000ac05000001000000cf076d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,
|
||||||
|
05000000ac0500000200000000006d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS,
|
||||||
|
05000000ac050000020000004f066d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS,
|
||||||
|
050000004c050000cc090000df070000,DUALSHOCK 4 Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,
|
||||||
|
4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:iOS,
|
||||||
|
4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS,
|
||||||
|
05000000ac0500000300000000006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS,
|
||||||
|
05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS,
|
||||||
|
05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,
|
||||||
|
05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,
|
||||||
|
050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,
|
|
@ -0,0 +1,141 @@
|
||||||
|
-- The class responsible for holding an animation's graphics.
|
||||||
|
-- It takes in an already loaded image, the width and height of each frames, and a list of frames in terms of indexed position on the image.
|
||||||
|
-- player_sheet = Image('player_sheet')
|
||||||
|
-- player_idle_frames = AnimationFrames(player_sheet, 32, 32, {{1, 1}, {2, 1}})
|
||||||
|
-- player_run_frames = AnimationFrames(player_sheet, 32, 32, {{1, 2}, {2, 2}, {3, 2}})
|
||||||
|
-- player_attack_frames = AnimationFrames(player_sheet, 32, 32, {{1, 3}, {2, 3}, {3, 3}, {4, 3}})
|
||||||
|
--
|
||||||
|
-- In the example above we first load an image, and then load 3 player animations.
|
||||||
|
-- Each animation comes from different rows in the same spritesheet, and that's reflected by the last argument in each call.
|
||||||
|
-- If your animation comes from a single spritesheet that doesn't have multiple animations, then you can omit the last argument and it will automatically go through it.
|
||||||
|
AnimationFrames = Object:extend()
|
||||||
|
function AnimationFrames:init(image, frame_w, frame_h, frames_list)
|
||||||
|
self.source = image
|
||||||
|
self.frame_w, self.frame_h = frame_w, frame_h
|
||||||
|
self.frames_list = frames_list
|
||||||
|
|
||||||
|
if type(self.frames_list) == 'number' then -- the source is a single row spritesheet and number of frames are specified
|
||||||
|
local frames_list = {}
|
||||||
|
for i = 1, self.frames_list do table.insert(frames_list, {i, 1}) end
|
||||||
|
self.frames_list = frames_list
|
||||||
|
elseif not self.frames_list then
|
||||||
|
local frames_list = {}
|
||||||
|
for i = 1, math.floor(self.source.w/self.frame_w) do table.insert(frames_list, {i, 1}) end
|
||||||
|
self.frames_list = frames_list
|
||||||
|
end
|
||||||
|
|
||||||
|
self.frames = {}
|
||||||
|
for i, frame in ipairs(self.frames_list) do
|
||||||
|
self.frames[i] = {quad = love.graphics.newQuad((frame[1]-1)*self.frame_w, (frame[2]-1)*self.frame_h, self.frame_w, self.frame_h, self.source.w, self.source.h), w = self.frame_w, h = self.frame_h}
|
||||||
|
end
|
||||||
|
self.size = #self.frames
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function AnimationFrames:draw(frame, x, y, r, sx, sy, ox, oy, color)
|
||||||
|
local _r, g, b, a
|
||||||
|
if color then
|
||||||
|
_r, g, b, a = love.graphics.getColor()
|
||||||
|
graphics.set_color(color)
|
||||||
|
end
|
||||||
|
love.graphics.draw(self.source.image, self.frames[frame].quad, x, y, r or 0, sx or 1, sy or sx or 1, self.frames[frame].w/2 + (ox or 0), self.frames[frame].h/2 + (oy or 0))
|
||||||
|
if color then love.graphics.setColor(_r, g, b, a) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- The class that logically updates an animation.
|
||||||
|
-- This being separated from the visual part of an animation is useful whenever you need animation-like behavior unrelated to graphics, like making your own animations with code only. For instance:
|
||||||
|
--[[
|
||||||
|
self.animation = AnimationLogic(0.04, 6, 'loop', {
|
||||||
|
[1] = function()
|
||||||
|
if self.parent:is(Player) then
|
||||||
|
for i = 1, random:int(1, 3) do DustParticle(game.current_state.floor, self.parent.x, self.parent.y)) end
|
||||||
|
end
|
||||||
|
self.z = 9
|
||||||
|
end,
|
||||||
|
[2] = function() self.parent.timer:tween(0.025, self, {z = 6}, math.linear, nil, 'move_2') end,
|
||||||
|
[3] = function() self.parent.timer:tween(0.025, self, {z = 3}, math.linear, nil, 'move_3') end,
|
||||||
|
[4] = function()
|
||||||
|
self.parent.timer:tween(0.025, self, {z = 0}, math.linear, nil, 'move_4')
|
||||||
|
self.sx = 0.1
|
||||||
|
self.parent.timer:tween(0.05, self, {sx = 0}, math.linear, nil, 'move_5')
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
]]--
|
||||||
|
--
|
||||||
|
-- That was an example of a code-only movement animation for a game I'm making.
|
||||||
|
-- The arguments that this takes are the delay between each frame, how many frames there are, the loop mode ('loop', 'once' or 'bounce') and a table of actions.
|
||||||
|
-- The delay argument can either be a number or a table, if it's a table then the delay for each frame can be set individually:
|
||||||
|
-- animation = AnimationLogic({0.02, 0.04, 0.06, 0.04}, ...)
|
||||||
|
-- In the example above, it would take 0.02s to go from frame 1 to 2, 0.04s from 2 to 3, 0.06s from 3 to 4 and 0.04s from 4 to 5 (or 1 if there are only 4 frames).
|
||||||
|
-- Loop can be either: 'loop', the animation will start once from frame 1 once it reaches the end; 'once', it will stop once it reaches the end; 'bounce', it will reverse once it reaches the end or start
|
||||||
|
-- Finally, the actions table can contain a list of functions, as shown in the code-only animation example above, and each function will be performed when that frame is reached.
|
||||||
|
-- In that example, once the second frame is reached, this function would be executed:
|
||||||
|
-- function() self.parent.timer:tween(0.025, self, {z = 6}, math.linear, nil, 'move_2') end
|
||||||
|
-- The index 0 can be used to perform an action once the animation reaches its end:
|
||||||
|
-- self.animation = AnimationLogic(0.04, self.player_dead_frames.size, 'once', {[0] = function() self.dead = true end})
|
||||||
|
AnimationLogic = Object:extend()
|
||||||
|
function AnimationLogic:init(delay, frames, loop_mode, actions)
|
||||||
|
self.delay = delay
|
||||||
|
self.frames = frames
|
||||||
|
self.loop_mode = loop_mode or "once"
|
||||||
|
self.actions = actions
|
||||||
|
self.timer = 0
|
||||||
|
self.frame = 1
|
||||||
|
self.direction = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function AnimationLogic:update(dt)
|
||||||
|
if self.dead then return end
|
||||||
|
|
||||||
|
self.timer = self.timer + dt
|
||||||
|
local delay = self.delay
|
||||||
|
if type(self.delay) == "table" then delay = self.delay[self.frame] end
|
||||||
|
|
||||||
|
if self.timer > delay then
|
||||||
|
self.timer = 0
|
||||||
|
self.frame = self.frame + self.direction
|
||||||
|
if self.frame > self.frames or self.frame < 1 then
|
||||||
|
if self.loop_mode == "once" then
|
||||||
|
self.frame = self.frames
|
||||||
|
self.dead = true
|
||||||
|
elseif self.loop_mode == "loop" then
|
||||||
|
self.frame = 1
|
||||||
|
elseif self.loop_mode == "bounce" then
|
||||||
|
self.direction = -self.direction
|
||||||
|
self.frame = self.frame + 2*self.direction
|
||||||
|
end
|
||||||
|
if self.actions and self.actions[0] then self.actions[0]() end
|
||||||
|
end
|
||||||
|
if self.actions and self.actions[self.frame] then self.actions[self.frame]() end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- The Animation class, a mix of AnimationFrames and AnimationLogic.
|
||||||
|
-- Takes in a delay, an AnimationFrames object, the loop mode and a table of actions.
|
||||||
|
-- Read more about the AnimationFrames and AnimationLogic classes as everything there applies here.
|
||||||
|
Animation = Object:extend()
|
||||||
|
function Animation:init(delay, animation_frames, loop_mode, actions)
|
||||||
|
self.delay = delay
|
||||||
|
self.animation_frames = animation_frames
|
||||||
|
self.size = self.animation_frames.size
|
||||||
|
self.loop_mode = loop_mode
|
||||||
|
self.actions = actions
|
||||||
|
self.animation_logic = AnimationLogic(self.delay, self.animation_frames.size, self.loop_mode, self.actions)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Animation:update(dt)
|
||||||
|
self.animation_logic:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Animation:draw(x, y, r, sx, sy, ox, oy, color)
|
||||||
|
self.animation_frames:draw(self.animation_logic.frame, x, y, r, sx, sy, ox, oy, color)
|
||||||
|
end
|
|
@ -0,0 +1,364 @@
|
||||||
|
Shake = Object:extend()
|
||||||
|
function Shake:init(amplitude, duration, frequency)
|
||||||
|
self.amplitude = amplitude or 0
|
||||||
|
self.duration = duration or 0
|
||||||
|
self.frequency = frequency or 60
|
||||||
|
self.samples = {}
|
||||||
|
for i = 1, (duration/1000)*frequency do self.samples[i] = 2*love.math.random()-1 end
|
||||||
|
self.ti = love.timer.getTime()*1000
|
||||||
|
self.t = 0
|
||||||
|
self.shaking = true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Shake:update(dt)
|
||||||
|
self.t = love.timer.getTime()*1000 - self.ti
|
||||||
|
if self.t > self.duration then
|
||||||
|
self.shaking = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Shake:get_noise(s)
|
||||||
|
return self.samples[s] or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Shake:get_decay(t)
|
||||||
|
if t > self.duration then return end
|
||||||
|
return (self.duration - t)/self.duration
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Shake:get_amplitude(t)
|
||||||
|
if not t then
|
||||||
|
if not self.shaking then return 0 end
|
||||||
|
t = self.t
|
||||||
|
end
|
||||||
|
local s = (t/1000)*self.frequency
|
||||||
|
local s0 = math.floor(s)
|
||||||
|
local s1 = s0 + 1
|
||||||
|
local k = self:get_decay(t)
|
||||||
|
return self.amplitude*(self:get_noise(s0) + (s-s0)*(self:get_noise(s1) - self:get_noise(s0)))*k
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- The camera object. A global instance of this called "camera" is created automatically, and the Game class also contains its own instance of in the .camera attribute.
|
||||||
|
-- This class handles drawing of the game world through a viewport and the functions needed to make that happen.
|
||||||
|
-- A common setup looks like this:
|
||||||
|
--[[
|
||||||
|
function Arena:on_enter()
|
||||||
|
game.camera.follow_style = 'lockon'
|
||||||
|
game.camera.lerp.x = 0.1
|
||||||
|
game.camera.lerp.y = 0.1
|
||||||
|
|
||||||
|
self.main = Group(game.camera):set_as_physics_world(192, 0, 0, {'player', 'enemy', 'projectile', 'solid'})
|
||||||
|
self.effects = Group(game.camera)
|
||||||
|
self.floor = Group(game.camera)
|
||||||
|
self.ui = Group()
|
||||||
|
|
||||||
|
self.player = Player(gw/2, gh/2)
|
||||||
|
self.main:add_object(self.player)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Arena:update(dt)
|
||||||
|
game.camera:follow_object(self.player)
|
||||||
|
game.camera.x = math.floor(game.camera.x)
|
||||||
|
game.camera.y = math.floor(game.camera.y)
|
||||||
|
|
||||||
|
self.main:update(dt)
|
||||||
|
self.floor:update(dt)
|
||||||
|
self.effects:update(dt)
|
||||||
|
self.ui:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Arena:draw()
|
||||||
|
self.floor:draw()
|
||||||
|
self.main:sort_by_y()
|
||||||
|
self.main:draw()
|
||||||
|
self.effects:draw()
|
||||||
|
self.ui:draw()
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- Here we see 4 groups being created and for 3 of them the game's camera instance is attached.
|
||||||
|
-- If a group has a camera instance attached to it then whenever group:draw() is called it will draw all objects to the camera's canvas affected by the camera's translation, zoom and rotation.
|
||||||
|
-- Additionally, we also see some basic following functionality, as the camera is told to follow the player with the 'lockon' follow style and with some lerping going on.
|
||||||
|
-- Finally, the 4th group has no camera attached to it, because for UI elements we want them to be drawn in static screen positions.
|
||||||
|
--
|
||||||
|
-- The arguments passed in to create a camera area:
|
||||||
|
-- x, y - the camera's position in world coordinates, the camera is always centered around its x, y coordinates
|
||||||
|
-- w, h - the camera's size, generally this should be the same as game_width and game_height (or gw and gh) passed in engine_run
|
||||||
|
Camera = Object:extend()
|
||||||
|
function Camera:init(x, y, w, h)
|
||||||
|
self.x, self.y = x, y
|
||||||
|
self.w, self.h = w or gw, h or gh
|
||||||
|
self.r, self.sx, self.sy = 0, 1, 1
|
||||||
|
self.mouse = Vector(0, 0)
|
||||||
|
self.last_mouse = Vector(0, 0)
|
||||||
|
self.mouse_dt = Vector(0, 0)
|
||||||
|
self.shakes = {x = {}, y = {}}
|
||||||
|
self.spring = {x = Spring(), y = Spring()}
|
||||||
|
self.lerp = Vector(1, 1)
|
||||||
|
self.lead = Vector(1, 1)
|
||||||
|
self.impulse = Vector(0, 0)
|
||||||
|
self.follow_style = "no_deadzone"
|
||||||
|
self.shake_amount = Vector(0, 0)
|
||||||
|
self.last_shake_amount = Vector(0, 0)
|
||||||
|
self.last_target = Vector(0, 0)
|
||||||
|
self.scroll = Vector(0, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Set ignore_scale to true when you want drawing of objects to be scaled when drawing the canvas rather than the objects themselves
|
||||||
|
-- That is useful for mipmapping a pixelated canvas, for instance, such that zooming out doesn't create lots of ugly artifacts
|
||||||
|
-- In that case you want to set ignore_scale to true, and then when drawing the main canvas multiply it by camera.sx*sx, camera.sy*sy instead of only sx, sy
|
||||||
|
-- You'll also want to create a canvas that is bigger than normal to account for the fact that you're zooming out of it
|
||||||
|
-- TODO: classify and unify all disparate methods of drawing in this class, also move "main canvas" here
|
||||||
|
|
||||||
|
-- Attaches the camera, meaning all further draw operations will be affected by its transform.
|
||||||
|
-- Accepts two values that go from 0 to 1 that represent how much parallaxing there should be for the next operations.
|
||||||
|
-- A value of 1 means no parallaxing, meaning the elements drawn will move at the same rate as all other elements, while a value of 0 means maximum parallaxing, which means the elements won't move at all.
|
||||||
|
-- Groups automatically call this function, but you can still pass these scroll factors to their draw calls.
|
||||||
|
-- In general if you have multiple layers of backgrounds and you want them to be parallaxed you'd do something like this:
|
||||||
|
--[[
|
||||||
|
function init()
|
||||||
|
back_backgrounds = Group(game.camera)
|
||||||
|
middle_backgrounds = Group(game.camera)
|
||||||
|
front_backgrounds = Group(game.camera)
|
||||||
|
main = Group(game.camera)
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw()
|
||||||
|
back_backgrounds:draw(0.5)
|
||||||
|
middle_backgrounds:draw(0.75)
|
||||||
|
front_backgrounds:draw(0.9)
|
||||||
|
main:draw()
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
--
|
||||||
|
-- In this example we have 4 layers are all drawn with different levels of parallax: 0.5 (half speed), 0.75, 0.9 and 1 (normal speed = no parallax).
|
||||||
|
function Camera:attach(scroll_factor_x, scroll_factor_y)
|
||||||
|
self.bx, self.by = self.x, self.y
|
||||||
|
self.x = self.bx*(scroll_factor_x or 1)
|
||||||
|
self.y = self.by*(scroll_factor_y or scroll_factor_x or 1)
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(self.w/2, self.h/2)
|
||||||
|
if not self.ignore_scale then love.graphics.scale(self.sx, self.sy) end
|
||||||
|
love.graphics.rotate(self.r)
|
||||||
|
love.graphics.translate(-self.x*(scroll_factor_x or 1), -self.y*(scroll_factor_y or 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Detaches the camera, meaning all further draw operations won't be affected by its transform.
|
||||||
|
-- This is also called automatically by groups that have cameras attached to them.
|
||||||
|
function Camera:detach()
|
||||||
|
love.graphics.pop()
|
||||||
|
self.x, self.y = self.bx, self.by
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the values passed in in world coordinates. This is useful when transforming things from screen space to world space, like when the mouse clicks on something.
|
||||||
|
-- If you look at camera:get_mouse_position you'll see that it uses this function on the values returned by love.mouse.getPosition (which return values in screen coordinates).
|
||||||
|
-- camera:get_world_coords(love.mouse.getPosition())
|
||||||
|
function Camera:get_world_coords(x, y)
|
||||||
|
local c, s = math.cos(-self.r), math.sin(-self.r)
|
||||||
|
x, y = (x - sx*self.w/2)/(sx*self.sx), (y - sy*self.h/2)/(sy*self.sy)
|
||||||
|
x, y = c*x - s*y, s*x + c*y
|
||||||
|
return x + self.x*(v or 1), y + self.y*(v or 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the values passed in in local coordinates. This is useful when transforming things from world space to screen space, like when displaying UI according to the position of game objects.
|
||||||
|
-- x, y = camera:get_local_coords(player.x, player.y)
|
||||||
|
function Camera:get_local_coords(x, y)
|
||||||
|
local c, s = math.cos(self.r), math.sin(self.r)
|
||||||
|
x, y = x - self.x*(v or 1), y - self.y*(v or 1)
|
||||||
|
x, y = c*x - s*y, s*x + c*y
|
||||||
|
return x*self.sx + self.w/2, y*self.sy + self.h/2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Camera:update(dt)
|
||||||
|
self.mouse.x, self.mouse.y = self:get_mouse_position()
|
||||||
|
self.mouse_dt.x, self.mouse_dt.y = self.mouse.x - self.last_mouse.x, self.mouse.y - self.last_mouse.y
|
||||||
|
self.shake_amount:set(0, 0)
|
||||||
|
for _, z in ipairs({"x", "y"}) do
|
||||||
|
for i = #self.shakes[z], 1, -1 do
|
||||||
|
self.shakes[z][i]:update(dt)
|
||||||
|
self.shake_amount[z] = self.shake_amount[z] + self.shakes[z][i]:get_amplitude()
|
||||||
|
if not self.shakes[z][i].shaking then
|
||||||
|
table.remove(self.shakes[z], i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.spring.x:update(dt)
|
||||||
|
self.spring.y:update(dt)
|
||||||
|
self.shake_amount:add(self.spring.x.x, self.spring.y.x)
|
||||||
|
self.x, self.y = self.x - self.last_shake_amount.x, self.y - self.last_shake_amount.y
|
||||||
|
self.x, self.y = self.x + self.shake_amount.x, self.y + self.shake_amount.y
|
||||||
|
self.last_shake_amount:set(self.shake_amount)
|
||||||
|
self.x = self.x + self.impulse.x*dt
|
||||||
|
self.y = self.y + self.impulse.y*dt
|
||||||
|
self.impulse:mul(0.9*refresh_rate*dt)
|
||||||
|
|
||||||
|
if self.bound then
|
||||||
|
self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2)
|
||||||
|
self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.last_mouse.x, self.last_mouse.y = self.mouse.x, self.mouse.y
|
||||||
|
if not self.target then return end
|
||||||
|
|
||||||
|
if self.follow_style == "lockon" then
|
||||||
|
local w, h = self.w/16, self.w/16
|
||||||
|
self:set_deadzone((self.w - w)/2, (self.h - h)/2, w, h)
|
||||||
|
elseif self.follow_style == "lockon_tight" then
|
||||||
|
local w, h = self.w/64, self.w/64
|
||||||
|
self:set_deadzone((self.w - w)/2, (self.h - h)/2, w, h)
|
||||||
|
elseif self.follow_style == "lockon_loose" then
|
||||||
|
local w, h = self.w/4, self.w/4
|
||||||
|
self:set_deadzone((self.w - w)/2, (self.h - h)/2, w, h)
|
||||||
|
elseif self.follow_style == "platformer" then
|
||||||
|
local w, h = self.w/8, self.h/3
|
||||||
|
self:set_deadzone((self.w - w)/2, (self.h - h)/2 - h*0.25, w, h)
|
||||||
|
elseif self.follow_style == "topdown" then
|
||||||
|
local s = math.max(self.w, self.h)/4
|
||||||
|
self:set_deadzone((self.w - s)/2, (self.h - s)/2, s, s)
|
||||||
|
elseif self.follow_style == "topdown_tight" then
|
||||||
|
local s = math.max(self.w, self.h)/8
|
||||||
|
self:set_deadzone((self.w - s)/2, (self.h - s)/2, s, s)
|
||||||
|
elseif self.follow_style == "screen_by_screen" then
|
||||||
|
self:set_deadzone(0, 0, 0, 0)
|
||||||
|
elseif self.follow_style == "no_deadzone" then
|
||||||
|
self.deadzone = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.deadzone then
|
||||||
|
self.x, self.y = self.target.x, self.target.y
|
||||||
|
if self.bound then
|
||||||
|
self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2)
|
||||||
|
self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local dx1, dy1, dx2, dy2 = self.deadzone.x, self.deadzone.y, self.deadzone.x + self.deadzone.w, self.deadzone.y + self.deadzone.h
|
||||||
|
local scroll_x, scroll_y = 0, 0
|
||||||
|
local target_x, target_y = self:get_local_coords(self.target.x, self.target.y)
|
||||||
|
local x, y = self:get_local_coords(self.x, self.y)
|
||||||
|
|
||||||
|
if self.follow_style == "screen_by_screen" then
|
||||||
|
if self.bound then
|
||||||
|
if self.x > self.bounds_min.x + self.w/2 and target_x < 0 then self.scroll.x = math.snap_center(self.scroll.x - self.w/self.sx, self.w/self.sx) end
|
||||||
|
if self.x < self.bounds_max.x - self.w/2 and target_x >= self.w then self.scroll.x = math.snap_center(self.scroll.x + self.w/self.sx, self.w/self.sx) end
|
||||||
|
if self.y > self.bounds_min.y + self.h/2 and target_y < 0 then self.scroll.y = math.snap_center(self.scroll.y - self.h/self.sy, self.h/self.sy) end
|
||||||
|
if self.y < self.bounds_max.y - self.h/2 and target_y >= self.h then self.scroll.y = math.snap_center(self.scroll.y + self.h/self.sy, self.h/self.sy) end
|
||||||
|
else
|
||||||
|
if target_x < 0 then self.scroll.x = math.snap_center(self.scroll.x - self.w/self.sx, self.w/self.sx) end
|
||||||
|
if target_x >= self.w then self.scroll.x = math.snap_center(self.scroll.x + self.w/self.sx, self.w/self.sx) end
|
||||||
|
if target_y < 0 then self.scroll.y = math.snap_center(self.scroll.y - self.h/self.sy, self.h/self.sy) end
|
||||||
|
if target_y >= self.h then self.scroll.y = math.snap_center(self.scroll.y + self.h/self.sy, self.h/self.sy) end
|
||||||
|
end
|
||||||
|
self.x = math.lerp(self.lerp.x, self.x, self.scroll.x)
|
||||||
|
self.y = math.lerp(self.lerp.y, self.y, self.scroll.y)
|
||||||
|
|
||||||
|
if self.bound then
|
||||||
|
self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2)
|
||||||
|
self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
if target_x < x + (dx1 + dx2 - x) then
|
||||||
|
local d = target_x - dx1
|
||||||
|
if d < 0 then scroll_x = d end
|
||||||
|
end
|
||||||
|
if target_x > x - (dx1 + dx2 - x) then
|
||||||
|
local d = target_x - dx2
|
||||||
|
if d > 0 then scroll_x = d end
|
||||||
|
end
|
||||||
|
if target_y < y + (dy1 + dy2 - y) then
|
||||||
|
local d = target_y - dy1
|
||||||
|
if d < 0 then scroll_y = d end
|
||||||
|
end
|
||||||
|
if target_y > y - (dy1 + dy2 - y) then
|
||||||
|
local d = target_y - dy2
|
||||||
|
if d > 0 then scroll_y = d end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.last_target.x and not self.last_target.y then self.last_target.x, self.last_target.y = self.target.x, self.target.y end
|
||||||
|
scroll_x = scroll_x + (self.target.x - self.last_target.x)*self.lead.x
|
||||||
|
scroll_y = scroll_y + (self.target.y - self.last_target.y)*self.lead.y
|
||||||
|
self.last_target.x, self.last_target.y = self.target.x, self.target.y
|
||||||
|
self.x = math.lerp(self.lerp.x, self.x, self.x + scroll_x)
|
||||||
|
self.y = math.lerp(self.lerp.y, self.y, self.y + scroll_y)
|
||||||
|
|
||||||
|
if self.bound then
|
||||||
|
self.x = math.min(math.max(self.x, self.bounds_min.x + self.w/2), self.bounds_max.x - self.w/2)
|
||||||
|
self.y = math.min(math.max(self.y, self.bounds_min.y + self.h/2), self.bounds_max.y - self.h/2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Shakes the camera with a certain intensity for duration seconds and with the specified frequency
|
||||||
|
-- Higher frequency means jerkier movement, lower frequency means smoother movement
|
||||||
|
-- camera:shake(10, 1, 120) -> shakes the camera with 10 intensity for 1 second and 120 frequency
|
||||||
|
function Camera:shake(intensity, duration, frequency)
|
||||||
|
table.insert(self.shakes.x, Shake(intensity, 1000*(duration or 0), frequency or 60))
|
||||||
|
table.insert(self.shakes.y, Shake(intensity, 1000*(duration or 0), frequency or 60))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Shakes the camera with a certain intensity towards angle r using a spring mechanism
|
||||||
|
-- k and d are stiffness and damping spring values (see spring file for more)
|
||||||
|
-- camera:shake(10, math.pi/4) -> shakes the camera with 10 intensity diagonally
|
||||||
|
function Camera:spring_shake(intensity, r, k, d)
|
||||||
|
self.spring.x:pull(-intensity*math.cos(r or 0), k, d)
|
||||||
|
self.spring.y:pull(-intensity*math.sin(r or 0), k, d)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- When following an object, this function sets a deadzone in which the camera can move freely in before having to go back to following the object
|
||||||
|
-- TODO: add STALKER-X documentation examples of all deadzones and lerping modes here
|
||||||
|
function Camera:set_deadzone(x, y, w, h)
|
||||||
|
self.deadzone = {x = x, y = y, w = w, h = h}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the boundaries of the camera as a rectangle.
|
||||||
|
-- The camera's center will not be allowed to move outside the boundaries of this rectangle.
|
||||||
|
-- TODO: this doesn't seem to work when zooming levels are different than 1, fix it
|
||||||
|
function Camera:set_bounds(x, y, w, h)
|
||||||
|
self.bound = true
|
||||||
|
self.bounds_min = {x = x - w/2, y = y - h/2}
|
||||||
|
self.bounds_max = {x = x + w/2, y = y + h/2}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Tells the camera to follow the object
|
||||||
|
-- Previously set lerp, lead, follow styles and deadzone variables apply when following the object
|
||||||
|
function Camera:follow_object(obj)
|
||||||
|
self.target = obj
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the mouse's position in world coordinates
|
||||||
|
-- x, y = camera:get_mouse_position()
|
||||||
|
function Camera:get_mouse_position()
|
||||||
|
return self:get_world_coords(love.mouse.getPosition())
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the angle from a point to the mouse
|
||||||
|
-- x, y = camera:angle_to_mouse(point.x, point.y)
|
||||||
|
function Camera:angle_to_mouse(x, y)
|
||||||
|
local mx, my = self:get_mouse_position()
|
||||||
|
return math.angle(x, y, mx, my)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Camera:apply_impulse(f, r)
|
||||||
|
self.impulse:set(f*math.cos(r), f*math.sin(r))
|
||||||
|
end
|
|
@ -0,0 +1,67 @@
|
||||||
|
-- A canvas object for offscreen rendering.
|
||||||
|
Canvas = Object:extend()
|
||||||
|
function Canvas:init(w, h, opts)
|
||||||
|
local opts = opts or {}
|
||||||
|
self.w, self.h = w, h
|
||||||
|
self.canvas = love.graphics.newCanvas(self.w, self.h, {msaa = opts.msaa})
|
||||||
|
self.stencil = opts.stencil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws the canvas to the screen.
|
||||||
|
--[[
|
||||||
|
function init()
|
||||||
|
canvas = Canvas(gw, gh)
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw()
|
||||||
|
canvas:draw_to(function()
|
||||||
|
-- draw your game
|
||||||
|
end)
|
||||||
|
canvas:draw(0, 0, 0, sx, sy)
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
function Canvas:draw(x, y, r, sx, sy, ox, oy)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.setBlendMode("alpha", "premultiplied")
|
||||||
|
love.graphics.draw(self.canvas, x or 0, y or 0, r or 0, sx or 1, sy or 1, ox or 0, oy or 0)
|
||||||
|
love.graphics.setBlendMode("alpha")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Canvas:draw2(x, y, r, sx, sy, ox, oy)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.draw(self.canvas, x or 0, y or 0, r or 0, sx or 1, sy or 1, ox or 0, oy or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Takes in a function and uses it to draw to this canvas.
|
||||||
|
-- canvas:draw_to(function()
|
||||||
|
-- graphics.rectangle(gw/2, gh/2, 50, 50)
|
||||||
|
-- end)
|
||||||
|
function Canvas:draw_to(action)
|
||||||
|
love.graphics.setCanvas({self.canvas, stencil = self.stencil})
|
||||||
|
love.graphics.clear()
|
||||||
|
action()
|
||||||
|
love.graphics.setCanvas()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this canvas as the active one.
|
||||||
|
function Canvas:set()
|
||||||
|
current_canvas = self
|
||||||
|
love.graphics.setCanvas(self.canvas)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Unsets this canvas as the active one.
|
||||||
|
function Canvas:unset()
|
||||||
|
current_canvas = nil
|
||||||
|
love.graphics.setCanvas()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Clears this canvas' buffer.
|
||||||
|
function Canvas:clear()
|
||||||
|
love.graphics.clear()
|
||||||
|
end
|
|
@ -0,0 +1,91 @@
|
||||||
|
-- A basic color object.
|
||||||
|
-- Colors can be created in 3 forms:
|
||||||
|
-- color = Color('#ffffff')
|
||||||
|
-- color = Color(255, 255, 255)
|
||||||
|
-- color = Color(1, 1, 1)
|
||||||
|
-- You can access the colors values via .r, .g, .b and .a.
|
||||||
|
-- You can create a copy of a color by calling color:clone().
|
||||||
|
Color = Object:extend()
|
||||||
|
function Color:init(r, g, b, a)
|
||||||
|
if type(r) == "string" then
|
||||||
|
local hex = r:gsub("#", "")
|
||||||
|
self.r = tonumber("0x" .. hex:sub(1, 2))/255
|
||||||
|
self.g = tonumber("0x" .. hex:sub(3, 4))/255
|
||||||
|
self.b = tonumber("0x" .. hex:sub(5, 6))/255
|
||||||
|
self.a = 1
|
||||||
|
else
|
||||||
|
if r > 1 or g > 1 or b > 1 then
|
||||||
|
self.r = r/255
|
||||||
|
self.g = g/255
|
||||||
|
self.b = b/255
|
||||||
|
self.a = (a or 255)/255
|
||||||
|
else
|
||||||
|
self.r = r
|
||||||
|
self.g = g
|
||||||
|
self.b = b
|
||||||
|
self.a = a or 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Color:clone()
|
||||||
|
return Color(self.r, self.g, self.b, self.a)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Color:lighten(v)
|
||||||
|
local h, s, l = self:_to_hsl()
|
||||||
|
l = l + v
|
||||||
|
self.r, self.g, self.b = self:_to_rgb(h, s, l)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Color:darken(v)
|
||||||
|
local h, s, l = self:_to_hsl()
|
||||||
|
l = l - v
|
||||||
|
self.r, self.g, self.b = self:_to_rgb(h, s, l)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Color:fade(v)
|
||||||
|
self.a = self.a - v
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Color:_to_hsl()
|
||||||
|
local max, min = math.max(self.r, self.g, self.b), math.min(self.r, self.g, self.b)
|
||||||
|
local h, s, l
|
||||||
|
l = (max + min)/2
|
||||||
|
if max == min then h, s = 0, 0
|
||||||
|
else
|
||||||
|
local d = max - min
|
||||||
|
if l > 0.5 then s = d/(2 - max - min) else s = d/(max + min) end
|
||||||
|
if max == self.r then
|
||||||
|
h = (self.g - self.b)/d
|
||||||
|
if self.g < self.b then h = h + 6 end
|
||||||
|
elseif max == self.g then h = (self.b - self.r)/d + 2
|
||||||
|
elseif max == self.b then h = (self.r - self.g)/d + 4 end
|
||||||
|
h = h/6
|
||||||
|
end
|
||||||
|
return h, s, l
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Color:_to_rgb(h, s, l)
|
||||||
|
if s == 0 then return math.clamp(l, 0, 1), math.clamp(l, 0, 1), math.clamp(l, 0, 1) end
|
||||||
|
local function to(p, q, t)
|
||||||
|
if t < 0 then t = t + 1 end
|
||||||
|
if t > 1 then t = t - 1 end
|
||||||
|
if t < .16667 then return p + (q - p)*6*t end
|
||||||
|
if t < .5 then return q end
|
||||||
|
if t < .66667 then return p + (q - p)*(.66667 - t)*6 end
|
||||||
|
return p
|
||||||
|
end
|
||||||
|
local q = l < .5 and l*(1 + s) or l + s - l*s
|
||||||
|
local p = 2*l - q
|
||||||
|
return math.clamp(to(p, q, h + .33334), 0, 1), math.clamp(to(p, q, h), 0, 1), math.clamp(to(p, q, h - .33334), 0, 1)
|
||||||
|
end
|
|
@ -0,0 +1,16 @@
|
||||||
|
-- The base Font class.
|
||||||
|
Font = Object:extend()
|
||||||
|
function Font:init(asset_name, font_size)
|
||||||
|
self.font = love.graphics.newFont("assets/fonts/" .. asset_name .. ".ttf", font_size)
|
||||||
|
self.h = self.font:getHeight()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Font:get_text_width(text)
|
||||||
|
return self.font:getWidth(text)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Font:get_height()
|
||||||
|
return self.font:getHeight()
|
||||||
|
end
|
|
@ -0,0 +1,370 @@
|
||||||
|
graphics = {}
|
||||||
|
graphics.debug_queries = {}
|
||||||
|
graphics.debug_draw = false
|
||||||
|
|
||||||
|
|
||||||
|
-- All operations after this is called will be affected by the transform.
|
||||||
|
function graphics.push(x, y, r, sx, sy)
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(x or 0, y or 0)
|
||||||
|
love.graphics.scale(sx or 1, sy or sx or 1)
|
||||||
|
love.graphics.rotate(r or 0)
|
||||||
|
love.graphics.translate(-x or 0, -y or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- All operations after this is called will not be affected by the transform set with graphics.push.
|
||||||
|
function graphics.pop()
|
||||||
|
love.graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.translate(x, y)
|
||||||
|
love.graphics.translate(x or 0, y or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.rotate(r)
|
||||||
|
love.graphics.rotate(r or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.scale(sx, sy)
|
||||||
|
love.graphics.scale(sx or 1, sy or sx or 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.update(dt)
|
||||||
|
for i = #self.debug_queries, 1, -1 do
|
||||||
|
local query = self.debug_queries[i]
|
||||||
|
query.frames = query.frames - 1
|
||||||
|
if query.frames <= 0 then table.remove(self.debug_queries, i) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Adds a polygon to be drawn to the screen for a few frames. Useful when debugging visual shapes.
|
||||||
|
function graphics.add_polygon_debug_query(vertices, frames)
|
||||||
|
table.insert(self.debug_queries, {vertices = vertices, frames = frames, type = "polygon"})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.draw_debug_queries()
|
||||||
|
for _, query in ipairs(self.debug_queries) do
|
||||||
|
if query.type == "polygon" then
|
||||||
|
self:polygon(query.vertices)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Prints text to the screen, alternative to using a Text object.
|
||||||
|
function graphics.print(text, font, x, y, r, sx, sy, ox, oy, color)
|
||||||
|
local _r, g, b, a = love.graphics.getColor()
|
||||||
|
if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end
|
||||||
|
love.graphics.print(text, font.font, x, y, r or 0, sx or 1, sy or 1, ox or 0, oy or 0)
|
||||||
|
if color then love.graphics.setColor(_r, g, b, a) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Prints text to the screen centered on x, y, alternative to using a Text object.
|
||||||
|
function graphics.print_centered(text, font, x, y, r, sx, sy, ox, oy, color)
|
||||||
|
local _r, g, b, a = love.graphics.getColor()
|
||||||
|
if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end
|
||||||
|
love.graphics.print(text, font.font, x, y, r or 0, sx or 1, sy or 1, (ox or 0) + font:get_text_width(text)/2, (oy or 0) + font.h/2)
|
||||||
|
if color then love.graphics.setColor(_r, g, b, a) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.shape(shape, color, line_width, ...)
|
||||||
|
local r, g, b, a = love.graphics.getColor()
|
||||||
|
if not color and not line_width then love.graphics[shape]("line", ...)
|
||||||
|
elseif color and not line_width then
|
||||||
|
love.graphics.setColor(color.r, color.g, color.b, color.a)
|
||||||
|
love.graphics[shape]("fill", ...)
|
||||||
|
else
|
||||||
|
if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end
|
||||||
|
love.graphics.setLineWidth(line_width)
|
||||||
|
love.graphics[shape]("line", ...)
|
||||||
|
love.graphics.setLineWidth(1)
|
||||||
|
end
|
||||||
|
love.graphics.setColor(r, g, b, a)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a rectangle of size w, h centered on x, y.
|
||||||
|
-- If rx, ry are passed in, then the rectangle will have rounded corners with radius of that size.
|
||||||
|
-- If color is passed in then the rectangle will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the rectangle will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.rectangle(x, y, w, h, rx, ry, color, line_width)
|
||||||
|
graphics.shape("rectangle", color, line_width, x - w/2, y - h/2, w, h, rx, ry)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a rectangle of size w, h centered on x - w/2, y - h/2.
|
||||||
|
-- If rx, ry are passed in, then the rectangle will have rounded corners with radius of that size.
|
||||||
|
-- If color is passed in then the rectangle will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the rectangle will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.rectangle2(x, y, w, h, rx, ry, color, line_width)
|
||||||
|
graphics.shape("rectangle", color, line_width, x, y, w, h, rx, ry)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a dashed rectangle of size w, h centerd on x, y.
|
||||||
|
-- dash_size and gap_size correspond to the dimensions of the dashing behavior.
|
||||||
|
function graphics.dashed_rectangle(x, y, w, h, dash_size, gap_size, color, line_width)
|
||||||
|
graphics.dashed_line(x - w/2, y - h/2, x + w/2, y - h/2, dash_size, gap_size, color, line_width)
|
||||||
|
graphics.dashed_line(x - w/2, y - h/2, x - w/2, y + h/2, dash_size, gap_size, color, line_width)
|
||||||
|
graphics.dashed_line(x - w/2, y + h/2, x + w/2, y + h/2, dash_size, gap_size, color, line_width)
|
||||||
|
graphics.dashed_line(x + w/2, y - h/2, x + w/2, y + h/2, dash_size, gap_size, color, line_width)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws an isosceles triangle with size w, h centered on x, y pointed to the right (angle 0).
|
||||||
|
-- If color is passed in then the triangle will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the triangle will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.triangle(x, y, w, h, color, line_width)
|
||||||
|
local x1, y1 = x + h/2, y
|
||||||
|
local x2, y2 = x - h/2, y - w/2
|
||||||
|
local x3, y3 = x - h/2, y + w/2
|
||||||
|
graphics.polygon({x1, y1, x2, y2, x3, y3}, color, line_width)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws an equilateral triangle with size w centered on x, y pointed to the right (angle 0).
|
||||||
|
-- If color is passed in then the triangle will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the triangle will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.triangle_equilateral(x, y, w, color, line_width)
|
||||||
|
local h = math.sqrt(math.pow(w, 2) - math.pow(w/2, 2))
|
||||||
|
graphics.triangle(x, y, w, h, color, line_width)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a circle of radius r centered on x, y.
|
||||||
|
-- If color is passed in then the circle will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the circle will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.circle(x, y, r, color, line_width)
|
||||||
|
graphics.shape("circle", color, line_width, x, y, r)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a polygon with the given points.
|
||||||
|
-- If color is passed in then the polygon will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the polygon will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.polygon(vertices, color, line_width)
|
||||||
|
graphics.shape("polygon", color, line_width, vertices)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a line with the given points.
|
||||||
|
function graphics.line(x1, y1, x2, y2, color, line_width)
|
||||||
|
local r, g, b, a = love.graphics.getColor()
|
||||||
|
if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end
|
||||||
|
if line_width then love.graphics.setLineWidth(line_width) end
|
||||||
|
love.graphics.line(x1, y1, x2, y2)
|
||||||
|
love.graphics.setColor(r, g, b, a)
|
||||||
|
love.graphics.setLineWidth(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.polyline(color, line_width, ...)
|
||||||
|
local r, g, b, a = love.graphics.getColor()
|
||||||
|
if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end
|
||||||
|
if line_width then love.graphics.setLineWidth(line_width) end
|
||||||
|
love.graphics.line(...)
|
||||||
|
love.graphics.setColor(r, g, b, a)
|
||||||
|
love.graphics.setLineWidth(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a line with rounded ends with the given points.
|
||||||
|
-- If color is passed in then the line will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the line will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.rounded_line(x1, y1, x2, y2, color, line_width)
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(x1, y1)
|
||||||
|
love.graphics.rotate(math.angle(x1, y1, x2, y2))
|
||||||
|
love.graphics.translate(-x1, -y1)
|
||||||
|
graphics.rectangle(x1, y1 - line_width/4, math.length(x2-x1, y2-y1), line_width/2, line_width/4, line_width/4, color)
|
||||||
|
love.graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a dashed line with the given points.
|
||||||
|
-- dash_size and gap_size correspond to the dimensions of the dashing behavior.
|
||||||
|
-- If color is passed in then the lines will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the lines will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.dashed_line(x1, y1, x2, y2, dash_size, gap_size, color, line_width)
|
||||||
|
local r, g, b, a = love.graphics.getColor()
|
||||||
|
if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end
|
||||||
|
if line_width then love.graphics.setLineWidth(line_width) end
|
||||||
|
local dx, dy = x2-x1, y2-y1
|
||||||
|
local an, st = math.atan2(dy, dx), dash_size + gap_size
|
||||||
|
local len = math.sqrt(dx*dx + dy*dy)
|
||||||
|
local nm = (len-dash_size)/st
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(x1, y1)
|
||||||
|
love.graphics.rotate(an)
|
||||||
|
for i = 0, nm do love.graphics.line(i*st, 0, i*st + dash_size, 0) end
|
||||||
|
love.graphics.line(nm*st, 0, nm*st + dash_size, 0)
|
||||||
|
love.graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a dashed line with rounded ends with the given points.
|
||||||
|
-- dash_size and gap_size correspond to the dimensions of the dashing behavior.
|
||||||
|
-- If color is passed in then the lines will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the lines will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.dashed_rounded_line(x1, y1, x2, y2, dash_size, gap_size, color, line_width)
|
||||||
|
if color then love.graphics.setColor(color.r, color.g, color.b, color.a) end
|
||||||
|
if line_width then love.graphics.setLineWidth(line_width) end
|
||||||
|
local dx, dy = x2-x1, y2-y1
|
||||||
|
local an, st = math.atan2(dy, dx), dash_size + gap_size
|
||||||
|
local len = math.sqrt(dx*dx + dy*dy)
|
||||||
|
local nm = (len-dash_size)/st
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(x1, y1)
|
||||||
|
love.graphics.rotate(an)
|
||||||
|
for i = 0, nm do
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(i*st, 0)
|
||||||
|
love.graphics.rotate(math.angle(i*st, 0, i*st + dash_size, 0))
|
||||||
|
love.graphics.translate(-i*st, -0)
|
||||||
|
graphics.shape("rectangle", color, nil, i*st, 0, math.length((i*st + dash_size)-(i*st), 0-0), line_width/2, line_width/4, line_width/4)
|
||||||
|
love.graphics.pop()
|
||||||
|
end
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(nm*st, 0)
|
||||||
|
love.graphics.rotate(math.angle(nm*st, 0, nm*st + dash_size, 0))
|
||||||
|
love.graphics.translate(-nm*st, -0)
|
||||||
|
graphics.shape("rectangle", color, nil, nm*st, 0, math.length((nm*st + dash_size)-(nm*st), 0-0), line_width/2, line_width/4, line_width/4)
|
||||||
|
love.graphics.pop()
|
||||||
|
love.graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws an ellipse with radius rx, ry centered on x, y.
|
||||||
|
-- If color is passed in then the ellipse will be filled with that color (color is Color object)
|
||||||
|
-- If line_width is passed in then the ellipse will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function graphics.ellipse(x, y, rx, ry, color, line_width)
|
||||||
|
graphics.shape("ellipse", color, line_width, x, y, rx, ry)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the currently active shader, the passed in argument should be a Shader object.
|
||||||
|
function graphics.set_shader(shader)
|
||||||
|
if not shader then love.graphics.setShader()
|
||||||
|
else love.graphics.setShader(shader.shader) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the currently active color, the passed in argument should be a Color object.
|
||||||
|
function graphics.set_color(color)
|
||||||
|
love.graphics.setColor(color.r, color.g, color.b, color.a)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the currently active background color, the passed in argument should be a Color object.
|
||||||
|
function graphics.set_background_color(color)
|
||||||
|
love.graphics.setBackgroundColor(color.r, color.g, color.b, color.a)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.set_line_width(line_width)
|
||||||
|
love.graphics.setLineWidth(line_width)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the line style, possible values are 'rough' and 'smooth'.
|
||||||
|
function graphics.set_line_style(style)
|
||||||
|
love.graphics.setLineStyle(style)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the default filter mode, possible values are 'nearest' and 'linear'.
|
||||||
|
function graphics.set_default_filter(min, max)
|
||||||
|
love.graphics.setDefaultFilter(min, max)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.set_mouse_visible(value)
|
||||||
|
love.mouse.setVisible(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.stencil(...)
|
||||||
|
love.graphics.stencil(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function graphics.set_stencil_test(...)
|
||||||
|
love.graphics.setStencilTest(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local stencil_mask_shader = love.graphics.newShader[[
|
||||||
|
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc) {
|
||||||
|
vec4 t = Texel(texture, tc);
|
||||||
|
if (t.a == 0.0) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Draws the second image on top of the first but only the portions of it that aren't transparent are drawn.
|
||||||
|
-- action1 and action2 are functions that draw the images.
|
||||||
|
-- graphics.draw_intersection(function() player_image:draw(player.x, player.y) end, function() gradient_image:draw(player.x, player.y) end) -> draws the player with a gradient applied to it
|
||||||
|
function graphics.draw_intersection(action1, action2)
|
||||||
|
graphics.stencil(function() love.graphics.setShader(stencil_mask_shader); action1(); love.graphics.setShader() end, 'replace', 1)
|
||||||
|
graphics.set_stencil_test('greater', 0)
|
||||||
|
action2()
|
||||||
|
graphics.set_stencil_test()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- A very specific function to be used with rtfx.bat to generated RTFX animations.
|
||||||
|
-- This is not very useful in contexts other than this very specific thing, so it should probably not be here.
|
||||||
|
-- TODO: some kind of plugin system for functions like these that are very specific and not generalizable but still useful.
|
||||||
|
function graphics.generate_rtfx_animation(w, h)
|
||||||
|
local files = system.enumerate_files("assets/frames")
|
||||||
|
if #files <= 0 then return end
|
||||||
|
local frames = {}
|
||||||
|
for _, file in ipairs(files) do table.insert(frames, love.image.newImageData(file)) end
|
||||||
|
|
||||||
|
local out_frames = {}
|
||||||
|
local idw, idh = frames[1]:getDimensions()
|
||||||
|
local tw, th = w or 4, h or 4
|
||||||
|
local ow, oh = idw/tw, idh/th
|
||||||
|
|
||||||
|
for k = 1, #frames do
|
||||||
|
local image_data = frames[k]
|
||||||
|
local out_image_data = love.image.newImageData(ow, oh)
|
||||||
|
for i = 1, image_data:getWidth(), tw do
|
||||||
|
for j = 1, image_data:getHeight(), th do
|
||||||
|
local yes_or_no = {}
|
||||||
|
for x = 0, tw-1 do
|
||||||
|
for y = 0, th-1 do
|
||||||
|
local r, g, b, a = image_data:getPixel(i+x-1, j+y-1)
|
||||||
|
-- if r >= 0.01 and g >= 0.01 and b >= 0.01 then table.insert(yes_or_no, 1) end
|
||||||
|
if a >= 0.5 then table.insert(yes_or_no, 1) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #yes_or_no >= (tw*th)/2 then
|
||||||
|
out_image_data:setPixel(math.floor((i-1)/tw), math.floor((j-1)/th), 1, 1, 1, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(out_frames, out_image_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
local spritesheet_data = love.image.newImageData(ow*#out_frames, oh)
|
||||||
|
for k = 1, #out_frames do
|
||||||
|
for i = 0, out_frames[k]:getWidth()-1 do
|
||||||
|
for j = 0, out_frames[k]:getHeight()-1 do
|
||||||
|
spritesheet_data:setPixel(i + (k-1)*ow, j, out_frames[k]:getPixel(i, j))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
spritesheet_data:encode("png", "anim.png")
|
||||||
|
end
|
|
@ -0,0 +1,72 @@
|
||||||
|
-- The base Image class.
|
||||||
|
Image = Object:extend()
|
||||||
|
function Image:init(asset_name)
|
||||||
|
self.image = love.graphics.newImage("assets/images/" .. asset_name .. ".png")
|
||||||
|
self.w = self.image:getWidth()
|
||||||
|
self.h = self.image:getHeight()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Image:draw(x, y, r, sx, sy, ox, oy, color)
|
||||||
|
local _r, g, b, a
|
||||||
|
if color then
|
||||||
|
_r, g, b, a = love.graphics.getColor()
|
||||||
|
graphics.set_color(color)
|
||||||
|
end
|
||||||
|
love.graphics.draw(self.image, x, y, r or 0, sx or 1, sy or sx or 1, self.w/2 + (ox or 0), self.h/2 + (oy or 0))
|
||||||
|
if color then love.graphics.setColor(_r, g, b, a) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- The base Quad class. Useful for loading pieces of images as independent Image objects. Every function that takes in an Image also takes in a Quad.
|
||||||
|
Quad = Object:extend()
|
||||||
|
function Quad:init(image, tile_w, tile_h, tile_coordinates)
|
||||||
|
self.image = image
|
||||||
|
self.quad = love.graphics.newQuad((tile_coordinates[1]-1)*tile_w, (tile_coordinates[2]-1)*tile_h, tile_w, tile_h, self.image.w, self.image.h)
|
||||||
|
self.w, self.h = tile_w, tile_h
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Quad:draw(x, y, r, sx, sy, ox, oy)
|
||||||
|
love.graphics.draw(self.image.image, self.quad, x, y, r or 0, sx or 1, sy or sx or 1, self.w/2 + (ox or 0), self.h/2 + (oy or 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- A linear gradient image.
|
||||||
|
-- The first argument is the direction of the gradient and can be either 'horizontal' or 'vertical'.
|
||||||
|
GradientImage = Object:extend()
|
||||||
|
function GradientImage:init(direction, ...)
|
||||||
|
local colors = {...}
|
||||||
|
local mesh_data = {}
|
||||||
|
|
||||||
|
if direction == "horizontal" then
|
||||||
|
for i = 1, #colors do
|
||||||
|
local color = colors[i]
|
||||||
|
local x = (i-1)/(#colors-1)
|
||||||
|
table.insert(mesh_data, {x, 1, x, 1, color.r, color.g, color.b, color.a or 1})
|
||||||
|
table.insert(mesh_data, {x, 0, x, 0, color.r, color.g, color.b, color.a or 1})
|
||||||
|
end
|
||||||
|
elseif direction == "vertical" then
|
||||||
|
for i = 1, #colors do
|
||||||
|
local color = colors[i]
|
||||||
|
local y = (i-1)/(#colors-1)
|
||||||
|
table.insert(mesh_data, {1, y, 1, y, color.r, color.g, color.b, color.a or 1})
|
||||||
|
table.insert(mesh_data, {0, y, 0, y, color.r, color.g, color.b, color.a or 1})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.mesh = love.graphics.newMesh(mesh_data, "strip", "static")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws the gradient image with size w, h centered on x, y.
|
||||||
|
function GradientImage:draw(x, y, w, h, r, sx, sy, ox, oy)
|
||||||
|
graphics.push(x, y, r)
|
||||||
|
love.graphics.draw(self.mesh, x - (sx or 1)*(w + (ox or 0))/2, y - (sy or 1)*(h + (oy or 0))/2, 0, w*(sx or 1), h*(sy or sx or 1))
|
||||||
|
graphics.pop()
|
||||||
|
end
|
|
@ -0,0 +1,31 @@
|
||||||
|
-- The base Shader class.
|
||||||
|
Shader = Object:extend()
|
||||||
|
function Shader:init(vertex_name, fragment_name)
|
||||||
|
self.shader = love.graphics.newShader("assets/shaders/" .. (vertex_name or "default.vert"), "assets/shaders/" .. fragment_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets this shader as the active one.
|
||||||
|
function Shader:set()
|
||||||
|
current_shader = self
|
||||||
|
love.graphics.setShader(self.shader)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Unsets this shader as the active one.
|
||||||
|
function Shader:unset()
|
||||||
|
current_shader = nil
|
||||||
|
love.graphics.setShader()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Takes in a parameter and the data that corresponds to it and sends it to the shader.
|
||||||
|
-- shader:send('displacement_map', displacement_canvas)
|
||||||
|
function Shader:send(value, data)
|
||||||
|
if data:is(Canvas) then
|
||||||
|
self.shader:send(value, data.canvas)
|
||||||
|
elseif data:is(Image) then
|
||||||
|
self.shader:send(value, data.image)
|
||||||
|
else
|
||||||
|
self.shader:send(value, data)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,276 @@
|
||||||
|
-- A generic text object.
|
||||||
|
-- It implements a character based tagging system which should allow you to implement any kind of text effect possible, from setting a character's color to making it become visible, shake and play sounds.
|
||||||
|
-- You would use it like this:
|
||||||
|
--[[
|
||||||
|
yellow_text_tag = TextTag({
|
||||||
|
init = function(c, i, text)
|
||||||
|
text.yellow = Color(1, 0.5, 0, 1)
|
||||||
|
end,
|
||||||
|
draw = function(c, i, text)
|
||||||
|
graphics.set_color(text.yellow)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
shaking_text_tag = TextTag({
|
||||||
|
init = function(c, i, text)
|
||||||
|
c.shaking_intensity = 8
|
||||||
|
end,
|
||||||
|
update = function(c, dt, i, text)
|
||||||
|
c.ox = random:float(-c.shaking_intensity, c.shaking_intensity)
|
||||||
|
c.oy = random:float(-c.shaking_intensity, c.shaking_intensity)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
text = Text({
|
||||||
|
{text: '[yellow]This text is yellow', font: some_font, alignment: 'center', height_offset: -10}
|
||||||
|
{text: '[shaking]This text is shaking', font: some_other_font, alignment: 'center', height_multiplier: 1.2}
|
||||||
|
{text: 'This text is normal', font: yet_another_font, alignment: 'center', height_multiplier: 1.2}
|
||||||
|
{text: '[yellow, shaking]This text is yellow and shaking []while this text is normal', font: some_font, alignment: 'center'}
|
||||||
|
}, {yellow = yellow_text_tag, shaking = shaking_text_tag})
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- There are two main things happening in the example above: first we're creating TextTags and then we're creating a text object that uses those tags.
|
||||||
|
-- The way each tag works is fairly simple: a tag accepts 3 functions, init, update and draw, and each of those functions operates on the text's characters one at a time.
|
||||||
|
-- In the example above, the text without tags is 'This text is yellow while this text is shaking and this text is normal'
|
||||||
|
-- For each of the characters in that string, different functions will be applied based on what tags were previously applied to it.
|
||||||
|
-- init, update and draw functions take in 3 arguments in common:
|
||||||
|
-- c - the character in question, a table containing .x, .y, .r, .sx, .sy, .ox, .oy and .character attributes.
|
||||||
|
-- i - the index of character in the string
|
||||||
|
-- text - the reference to the text object
|
||||||
|
-- The update function also takes in dt as the second argument.
|
||||||
|
--
|
||||||
|
-- After we're done creating TextTags, we have to create the actual text object.
|
||||||
|
-- The way this is done is by specifying each line of the text object, along with its font, alignment, height multipliers and height offsets.
|
||||||
|
-- The first argument (text_data) is a table of tables containing all relevant info:
|
||||||
|
-- text - the actual string containing the text to be displayed, along with any tag information
|
||||||
|
-- font - the font to be used for the text
|
||||||
|
-- alignment (optional) - how the text should align itself, possible values are 'center', 'justified', 'right', if not specified then by default it's 'left'
|
||||||
|
-- height_offset (optional) - how many pixels the line below this one should be offset by
|
||||||
|
-- height_multiplier (optional) - multiplier over the font's height for placing the line below
|
||||||
|
-- The text object itself also has .w and .h which corresponds to the width of the biggest line and height of all lines + offsets, respectively.
|
||||||
|
-- If 'alignment_width' is set to a specific line then that line will be automatically set to that width, and if it is the biggest then .w will also be set to that value.
|
||||||
|
Text = Object:extend()
|
||||||
|
function Text:init(text_data, text_tags)
|
||||||
|
self.trigger = Trigger()
|
||||||
|
self.text_data = text_data
|
||||||
|
self.text_tags = text_tags
|
||||||
|
self.white = Color(1, 1, 1, 1)
|
||||||
|
self:set_text(text_data)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Text:update(dt)
|
||||||
|
self.trigger:update(dt)
|
||||||
|
self:format_text()
|
||||||
|
for _, line in ipairs(self.lines) do
|
||||||
|
for i, c in ipairs(line.characters) do
|
||||||
|
for k, v in pairs(self.text_tags) do
|
||||||
|
for _, tag in ipairs(c.tags) do
|
||||||
|
if tag == k then
|
||||||
|
if v.actions.update then
|
||||||
|
v.actions.update(c, dt, i, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws the text object centered at the specified location.
|
||||||
|
function Text:draw(x, y, r, sx, sy)
|
||||||
|
for _, line in ipairs(self.lines) do
|
||||||
|
for i, c in ipairs(line.characters) do
|
||||||
|
for k, v in pairs(self.text_tags) do
|
||||||
|
for _, tag in ipairs(c.tags) do
|
||||||
|
if tag == k then
|
||||||
|
if v.actions.draw then
|
||||||
|
v.actions.draw(c, i, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
graphics.push(x, y, r, sx, sy)
|
||||||
|
graphics.print(c.character, line.font, x + c.x - self.w/2, y + c.y - self.h/2, c.r or 0, c.sx or 1, c.sy or c.sx or 1, c.ox or 0, c.oy or 0)
|
||||||
|
graphics.pop()
|
||||||
|
graphics.set_color(self.white)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Text:format_text()
|
||||||
|
self.w = 0
|
||||||
|
for i, line in ipairs(self.lines) do
|
||||||
|
local line_width = math.max(line.font:get_text_width(line.raw_text), line.alignment_width or 0)
|
||||||
|
if line_width > self.w then
|
||||||
|
self.w = line_width
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local x, y = 0, 0
|
||||||
|
for j, line in ipairs(self.lines) do
|
||||||
|
local h = (line.font.h*(line.height_multiplier or 1) + (line.height_offset or 0))*(line.sy or 1)
|
||||||
|
for i, c in ipairs(line.characters) do
|
||||||
|
c.x = x
|
||||||
|
c.y = y
|
||||||
|
c.sx = line.sx or 1
|
||||||
|
c.sy = line.sy or 1
|
||||||
|
x = x + line.font:get_text_width(c.character)
|
||||||
|
end
|
||||||
|
y = y + h
|
||||||
|
x = 0
|
||||||
|
end
|
||||||
|
self.h = y
|
||||||
|
|
||||||
|
for i, line in ipairs(self.lines) do
|
||||||
|
if line.alignment == "right" then
|
||||||
|
local text_width = 0
|
||||||
|
for _, c in ipairs(line.characters) do text_width = text_width + line.font:get_text_width(c.character) end
|
||||||
|
local left_over_width = self.w - (line.alignment_width or text_width)
|
||||||
|
for _, c in ipairs(line.characters) do c.x = c.x + left_over_width end
|
||||||
|
|
||||||
|
elseif line.alignment == "center" then
|
||||||
|
local text_width = 0
|
||||||
|
for _, c in ipairs(line.characters) do text_width = text_width + line.font:get_text_width(c.character) end
|
||||||
|
local left_over_width = self.w - (line.alignment_width or text_width)
|
||||||
|
for _, c in ipairs(line.characters) do c.x = c.x + left_over_width/2 end
|
||||||
|
|
||||||
|
elseif line.alignment == "justified" then
|
||||||
|
local text_width = 0
|
||||||
|
for _, c in ipairs(line.characters) do text_width = text_width + line.font:get_text_width(c.character) end
|
||||||
|
local left_over_width = self.w - (line.alignment_width or text_width)
|
||||||
|
local spaces_count = 0
|
||||||
|
for _, c in ipairs(line.characters) do
|
||||||
|
if c.character == " " then
|
||||||
|
spaces_count = spaces_count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local added_width_to_each_space = math.floor(left_over_width/spaces_count)
|
||||||
|
local total_added_width = 0
|
||||||
|
for _, c in ipairs(characters) do
|
||||||
|
if c.character == " " then
|
||||||
|
c.x = c.x + added_width_to_each_space
|
||||||
|
total_added_width = total_added_width + added_width_to_each_space
|
||||||
|
else
|
||||||
|
c.x = c.x + total_added_width
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Text:parse(text_data)
|
||||||
|
for _, line in ipairs(text_data) do
|
||||||
|
local tags = {}
|
||||||
|
for i, tags_text, j in line.text:gmatch("()%[(.-)%]()") do
|
||||||
|
if tags_text == "" then
|
||||||
|
table.insert(tags, {i = tonumber(i), j = tonumber(j)-1})
|
||||||
|
line.tags = tags
|
||||||
|
else
|
||||||
|
local local_tags = {}
|
||||||
|
for tag in tags_text:gmatch("[%w_]+") do table.insert(local_tags, tag) end
|
||||||
|
table.insert(tags, {i = tonumber(i), j = tonumber(j)-1, tags = local_tags})
|
||||||
|
line.tags = tags
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not line.tags then line.tags = {} end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, line in ipairs(text_data) do
|
||||||
|
line.characters = {}
|
||||||
|
local current_tags = nil
|
||||||
|
for i = 1, #line.text do
|
||||||
|
local c = line.text:sub(i, i)
|
||||||
|
local inside_tags = false
|
||||||
|
for _, tag in ipairs(line.tags) do
|
||||||
|
if i >= tag.i and i <= tag.j then
|
||||||
|
inside_tags = true
|
||||||
|
current_tags = tag.tags
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not inside_tags then
|
||||||
|
table.insert(line.characters, {character = c, visible = true, tags = current_tags or {}})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, line in ipairs(text_data) do
|
||||||
|
local raw_text = ""
|
||||||
|
for _, character in ipairs(line.characters) do
|
||||||
|
raw_text = raw_text .. character.character
|
||||||
|
end
|
||||||
|
line.raw_text = raw_text
|
||||||
|
end
|
||||||
|
|
||||||
|
return text_data
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets new text.
|
||||||
|
-- Reapplies all modifications (wrap width, justification, etc).
|
||||||
|
function Text:set_text(text_data)
|
||||||
|
self.lines = self:parse(text_data)
|
||||||
|
self:format_text()
|
||||||
|
for _, line in ipairs(self.lines) do
|
||||||
|
for i, c in ipairs(line.characters) do
|
||||||
|
for k, v in pairs(self.text_tags) do
|
||||||
|
for _, tag in ipairs(c.tags) do
|
||||||
|
if tag == k then
|
||||||
|
if v.actions.init then
|
||||||
|
v.actions.init(c, i, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the line's alignment width.
|
||||||
|
-- This is used to align the text according to the alignment option
|
||||||
|
-- For instance, if the alignment width is 200 and the alignment is 'right', then the right edge used for this alignment will be 200 units to the right
|
||||||
|
function Text:set_alignment_width(line, alignment_width)
|
||||||
|
self.alignment_width = alignment_width
|
||||||
|
self:format_text()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the text's line height.
|
||||||
|
-- Lines are automatically placed vertically using the font's height for spacing, but you can increase or decrease this distance by setting these values.
|
||||||
|
function Text:set_line_height_data(line, offset, multiplier)
|
||||||
|
self.lines[line].height_offset = offset or 0
|
||||||
|
self.lines[line].height_multiplier = multiplier or 1
|
||||||
|
self:format_text()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the text's font. By default texts use the global font.
|
||||||
|
function Text:set_font(line, font)
|
||||||
|
self.lines[line].font = font
|
||||||
|
self:format_text()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Sets the alignment behavior for the given line.
|
||||||
|
-- Possible behaviors are: 'right', 'center' and 'justified'
|
||||||
|
function Text:set_alignment(line, alignment)
|
||||||
|
self.lines[line].alignment = alignment
|
||||||
|
self:format_text()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- The text tag objects to be used with text instances.
|
||||||
|
TextTag = Object:extend()
|
||||||
|
function TextTag:init(actions)
|
||||||
|
self.actions = actions
|
||||||
|
end
|
|
@ -0,0 +1,27 @@
|
||||||
|
-- The class responsible for loading and drawing tilesets.
|
||||||
|
-- This is primarily used by the Tilemap class.
|
||||||
|
Tileset = Object:extend()
|
||||||
|
function Tileset:init(image, tile_w, tile_h)
|
||||||
|
self.image = image
|
||||||
|
self.tile_w, self.tile_h = tile_w, tile_h
|
||||||
|
self.grid = Grid(math.floor(self.image.w/self.tile_w), math.floor(self.image.h/self.tile_h), 0)
|
||||||
|
self.w, self.h = self.grid.w, self.grid.h
|
||||||
|
for i = 1, self.grid.w do
|
||||||
|
for j = 1, self.grid.h do
|
||||||
|
self.grid:set(i, j, love.graphics.newQuad((i-1)*self.tile_w, (j-1)*self.tile_h, self.tile_w, self.tile_h, self.image.w, self.image.h))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a tile based on its tileset 1D index.
|
||||||
|
-- If the tileset has width 10 (10 columns) then the index 11 corresponds to the first tile in the second row.
|
||||||
|
function Tileset:draw_tile(index, x, y, r, sx, sy, ox, oy)
|
||||||
|
love.graphics.draw(self.image.image, self:get_quad(index), x, y, r or 0, sx or 1, sy or sx or 1, ox or 0, oy or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the quad that represents the tile at the given index.
|
||||||
|
function Tileset:get_quad(index)
|
||||||
|
return self.grid:get(math.index_to_coordinates(index, self.w))
|
||||||
|
end
|
|
@ -0,0 +1,157 @@
|
||||||
|
local path = ...
|
||||||
|
if not path:find("init") then
|
||||||
|
require(path .. ".datastructures.string")
|
||||||
|
require(path .. ".datastructures.table")
|
||||||
|
require(path .. ".external")
|
||||||
|
require(path .. ".graphics.graphics")
|
||||||
|
require(path .. ".game.object")
|
||||||
|
require(path .. ".system")
|
||||||
|
require(path .. ".datastructures.graph")
|
||||||
|
require(path .. ".datastructures.grid")
|
||||||
|
require(path .. ".game.gameobject")
|
||||||
|
require(path .. ".game.group")
|
||||||
|
require(path .. ".game.state")
|
||||||
|
require(path .. ".game.physics")
|
||||||
|
require(path .. ".game.steering")
|
||||||
|
require(path .. ".graphics.animation")
|
||||||
|
require(path .. ".graphics.camera")
|
||||||
|
require(path .. ".graphics.canvas")
|
||||||
|
require(path .. ".graphics.color")
|
||||||
|
require(path .. ".graphics.font")
|
||||||
|
require(path .. ".graphics.image")
|
||||||
|
require(path .. ".graphics.shader")
|
||||||
|
require(path .. ".graphics.text")
|
||||||
|
require(path .. ".graphics.tileset")
|
||||||
|
require(path .. ".map.solid")
|
||||||
|
require(path .. ".map.tilemap")
|
||||||
|
require(path .. ".math.polygon")
|
||||||
|
require(path .. ".math.chain")
|
||||||
|
require(path .. ".math.circle")
|
||||||
|
require(path .. ".math.line")
|
||||||
|
require(path .. ".math.math")
|
||||||
|
require(path .. ".math.random")
|
||||||
|
require(path .. ".math.rectangle")
|
||||||
|
require(path .. ".math.spring")
|
||||||
|
require(path .. ".math.triangle")
|
||||||
|
require(path .. ".math.vector")
|
||||||
|
require(path .. ".game.trigger")
|
||||||
|
require(path .. ".game.input")
|
||||||
|
require(path .. ".sound")
|
||||||
|
require(path .. ".game.parent")
|
||||||
|
require(path .. ".game.springs")
|
||||||
|
require(path .. ".game.flashes")
|
||||||
|
require(path .. ".game.hitfx")
|
||||||
|
end
|
||||||
|
|
||||||
|
function engine_run(config)
|
||||||
|
if not web then
|
||||||
|
love.filesystem.setIdentity(config.game_name)
|
||||||
|
|
||||||
|
local _, _, flags = love.window.getMode()
|
||||||
|
local window_width, window_height = love.window.getDesktopDimensions(flags.display)
|
||||||
|
if config.window_width ~= 'max' then window_width = config.window_width end
|
||||||
|
if config.window_height ~= 'max' then window_height = config.window_height end
|
||||||
|
|
||||||
|
local limits = love.graphics.getSystemLimits()
|
||||||
|
local anisotropy = limits.anisotropy
|
||||||
|
msaa = limits.canvasmsaa
|
||||||
|
if config.msaa ~= 'max' then msaa = config.msaa end
|
||||||
|
if config.anisotropy ~= 'max' then anisotropy = config.anisotropy end
|
||||||
|
|
||||||
|
gw, gh = config.game_width or 480, config.game_height or 270
|
||||||
|
sx, sy = window_width/(config.game_width or 480), window_height/(config.game_height or 270)
|
||||||
|
ww, wh = window_width, window_height
|
||||||
|
|
||||||
|
love.window.setMode(window_width, window_height, {fullscreen = config.fullscreen, vsync = config.vsync, msaa = msaa or 0, display = config.display})
|
||||||
|
love.window.setTitle(config.game_name)
|
||||||
|
|
||||||
|
else
|
||||||
|
gw, gh = config.game_width or 480, config.game_height or 270
|
||||||
|
sx, sy = 2, 2
|
||||||
|
ww, wh = 960, 540
|
||||||
|
end
|
||||||
|
|
||||||
|
love.graphics.setBackgroundColor(0, 0, 0, 1)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.joystick.loadGamepadMappings("engine/gamecontrollerdb.txt")
|
||||||
|
graphics.set_line_style(config.line_style or "rough")
|
||||||
|
graphics.set_default_filter(config.default_filter or "nearest", config.default_filter or "nearest", anisotropy or 0)
|
||||||
|
|
||||||
|
combine = Shader("default.vert", "combine.frag")
|
||||||
|
replace = Shader("default.vert", "replace.frag")
|
||||||
|
full_combine = Shader("default.vert", "full_combine.frag")
|
||||||
|
|
||||||
|
input = Input()
|
||||||
|
input:bind_all()
|
||||||
|
for k, v in pairs(config.input or {}) do input:bind(k, v) end
|
||||||
|
random = Random()
|
||||||
|
trigger = Trigger()
|
||||||
|
camera = Camera(gw/2, gh/2)
|
||||||
|
mouse = Vector(0, 0)
|
||||||
|
last_mouse = Vector(0, 0)
|
||||||
|
mouse_dt = Vector(0, 0)
|
||||||
|
init()
|
||||||
|
|
||||||
|
if love.timer then love.timer.step() end
|
||||||
|
|
||||||
|
if not web then
|
||||||
|
_, _, flags = love.window.getMode()
|
||||||
|
fixed_dt = 1/flags.refreshrate
|
||||||
|
else fixed_dt = 1/60 end
|
||||||
|
|
||||||
|
local accumulator = fixed_dt
|
||||||
|
local dt = 0
|
||||||
|
frame, time = 0, 0
|
||||||
|
|
||||||
|
if not web then refresh_rate = flags.refreshrate
|
||||||
|
else refresh_rate = 60 end
|
||||||
|
|
||||||
|
return function()
|
||||||
|
if love.event then
|
||||||
|
love.event.pump()
|
||||||
|
for name, a, b, c, d, e, f in love.event.poll() do
|
||||||
|
if name == "quit" then
|
||||||
|
if not love.quit or not love.quit() then
|
||||||
|
return a or 0
|
||||||
|
end
|
||||||
|
elseif name == "keypressed" then input.keyboard_state[a] = true; input.last_key_pressed = a
|
||||||
|
elseif name == "keyreleased" then input.keyboard_state[a] = false
|
||||||
|
elseif name == "mousepressed" then input.mouse_state[input.mouse_buttons[c]] = true; input.last_key_pressed = input.mouse_buttons[c]
|
||||||
|
elseif name == "mousereleased" then input.mouse_state[input.mouse_buttons[c]] = false
|
||||||
|
elseif name == "wheelmoved" then if b == 1 then input.mouse_state.wheel_up = true elseif b == -1 then input.mouse_state.wheel_down = true end
|
||||||
|
elseif name == "gamepadpressed" then input.gamepad_state[input.index_to_gamepad_button[b]] = true; input.last_key_pressed = input.index_to_gamepad_button[b]
|
||||||
|
elseif name == "gamepadreleased" then input.gamepad_state[input.index_to_gamepad_button[b]] = false
|
||||||
|
elseif name == "gamepadaxis" then input.gamepad_axis[input.index_to_gamepad_axis[b]] = c
|
||||||
|
elseif name == "textinput" then input:textinput(a) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if love.timer then dt = love.timer.step() end
|
||||||
|
|
||||||
|
accumulator = accumulator + dt
|
||||||
|
while accumulator >= fixed_dt do
|
||||||
|
frame = frame + 1
|
||||||
|
input:update(fixed_dt)
|
||||||
|
trigger:update(fixed_dt)
|
||||||
|
camera:update(fixed_dt)
|
||||||
|
local mx, my = love.mouse.getPosition()
|
||||||
|
mouse:set(mx/sx, my/sy)
|
||||||
|
mouse_dt:set(mouse.x - last_mouse.x, mouse.y - last_mouse.y)
|
||||||
|
update(dt)
|
||||||
|
system.update()
|
||||||
|
input.last_key_pressed = nil
|
||||||
|
last_mouse:set(mouse.x, mouse.y)
|
||||||
|
accumulator = accumulator - fixed_dt
|
||||||
|
time = time + fixed_dt
|
||||||
|
end
|
||||||
|
|
||||||
|
if love.graphics and love.graphics.isActive() then
|
||||||
|
love.graphics.origin()
|
||||||
|
love.graphics.clear(love.graphics.getBackgroundColor())
|
||||||
|
draw()
|
||||||
|
love.graphics.present()
|
||||||
|
end
|
||||||
|
|
||||||
|
if love.timer then love.timer.sleep(0.001) end
|
||||||
|
end
|
||||||
|
end
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,4 @@
|
||||||
|
call "C:\Program Files\7-Zip\7z.exe" a -r %1.zip -w ..\..\ -xr!engine/love -xr!builds -xr!.git -xr!*.moon
|
||||||
|
rename %1.zip %1.love
|
||||||
|
call love-js -c -m 268435456 -t %1 %2\engine\love\%1.love ..\..\builds\web
|
||||||
|
del %1.love
|
|
@ -0,0 +1,14 @@
|
||||||
|
call "C:\Program Files\7-Zip\7z.exe" a -r %1.zip -w ..\..\ -xr!engine/love -xr!builds -xr!.git -xr!*.moon -xr!conf.lua
|
||||||
|
rename %1.zip %1.love
|
||||||
|
copy /b "love.exe"+"%1.love" "%1.exe"
|
||||||
|
del %1.love
|
||||||
|
mkdir %1
|
||||||
|
for %%I in (*.dll) do copy %%I %1\
|
||||||
|
for %%I in (*.txt) do copy %%I %1\
|
||||||
|
copy %1.exe %1\
|
||||||
|
del %1.exe
|
||||||
|
call "C:\Program Files\7-Zip\7z.exe" a %1.zip %1\
|
||||||
|
del /q %1\
|
||||||
|
rmdir /q %1\
|
||||||
|
copy %1.zip ..\..\builds\windows\
|
||||||
|
del %1.zip
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,98 @@
|
||||||
|
LÖVE is an *awesome* framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, Mac OS X, Linux, Android, and iOS.
|
||||||
|
|
||||||
|
[![Build Status: Windows](https://ci.appveyor.com/api/projects/status/u1a69u5o5ej1pus4?svg=true)](https://ci.appveyor.com/project/AlexSzpakowski/love)
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
We use our [wiki][wiki] for documentation.
|
||||||
|
If you need further help, feel free to ask on our [forums][forums], our [Discord server][discord], or our IRC channel [#love on OFTC][irc].
|
||||||
|
|
||||||
|
Compilation
|
||||||
|
-----------
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
Follow the instructions at the [megasource][megasource] repository page.
|
||||||
|
|
||||||
|
### *nix
|
||||||
|
Run `platform/unix/automagic` from the repository root, then run ./configure and make.
|
||||||
|
|
||||||
|
$ platform/unix/automagic
|
||||||
|
$ ./configure
|
||||||
|
$ make
|
||||||
|
|
||||||
|
When using a source release, automagic has already been run, and the first step can be skipped.
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
Download the required frameworks from [here][dependencies] and place them in `/Library/Frameworks/`.
|
||||||
|
|
||||||
|
Then use the Xcode project found at `platform/xcode/love.xcodeproj` to build the `love-macosx` target.
|
||||||
|
|
||||||
|
### iOS
|
||||||
|
Download the `ios-libraries` zip file corresponding to the LÖVE version being used from [here][dependencies-ios],
|
||||||
|
unzip it, and place the `include` and `libraries` subfolders into LÖVE's `platform/xcode/ios` folder.
|
||||||
|
|
||||||
|
Then use the Xcode project found at `platform/xcode/love.xcodeproj` to build the `love-ios` target.
|
||||||
|
|
||||||
|
See `readme-iOS.rtf` for more information.
|
||||||
|
|
||||||
|
### Android
|
||||||
|
Visit the [Android build repository][android-repository] for build instructions.
|
||||||
|
|
||||||
|
Repository information
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
We use the 'default' branch for development, and therefore it should not be considered stable.
|
||||||
|
Also used is the 'minor' branch, which is used for features in the next minor version and it is
|
||||||
|
not our development target (which would be the next revision - version numbers are formatted major.minor.revision.)
|
||||||
|
|
||||||
|
We tag all our releases (since we started using mercurial), and have binary downloads available for them.
|
||||||
|
|
||||||
|
Experimental changes are developed in the separate [love-experiments][love-experiments] repository.
|
||||||
|
|
||||||
|
Contributing
|
||||||
|
------------
|
||||||
|
|
||||||
|
The best places to contribute are through the Bitbucket issue tracker and the official Discord server or IRC channel.
|
||||||
|
For code contributions, pull requests and patches are welcome. Be sure to read the [source code style guide][codestyle].
|
||||||
|
|
||||||
|
Builds
|
||||||
|
------
|
||||||
|
|
||||||
|
Releases are found in the 'downloads' section on bitbucket, are linked on [the site][site],
|
||||||
|
and there's a ppa for ubuntu, [ppa:bartbes/love-stable][stableppa].
|
||||||
|
|
||||||
|
There are also unstable/nightly builds:
|
||||||
|
|
||||||
|
- Most can be found [here][builds].
|
||||||
|
- For ubuntu linux they are in [ppa:bartbes/love-unstable][unstableppa]
|
||||||
|
- For arch linux there's [love-hg][aur] in the AUR.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
- SDL2
|
||||||
|
- OpenGL 2.1+ / OpenGL ES 2+
|
||||||
|
- OpenAL
|
||||||
|
- Lua / LuaJIT / LLVM-lua
|
||||||
|
- FreeType
|
||||||
|
- ModPlug
|
||||||
|
- mpg123
|
||||||
|
- Vorbisfile
|
||||||
|
- Theora
|
||||||
|
|
||||||
|
[site]: http://love2d.org
|
||||||
|
[wiki]: http://love2d.org/wiki
|
||||||
|
[forums]: http://love2d.org/forums
|
||||||
|
[discord]: https://discord.gg/rhUets9
|
||||||
|
[irc]: irc://irc.oftc.net/love
|
||||||
|
[dependencies]: http://love2d.org/sdk
|
||||||
|
[dependencies-ios]: https://bitbucket.org/rude/love/downloads/
|
||||||
|
[megasource]: https://bitbucket.org/rude/megasource
|
||||||
|
[builds]: http://love2d.org/builds
|
||||||
|
[stableppa]: https://launchpad.net/~bartbes/+archive/love-stable
|
||||||
|
[unstableppa]: https://launchpad.net/~bartbes/+archive/love-unstable
|
||||||
|
[aur]: http://aur.archlinux.org/packages/love-hg
|
||||||
|
[love-experiments]: https://bitbucket.org/bartbes/love-experiments
|
||||||
|
[codestyle]: https://love2d.org/wiki/Code_Style
|
||||||
|
[android-repository]: https://bitbucket.org/MartinFelis/love-android-sdl2
|
|
@ -0,0 +1,19 @@
|
||||||
|
Solid = Object:extend()
|
||||||
|
Solid:implement(GameObject)
|
||||||
|
Solid:implement(Physics)
|
||||||
|
|
||||||
|
|
||||||
|
function Solid:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self:set_as_chain(true, self.vertices, 'static', 'solid')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Solid:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Solid:draw()
|
||||||
|
self:draw_game_object()
|
||||||
|
end
|
|
@ -0,0 +1,66 @@
|
||||||
|
-- A tilemap class responsible for the loading and drawing of maps made of tiles.
|
||||||
|
-- The x, y coordinates passed in represent the center of the map.
|
||||||
|
-- A tileset object containing the tileset to be used by the map must be passed in, as well as a grid object containing the map itself.
|
||||||
|
-- If tile_rules is also passed in, then the grid instance must contain its values in relation to what the tiling rules expect.
|
||||||
|
-- If no tiling rules are present then the grid will contain the 1D index of each tile in the tileset, so if the tileset has 5 columns, the first element in the second row will be numbered 6 in the grid.
|
||||||
|
-- If solid_rules is passed in, then the that function should receive a tile index and return true on those that are supposed to form a solid object, for instance:
|
||||||
|
-- function(index) return index ~= 0 end would make every tile index that isn't 0 into a solid object.
|
||||||
|
-- The created solids are stored in .solids after the tilemap instance is created. They should be added to the same group that you want gameplay objects to collide with the map's solid walls.
|
||||||
|
-- Solids are evaluated before tile rules are applied to the tile grid.
|
||||||
|
Tilemap = Object:extend()
|
||||||
|
function Tilemap:init(x, y, tileset, tile_grid, tile_rules, solid_rules)
|
||||||
|
self.tileset = tileset
|
||||||
|
self.grid = tile_grid
|
||||||
|
self.x, self.y = x, y
|
||||||
|
self.w, self.h = self.grid.w*self.tileset.tile_w, self.grid.h*self.tileset.tile_h
|
||||||
|
self.tile_rules = tile_rules
|
||||||
|
self.solid_rules = solid_rules
|
||||||
|
|
||||||
|
-- Create solids from the tile grid
|
||||||
|
local tw, th = self.tileset.tile_w, self.tileset.tile_h
|
||||||
|
if self.solid_rules then
|
||||||
|
local ox, oy = self.x - self.w/2, self.y - self.h/2
|
||||||
|
local tile_polygons = {}
|
||||||
|
for i = 1, self.grid.w do
|
||||||
|
for j = 1, self.grid.h do
|
||||||
|
if self.solid_rules(self.grid:get(i, j)) then
|
||||||
|
table.insert(tile_polygons, Polygon({ox + (i-1)*tw, oy + (j-1)*th, ox + i*tw, oy + (j-1)*th, ox + i*tw, oy + j*th, ox + (i-1)*tw, oy + j*th}))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.solids_vertices = {}
|
||||||
|
for _, solid in ipairs(Polygon.merge_polygons(tile_polygons)) do
|
||||||
|
table.insert(self.solids_vertices, solid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.tile_rules:is(TilekitRules) then
|
||||||
|
self.grid = Grid(self.grid.w, self.grid.h, self.tile_rules.process({w = self.grid.w, h = self.grid.h, data = self.grid.grid}).data)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create spritebatch
|
||||||
|
self.spritebatch = love.graphics.newSpriteBatch(self.tileset.image.image, 8192, 'static')
|
||||||
|
for i = 1, self.grid.w do
|
||||||
|
for j = 1, self.grid.h do
|
||||||
|
local v = self.grid:get(i, j)
|
||||||
|
if v ~= 0 then
|
||||||
|
self.spritebatch:add(self.tileset:get_quad(v), (i-1)*tw, (j-1)*th)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Tilemap:draw(r, sx, sy, ox, oy)
|
||||||
|
love.graphics.draw(self.spritebatch, self.x - self.w/2, self.y - self.h/2, r or 0, sx or 1, sy or sx or 1, ox or 0, oy or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- This class is responsible for loading tile rules exported by rxi's Tilekit https://rxi.itch.io/tilekit
|
||||||
|
-- An instance of this class should be passed in as the third argument for a Tilemap instance
|
||||||
|
TilekitRules = Object:extend()
|
||||||
|
function TilekitRules:init(rules_filename)
|
||||||
|
self.process = require('assets/maps/' .. rules_filename)
|
||||||
|
end
|
|
@ -0,0 +1,115 @@
|
||||||
|
-- A chain class. If loop is true then this is the same as a polygon, otherwise its a collection of connected lines (an open polygon).
|
||||||
|
-- Implements every function that Polygon does.
|
||||||
|
Chain = Object:extend()
|
||||||
|
Chain:implement(Polygon)
|
||||||
|
function Chain:init(loop, vertices)
|
||||||
|
self.loop = loop
|
||||||
|
self.vertices = vertices
|
||||||
|
self:get_size()
|
||||||
|
self:get_bounds()
|
||||||
|
self:get_centroid()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws the chain of lines with the given color and width.
|
||||||
|
function Chain:draw(color, line_width)
|
||||||
|
if self.loop and not line_width then
|
||||||
|
graphics.polygon(self.vertices, color, line_width)
|
||||||
|
else
|
||||||
|
for i = 1, #self.vertices-2, 2 do
|
||||||
|
graphics.line(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], color, line_width)
|
||||||
|
if self.loop and i == #self.vertices-2 then
|
||||||
|
graphics.line(self.vertices[i], self.vertices[i+1], self.vertices[1], self.vertices[2], color, line_width)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- If loop is true, returns true if the point is inside the polygon.
|
||||||
|
-- If loop is false, returns true if the point lies on any of the chain's lines.
|
||||||
|
-- colliding = chain:is_colliding_with_point(x, y)
|
||||||
|
function Chain:is_colliding_with_point(x, y)
|
||||||
|
if self.loop then
|
||||||
|
return mlib.polygon.checkPoint(x, y, self.vertices)
|
||||||
|
else
|
||||||
|
for i = 1, #self.vertices-2, 2 do
|
||||||
|
if mlib.segment.checkPoint(x, y, self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3]) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- If loop is true, returns true if the line is colliding with the polygon.
|
||||||
|
-- If loop is false, returns true if the line is colliding with any of the chain's lines.
|
||||||
|
-- colliding = chain:is_colliding_with_line(line)
|
||||||
|
function Chain:is_colliding_with_line(line)
|
||||||
|
if self.loop then
|
||||||
|
return mlib.polygon.isSegmentInside(line.x1, line.y1, line.x2, line.y2, self.vertices)
|
||||||
|
else
|
||||||
|
for i = 1, #self.vertices-2, 2 do
|
||||||
|
if mlib.segment.getIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], line.x1, line.y1, line.x2, line.y2) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- If loop is true for both chains, returns true if the polygon is colliding with the polygon.
|
||||||
|
-- If loop is false for both chains, returns true if any of the lines of one chain are colliding with any of the lines of the other chain.
|
||||||
|
-- If one is true and the other is false, returns true if the one that's a polygon is colliding with any of the lines of the one that is a chain.
|
||||||
|
-- colliding = chain:is_colliding_with_chain(other_chain)
|
||||||
|
function Chain:is_colliding_with_chain(chain)
|
||||||
|
if self.loop and chain.loop then
|
||||||
|
return mlib.polygon.isPolygonInside(self.vertices, chain.vertices) or mlib.polygon.isPolygonInside(chain.vertices, self.vertices)
|
||||||
|
elseif self.loop and not chain.loop then
|
||||||
|
return chain:is_colliding_with_polygon(self)
|
||||||
|
elseif not self.loop and chain.loop then
|
||||||
|
return self:is_colliding_with_polygon(chain)
|
||||||
|
else
|
||||||
|
for i = 1, #self.vertices-2, 2 do
|
||||||
|
for j = 1, #chain.vertices-2, 2 do
|
||||||
|
if mlib.segment.getIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], chain.vertices[j], chain.vertices[j+1], chain.vertices[j+2], chain.vertices[j+3]) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- If loop is true, returns true if the circle is colliding with the polygon.
|
||||||
|
-- If loop is false, returns true if the circle is colliding with any of the chain's lines.
|
||||||
|
-- colliding = chain:is_colliding_with_circle(circle)
|
||||||
|
function Chain:is_colliding_with_circle(circle)
|
||||||
|
if self.loop then
|
||||||
|
return mlib.polygon.isCircleCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or
|
||||||
|
mlib.circle.isPolygonCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or
|
||||||
|
mlib.polygon.getCircleIntersection(circle.x, circle.y, circle.rs, self.vertices)
|
||||||
|
else
|
||||||
|
for i = 1, #self.vertices-2, 2 do
|
||||||
|
if mlib.circle.getSegmentIntersection(circle.x, circle.y, circle.rs, self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3]) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- If loop is true, returns true if the polygon is colliding with the polygon.
|
||||||
|
-- If loop is false, returns true if the polygon is colliding with any of the chain's lines.
|
||||||
|
-- colliding = chain:is_colliding_with_polygon(polygon)
|
||||||
|
function Chain:is_colliding_with_polygon(polygon)
|
||||||
|
if self.loop then
|
||||||
|
return mlib.polygon.isPolygonInside(self.vertices, polygon.vertices) or mlib.polygon.isPolygonInside(polygon.vertices, self.vertices)
|
||||||
|
else
|
||||||
|
for i = 1, #self.vertices-2, 2 do
|
||||||
|
if mlib.polygon.getSegmentIntersection(self.vertices[i], self.vertices[i+1], self.vertices[i+2], self.vertices[i+3], polygon.vertices) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,85 @@
|
||||||
|
-- A circle class.
|
||||||
|
Circle = Object:extend()
|
||||||
|
function Circle:init(x, y, rs)
|
||||||
|
self.x, self.y = x, y
|
||||||
|
self.rs = rs
|
||||||
|
self.w, self.h = 2*self.rs, 2*self.rs
|
||||||
|
self.x1, self.y1, self.x2, self.y2 = self.x - self.rs, self.y - self.rs, self.x + self.rs, self.y + self.rs
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws the circle .
|
||||||
|
-- If color is passed in then the circle will be filled with that color (color is a Color instance)
|
||||||
|
-- If line_width is passed in then the circle will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function Circle:draw(color, line_width)
|
||||||
|
graphics.circle(self.x, self.y, self.rs, color, line_width)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Moves the circle directly to the given position.
|
||||||
|
-- circle:move_to(20, 20) -> moves the circle to position 20, 20
|
||||||
|
function Circle:move_to(x, y)
|
||||||
|
self.x, self.y = x, y
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if this polygon is colliding with the given shape.
|
||||||
|
-- colliding = polygon:is_colliding_with_shape(shape)
|
||||||
|
function Circle:is_colliding_with_shape(shape)
|
||||||
|
if shape:is(Line) then
|
||||||
|
return self:is_colliding_with_line(shape)
|
||||||
|
elseif shape:is(Chain) then
|
||||||
|
return self:is_colliding_with_chain(shape)
|
||||||
|
elseif shape:is(Circle) then
|
||||||
|
return self:is_colliding_with_circle(shape)
|
||||||
|
elseif shape:is(Polygon) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(Rectangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(EmeraldRectangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(Triangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(EquilateralTriangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the point is inside the circle.
|
||||||
|
-- colliding = polygon:is_colliding_with_point(x, y)
|
||||||
|
function Circle:is_colliding_with_point(x, y)
|
||||||
|
return mlib.circle.checkPoint(x, y, self.x, self.y, self.rs)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the line is colliding with this circle.
|
||||||
|
-- colliding = circle:is_colliding_with_line(line)
|
||||||
|
function Circle:is_colliding_with_line(line)
|
||||||
|
return mlib.circle.getSegmentIntersection(self.x, self.y, self.rs, line.x1, line.y1, line.x2, line.y2)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the chain is colliding with this circle.
|
||||||
|
-- colliding = circle:is_colliding_with_chain(chain)
|
||||||
|
function Circle:is_colliding_with_chain(chain)
|
||||||
|
return chain:is_colliding_with_circle(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the circle is colliding with this circle.
|
||||||
|
-- colliding = circle:is_colliding_with_circle(other_circle)
|
||||||
|
function Circle:is_colliding_with_circle(circle)
|
||||||
|
return mlib.circle.isCircleCompletelyInside(self.x, self.y, self.rs, circle.x, circle.y, circle.rs) or
|
||||||
|
mlib.circle.isCircleCompletelyInside(circle.x, circle.y, circle.rs, self.x, self.y, self.rs) or
|
||||||
|
mlib.circle.getCircleIntersection(self.x, self.y, self.rs, circle.x, circle.y, circle.rs)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the polygon is colliding with this circle.
|
||||||
|
-- colliding = circle:is_colliding_with_polygon(polygon)
|
||||||
|
function Circle:is_colliding_with_polygon(polygon)
|
||||||
|
return mlib.polygon.isCircleCompletelyInside(self.x, self.y, self.rs, polygon.vertices) or
|
||||||
|
mlib.circle.isPolygonCompletelyInside(self.x, self.y, self.rs, polygon.vertices) or
|
||||||
|
mlib.polygon.getCircleIntersection(self.x, self.y, self.rs, polygon.vertices)
|
||||||
|
end
|
|
@ -0,0 +1,96 @@
|
||||||
|
-- A line class.
|
||||||
|
-- Implements every function that Polygon does.
|
||||||
|
Line = Object:extend()
|
||||||
|
Line:implement(Polygon)
|
||||||
|
function Line:init(x1, y1, x2, y2)
|
||||||
|
self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2
|
||||||
|
self.x, self.y = (self.x1 + self.x2)/2, (self.y1 + self.y2)/2
|
||||||
|
self.vertices = {x1, y1, x2, y2}
|
||||||
|
self:get_size()
|
||||||
|
self:get_bounds()
|
||||||
|
self:get_centroid()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws the line with the given color and width.
|
||||||
|
function Line:draw(color, line_width)
|
||||||
|
graphics.line(self.x1, self.y1, self.x2, self.y2, color, line_width)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Noisifies the line, returning a Chain instance with the results.
|
||||||
|
-- offset corresponds to the maximum amount of perpendicular offseting each line will have
|
||||||
|
-- generations corresponds to the number of times the line will be subdivided
|
||||||
|
-- The higher the number of generations, the higher the number of final lines generates and the more granular the noisification will be
|
||||||
|
-- line:noisify(15, 4) -> noisifies the line with 15 maximum units of offseting with 4 generations
|
||||||
|
function Line:noisify(offset, generations)
|
||||||
|
local lines = {}
|
||||||
|
local generations = generations or 4
|
||||||
|
local offset = offset or 8
|
||||||
|
table.insert(lines, {x1 = self.x1, y1 = self.y1, x2 = self.x2, y2 = self.y2})
|
||||||
|
|
||||||
|
for i = 1, generations do
|
||||||
|
for i = #lines, 1, -1 do
|
||||||
|
local spx, spy = lines[i].x1, lines[i].y1
|
||||||
|
local epx, epy = lines[i].x2, lines[i].y2
|
||||||
|
table.remove(lines, i)
|
||||||
|
|
||||||
|
local mpx, mpy = (spx + epx)/2, (spy + epy)/2
|
||||||
|
local pnx, pny = Vector(epx - spx, epy - spy):normalize():perpendicular():unpack()
|
||||||
|
mpx = mpx + pnx*random:float(-offset, offset)
|
||||||
|
mpy = mpy + pny*random:float(-offset, offset)
|
||||||
|
table.insert(lines, i, {x1 = spx, y1 = spy, x2 = mpx, y2 = mpy})
|
||||||
|
table.insert(lines, i+1, {x1 = mpx, y1 = mpy, x2 = epx, y2 = epy})
|
||||||
|
end
|
||||||
|
offset = offset/2
|
||||||
|
end
|
||||||
|
|
||||||
|
local vertices = {}
|
||||||
|
for i, line in ipairs(lines) do
|
||||||
|
if i == #lines then
|
||||||
|
table.insert(vertices, line.x1)
|
||||||
|
table.insert(vertices, line.y1)
|
||||||
|
table.insert(vertices, line.x2)
|
||||||
|
table.insert(vertices, line.y2)
|
||||||
|
else
|
||||||
|
table.insert(vertices, line.x1)
|
||||||
|
table.insert(vertices, line.y1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return Chain(false, vertices)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the point lies on the line.
|
||||||
|
-- colliding = line:is_colliding_with_point(x, y)
|
||||||
|
function Line:is_colliding_with_point(x, y)
|
||||||
|
return mlib.segment.checkPoint(x, y, self.x1, self.y1, self.x2, self.y2)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the line is colliding with this line.
|
||||||
|
-- colliding = line:is_colliding_with_line(other_line)
|
||||||
|
function Line:is_colliding_with_line(line)
|
||||||
|
return mlib.segment.getIntersection(self.x1, self.y1, self.x2, self.y2, line.x1, line.y1, line.x2, line.y2)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the chain is colliding with this line.
|
||||||
|
-- colliding = line:is_colliding_with_chain(chain)
|
||||||
|
function Line:is_colliding_with_chain(chain)
|
||||||
|
return chain:is_colliding_with_line(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the circle is colliding with this line.
|
||||||
|
-- colliding = line:is_colliding_with_circle(circle)
|
||||||
|
function Line:is_colliding_with_circle(circle)
|
||||||
|
return mlib.circle.getSegmentIntersection(circle.x, circle.y, circle.rs, self.x1, self.y1, self.x2, self.y2)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the polygon is colliding with this line .
|
||||||
|
-- colliding = line:is_colliding_with_polygon(polygon)
|
||||||
|
function Line:is_colliding_with_polygon(polygon)
|
||||||
|
return mlib.polygon.getSegmentIntersection(self.x1, self.y1, self.x2, self.y2, polygon.vertices)
|
||||||
|
end
|
|
@ -0,0 +1,635 @@
|
||||||
|
-- Returns the 2D coordinates of a given index with a grid of a given width
|
||||||
|
-- math.index_to_coordinates(11, 10) -> 1, 2
|
||||||
|
-- math.index_to_coordinates(2, 4) -> 2, 1
|
||||||
|
-- math.index_to_coordinates(17, 7) -> 3, 3
|
||||||
|
-- math.index_to_coordinates(17, 4) -> 1, 5
|
||||||
|
-- math.index_to_coordinates(4, 4) -> 4, 1
|
||||||
|
function math.index_to_coordinates(n, w)
|
||||||
|
local i, j = n % w, math.ceil(n/w)
|
||||||
|
if i == 0 then i = w end
|
||||||
|
return i, j
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the 1D index of the given 2D coordinates with a grid of a given width
|
||||||
|
-- math.coordinates_to_index(1, 2, 10) -> 11
|
||||||
|
-- math.coordinates_to_index(2, 1, 4) -> 2
|
||||||
|
-- math.coordinates_to_index(3, 3, 7) -> 17
|
||||||
|
-- math.coordinates_to_index(1, 5, 4) -> 17
|
||||||
|
-- math.coordinates_to_index(4, 1, 4) -> 4
|
||||||
|
function math.coordinates_to_index(i, j, w)
|
||||||
|
return i + (j-1)*w
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns rectangle vertices based on top-left and bottom-right coordinates
|
||||||
|
-- math.to_rectangle_vertices(0, 0, 40, 40) -> vertices for a rectangle centered on 20, 20
|
||||||
|
function math.to_rectangle_vertices(x1, y1, x2, y2)
|
||||||
|
return {x1, y1, x2, y1, x2, y2, x1, y2}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rotates the point by r radians with ox, oy as pivot.
|
||||||
|
-- x, y = math.rotate_point(player.x, player.y, math.pi/4)
|
||||||
|
function math.rotate_point(x, y, r, ox, oy)
|
||||||
|
return x*math.cos(r) - y*math.sin(r) + ox - ox*math.cos(r) + oy*math.sin(r), x*math.sin(r) + y*math.cos(r) + oy - oy*math.cos(r) - ox*math.sin(r)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Scales the point by sx, sy with ox, oy as pivot.
|
||||||
|
-- x, y = math.scale_point(player.x, player.y, 2, 2, player.x - player.w/2, player.y - player.h/2)
|
||||||
|
function math.scale_point(x, y, sx, sy, ox, oy)
|
||||||
|
return x*sx + ox - ox*sx, y*sy + oy - oy*sy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rotates and scales the point by r radians and sx, sy with ox, oy as pivot.
|
||||||
|
-- x, y = math.rotate_scale_point(player.x, player.y, math.pi/4, 2, 2, player.x - player.w/2, player.y - player.h/2)
|
||||||
|
function math.rotate_scale_point(x, y, r, sx, sy, ox, oy)
|
||||||
|
local rx, ry = math.rotate_point(x, y, r, ox, oy)
|
||||||
|
return math.scale_point(rx, ry, sx, sy, ox, oy)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns -1 if the angle is on either left quadrants and 1 if its on either right quadrants.
|
||||||
|
-- h = math.angle_to_horizontal(math.pi/4) -> 1
|
||||||
|
-- h = math.angle_to_horizontal(-math.pi/4) -> 1
|
||||||
|
-- h = math.angle_to_horizontal(-3*math.pi/4) -> -1
|
||||||
|
-- h = math.angle_to_horizontal(3*math.pi/4) -> -1
|
||||||
|
function math.angle_to_horizontal(r)
|
||||||
|
if r > math.pi/2 or r < -math.pi/2 then return -1
|
||||||
|
elseif r <= math.pi/2 and r >= -math.pi/2 then return 1 end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns -1 if the angle is on either bottom quadrants and 1 if its on either top quadrants.
|
||||||
|
-- h = math.angle_to_horizontal(math.pi/4) -> -1
|
||||||
|
-- h = math.angle_to_horizontal(-math.pi/4) -> 1
|
||||||
|
-- h = math.angle_to_horizontal(-3*math.pi/4) -> 1
|
||||||
|
-- h = math.angle_to_horizontal(3*math.pi/4) -> -1
|
||||||
|
function math.angle_to_vertical(r)
|
||||||
|
if r > 0 and r < math.pi then return -1
|
||||||
|
elseif r <= 0 and r >= -math.pi then return 1 end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Snaps the value v to the closest number divisible by x and then centers it. This is useful when doing calculations for grids where each cell would be of size x, for instance.
|
||||||
|
-- v = math.snap_center(12, 16) -> 8
|
||||||
|
-- v = math.snap_center(17, 16) -> 24
|
||||||
|
-- v = math.snap_center(12, 12) -> 6
|
||||||
|
-- v = math.snap_center(13, 12) -> 18
|
||||||
|
function math.snap_center(v, x)
|
||||||
|
return math.ceil(v/x)*x - x/2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the squared distance between both points.
|
||||||
|
-- d = math.distance(player.x, player.y, enemy.x, enemy)
|
||||||
|
function math.distance(x1, y1, x2, y2)
|
||||||
|
return math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Loops value t such that is never higher than length and never lower than 0.
|
||||||
|
-- v = math.loop(3, 2.5) -> 0.5
|
||||||
|
-- v = math.loop(3*math.pi, 2*math.pi) -> math.pi
|
||||||
|
function math.loop(t, length)
|
||||||
|
return math.clamp(t-math.floor(t/length)*length, 0, length)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Clamps the value to between 0 and 1.
|
||||||
|
-- v = math.clamp01(-0.1) -> 0
|
||||||
|
-- v = math.clamp01(1.1) -> 1
|
||||||
|
function math.clamp01(v)
|
||||||
|
if v < 0 then return 0
|
||||||
|
elseif v > 1 then return 1
|
||||||
|
else return v end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rounds the number n to p digits of precision.
|
||||||
|
-- n = math.round(10.94, 1) -> 10.9
|
||||||
|
-- n = math.round(45.321, 0) -> 45
|
||||||
|
-- n = math.round(101.9157289403, 5) -> 101.91572
|
||||||
|
function math.round(n, p)
|
||||||
|
local m = 10^(p or 0)
|
||||||
|
return math.floor(n*m+0.5)/m
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Floors value v to the closest number divisible by x.
|
||||||
|
-- v = math.snap(15, 16) -> 0
|
||||||
|
-- v = math.snap(17, 16) -> 16
|
||||||
|
-- v = math.snap(13, 4) -> 12
|
||||||
|
function math.snap(v, x)
|
||||||
|
return math.round(v/x, 0)*x
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Clamps value v between min and max.
|
||||||
|
-- v = math.clamp(-4, 0, 10) -> 0
|
||||||
|
-- v = math.clamp(83, 0, 10) -> 10
|
||||||
|
-- v = math.clamp(0, -10, -4) -> -4
|
||||||
|
function math.clamp(v, min, max)
|
||||||
|
return math.min(math.max(v, min), max)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the squared length of x, y.
|
||||||
|
-- l = math.length(x, y)
|
||||||
|
function math.length(x, y)
|
||||||
|
return math.sqrt(x*x + y*y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the normalized values of x, y.
|
||||||
|
-- nx, ny = math.normalize(x, y)
|
||||||
|
function math.normalize(x, y)
|
||||||
|
if math.abs(x) < 0.0001 and math.abs(y) < 0.0001 then return x, y end
|
||||||
|
local l = math.length(x, y)
|
||||||
|
return x/l, y/l
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the sign of value v.
|
||||||
|
-- s = math.sign(10) -> 1
|
||||||
|
-- s = math.sign(-10) -> -1
|
||||||
|
-- s = math.sign(0) -> 0
|
||||||
|
function math.sign(v)
|
||||||
|
if v > 0 then return 1
|
||||||
|
elseif v < 0 then return -1
|
||||||
|
else return 0 end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the angle between point x, y and point px, py.
|
||||||
|
-- r = math.angle(player.x, player.y, enemy.x, enemy)
|
||||||
|
function math.angle(x, y, px, py)
|
||||||
|
return math.atan2(py - y, px - x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Remaps value v using its previous range of old_min, old_max into the new range new_min, new_max.
|
||||||
|
-- v = math.remap(10, 0, 20, 0, 1) -> 0.5 because 10 is 50% of 0, 20 and thus 0.5 is 50% of 0, 1
|
||||||
|
-- v = math.remap(3, 0, 3, 0, 100) -> 100
|
||||||
|
-- v = math.remap(2.5, -5, 5, -100, 100) -> 50
|
||||||
|
function math.remap(v, old_min, old_max, new_min, new_max)
|
||||||
|
return ((v - old_min)/(old_max - old_min))*(new_max - new_min) + new_min
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO: fix this since it doesn't work properly for some reason
|
||||||
|
-- Lerp corrected for usage with delta time, see more here https://www.construct.net/en/blogs/ashleys-blog-2/using-lerp-delta-time-924
|
||||||
|
-- f is a value between 0 and 1 that corresponds to how much of the distance between src and dst will be covered per second, regardless of frame rate.
|
||||||
|
-- math.lerp_dt(0.25, dt, self.x, self.x + 100) -> will cover 75% of the distance between self.x and self.x + 100 per second
|
||||||
|
function math.lerp_dt(f, dt, src, dst)
|
||||||
|
return math.lerp((1-f^dt), src, dst)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Same as math.lerp_angle except correted for usage with delta time.
|
||||||
|
-- math.lerp_angle_dt(0.1, dt, enemy.r, enemy:angle_to_object(player)) -> will cover 90% of the distance between enemy.r and and the enemy's angle to the player per second
|
||||||
|
function math.lerp_angle_dt(f, dt, src, dst)
|
||||||
|
return math.lerp_angle((1-f^dt), src, dst)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Lerps src to dst with lerp value.
|
||||||
|
-- v = math.lerp(0.2, self.x, self.x + 100)
|
||||||
|
function math.lerp(value, src, dst)
|
||||||
|
return src*(1 - value) + dst*value
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Lerps the src angle towards dst using value as the lerp amount.
|
||||||
|
-- enemy.r = math.lerp_angle(0.2, enemy.r, enemy:angle_to_object(player))
|
||||||
|
function math.lerp_angle(value, src, dst)
|
||||||
|
local dt = math.loop((dst-src), 2*math.pi)
|
||||||
|
if dt > math.pi then dt = dt - 2*math.pi end
|
||||||
|
return src + dt*math.clamp01(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local PI = math.pi
|
||||||
|
local PI2 = math.pi/2
|
||||||
|
local LN2 = math.log(2)
|
||||||
|
local LN210 = 10*math.log(2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function math.linear(t)
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.sine_in(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else return 1 - math.cos(t*PI2) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.sine_out(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else return math.sin(t*PI2) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.sine_in_out(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else return -0.5*(math.cos(t*PI) - 1) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.sine_out_in(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
elseif t < 0.5 then return 0.5*math.sin((t*2)*PI2)
|
||||||
|
else return -0.5*math.cos((t*2-1)*PI2) + 1 end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quad_in(t)
|
||||||
|
return t*t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quad_out(t)
|
||||||
|
return -t*(t-2)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quad_in_out(t)
|
||||||
|
if t < 0.5 then
|
||||||
|
return 2*t*t
|
||||||
|
else
|
||||||
|
t = t - 1
|
||||||
|
return -2*t*t + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quad_out_in(t)
|
||||||
|
if t < 0.5 then
|
||||||
|
t = t*2
|
||||||
|
return -0.5*t*(t-2)
|
||||||
|
else
|
||||||
|
t = t*2 - 1
|
||||||
|
return 0.5*t*t + 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.cubic_in(t)
|
||||||
|
return t*t*t
|
||||||
|
end
|
||||||
|
|
||||||
|
function math.cubic_out(t)
|
||||||
|
t = t - 1
|
||||||
|
return t*t*t + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.cubic_in_out(t)
|
||||||
|
t = t*2
|
||||||
|
if t < 1 then
|
||||||
|
return 0.5*t*t*t
|
||||||
|
else
|
||||||
|
t = t - 2
|
||||||
|
return 0.5*(t*t*t + 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.cubic_out_in(t)
|
||||||
|
t = t*2 - 1
|
||||||
|
return 0.5*(t*t*t + 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quart_in(t)
|
||||||
|
return t*t*t*t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quart_out(t)
|
||||||
|
t = t - 1
|
||||||
|
t = t*t
|
||||||
|
return 1 - t*t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quart_in_out(t)
|
||||||
|
t = t*2
|
||||||
|
if t < 1 then
|
||||||
|
return 0.5*t*t*t*t
|
||||||
|
else
|
||||||
|
t = t - 2
|
||||||
|
t = t*t
|
||||||
|
return -0.5*(t*t - 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quart_out_in(t)
|
||||||
|
if t < 0.5 then
|
||||||
|
t = t*2 - 1
|
||||||
|
t = t*t
|
||||||
|
return -0.5*t*t + 0.5
|
||||||
|
else
|
||||||
|
t = t*2 - 1
|
||||||
|
t = t*t
|
||||||
|
return 0.5*t*t + 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quint_in(t)
|
||||||
|
return t*t*t*t*t
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quint_out(t)
|
||||||
|
t = t - 1
|
||||||
|
return t*t*t*t*t + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quint_in_out(t)
|
||||||
|
t = t*2
|
||||||
|
if t < 1 then
|
||||||
|
return 0.5*t*t*t*t*t
|
||||||
|
else
|
||||||
|
t = t - 2
|
||||||
|
return 0.5*t*t*t*t*t + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.quint_out_in(t)
|
||||||
|
t = t*2 - 1
|
||||||
|
return 0.5*(t*t*t*t*t + 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.expo_in(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
else return math.exp(LN210*(t - 1)) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.expo_out(t)
|
||||||
|
if t == 1 then return 1
|
||||||
|
else return 1 - math.exp(-LN210*t) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.expo_in_out(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1 end
|
||||||
|
t = t*2
|
||||||
|
if t < 1 then return 0.5*math.exp(LN210*(t - 1))
|
||||||
|
else return 0.5*(2 - math.exp(-LN210*(t - 1))) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.expo_out_in(t)
|
||||||
|
if t < 0.5 then return 0.5*(1 - math.exp(-20*LN2*t))
|
||||||
|
elseif t == 0.5 then return 0.5
|
||||||
|
else return 0.5*(math.exp(20*LN2*(t - 1)) + 1) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.circ_in(t)
|
||||||
|
if t < -1 or t > 1 then return 0
|
||||||
|
else return 1 - math.sqrt(1 - t*t) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.circ_out(t)
|
||||||
|
if t < 0 or t > 2 then return 0
|
||||||
|
else return math.sqrt(t*(2 - t)) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.circ_in_out(t)
|
||||||
|
if t < -0.5 or t > 1.5 then return 0.5
|
||||||
|
else
|
||||||
|
t = t*2
|
||||||
|
if t < 1 then return -0.5*(math.sqrt(1 - t*t) - 1)
|
||||||
|
else
|
||||||
|
t = t - 2
|
||||||
|
return 0.5*(math.sqrt(1 - t*t) + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.circ_out_in(t)
|
||||||
|
if t < 0 then return 0
|
||||||
|
elseif t > 1 then return 1
|
||||||
|
elseif t < 0.5 then
|
||||||
|
t = t*2 - 1
|
||||||
|
return 0.5*math.sqrt(1 - t*t)
|
||||||
|
else
|
||||||
|
t = t*2 - 1
|
||||||
|
return -0.5*((math.sqrt(1 - t*t) - 1) - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.bounce_in(t)
|
||||||
|
t = 1 - t
|
||||||
|
if t < 1/2.75 then return 1 - (7.5625*t*t)
|
||||||
|
elseif t < 2/2.75 then
|
||||||
|
t = t - 1.5/2.75
|
||||||
|
return 1 - (7.5625*t*t + 0.75)
|
||||||
|
elseif t < 2.5/2.75 then
|
||||||
|
t = t - 2.25/2.75
|
||||||
|
return 1 - (7.5625*t*t + 0.9375)
|
||||||
|
else
|
||||||
|
t = t - 2.625/2.75
|
||||||
|
return 1 - (7.5625*t*t + 0.984375)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.bounce_out(t)
|
||||||
|
if t < 1/2.75 then return 7.5625*t*t
|
||||||
|
elseif t < 2/2.75 then
|
||||||
|
t = t - 1.5/2.75
|
||||||
|
return 7.5625*t*t + 0.75
|
||||||
|
elseif t < 2.5/2.75 then
|
||||||
|
t = t - 2.25/2.75
|
||||||
|
return 7.5625*t*t + 0.9375
|
||||||
|
else
|
||||||
|
t = t - 2.625/2.75
|
||||||
|
return 7.5625*t*t + 0.984375
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.bounce_in_out(t)
|
||||||
|
if t < 0.5 then
|
||||||
|
t = 1 - t*2
|
||||||
|
if t < 1/2.75 then return (1 - (7.5625*t*t))*0.5
|
||||||
|
elseif t < 2/2.75 then
|
||||||
|
t = t - 1.5/2.75
|
||||||
|
return (1 - (7.5625*t*t + 0.75))*0.5
|
||||||
|
elseif t < 2.5/2.75 then
|
||||||
|
t = t - 2.25/2.75
|
||||||
|
return (1 - (7.5625*t*t + 0.9375))*0.5
|
||||||
|
else
|
||||||
|
t = t - 2.625/2.75
|
||||||
|
return (1 - (7.5625*t*t + 0.984375))*0.5
|
||||||
|
end
|
||||||
|
else
|
||||||
|
t = t*2 - 1
|
||||||
|
if t < 1/2.75 then return (7.5625*t*t)*0.5 + 0.5
|
||||||
|
elseif t < 2/2.75 then
|
||||||
|
t = t - 1.5/2.75
|
||||||
|
return (7.5625*t*t + 0.75)*0.5 + 0.5
|
||||||
|
elseif t < 2.5/2.75 then
|
||||||
|
t = t - 2.25/2.75
|
||||||
|
return (7.5625*t*t + 0.9375)*0.5 + 0.5
|
||||||
|
else
|
||||||
|
t = t - 2.625/2.75
|
||||||
|
return (7.5625*t*t + 0.984375)*0.5 + 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.bounce_out_in(t)
|
||||||
|
if t < 0.5 then
|
||||||
|
t = t*2
|
||||||
|
if t < 1/2.75 then return (7.5625*t*t)*0.5
|
||||||
|
elseif t < 2/2.75 then
|
||||||
|
t = t - 1.5/2.75
|
||||||
|
return (7.5625*t*t + 0.75)*0.5
|
||||||
|
elseif t < 2.5/2.75 then
|
||||||
|
t = t - 2.25/2.75
|
||||||
|
return (7.5625*t*t + 0.9375)*0.5
|
||||||
|
else
|
||||||
|
t = t - 2.625/2.75
|
||||||
|
return (7.5625*t*t + 0.984375)*0.5
|
||||||
|
end
|
||||||
|
else
|
||||||
|
t = 1 - (t*2 - 1)
|
||||||
|
if t < 1/2.75 then return 0.5 - (7.5625*t*t)*0.5 + 0.5
|
||||||
|
elseif t < 2/2.75 then
|
||||||
|
t = t - 1.5/2.75
|
||||||
|
return 0.5 - (7.5625*t*t + 0.75)*0.5 + 0.5
|
||||||
|
elseif t < 2.5/2.75 then
|
||||||
|
t = t - 2.25/2.75
|
||||||
|
return 0.5 - (7.5625*t*t + 0.9375)*0.5 + 0.5
|
||||||
|
else
|
||||||
|
t = t - 2.625/2.75
|
||||||
|
return 0.5 - (7.5625*t*t + 0.984375)*0.5 + 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local overshoot = 1.70158
|
||||||
|
|
||||||
|
function math.back_in(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else return t*t*((overshoot + 1)*t - overshoot) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.back_out(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else
|
||||||
|
t = t - 1
|
||||||
|
return t*t*((overshoot + 1)*t + overshoot) + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.back_in_out(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else
|
||||||
|
t = t*2
|
||||||
|
if t < 1 then return 0.5*(t*t*(((overshoot*1.525) + 1)*t - overshoot*1.525))
|
||||||
|
else
|
||||||
|
t = t - 2
|
||||||
|
return 0.5*(t*t*(((overshoot*1.525) + 1)*t + overshoot*1.525) + 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.back_out_in(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
elseif t < 0.5 then
|
||||||
|
t = t*2 - 1
|
||||||
|
return 0.5*(t*t*((overshoot + 1)*t + overshoot) + 1)
|
||||||
|
else
|
||||||
|
t = t*2 - 1
|
||||||
|
return 0.5*t*t*((overshoot + 1)*t - overshoot) + 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local amplitude = 1
|
||||||
|
local period = 0.0003
|
||||||
|
|
||||||
|
function math.elastic_in(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else
|
||||||
|
t = t - 1
|
||||||
|
return -(amplitude*math.exp(LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.elastic_out(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else return math.exp(-LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period) + 1 end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.elastic_in_out(t)
|
||||||
|
if t == 0 then return 0
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else
|
||||||
|
t = t*2
|
||||||
|
if t < 1 then
|
||||||
|
t = t - 1
|
||||||
|
return -0.5*(amplitude*math.exp(LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period))
|
||||||
|
else
|
||||||
|
t = t - 1
|
||||||
|
return amplitude*math.exp(-LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period)*0.5 + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function math.elastic_out_in(t)
|
||||||
|
if t < 0.5 then
|
||||||
|
t = t*2
|
||||||
|
if t == 0 then return 0
|
||||||
|
else return (amplitude/2)*math.exp(-LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period) + 0.5 end
|
||||||
|
else
|
||||||
|
if t == 0.5 then return 0.5
|
||||||
|
elseif t == 1 then return 1
|
||||||
|
else
|
||||||
|
t = t*2 - 1
|
||||||
|
t = t - 1
|
||||||
|
return -((amplitude/2)*math.exp(LN210*t)*math.sin((t*0.001 - period/4)*(2*PI)/period)) + 0.5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,227 @@
|
||||||
|
-- A polygon class.
|
||||||
|
Polygon = Object:extend()
|
||||||
|
function Polygon:init(vertices)
|
||||||
|
self.vertices = vertices
|
||||||
|
self:get_size()
|
||||||
|
self:get_bounds()
|
||||||
|
self:get_centroid()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws the polygon.
|
||||||
|
-- If color is passed in then the polygon will be filled with that color (color is a Color instance)
|
||||||
|
-- If line_width is passed in then the polygon will not be filled and will instead be drawn as a set of lines of the given width.
|
||||||
|
function Polygon:draw(color, line_width)
|
||||||
|
graphics.polygon(self.vertices, color, line_width)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Noisifies each line that makes up the polygon.
|
||||||
|
-- offset corresponds to the maximum amount of perpendicular offseting each line will have
|
||||||
|
-- generations corresponds to the number of times the line will be subdivided
|
||||||
|
-- The higher the number of generations, the higher the number of final lines generates and the more granular the noisification will be
|
||||||
|
-- polygon:noisify(15, 4) -> noisifies the polygon with 15 maximum units of offseting with 4 generations
|
||||||
|
function Polygon:noisify(offset, generations)
|
||||||
|
local noisified_vertices = {}
|
||||||
|
for i = 1, #self.vertices, 2 do
|
||||||
|
local x1, y1 = vs[i], vs[i+1]
|
||||||
|
local x2, y2 = vs[i+2], vs[i+3]
|
||||||
|
if not x2 and not y2 then x2, y2 = vs[1], vs[2] end
|
||||||
|
local noisified_line = math.noisify_line(x1, y1, x2, y2, offset, generations)
|
||||||
|
table.insert(noisified_vertices, noisified_line)
|
||||||
|
end
|
||||||
|
local flattened = table.flatten(noisified_vertices)
|
||||||
|
local final_vertices = {}
|
||||||
|
for i = 1, #flattened, 2 do
|
||||||
|
local x1, y1 = flattened[i], flattened[i+1]
|
||||||
|
local x2, y2 = flattened[i+2], flattened[i+3]
|
||||||
|
if not x2 and not y2 then x2, y2 = flattened[1], flattened[2] end
|
||||||
|
if math.distance(x1, y1, x2, y2) > 0.025 then
|
||||||
|
table.insert(final_vertices, x1)
|
||||||
|
table.insert(final_vertices, y1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.vertices = final_vertices
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local path_to_polygon = function(path)
|
||||||
|
local vs = {}
|
||||||
|
for i = 1, path:size() do
|
||||||
|
local p = path:get(i)
|
||||||
|
table.insert(vs, tonumber(p.x))
|
||||||
|
table.insert(vs, tonumber(p.y))
|
||||||
|
end
|
||||||
|
return vs
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local polygon_to_path = function(vs)
|
||||||
|
local path = clipper.Path()
|
||||||
|
for i = 1, #vs, 2 do path:add(vs[i], vs[i+1]) end
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Inflates the polygon around its center.
|
||||||
|
-- polygon:inflate(10) -> inflates the polygon by 10 units
|
||||||
|
function Polygon:inflate(s)
|
||||||
|
self.vertices = path_to_polygon(clipper.ClipperOffset():offsetPath(polygon_to_path(self.vertices), s, 'miter', 'closedPolygon'):get(1))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Moves the polygon directly to the given position.
|
||||||
|
-- polygon:move_to(20, 20) -> moves the polygon to position 20, 20
|
||||||
|
function Polygon:move_to(x, y)
|
||||||
|
if self.x and self.y then self:translate(x - self.x, y - self.y) end
|
||||||
|
self.x, self.y = x, y
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Translates the polygon by the given amount.
|
||||||
|
-- polygon:translate(20, 20) -> moves the polygon by 20, 20 units
|
||||||
|
function Polygon:translate(x, y)
|
||||||
|
for i = 1, #self.vertices, 2 do
|
||||||
|
self.vertices[i] = self.vertices[i] + x
|
||||||
|
self.vertices[i+1] = self.vertices[i+1] + y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Scales the polygon by the given amount around the given pivot.
|
||||||
|
-- polygon:scale(2) -> scales the polygon by 2 around its center (if set) or 0
|
||||||
|
function Polygon:scale(sx, sy, ox, oy)
|
||||||
|
for i = 1, #self.vertices, 2 do
|
||||||
|
self.vertices[i], self.vertices[i+1] = math.scale_point(self.vertices[i], self.vertices[i+1], sx or 1, sy or sx or 1, ox or self.cx or 0, oy or self.cy or 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Rotates the polygon by the given amount around the given pivot.
|
||||||
|
-- polygon:rotate(math.pi/4) -> rotates the polygon by 45 degrees around its center (if set) or 0
|
||||||
|
function Polygon:rotate(r, ox, oy)
|
||||||
|
for i = 1, #self.vertices, 2 do
|
||||||
|
self.vertices[i], self.vertices[i+1] = math.rotate_point(self.vertices[i], self.vertices[i+1], r, ox or self.cx or 0, oy or self.cy or 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the polygons size.
|
||||||
|
-- This calculates the bounding box of the polygon and sets that size to the .w, .h attributes.
|
||||||
|
-- w, h = polygon:get_size()
|
||||||
|
function Polygon:get_size()
|
||||||
|
local min_x, min_y, max_x, max_y = 1000000, 1000000, -1000000, -1000000
|
||||||
|
for i = 1, #self.vertices, 2 do
|
||||||
|
if self.vertices[i] < min_x then min_x = self.vertices[i] end
|
||||||
|
if self.vertices[i] > max_x then max_x = self.vertices[i] end
|
||||||
|
if self.vertices[i+1] < min_y then min_y = self.vertices[i+1] end
|
||||||
|
if self.vertices[i+1] > max_y then max_y = self.vertices[i+1] end
|
||||||
|
end
|
||||||
|
self.w, self.h = math.abs(max_x - min_x), math.abs(max_y - min_y)
|
||||||
|
return self.w, self.h
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the polygons bounding box top-left and bottom-right positions.
|
||||||
|
-- This calculates the bounding box of the polygon and sets those positions to the .x1, .y1, .x2, .y2 attributes.
|
||||||
|
-- x1, y1, x2, y2 = polygon:get_bounds()
|
||||||
|
function Polygon:get_bounds()
|
||||||
|
local min_x, min_y, max_x, max_y = 1000000, 1000000, -1000000, -1000000
|
||||||
|
for i = 1, #self.vertices, 2 do
|
||||||
|
if self.vertices[i] < min_x then min_x = self.vertices[i] end
|
||||||
|
if self.vertices[i] > max_x then max_x = self.vertices[i] end
|
||||||
|
if self.vertices[i+1] < min_y then min_y = self.vertices[i+1] end
|
||||||
|
if self.vertices[i+1] > max_y then max_y = self.vertices[i+1] end
|
||||||
|
end
|
||||||
|
self.x1, self.y1, self.x2, self.y2 = min_x, min_y, max_x, max_y
|
||||||
|
return self.x1, self.y1, self.x2, self.y2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the centroid of the polygon.
|
||||||
|
-- This calculates the centroid (average of all points) and sets it to the .x, .y attributes.
|
||||||
|
-- x, y = polygon:get_centroid()
|
||||||
|
-- TODO: implement get_visual_center https://github.com/mapbox/polylabel/blob/master/polylabel.js
|
||||||
|
function Polygon:get_centroid()
|
||||||
|
local sum_x, sum_y = 0, 0
|
||||||
|
for i = 1, #self.vertices, 2 do
|
||||||
|
sum_x = sum_x + self.vertices[i]
|
||||||
|
sum_y = sum_y + self.vertices[i+1]
|
||||||
|
end
|
||||||
|
self.cx, self.cy = sum_x/(#self.vertices/2), sum_y/(#self.vertices/2)
|
||||||
|
return self.cx, self.cy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if this polygon is colliding with the given shape.
|
||||||
|
-- colliding = polygon:is_colliding_with_shape(shape)
|
||||||
|
function Polygon:is_colliding_with_shape(shape)
|
||||||
|
if shape:is(Line) then
|
||||||
|
return self:is_colliding_with_line(shape)
|
||||||
|
elseif shape:is(Chain) then
|
||||||
|
return self:is_colliding_with_chain(shape)
|
||||||
|
elseif shape:is(Circle) then
|
||||||
|
return self:is_colliding_with_circle(shape)
|
||||||
|
elseif shape:is(Polygon) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(Rectangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(EmeraldRectangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(Triangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
elseif shape:is(EquilateralTriangle) then
|
||||||
|
return self:is_colliding_with_polygon(shape)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the point is inside the polygon.
|
||||||
|
-- colliding = polygon:is_colliding_with_point(x, y)
|
||||||
|
function Polygon:is_colliding_with_point(x, y)
|
||||||
|
return mlib.polygon.checkPoint(x, y, self.vertices)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the line is colliding with this polygon.
|
||||||
|
-- colliding = polygon:is_colliding_with_line(line)
|
||||||
|
function Polygon:is_colliding_with_line(line)
|
||||||
|
return mlib.polygon.isSegmentInside(line.x1, line.y1, line.x2, line.y2, self.vertices)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the chain is colliding with this polygon.
|
||||||
|
-- colliding = polygon:is_colliding_with_chain(chain)
|
||||||
|
function Polygon:is_colliding_with_chain(chain)
|
||||||
|
return chain:is_colliding_with_polygon(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the circle is colliding with this circle.
|
||||||
|
-- colliding = polygon:is_colliding_with_circle(circle)
|
||||||
|
function Polygon:is_colliding_with_circle(circle)
|
||||||
|
return mlib.polygon.isCircleCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or
|
||||||
|
mlib.circle.isPolygonCompletelyInside(circle.x, circle.y, circle.rs, self.vertices) or
|
||||||
|
mlib.polygon.getCircleIntersection(circle.x, circle.y, circle.rs, self.vertices)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true if the polygon is colliding with this polygon.
|
||||||
|
-- colliding = polygon:is_colliding_with_polygon(other_polygon)
|
||||||
|
function Polygon:is_colliding_with_polygon(polygon)
|
||||||
|
return mlib.polygon.isPolygonInside(self.vertices, polygon.vertices) or mlib.polygon.isPolygonInside(polygon.vertices, self.vertices)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returned results can be either the merged polygons or the holes inside them (or a polygon inside a hole, or a hole inside that polygon, and so on...)
|
||||||
|
-- Unfortunately for now it doesn't really report which polygons are which, so this function has some limited utility.
|
||||||
|
function Polygon.merge_polygons(polygons)
|
||||||
|
local cl = clipper.Clipper()
|
||||||
|
local paths = clipper.Paths()
|
||||||
|
for _, polygon in ipairs(polygons) do paths:add(polygon_to_path(polygon.vertices)) end
|
||||||
|
cl:addPaths(paths, 'subject')
|
||||||
|
local out = cl:execute('union')
|
||||||
|
local out_polygons = {}
|
||||||
|
for i = 1, out:size() do table.insert(out_polygons, path_to_polygon(out:get(i))) end
|
||||||
|
return out_polygons
|
||||||
|
end
|
|
@ -0,0 +1,94 @@
|
||||||
|
-- The base random class.
|
||||||
|
-- You can create a new Random object with its own seed by passing it in on the constructor.
|
||||||
|
-- A global instance of this called "random" is available by default.
|
||||||
|
Random = Object:extend()
|
||||||
|
function Random:init(seed)
|
||||||
|
seed = seed or os.time()
|
||||||
|
self.generator = love.math.newRandomGenerator(seed)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns true at the given chance.
|
||||||
|
-- random:bool(50) -> returns true 50% of the time
|
||||||
|
-- random:bool(25) -> returns true 25% of the time
|
||||||
|
-- random:bool(3) -> returns true 3% of the time
|
||||||
|
function Random:bool(chance)
|
||||||
|
if self.generator:random(1, 1000) < 10*(chance or 50) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a random real number between the range.
|
||||||
|
-- random:bool(0, 1) -> returns a random number between 0 and 1, like 0.432
|
||||||
|
-- random:bool(-100, 45.2) -> returns a random number between -100 and 45.2, like -99.7
|
||||||
|
function Random:float(min, max)
|
||||||
|
min = min or 0
|
||||||
|
max = max or 1
|
||||||
|
return (min > max and (self.generator:random()*(min - max) + max)) or (self.generator:random()*(max - min) + min)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a random integer number between the range.
|
||||||
|
-- random:int(1, 7) -> returns a random integer between 1 and 7, like 4
|
||||||
|
-- random:int(-2, 0) -> returns a random integer between -2 and 0, like -2
|
||||||
|
function Random:int(min, max)
|
||||||
|
return self.generator:random(min or 0, max or 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a random value of the table.
|
||||||
|
-- a = {7, 6, 5, 4}
|
||||||
|
-- random:table(a) -> returns either 7, 6, 5 or 4 randomly
|
||||||
|
function Random:table(t)
|
||||||
|
return t[self.generator:random(1, #t)]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns a random value of the table and also removes it.
|
||||||
|
-- a = {7, 6, 5, 4}
|
||||||
|
-- random:table(a) -> returns either 7, 6, 5 or 4 randomly and removes it from the table as well
|
||||||
|
function Random:table_remove(t)
|
||||||
|
return table.remove(t, self.generator:random(1, #t))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a 1 at the given chance, otherwise returns -1.
|
||||||
|
-- random:sign(65) -> returns 1 65% of the time and -1 35% of the time
|
||||||
|
-- random:sign(20) -> returns 1 20% of the time and -1 80% of the time
|
||||||
|
function Random:sign(chance)
|
||||||
|
if self.generator:random(1, 1000) < 10*(chance or 50) then return 1
|
||||||
|
else return -1 end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a random index at the given weights.
|
||||||
|
-- random:weighted_pick(50, 30, 20) -> will return 1 50% of the time, 2 30% of the time and 3 20% of the time
|
||||||
|
-- random:weighted_pick(10, 8, 2) -> will return 1 50% of the time, 2 40% of the time and 3 10% of the time
|
||||||
|
-- random:weighted_pick(2, 1) -> will return 1 66% of the time, will return 2 33% of the time
|
||||||
|
function Random:weighted_pick(...)
|
||||||
|
local weights = {...}
|
||||||
|
local total_weight = 0
|
||||||
|
local pick = 0
|
||||||
|
for _, weight in ipairs(weights) do total_weight = total_weight + weight end
|
||||||
|
|
||||||
|
total_weight = self:float(0, total_weight)
|
||||||
|
for i = 1, #weights do
|
||||||
|
if total_weight < weights[i] then
|
||||||
|
pick = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
total_weight = total_weight - weights[i]
|
||||||
|
end
|
||||||
|
return pick
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns a unique identifier.
|
||||||
|
function Random:uid()
|
||||||
|
local fn = function(x)
|
||||||
|
local r = self:int(1, 16) - 1
|
||||||
|
r = (x == "x") and (r + 1) or (r % 4) + 9
|
||||||
|
return ("0123456789abcdef"):sub(r, r)
|
||||||
|
end
|
||||||
|
return (("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"):gsub("[xy]", fn))
|
||||||
|
end
|
|
@ -0,0 +1,39 @@
|
||||||
|
-- A rectangle class.
|
||||||
|
-- Implements every function that Polygon does.
|
||||||
|
Rectangle = Object:extend()
|
||||||
|
Rectangle:implement(Polygon)
|
||||||
|
function Rectangle:init(x, y, w, h, r)
|
||||||
|
self.x, self.y, self.w, self.h, self.r = x, y, w, h, r
|
||||||
|
local x1, y1 = math.rotate_point(x - w/2, y - h/2, r or 0, x, y)
|
||||||
|
local x2, y2 = math.rotate_point(x + w/2, y - h/2, r or 0, x, y)
|
||||||
|
local x3, y3 = math.rotate_point(x + w/2, y + h/2, r or 0, x, y)
|
||||||
|
local x4, y4 = math.rotate_point(x - w/2, y + h/2, r or 0, x, y)
|
||||||
|
self.vertices = {x1, y1, x2, y2, x3, y3, x4, y4}
|
||||||
|
self:get_size()
|
||||||
|
self:get_bounds()
|
||||||
|
self:get_centroid()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- An emerald rectangle class. This is a rectangle with its corners cut by the given rx, ry amount.
|
||||||
|
-- Implements every function that Polygon does.
|
||||||
|
EmeraldRectangle = Object:extend()
|
||||||
|
EmeraldRectangle:implement(Polygon)
|
||||||
|
function EmeraldRectangle:init(x, y, w, h, rx, ry, r)
|
||||||
|
self.x, self.y, self.w, self.h, self.r = x, y, w, h, r
|
||||||
|
self.rx, self.ry = rx, ry
|
||||||
|
local x1, y1 = math.rotate_scale_point(x - w/2, y - h/2 + ry, r or 0, x, y)
|
||||||
|
local x2, y2 = math.rotate_scale_point(x - w/2 + rx, y - h/2, r or 0, x, y)
|
||||||
|
local x3, y3 = math.rotate_scale_point(x + w/2 - rx, y - h/2, r or 0, x, y)
|
||||||
|
local x4, y4 = math.rotate_scale_point(x + w/2, y - h/2 + ry, r or 0, x, y)
|
||||||
|
local x5, y5 = math.rotate_scale_point(x + w/2, y + h/2 - ry, r or 0, x, y)
|
||||||
|
local x6, y6 = math.rotate_scale_point(x + w/2 - rx, y + h/2, r or 0, x, y)
|
||||||
|
local x7, y7 = math.rotate_scale_point(x - w/2 + rx, y + h/2, r or 0, x, y)
|
||||||
|
local x8, y8 = math.rotate_scale_point(x - w/2, y + h/2 - ry, r or 0, x, y)
|
||||||
|
self.vertices = {x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8}
|
||||||
|
self:get_size()
|
||||||
|
self:get_bounds()
|
||||||
|
self:get_centroid()
|
||||||
|
end
|
|
@ -0,0 +1,70 @@
|
||||||
|
-- A Spring class. This is extremely useful for juicing things up.
|
||||||
|
-- See this article https://github.com/a327ex/blog/issues/60 for more details.
|
||||||
|
-- The argument passed in are: the initial value of the spring, its stiffness and damping.
|
||||||
|
Spring = Object:extend()
|
||||||
|
function Spring:init(x, k, d)
|
||||||
|
self.x = x or 0
|
||||||
|
self.k = k or 100
|
||||||
|
self.d = d or 10
|
||||||
|
self.target_x = self.x
|
||||||
|
self.v = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Spring:update(dt)
|
||||||
|
local a = -self.k*(self.x - self.target_x) - self.d*self.v
|
||||||
|
self.v = self.v + a*dt
|
||||||
|
self.x = self.x + self.v*dt
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Pull the spring with a certain amount of force. This force should be related to the initial value you set to the spring.
|
||||||
|
function Spring:pull(f, k, d)
|
||||||
|
if k then self.k = k end
|
||||||
|
if d then self.d = d end
|
||||||
|
self.x = self.x + f
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Animates the spring such that it reaches the target value in a smoothy springy motion.
|
||||||
|
-- Unlike pull, which tugs on the spring so that it bounces around the anchor, this changes that anchor itself.
|
||||||
|
function Spring:animate(x, k, d)
|
||||||
|
if k then self.k = k end
|
||||||
|
if d then self.d = d end
|
||||||
|
self.target_x = x
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
|
NSpring = Object:extend()
|
||||||
|
|
||||||
|
|
||||||
|
function NSpring:new(x, z, o)
|
||||||
|
self.x = x or 0
|
||||||
|
self.z = z or 0.5
|
||||||
|
self.o = o or 2*math.pi
|
||||||
|
self.target_x = self.x
|
||||||
|
self.v = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function NSpring:update(dt)
|
||||||
|
local f = 1 + 2*dt*self.z*self.o
|
||||||
|
local oo = self.o*self.o
|
||||||
|
local hoo = dt*oo
|
||||||
|
local hhoo = dt*hoo
|
||||||
|
local det_inv = 1/(f+hhoo)
|
||||||
|
local det_x = f*self.x + dt*self.v + hhoo*self.target_x
|
||||||
|
local det_v = self.v + hoo*(self.target_x - self.x)
|
||||||
|
self.x = det_x*det_inv
|
||||||
|
self.v = det_v*det_inv
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function NSpring:animate(target_x, pd, td)
|
||||||
|
self.z = math.log(pd)/(self.o*td)
|
||||||
|
self.target_x = target_x
|
||||||
|
end
|
||||||
|
]]--
|
|
@ -0,0 +1,31 @@
|
||||||
|
-- An isosceles triangle class. This is a triangle with size w, h centered on x, y pointed to the right (angle 0).
|
||||||
|
-- Implements every function that Polygon does.
|
||||||
|
Triangle = Object:extend()
|
||||||
|
Triangle:implement(Polygon)
|
||||||
|
function Triangle:init(x, y, w, h)
|
||||||
|
self.x, self.y, self.w, self.h = x, y, w, h
|
||||||
|
local x1, y1 = x + h/2, y
|
||||||
|
local x2, y2 = x - h/2, y - w/2
|
||||||
|
local x3, y3 = x - h/2, y + w/2
|
||||||
|
self.vertices = {x1, y1, x2, y2, x3, y3}
|
||||||
|
self:get_size()
|
||||||
|
self:get_bounds()
|
||||||
|
self:get_centroid()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- An equilateral triangle class. This is a tringle with size w centered on x, y pointed to the right (angle 0).
|
||||||
|
-- Implements every function that Polygon does.
|
||||||
|
EquilateralTriangle = Object:extend()
|
||||||
|
EquilateralTriangle:implement(Polygon)
|
||||||
|
function EquilateralTriangle:init(x, y, w)
|
||||||
|
self.x, self.y, self.w = x, y, w
|
||||||
|
local h = math.sqrt(math.pow(w, 2) - math.pow(w/2, 2))
|
||||||
|
local x1, y1 = x + h/2, y
|
||||||
|
local x2, y2 = x - h/2, y - w/2
|
||||||
|
local x3, y3 = x - h/2, y + w/2
|
||||||
|
self.vertices = {x1, y1, x2, y2, x3, y3}
|
||||||
|
self:get_size()
|
||||||
|
self:get_bounds()
|
||||||
|
self:get_centroid()
|
||||||
|
end
|
|
@ -0,0 +1,253 @@
|
||||||
|
-- The base Vector class.
|
||||||
|
local EPSILON = 0.0001
|
||||||
|
local EPSILON_SQUARED = EPSILON*EPSILON
|
||||||
|
Vector = Object:extend()
|
||||||
|
function Vector:init(x, y)
|
||||||
|
self.x = x or 0
|
||||||
|
self.y = y or x or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:clone()
|
||||||
|
return Vector(self.x, self.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:unpack()
|
||||||
|
return self.x, self.y
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector.__tostring(self)
|
||||||
|
return "(" .. tonumber(self.x) .. ", " .. tonumber(self.y) .. ")"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:set(x, y)
|
||||||
|
if not y then
|
||||||
|
self.x = x.x
|
||||||
|
self.y = x.y
|
||||||
|
else
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:add(x, y)
|
||||||
|
if not y then
|
||||||
|
self.x = self.x + x.x
|
||||||
|
self.y = self.y + x.y
|
||||||
|
else
|
||||||
|
self.x = self.x + x
|
||||||
|
self.y = self.y + y
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:sub(x, y)
|
||||||
|
if not y then
|
||||||
|
self.x = self.x - x.x
|
||||||
|
self.y = self.y - x.y
|
||||||
|
else
|
||||||
|
self.x = self.x - x
|
||||||
|
self.y = self.y - y
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:mul(s)
|
||||||
|
if type(s) == "table" then
|
||||||
|
self.x = self.x*s.x
|
||||||
|
self.y = self.y*s.y
|
||||||
|
else
|
||||||
|
self.x = self.x*s
|
||||||
|
self.y = self.y*s
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:div(s)
|
||||||
|
if type(s) == "table" then
|
||||||
|
self.x = self.x*s.x
|
||||||
|
self.y = self.y*s.y
|
||||||
|
else
|
||||||
|
self.x = self.x/s
|
||||||
|
self.y = self.y/s
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:scale(k)
|
||||||
|
self.x = self.x*k
|
||||||
|
self.y = self.y*k
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:rotate(p, r)
|
||||||
|
local cos = math.cos(r)
|
||||||
|
local sin = math.sin(r)
|
||||||
|
local dx = self.x - p.x
|
||||||
|
local dy = self.y - p.y
|
||||||
|
self.x = dx*cos - sin*dy + p.x
|
||||||
|
self.y = sin*dx + cos*dy + p.y
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:floor()
|
||||||
|
self.x = math.floor(self.x)
|
||||||
|
self.y = math.floor(self.y)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:ceil()
|
||||||
|
self.x = math.ceil(self.x)
|
||||||
|
self.y = math.ceil(self.y)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:round(p)
|
||||||
|
self.x = math.round(self.x, p)
|
||||||
|
self.y = math.round(self.y, p)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:dot(v)
|
||||||
|
return self.x*v.x + self.y*v.y
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:is_perpendicular(v)
|
||||||
|
return math.abs(self:dot(v)) < EPSILON_SQUARED
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:cross(v)
|
||||||
|
return self.x*v.y - self.y*v.x
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:is_parallel(v)
|
||||||
|
return math.abs(self:cross(v)) < EPSILON_SQUARED
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:is_set()
|
||||||
|
return self.x or self.y
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:is_zero()
|
||||||
|
return math.abs(self.x) < EPSILON and math.abs(self.y) < EPSILON
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:zero()
|
||||||
|
self.x = 0
|
||||||
|
self.y = 0
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:length()
|
||||||
|
return math.sqrt(self.x*self.x + self.y*self.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:length_squared()
|
||||||
|
return self.x*self.x + self.y*self.y
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:normalize()
|
||||||
|
if self:is_zero() then return self end
|
||||||
|
return self:scale(1/self:length())
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:perpendicular()
|
||||||
|
return Vector(-self.y, self.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:left_normal()
|
||||||
|
return Vector(self.y, -self.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:invert()
|
||||||
|
self.x = self.x*-1
|
||||||
|
self.y = self.y*-1
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:project_to(v)
|
||||||
|
local lsq = v:length_squared()
|
||||||
|
local dp = self:dot(v)
|
||||||
|
return Vector(dp*v.x/lsq, dp*v.y/lsq)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:truncate(max)
|
||||||
|
local s = max*max/self:length_squared()
|
||||||
|
s = (s > 1 and 1) or math.sqrt(s)
|
||||||
|
self.x = self.x*s
|
||||||
|
self.y = self.y*s
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:angle_to(v)
|
||||||
|
return math.atan2(v.y - self.y, v.x - self.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:angle()
|
||||||
|
return math.atan2(self.y, self.x)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:distance_squared(v)
|
||||||
|
local dx = v.x - self.x
|
||||||
|
local dy = v.y - self.y
|
||||||
|
return dx*dx + dy*dy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:distance(v)
|
||||||
|
return math.sqrt(self:distance_squared(v))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:bounce(normal, bounce_coefficient)
|
||||||
|
local d = (1 + (bounce_coefficient or 1))*self:dot(normal)
|
||||||
|
self.x = self.x - d*normal.x
|
||||||
|
self.y = self.y - d*normal.y
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:overlaps_with_circle(cx, cy, r)
|
||||||
|
return mlib.circle.checkPoint(self.x, self.y, cx, cy, r)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:overlaps_with_polygon(vs)
|
||||||
|
return mlib.polygon.checkPoint(self.x, self.y, vs)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Vector:overlaps_with_rectangle(x, y, w, h)
|
||||||
|
return mlib.polygon.checkPoint(self.x, self.y, x - w/2, y - h/2, x + w/2, y - h/2, x + w/2, y + h/2, x - w/2, y + h/2)
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
-- TODO: actually implement this later, for now ripple works fine with just name swaps on top of it for naming consistency.
|
||||||
|
Sound = function(asset_name, options) return ripple.newSound(love.audio.newSource('assets/sounds/' .. asset_name, 'static'), options) end
|
||||||
|
SoundTag = ripple.newTag
|
||||||
|
Effect = love.audio.setEffect
|
|
@ -0,0 +1,154 @@
|
||||||
|
system = {}
|
||||||
|
local state_path = love.filesystem.getSaveDirectory() .. "/state"
|
||||||
|
|
||||||
|
|
||||||
|
function system.update(dt)
|
||||||
|
if input.f12.pressed then
|
||||||
|
for k, v in pairs(system.type_count()) do
|
||||||
|
print(k, v)
|
||||||
|
end
|
||||||
|
print("-- " .. math.round(tonumber(collectgarbage("count"))/1024, 3) .. "MB --")
|
||||||
|
print()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
global_type_table = nil
|
||||||
|
function system.type_name(o)
|
||||||
|
if global_type_table == nil then
|
||||||
|
global_type_table = {}
|
||||||
|
for k, v in pairs(_G) do
|
||||||
|
global_type_table[v] = k
|
||||||
|
end
|
||||||
|
global_type_table[0] = "table"
|
||||||
|
end
|
||||||
|
return global_type_table[getmetatable(o) or 0] or "Unknown"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.count_all(f)
|
||||||
|
local seen = {}
|
||||||
|
local count_table
|
||||||
|
count_table = function(t)
|
||||||
|
if seen[t] then return end
|
||||||
|
f(t)
|
||||||
|
seen[t] = true
|
||||||
|
for k, v in pairs(t) do
|
||||||
|
if type(v) == "table" then count_table(v)
|
||||||
|
elseif type(v) == "userdata" then f(v) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
count_table(_G)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.type_count()
|
||||||
|
local counts = {}
|
||||||
|
local enumerate = function(o)
|
||||||
|
local t = system.type_name(o)
|
||||||
|
counts[t] = (counts[t] or 0) + 1
|
||||||
|
end
|
||||||
|
system.count_all(enumerate)
|
||||||
|
return counts
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.enumerate_files(path, filter)
|
||||||
|
local function recursive_enumerate(path, files)
|
||||||
|
local items = love.filesystem.getDirectoryItems(path)
|
||||||
|
for _, item in ipairs(items) do
|
||||||
|
local file = path .. "/" .. item
|
||||||
|
local info = love.filesystem.getInfo(file)
|
||||||
|
if info.type == "file" then
|
||||||
|
table.insert(files, file)
|
||||||
|
elseif info.type == "directory" then
|
||||||
|
recursive_enumerate(file, files)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local files = {}
|
||||||
|
recursive_enumerate(path, files)
|
||||||
|
if filter then
|
||||||
|
local filtered_files = {}
|
||||||
|
for _, file in ipairs(files) do
|
||||||
|
if file:find(filter) then
|
||||||
|
table.insert(filtered_files, file:left(filter):right(path .. "/"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return filtered_files
|
||||||
|
else
|
||||||
|
return files
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.does_file_exist(path)
|
||||||
|
local file = io.open(path, "r")
|
||||||
|
if file then
|
||||||
|
file:close()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.load_files(path, filter, exclude_table)
|
||||||
|
local exclude_table = {unpack(exclude_table or {})}
|
||||||
|
for _, file in ipairs(system.enumerate_files(path, filter)) do
|
||||||
|
if not table.contains(exclude_table, file) then
|
||||||
|
require(path .. "." .. file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.save_file(filename, data)
|
||||||
|
binser.w(filename, data)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.load_file(filename)
|
||||||
|
return binser.r(filename)[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.save_state()
|
||||||
|
if not system.does_file_exist(love.filesystem.getSaveDirectory()) then love.filesystem.createDirectory("") end
|
||||||
|
binser.w(state_path, state)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.load_state()
|
||||||
|
if not system.does_file_exist(state_path) then system.save_state() end
|
||||||
|
state = binser.r(state_path)[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.get_main_directory()
|
||||||
|
return love.filesystem.getSource()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.get_save_directory()
|
||||||
|
return love.filesystem.getSaveDirectory()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.filedropped(file)
|
||||||
|
game:filedropped(love.filesystem.newFileData(file:read()))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.rename(old_path, new_path)
|
||||||
|
os.rename(old_path, new_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.execute(cmd)
|
||||||
|
os.execute(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function system.remove(path)
|
||||||
|
os.remove(path)
|
||||||
|
end
|
|
@ -0,0 +1,39 @@
|
||||||
|
require 'engine'
|
||||||
|
require 'shared'
|
||||||
|
require 'arena'
|
||||||
|
require 'objects'
|
||||||
|
|
||||||
|
|
||||||
|
function init()
|
||||||
|
shared_init()
|
||||||
|
|
||||||
|
input:bind('move_left', {'a', 'left'})
|
||||||
|
input:bind('move_right', {'d', 'right'})
|
||||||
|
input:bind('move_up', {'w', 'up'})
|
||||||
|
input:bind('move_down', {'s', 'down'})
|
||||||
|
|
||||||
|
main = Main()
|
||||||
|
main:add(Arena'arena')
|
||||||
|
main:go_to'arena'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(dt)
|
||||||
|
main:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function draw()
|
||||||
|
shared_draw(function()
|
||||||
|
main:draw()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function love.run()
|
||||||
|
return engine_run({
|
||||||
|
game_name = 'SNAKRX',
|
||||||
|
window_width = 480*3,
|
||||||
|
window_height = 270*3,
|
||||||
|
})
|
||||||
|
end
|
|
@ -0,0 +1,208 @@
|
||||||
|
Unit = Object:extend()
|
||||||
|
Unit:implement(GameObject)
|
||||||
|
Unit:implement(Physics)
|
||||||
|
function Unit:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self:set_as_rectangle(9, 9, 'dynamic', (self.player and 'player') or (self.enemy and 'enemy'))
|
||||||
|
|
||||||
|
if self.character == 'vagrant' then
|
||||||
|
self.color = fg[0]
|
||||||
|
self.visual_shape = 'triangle'
|
||||||
|
self.classes = {'ranger', 'warrior', 'mage'}
|
||||||
|
end
|
||||||
|
|
||||||
|
self:calculate_stats()
|
||||||
|
|
||||||
|
self.r = 0
|
||||||
|
self.hfx:add('hit', 1)
|
||||||
|
self.hp = self.max_hp
|
||||||
|
|
||||||
|
if self.leader then
|
||||||
|
self.previous_positions = {}
|
||||||
|
self.followers = {}
|
||||||
|
self.t:every(0.01, function()
|
||||||
|
table.insert(self.previous_positions, 1, {x = self.x, y = self.y, r = self.r})
|
||||||
|
if #self.previous_positions > 256 then self.previous_positions[257] = nil end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Unit:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
self:calculate_stats()
|
||||||
|
|
||||||
|
if self.player and self.leader then
|
||||||
|
if input.move_left.down then self.r = self.r - 1.66*math.pi*dt end
|
||||||
|
if input.move_right.down then self.r = self.r + 1.66*math.pi*dt end
|
||||||
|
self:set_velocity(self.v*math.cos(self.r), self.v*math.sin(self.r))
|
||||||
|
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
local hd = math.remap(math.abs(self.x - gw/2), 0, 192, 1, 0)
|
||||||
|
local vd = math.remap(math.abs(self.y - gh/2), 0, 108, 1, 0)
|
||||||
|
camera.x = camera.x + math.remap(vx, -100, 100, -24*hd, 24*hd)*dt
|
||||||
|
camera.y = camera.y + math.remap(vy, -100, 100, -8*vd, 8*vd)*dt
|
||||||
|
if input.move_right.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, math.pi/256)
|
||||||
|
elseif input.move_left.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, -math.pi/256)
|
||||||
|
elseif input.move_down.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, math.pi/256)
|
||||||
|
elseif input.move_up.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, -math.pi/256)
|
||||||
|
else camera.r = math.lerp_angle_dt(0.005, dt, camera.r, 0) end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.leader then
|
||||||
|
local d = math.ceil(self.v*0.1)*self.follower_index
|
||||||
|
local p = self.parent.previous_positions[d]
|
||||||
|
if p then
|
||||||
|
self:set_position(p.x, p.y)
|
||||||
|
self.r = p.r
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:set_angle(self.r)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Unit:draw()
|
||||||
|
graphics.push(self.x, self.y, self.r, self.hfx.hit.x, self.hfx.hit.x)
|
||||||
|
if self.visual_shape == 'triangle' then
|
||||||
|
graphics.triangle(self.x, self.y, self.shape.w, self.shape.h, self.hfx.hit.f and fg[0] or self.color)
|
||||||
|
elseif self.visual_shape == 'rectangle' then
|
||||||
|
graphics.rectangle(self.x, self.y, self.shape.w, self.shape.h, 2, 2, self.hfx.hit.f and fg[0] or self.color)
|
||||||
|
end
|
||||||
|
graphics.pop()
|
||||||
|
|
||||||
|
graphics.push(self.x, self.y, 0, self.hfx.hit.x, self.hfx.hit.x)
|
||||||
|
if self.show_hp then
|
||||||
|
graphics.line(self.x - 0.5*self.shape.w, self.y - self.shape.h, self.x + 0.5*self.shape.w, self.y - self.shape.h, bg[-3], 2)
|
||||||
|
local n = math.remap(self.hp, 0, self.max_hp, 0, 1)
|
||||||
|
graphics.line(self.x - 0.5*self.shape.w, self.y - self.shape.h, self.x - 0.5*self.shape.w + n*self.shape.w, self.y - self.shape.h, self.hfx.hit.f and fg[0] or ((self.player and green[0]) or (self.enemy and red[0])), 2)
|
||||||
|
end
|
||||||
|
graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Unit:on_collision_enter(other, contact)
|
||||||
|
if other:is(Wall) and self.leader then
|
||||||
|
self.hfx:use('hit', 0.5, 200, 10, 0.1)
|
||||||
|
camera:spring_shake(2, math.pi - self.r)
|
||||||
|
|
||||||
|
for i, unit in ipairs(self.followers) do
|
||||||
|
self.t:after((i-1)*self.v*0.00185, function()
|
||||||
|
unit.hfx:use('hit', 0.25, 200, 10, 0.1)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local nx, ny = contact:getNormal()
|
||||||
|
local vx, vy = self:get_velocity()
|
||||||
|
if nx == 0 then
|
||||||
|
self:set_velocity(vx, -vy)
|
||||||
|
self.r = 2*math.pi - self.r
|
||||||
|
end
|
||||||
|
if ny == 0 then
|
||||||
|
self:set_velocity(-vx, vy)
|
||||||
|
self.r = math.pi - self.r
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Unit:add_follower(unit)
|
||||||
|
table.insert(self.followers, unit)
|
||||||
|
unit.parent = self
|
||||||
|
unit.follower_index = #self.followers
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Unit:calculate_damage(dmg)
|
||||||
|
if self.def >= 0 then dmg = dmg*(100/(100+self.def))
|
||||||
|
else dmg = dmg*(2 - 100/(100+self.def)) end
|
||||||
|
return dmg
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Unit:calculate_stats()
|
||||||
|
self.base_hp = 100
|
||||||
|
self.base_dmg = 10
|
||||||
|
self.base_aspd = 1
|
||||||
|
self.base_cycle = 2
|
||||||
|
self.base_def = 0
|
||||||
|
self.base_mvspd = 75
|
||||||
|
self.class_hp_a = 0
|
||||||
|
self.class_dmg_a = 0
|
||||||
|
self.class_aspd_a = 0
|
||||||
|
self.class_cycle_a = 0
|
||||||
|
self.class_def_a = 0
|
||||||
|
self.class_mvspd_a = 0
|
||||||
|
self.class_hp_m = 1
|
||||||
|
self.class_dmg_m = 1
|
||||||
|
self.class_aspd_m = 1
|
||||||
|
self.class_cycle_m = 1
|
||||||
|
self.class_def_m = 1
|
||||||
|
self.class_mvspd_m = 1
|
||||||
|
self.buff_hp_a = 0
|
||||||
|
self.buff_dmg_a = 0
|
||||||
|
self.buff_aspd_a = 0
|
||||||
|
self.buff_cycle_a = 0
|
||||||
|
self.buff_def_a = 0
|
||||||
|
self.buff_mvspd_a = 0
|
||||||
|
self.buff_hp_m = 1
|
||||||
|
self.buff_dmg_m = 1
|
||||||
|
self.buff_aspd_m = 1
|
||||||
|
self.buff_cycle_m = 1
|
||||||
|
self.buff_def_m = 1
|
||||||
|
self.buff_mvspd_m = 1
|
||||||
|
|
||||||
|
for _, class in ipairs(self.classes) do
|
||||||
|
if class == 'warrior' then self.class_hp_m = self.class_hp_m*1.4
|
||||||
|
elseif class == 'ranger' then self.class_hp_m = self.class_hp_m*1
|
||||||
|
elseif class == 'mage' then self.class_hp_m = self.class_hp_m*0.6
|
||||||
|
elseif class == 'healer' then self.class_hp_m = self.class_hp_m*1.1
|
||||||
|
elseif class == 'cycler' then self.class_hp_m = self.class_hp_m*0.9 end
|
||||||
|
end
|
||||||
|
self.max_hp = (self.base_hp + self.class_hp_a + self.buff_hp_a)*self.class_hp_m*self.buff_hp_m
|
||||||
|
|
||||||
|
for _, class in ipairs(self.classes) do
|
||||||
|
if class == 'warrior' then self.class_dmg_m = self.class_dmg_m*1.1
|
||||||
|
elseif class == 'ranger' then self.class_dmg_m = self.class_dmg_m*1.2
|
||||||
|
elseif class == 'mage' then self.class_dmg_m = self.class_dmg_m*1.4
|
||||||
|
elseif class == 'healer' then self.class_dmg_m = self.class_dmg_m*1
|
||||||
|
elseif class == 'cycler' then self.class_dmg_m = self.class_dmg_m*1 end
|
||||||
|
end
|
||||||
|
self.dmg = (self.base_dmg + self.class_dmg_a + self.buff_dmg_a)*self.class_dmg_m*self.buff_dmg_m
|
||||||
|
|
||||||
|
for _, class in ipairs(self.classes) do
|
||||||
|
if class == 'warrior' then self.class_aspd_m = self.class_aspd_m*0.9
|
||||||
|
elseif class == 'ranger' then self.class_aspd_m = self.class_aspd_m*1.4
|
||||||
|
elseif class == 'mage' then self.class_aspd_m = self.class_aspd_m*1
|
||||||
|
elseif class == 'healer' then self.class_aspd_m = self.class_aspd_m*0.5
|
||||||
|
elseif class == 'cycler' then self.class_aspd_m = self.class_aspd_m*1 end
|
||||||
|
end
|
||||||
|
self.aspd = 1/((self.base_aspd + self.class_aspd_a + self.buff_aspd_a)*self.class_aspd_m*self.buff_aspd_m)
|
||||||
|
|
||||||
|
for _, class in ipairs(self.classes) do
|
||||||
|
if class == 'warrior' then self.class_cycle_m = self.class_cycle_m*1
|
||||||
|
elseif class == 'ranger' then self.class_cycle_m = self.class_cycle_m*1
|
||||||
|
elseif class == 'mage' then self.class_cycle_m = self.class_cycle_m*1.25
|
||||||
|
elseif class == 'healer' then self.class_cycle_m = self.class_cycle_m*1.1
|
||||||
|
elseif class == 'cycler' then self.class_cycle_m = self.class_cycle_m*1.5 end
|
||||||
|
end
|
||||||
|
self.cycle = (self.base_cycle + self.class_cycle_a + self.buff_cycle_a)*self.class_cycle_m*self.buff_cycle_m
|
||||||
|
|
||||||
|
for _, class in ipairs(self.classes) do
|
||||||
|
if class == 'warrior' then self.class_def_m = self.class_def_m*1.25
|
||||||
|
elseif class == 'ranger' then self.class_def_m = self.class_def_m*1.1
|
||||||
|
elseif class == 'mage' then self.class_def_m = self.class_def_m*1.5
|
||||||
|
elseif class == 'healer' then self.class_def_m = self.class_def_m*1.2
|
||||||
|
elseif class == 'cycler' then self.class_def_m = self.class_def_m*1 end
|
||||||
|
end
|
||||||
|
self.def = (self.base_def + self.class_def_a + self.buff_def_a)*self.class_def_m*self.buff_def_m
|
||||||
|
|
||||||
|
for _, class in ipairs(self.classes) do
|
||||||
|
if class == 'warrior' then self.class_mvspd_m = self.class_mvspd_m*0.9
|
||||||
|
elseif class == 'ranger' then self.class_mvspd_m = self.class_mvspd_m*1.2
|
||||||
|
elseif class == 'mage' then self.class_mvspd_m = self.class_mvspd_m*1
|
||||||
|
elseif class == 'healer' then self.class_mvspd_m = self.class_mvspd_m*1
|
||||||
|
elseif class == 'cycler' then self.class_mvspd_m = self.class_mvspd_m*1 end
|
||||||
|
end
|
||||||
|
self.v = (self.base_mvspd + self.class_mvspd_a + self.buff_mvspd_a)*self.class_mvspd_m*self.buff_mvspd_m
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd E:/a327ex/SNAKRX # change to the directory of the current project
|
||||||
|
engine/love/love.exe --console .
|
|
@ -0,0 +1,635 @@
|
||||||
|
function shared_init()
|
||||||
|
local colors = {
|
||||||
|
white = ColorRamp(Color(1, 1, 1, 1), 0.025),
|
||||||
|
black = ColorRamp(Color(0, 0, 0, 1), 0.025),
|
||||||
|
bg = ColorRamp(Color'#303030', 0.025),
|
||||||
|
fg = ColorRamp(Color'#dadada', 0.025),
|
||||||
|
fg_alt = ColorRamp(Color'#b0a89f', 0.025),
|
||||||
|
yellow = ColorRamp(Color'#facf00', 0.025),
|
||||||
|
orange = ColorRamp(Color'#f07021', 0.025),
|
||||||
|
blue = ColorRamp(Color'#019bd6', 0.025),
|
||||||
|
green = ColorRamp(Color'#8bbf40', 0.025),
|
||||||
|
red = ColorRamp(Color'#e91d39', 0.025),
|
||||||
|
purple = ColorRamp(Color'#8e559e', 0.025),
|
||||||
|
}
|
||||||
|
for name, color in pairs(colors) do _G[name] = color end
|
||||||
|
modal_transparent = Color(0.1, 0.1, 0.1, 0.5)
|
||||||
|
fg_transparent = Color(fg[0].r, fg[0].g, fg[0].b, 0.5)
|
||||||
|
|
||||||
|
graphics.set_background_color(bg[0])
|
||||||
|
graphics.set_color(fg[0])
|
||||||
|
slow_amount = 1
|
||||||
|
|
||||||
|
sfx = SoundTag()
|
||||||
|
sfx.volume = 0.5
|
||||||
|
music = SoundTag()
|
||||||
|
music.volume = 0.5
|
||||||
|
|
||||||
|
fat_font = Font('FatPixelFont', 8)
|
||||||
|
pixul_font = Font('PixulBrush', 8)
|
||||||
|
main_canvas = Canvas(gw, gh, {stencil = true})
|
||||||
|
shadow_canvas = Canvas(gw, gh)
|
||||||
|
shadow_shader = Shader(nil, 'shadow.frag')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function shared_draw(draw_action)
|
||||||
|
main_canvas:draw_to(function()
|
||||||
|
draw_action()
|
||||||
|
if flashing then graphics.rectangle(gw/2, gh/2, gw, gh, nil, nil, flash_color) end
|
||||||
|
end)
|
||||||
|
|
||||||
|
shadow_canvas:draw_to(function()
|
||||||
|
graphics.set_color(white[0])
|
||||||
|
shadow_shader:set()
|
||||||
|
main_canvas:draw2(0, 0, 0, 1, 1)
|
||||||
|
shadow_shader:unset()
|
||||||
|
end)
|
||||||
|
|
||||||
|
shadow_canvas:draw(6, 6, 0, sx, sy)
|
||||||
|
main_canvas:draw(0, 0, 0, sx, sy)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SpawnEffect = Object:extend()
|
||||||
|
SpawnEffect:implement(GameObject)
|
||||||
|
function SpawnEffect:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.target_color = self.color or red[0]
|
||||||
|
self.color = fg[0]
|
||||||
|
self.rs = 0
|
||||||
|
self.t:tween(0.1, self, {rs = 6}, math.cubic_in_out, function()
|
||||||
|
if self.action then self.action(self.x, self.y) end
|
||||||
|
self.spring:pull(1)
|
||||||
|
for i = 1, random:int(6, 8) do HitParticle{group = main.current.effects, self.x, self.y, color = self.target_color, duration = random:float(0.3, 0.5), w = random:float(5, 8), v = random:float(150, 200)} end
|
||||||
|
self.t:tween(0.25, self, {rs = 0}, math.linear, function() self.dead = true end)
|
||||||
|
self.t:after(0.15, function() self.color = self.target_color end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function SpawnEffect:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function SpawnEffect:draw()
|
||||||
|
graphics.circle(self.x, self.y, random:float(0.9, 1.1)*self.rs*self.spring.x, self.color)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Mixin to be added to a state so it can have nodemap creation, saving and manipulating capabilities.
|
||||||
|
Nodemap = Object:extend()
|
||||||
|
-- nodemap is a table that contains the definition of the skill tree or overmap.
|
||||||
|
-- Each node in it should have the following attributes defined:
|
||||||
|
-- .x, .y, .neighbors or .links. Optionally: .rs, .color, .visited, .can_be_visited, .on_visit, .on_draw, .data
|
||||||
|
-- An example would look like this:
|
||||||
|
-- nodemap = {
|
||||||
|
-- [1] = {x = x, y = y, visited = true, links = {2, 3, 4, 5}}
|
||||||
|
-- [2] = {x = x, y = y - 64, links = {1}}
|
||||||
|
-- [3] = {x = x + 64, y = y, links = {1}}
|
||||||
|
-- [4] = {x = x, y = y + 64, links = {1}}
|
||||||
|
-- [5] = {x = x - 64, y = y, links = {1}}
|
||||||
|
-- }
|
||||||
|
-- .data can be a table that contains other attributes. These will be automatically added to the Node object when it's created.
|
||||||
|
-- .on_visit should be defined if you want the button to do something when it's clicked. Example:
|
||||||
|
-- [2] = {x = x, y = y - 64, links = {1}, on_visit = function(visited_node) state.goto'level_2' end}
|
||||||
|
-- .on_draw should be used when you want to draw the node in some specific way rather than the default one.
|
||||||
|
-- color_mode can be nil or 'skill_tree', if it's the latter then nodes and edges will change colors according to if they were a part of a skill tree:
|
||||||
|
-- Unvisitable nodes are gray, visitable nodes are white, visited nodes are their default color
|
||||||
|
-- This is opposed to the default color mode, where all nodes and edges have their their default colors, and when they're visited they turn gray instead.
|
||||||
|
function Nodemap:generate_nodemap(group, nodemap, color_mode)
|
||||||
|
for id, node in pairs(nodemap) do
|
||||||
|
Node{group = group, x = node.x, y = node.y, node_id = id, neighbors = node.links, rs = node.rs, visited = node.visited, can_be_visited = node.can_be_visited, color = node.color, label = node.label, data = node.data,
|
||||||
|
on_visit = node.on_visit, on_draw = node.on_draw, color_mode = color_mode}
|
||||||
|
end
|
||||||
|
|
||||||
|
for id, node in pairs(nodemap) do
|
||||||
|
for _, node_id in ipairs(node.links) do
|
||||||
|
if nodemap[node_id] then
|
||||||
|
Edge{group = group, x = 0, y = 0, node1_id = id, node2_id = node_id, color_mode = color_mode}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Node = Object:extend()
|
||||||
|
Node:implement(GameObject)
|
||||||
|
function Node:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
for k, v in pairs(self.data) do self[k] = v end
|
||||||
|
self.data = nil
|
||||||
|
self.rs = self.rs or 6
|
||||||
|
self.shape = Circle(self.x, self.y, 1.5*self.rs)
|
||||||
|
self.interact_with_mouse = true
|
||||||
|
|
||||||
|
self.src_color = self.color
|
||||||
|
if self.color_mode == 'skill_tree' then
|
||||||
|
self.color = bg[5]
|
||||||
|
if self.visited then self.color = fg[0] end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.t:every_immediate(1.4, function()
|
||||||
|
if self.can_be_visited then
|
||||||
|
self.t:tween(0.7, self, {sx = 0.9, sy = 0.9}, math.linear, function()
|
||||||
|
self.t:tween(0.7, self, {sx = 1.1, sy = 1.1}, math.linear, nil, 'visit_pulse_1')
|
||||||
|
end, 'visit_pulse_2')
|
||||||
|
end
|
||||||
|
end, nil, nil, 'visit_pulse')
|
||||||
|
|
||||||
|
if self.label then self.label_r = 0 end
|
||||||
|
self.t:after(0.01, function()
|
||||||
|
if self.label then
|
||||||
|
local xs, ys = 0, 0
|
||||||
|
for _, neighbor_id in ipairs(self.neighbors) do
|
||||||
|
local neighbor = self.group:get_object_by_property('node_id', neighbor_id)
|
||||||
|
local r = math.angle(self.x, self.y, neighbor.x, neighbor.y)
|
||||||
|
x, y = math.cos(r), math.sin(r)
|
||||||
|
xs = xs + x
|
||||||
|
ys = ys + y
|
||||||
|
end
|
||||||
|
self.label_r = Vector(-xs, -ys):angle()
|
||||||
|
self.label_color = self.color
|
||||||
|
end
|
||||||
|
|
||||||
|
self.edges = {}
|
||||||
|
for _, neighbor_id in ipairs(self.neighbors) do
|
||||||
|
local edge = nil
|
||||||
|
edge = self.group:get_object_by_properties({'node1_id', 'node2_id'}, {self.node_id, neighbor_id})
|
||||||
|
if not edge then edge = self.group:get_object_by_properties({'node1_id', 'node2_id'}, {neighbor_id, self.node_id}) end
|
||||||
|
if edge then table.insert(self.edges, edge) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Node:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
|
||||||
|
if not self.visited then
|
||||||
|
for _, neighbor_id in ipairs(self.neighbors) do
|
||||||
|
local neighbor = self.group:get_object_by_property('node_id', neighbor_id)
|
||||||
|
if neighbor and neighbor.visited then
|
||||||
|
self.can_be_visited = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.color_mode == 'skill_tree' then
|
||||||
|
if self.can_be_visited then
|
||||||
|
self.color = bg[10]
|
||||||
|
if self.label then self.label_color = bg[10] end
|
||||||
|
if self.hot then
|
||||||
|
self.color = fg[0]
|
||||||
|
if self.label then self.label_color = fg[0] end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.hot and self.can_be_visited and not self.visited and input.m1.pressed then
|
||||||
|
self.t:cancel'visit_pulse'
|
||||||
|
self.t:cancel'visit_pulse_1'
|
||||||
|
self.t:cancel'visit_pulse_2'
|
||||||
|
self.sx, self.sy = 1, 1
|
||||||
|
self.spring:pull(0.25)
|
||||||
|
self.can_be_visited = false
|
||||||
|
self.visited = true
|
||||||
|
self.hot = false
|
||||||
|
if self.color_mode == 'skill_tree' then
|
||||||
|
self.color = self.src_color
|
||||||
|
if self.label then self.label_color = self.src_color end
|
||||||
|
else
|
||||||
|
self.color = bg[5]
|
||||||
|
if self.label then self.label_color = bg[5] end
|
||||||
|
end
|
||||||
|
if self.label then self.label_color = self.color end
|
||||||
|
if self.on_visit then self:on_visit() end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Node:draw()
|
||||||
|
if self.on_draw then
|
||||||
|
self:on_draw()
|
||||||
|
else
|
||||||
|
graphics.push(self.x, self.y, 0, self.spring.x*self.sx, self.spring.x*self.sy)
|
||||||
|
if self.hot and self.can_be_visited then graphics.circle(self.x, self.y, 1.15*self.shape.rs, self.color)
|
||||||
|
else graphics.circle(self.x, self.y, self.shape.rs, self.color, 3) end
|
||||||
|
graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.label then
|
||||||
|
local w = pixul_font:get_text_width(self.label)
|
||||||
|
local s = math.remap(self.rs, 6, 12, 3.5, 2.5)
|
||||||
|
graphics.print_centered(self.label, pixul_font, self.x + (w/6)*math.cos(self.label_r) + s*self.rs*math.cos(self.label_r), self.y + s*self.rs*math.sin(self.label_r), 0, self.spring.x*self.sx, self.spring.x*self.sy, nil, nil, self.label_color)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Node:on_mouse_enter()
|
||||||
|
self.hot = true
|
||||||
|
self.spring:pull(0.2, 200, 10)
|
||||||
|
for _, edge in ipairs(self.edges) do edge.spring:pull(0.15, 200, 10) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Node:on_mouse_exit()
|
||||||
|
self.hot = false
|
||||||
|
self.spring:pull(0.05, 200, 10)
|
||||||
|
for _, edge in ipairs(self.edges) do edge.spring:pull(0.05, 200, 10) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Edge = Object:extend()
|
||||||
|
Edge:implement(GameObject)
|
||||||
|
function Edge:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.node1 = self.group:get_object_by_property('node_id', self.node1_id)
|
||||||
|
self.node2 = self.group:get_object_by_property('node_id', self.node2_id)
|
||||||
|
local r = math.angle(self.node1.x, self.node1.y, self.node2.x, self.node2.y)
|
||||||
|
self.x1, self.y1 = self.node1.x + 2.75*self.node1.rs*math.cos(r), self.node1.y + 2.75*self.node1.rs*math.sin(r)
|
||||||
|
self.x2, self.y2 = self.node2.x + 2.75*self.node2.rs*math.cos(r - math.pi), self.node2.y + 2.75*self.node2.rs*math.sin(r - math.pi)
|
||||||
|
|
||||||
|
if self.color_mode == 'skill_tree' then self.color = bg[5]
|
||||||
|
else self.color = fg[0] end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Edge:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
|
||||||
|
if self.color_mode == 'skill' then
|
||||||
|
self.color = bg[5]
|
||||||
|
if (self.node1.visited and self.node2.can_be_visited) or (self.node2.visited and self.node1.can_be_visited) then self.color = bg[10] end
|
||||||
|
if (self.node1.visited and self.node2.visited) or (self.node1.visited and self.node2.hot) or (self.node2.visited and self.node1.hot) then self.color = fg[0] end
|
||||||
|
else
|
||||||
|
if self.node1.visited and self.node2.visited then self.color = bg[5] end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
self.color = bg[5]
|
||||||
|
if (self.node1.visited and self.node2.can_be_visited) or (self.node2.visited and self.node1.can_be_visited) then self.color = bg[10] end
|
||||||
|
if (self.node1.visited and self.node2.visited) or (self.node1.visited and self.node2.hot) or (self.node2.visited and self.node1.hot) then self.color = fg[0] end
|
||||||
|
]]--
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Edge:draw()
|
||||||
|
graphics.push((self.x1+self.x2)/2, (self.y1+self.y2)/2, 0, self.spring.x, self.spring.x)
|
||||||
|
graphics.line(self.x1, self.y1, self.x2, self.y2, self.color, 4)
|
||||||
|
graphics.circle(self.x1, self.y1, 2, self.color)
|
||||||
|
graphics.circle(self.x2, self.y2, 2, self.color)
|
||||||
|
graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HoverCrosshair = Object:extend()
|
||||||
|
HoverCrosshair:implement(GameObject)
|
||||||
|
function HoverCrosshair:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.ox, self.oy = 0, 0
|
||||||
|
self.sx, self.sy = 0, 0
|
||||||
|
self.line_width = 2
|
||||||
|
self.w, self.h = 10, 10
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HoverCrosshair:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
if self.animation then self.animation:update(dt) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HoverCrosshair:draw()
|
||||||
|
graphics.push(self.x, self.y, 0, self.sx*self.spring.x, self.sy*self.spring.x)
|
||||||
|
graphics.polyline(fg[0], self.line_width, self.x - self.ox, self.y - self.oy + 0.4*self.h, self.x - self.ox, self.y - self.oy, self.x - self.ox + 0.4*self.w, self.y - self.oy)
|
||||||
|
graphics.polyline(fg[0], self.line_width, self.x - self.ox, self.y + self.oy - 0.4*self.h, self.x - self.ox, self.y + self.oy, self.x - self.ox + 0.4*self.w, self.y + self.oy)
|
||||||
|
graphics.polyline(fg[0], self.line_width, self.x + self.ox - 0.4*self.w, self.y - self.oy, self.x + self.ox, self.y - self.oy, self.x + self.ox, self.y - self.oy + 0.4*self.h)
|
||||||
|
graphics.polyline(fg[0], self.line_width, self.x + self.ox - 0.4*self.w, self.y + self.oy, self.x + self.ox, self.y + self.oy, self.x + self.ox, self.y + self.oy - 0.4*self.h)
|
||||||
|
graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HoverCrosshair:activate(x, y, w, h, line_width)
|
||||||
|
w, h = 10, 10
|
||||||
|
line_width = 2
|
||||||
|
self.x, self.y = camera:get_local_coords(x, y)
|
||||||
|
self.t:cancel'deactivate'
|
||||||
|
self.t:tween(0.1, self, {sx = 1, sy = 1}, math.cubic_in_out, function() self.sx, self.sy = 1, 1 end, 'activate')
|
||||||
|
if self.w <= 10 and self.h <= 10 then
|
||||||
|
self.animation = AnimationLogic(0.075, 3, 'bounce', {
|
||||||
|
function() self.ox, self.oy = 0.6*self.w, 0.6*self.h end,
|
||||||
|
function() self.ox, self.oy = 0.8*self.w, 0.8*self.h end,
|
||||||
|
function() self.ox, self.oy = self.w, self.h end,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
self.animation = AnimationLogic(0.075, 3, 'bounce', {
|
||||||
|
function() self.ox, self.oy = 0.8*self.w, 0.8*self.h end,
|
||||||
|
function() self.ox, self.oy = 0.9*self.w, 0.9*self.h end,
|
||||||
|
function() self.ox, self.oy = self.w, self.h end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HoverCrosshair:deactivate()
|
||||||
|
self.t:cancel'activate'
|
||||||
|
self.t:tween(0.05, self, {sx = 0, sy = 0}, math.linear, function() self.sx, self.sy = 0, 0 end, 'deactivate')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TransitionEffect = Object:extend()
|
||||||
|
TransitionEffect:implement(GameObject)
|
||||||
|
function TransitionEffect:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
if not self.text then error('TransitionEffect must have a Text object defined to the .text attribute') end
|
||||||
|
self.rs = 0
|
||||||
|
self.text_sx, self.text_sy = 0, 0
|
||||||
|
self.t:after(0.25, function()
|
||||||
|
self.t:after(0.1, function()
|
||||||
|
self.t:tween(0.1, self, {text_sx = 1, text_sy = 1}, math.cubic_in_out)
|
||||||
|
end)
|
||||||
|
self.t:tween(0.75, self, {rs = gw}, math.linear, function()
|
||||||
|
if self.transition_action then self.transition_action(unpack(self.transition_action_args)) end
|
||||||
|
self.t:after(0.5, function()
|
||||||
|
self.x, self.y = gw/2, gh/2
|
||||||
|
self.t:after(0.7, function() self.t:tween(0.05, self, {text_sx = 0, text_sy = 0}, math.cubic_in_out) end)
|
||||||
|
self.t:tween(0.75, self, {rs = 0}, math.linear, function() self.text = nil; self.dead = true end)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TransitionEffect:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
if self.text then self.text:update(dt) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TransitionEffect:draw()
|
||||||
|
graphics.push(self.x, self.y, 0, self.sx, self.sy)
|
||||||
|
graphics.circle(self.x, self.y, self.rs, self.color)
|
||||||
|
graphics.pop()
|
||||||
|
if self.text then self.text:draw(gw/2, gh/2, 0, self.text_sx, self.text_sy) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
global_text_tags = {
|
||||||
|
red = TextTag{draw = function(c, i, text) graphics.set_color(red[0]) end},
|
||||||
|
orange = TextTag{draw = function(c, i, text) graphics.set_color(orange[0]) end},
|
||||||
|
yellow = TextTag{draw = function(c, i, text) graphics.set_color(yellow[0]) end},
|
||||||
|
green = TextTag{draw = function(c, i, text) graphics.set_color(green[0]) end},
|
||||||
|
purple = TextTag{draw = function(c, i, text) graphics.set_color(purple[0]) end},
|
||||||
|
blue = TextTag{draw = function(c, i, text) graphics.set_color(blue[0]) end},
|
||||||
|
bg = TextTag{draw = function(c, i, text) graphics.set_color(bg[0]) end},
|
||||||
|
fg = TextTag{draw = function(c, i, text) graphics.set_color(fg[0]) end},
|
||||||
|
wavy = TextTag{update = function(c, dt, i, text) c.oy = 2*math.sin(4*time + i) end},
|
||||||
|
}
|
||||||
|
|
||||||
|
InfoText = Object:extend()
|
||||||
|
InfoText:implement(GameObject)
|
||||||
|
function InfoText:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.sx, self.sy = 0, 0
|
||||||
|
self.ox, self.oy = 0, 0
|
||||||
|
self.ow, self.oh = 0, 0
|
||||||
|
self.text = Text({}, global_text_tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function InfoText:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function InfoText:draw()
|
||||||
|
graphics.push(self.x + self.ox, self.y + self.oy, 0, self.sx*self.spring.x, self.sy*self.spring.x)
|
||||||
|
graphics.rectangle(self.x + self.ox, self.y + self.oy, self.text.w + self.ow, self.text.h + self.oh, self.text.h/4, self.text.h/4, bg[-2])
|
||||||
|
self.text:draw(self.x + self.ox, self.y + self.oy + self.text.h/2)
|
||||||
|
graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function InfoText:activate(text, ox, oy, sx, sy, ow, oh)
|
||||||
|
ox, oy = 0, 0
|
||||||
|
sx, sy = 1, 1
|
||||||
|
ow, oh = 16, 4
|
||||||
|
self.text:set_text(text)
|
||||||
|
self.t:cancel'deactivate'
|
||||||
|
self.t:tween(0.1, self, {sx = sx, sy = sy}, math.cubic_in_out, function() self.sx, self.sy = sx, sy end, 'activate_1')
|
||||||
|
self.t:after(0.075, function() self.spring:pull(0.1, 200, 10) end, 'activate_2')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function InfoText:deactivate()
|
||||||
|
self.t:cancel'activate_1'
|
||||||
|
self.t:cancel'activate_2'
|
||||||
|
self.t:tween(0.05, self, {sy = 0}, math.linear, function() self.sy = 0 end, 'deactivate')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ColorRamp = Object:extend()
|
||||||
|
function ColorRamp:init(color, step)
|
||||||
|
self.color = color
|
||||||
|
self.step = step
|
||||||
|
for i = -10, 10 do
|
||||||
|
if i < 0 then
|
||||||
|
self[i] = self.color:clone():lighten(i*self.step)
|
||||||
|
elseif i > 0 then
|
||||||
|
self[i] = self.color:clone():lighten(i*self.step)
|
||||||
|
else
|
||||||
|
self[i] = self.color:clone()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
RefreshEffect = Object:extend()
|
||||||
|
RefreshEffect:implement(GameObject)
|
||||||
|
RefreshEffect:implement(Parent)
|
||||||
|
function RefreshEffect:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.oy = self.h/3
|
||||||
|
self.t:tween(0.15, self, {h = 0}, math.linear, function() self.dead = true end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function RefreshEffect:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
self:follow_parent_exclusively()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function RefreshEffect:draw()
|
||||||
|
graphics.push(self.x, self.y, self.r)
|
||||||
|
graphics.rectangle2(self.x - self.w/2, self.y - self.oy, self.w, self.h, nil, nil, fg[0])
|
||||||
|
graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function flash(duration, color)
|
||||||
|
flashing = true
|
||||||
|
flash_color = color or fg[0]
|
||||||
|
t:after(duration, function() flashing = false end, 'flash')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function slow(amount, duration, tween_method)
|
||||||
|
amount = amount or 0.5
|
||||||
|
duration = duration or 0.5
|
||||||
|
tween_method = tween_method or math.cubic_in_out
|
||||||
|
slow_amount = amount
|
||||||
|
t:tween(duration, _G, {slow_amount = 1}, tween_method, function() slow_amount = 1 end, 'slow')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HitCircle = Object:extend()
|
||||||
|
HitCircle:implement(GameObject)
|
||||||
|
function HitCircle:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.rs = self.rs or 8
|
||||||
|
self.duration = self.duration or 0.05
|
||||||
|
self.color = self.color or white
|
||||||
|
self.t:after(self.duration, function() self.dead = true end, 'die')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitCircle:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitCircle:draw()
|
||||||
|
graphics.circle(self.x, self.y, self.rs, self.color)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitCircle:scale_down(duration)
|
||||||
|
duration = duration or 0.2
|
||||||
|
self.t:cancel'die'
|
||||||
|
self.t:tween(self.duration, self, {rs = 0}, math.cubic_in_out, function() self.dead = true end)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitCircle:change_color(delay_multiplier, target_color)
|
||||||
|
delay_multiplier = delay_multiplier or 0.5
|
||||||
|
self.t:after(delay_multiplier*self.duration, function() self.color = target_color end)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HitParticle = Object:extend()
|
||||||
|
HitParticle:implement(GameObject)
|
||||||
|
function HitParticle:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.v = self.v or random:float(50, 150)
|
||||||
|
self.r = args.r or random:float(0, 2*math.pi)
|
||||||
|
self.duration = self.duration or random:float(0.2, 0.6)
|
||||||
|
self.w = self.w or random:float(3.5, 7)
|
||||||
|
self.h = self.h or self.w/2
|
||||||
|
self.color = self.color or white
|
||||||
|
self.t:tween(self.duration, self, {w = 2, h = 2, v = 0}, math.cubic_in_out, function() self.dead = true end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitParticle:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
self.x = self.x + self.v*math.cos(self.r)*dt
|
||||||
|
self.y = self.y + self.v*math.sin(self.r)*dt
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitParticle:draw()
|
||||||
|
graphics.push(self.x, self.y, self.r)
|
||||||
|
graphics.rectangle(self.x, self.y, self.w, self.h, 2, 2, self.color)
|
||||||
|
graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function HitParticle:change_color(delay_multiplier, target_color)
|
||||||
|
delay_multiplier = delay_multiplier or 0.5
|
||||||
|
self.t:after(delay_multiplier*self.duration, function() self.color = target_color end)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AnimationEffect = Object:extend()
|
||||||
|
AnimationEffect:implement(GameObject)
|
||||||
|
function AnimationEffect:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self.animation = Animation(self.delay, self.frames, 'once', {[0] = function() self.dead = true end})
|
||||||
|
self.color = self.color or white
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function AnimationEffect:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
self.animation:update(dt)
|
||||||
|
if self.linear_movement then
|
||||||
|
self.x = self.x + self.v*math.cos(self.r)*dt
|
||||||
|
self.y = self.y + self.v*math.sin(self.r)*dt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function AnimationEffect:draw()
|
||||||
|
self.animation:draw(self.x + (self.ox or 0), self.y + (self.ox or 0), self.r + (self.oa or 0), (self.flip_sx or 1)*self.sx, (self.flip_sy or 1)*self.sy, nil, nil, self.color)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function AnimationEffect:set_linear_movement(v, r)
|
||||||
|
self.v = v
|
||||||
|
self.r = r
|
||||||
|
self.linear_movement = true
|
||||||
|
local duration = self.animation.size*self.delay
|
||||||
|
self.t:after(2*duration/3, function() self.t:tween(duration/3, self, {v = 0}, math.cubic_in_out) end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Wall = Object:extend()
|
||||||
|
Wall:implement(GameObject)
|
||||||
|
Wall:implement(Physics)
|
||||||
|
function Wall:init(args)
|
||||||
|
self:init_game_object(args)
|
||||||
|
self:set_as_chain(true, self.vertices, 'static', 'solid')
|
||||||
|
self.color = self.color or fg[0]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Wall:update(dt)
|
||||||
|
self:update_game_object(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Wall:draw()
|
||||||
|
self.shape:draw(self.color)
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
Vagrant: shoots an ethereal projectile at any nearby enemy that deals physical and magical damage, medium range
|
||||||
|
Scout: throws a knife at any nearby enemy that deals physical damage and chains, small range
|
||||||
|
Cleric: heals every unit when any one drops below 50% HP
|
||||||
|
Swordsman: deals physical damage in an area around the unit, small range
|
||||||
|
Archer: shoots an arrow at any nearby enemy in front of the unit, long range
|
||||||
|
Wizard: shoots a projectile at any nearby enemy and deals AoE magical damage on contact, small range
|
||||||
|
|
||||||
|
Ranger: yellow, buff attack speed
|
||||||
|
Warrior: orange, buff attack damage
|
||||||
|
Healer: green, buff healing effectiveness
|
||||||
|
Mage: blue, debuff enemy magic resistance
|
||||||
|
Cycler: purple, buff cycle speed
|
||||||
|
|
||||||
|
HP
|
||||||
|
Damage
|
||||||
|
Attack speed -> stacks additively, capped at minimum 0.125s or +300%
|
||||||
|
Cycle speed -> stacks additively, capped at minimum 0.5s or +300%
|
||||||
|
Armor -> if armor >= 0 then dmg_m = 100/(100+armor) else dmg_m = 2-100/(100-armor)
|
||||||
|
Magic resistance -> if mr >= 0 then dmg_m = 100/(100+mr) else dmg_m = 2-100/(100-mr)
|
Loading…
Reference in New Issue