mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
added STI example with fixed STI THANKS karai17!
This commit is contained in:
parent
1bbc80f04d
commit
75980bba74
BIN
examples/gfx/border.bmp
Normal file
BIN
examples/gfx/border.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
examples/gfx/border_NRM.png
Normal file
BIN
examples/gfx/border_NRM.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
61
examples/gfx/map.lua
Normal file
61
examples/gfx/map.lua
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
return {
|
||||||
|
version = "1.1",
|
||||||
|
luaversion = "5.1",
|
||||||
|
orientation = "orthogonal",
|
||||||
|
width = 25,
|
||||||
|
height = 15,
|
||||||
|
tilewidth = 32,
|
||||||
|
tileheight = 32,
|
||||||
|
backgroundcolor = { 128, 128, 128, 0 },
|
||||||
|
properties = {},
|
||||||
|
tilesets = {
|
||||||
|
{
|
||||||
|
name = "base",
|
||||||
|
firstgid = 1,
|
||||||
|
tilewidth = 32,
|
||||||
|
tileheight = 32,
|
||||||
|
spacing = 0,
|
||||||
|
margin = 0,
|
||||||
|
image = "border.bmp",
|
||||||
|
imagewidth = 32,
|
||||||
|
imageheight = 32,
|
||||||
|
tileoffset = {
|
||||||
|
x = 0,
|
||||||
|
y = 0
|
||||||
|
},
|
||||||
|
properties = {},
|
||||||
|
tiles = {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layers = {
|
||||||
|
{
|
||||||
|
type = "tilelayer",
|
||||||
|
name = "Tile Layer 1",
|
||||||
|
x = 0,
|
||||||
|
y = 0,
|
||||||
|
width = 25,
|
||||||
|
height = 15,
|
||||||
|
visible = true,
|
||||||
|
opacity = 1,
|
||||||
|
properties = {},
|
||||||
|
encoding = "lua",
|
||||||
|
data = {
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
examples/gfx/map.tmx
Normal file
11
examples/gfx/map.tmx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="25" height="15" tilewidth="32" tileheight="32" backgroundcolor="#808080">
|
||||||
|
<tileset firstgid="1" name="base" tilewidth="32" tileheight="32">
|
||||||
|
<image source="border.bmp" width="32" height="32"/>
|
||||||
|
</tileset>
|
||||||
|
<layer name="Tile Layer 1" width="25" height="15">
|
||||||
|
<data encoding="base64" compression="zlib">
|
||||||
|
eJxjZGBgYBxGmFZg1A7K7SA2roiJ36FgBzFgIO2gJhi1gzw7aIkB2WcAjg==
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
</map>
|
79
examples/simple_tiled_impl.lua
Normal file
79
examples/simple_tiled_impl.lua
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
-- Example: STI Example
|
||||||
|
local LightWorld = require "lib"
|
||||||
|
local sti = require 'examples.vendor.sti'
|
||||||
|
|
||||||
|
function love.load()
|
||||||
|
x = 0
|
||||||
|
y = 0
|
||||||
|
z = 1
|
||||||
|
scale = 1
|
||||||
|
|
||||||
|
-- create light world
|
||||||
|
lightWorld = LightWorld({
|
||||||
|
ambient = {55,55,55},
|
||||||
|
})
|
||||||
|
|
||||||
|
map = sti.new("examples/gfx/map")
|
||||||
|
image_normal = love.graphics.newImage("examples/gfx/border_NRM.png")
|
||||||
|
|
||||||
|
-- create light
|
||||||
|
lightMouse = lightWorld:newLight(0, 0, 255, 127, 63, 300)
|
||||||
|
lightMouse:setGlowStrength(0.3)
|
||||||
|
|
||||||
|
-- walls
|
||||||
|
lightWorld:newRectangle(400, 32, 800, 64):setNormalMap(image_normal, 800, 64)
|
||||||
|
lightWorld:newRectangle(32, 272, 64, 416):setNormalMap(image_normal, 64, 416)
|
||||||
|
lightWorld:newRectangle(400, 464, 800, 32):setNormalMap(image_normal, 800, 32)
|
||||||
|
lightWorld:newRectangle(784, 272, 32, 416):setNormalMap(image_normal, 32, 416)
|
||||||
|
|
||||||
|
--blocks
|
||||||
|
lightWorld:newRectangle(224, 256, 128, 124):setNormalMap(image_normal, 128, 124)
|
||||||
|
lightWorld:newRectangle(592, 224, 224, 64):setNormalMap(image_normal, 224, 64)
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.update(dt)
|
||||||
|
love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")")
|
||||||
|
|
||||||
|
if love.keyboard.isDown("down") then
|
||||||
|
y = y - dt * 200
|
||||||
|
elseif love.keyboard.isDown("up") then
|
||||||
|
y = y + dt * 200
|
||||||
|
end
|
||||||
|
|
||||||
|
if love.keyboard.isDown("right") then
|
||||||
|
x = x - dt * 200
|
||||||
|
elseif love.keyboard.isDown("left") then
|
||||||
|
x = x + dt * 200
|
||||||
|
end
|
||||||
|
|
||||||
|
if love.keyboard.isDown("-") then
|
||||||
|
scale = scale - 0.01
|
||||||
|
elseif love.keyboard.isDown("=") then
|
||||||
|
scale = scale + 0.01
|
||||||
|
end
|
||||||
|
|
||||||
|
map:update(dt)
|
||||||
|
lightMouse:setPosition((love.mouse.getX() - x)/scale, (love.mouse.getY() - y)/scale, z)
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.mousepressed(x, y, c)
|
||||||
|
if c == "wu" then
|
||||||
|
z = z + 1
|
||||||
|
elseif c == "wd" then
|
||||||
|
z = z - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.draw()
|
||||||
|
lightWorld:setTranslation(x, y, scale)
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(x, y)
|
||||||
|
love.graphics.scale(scale)
|
||||||
|
lightWorld:draw(function()
|
||||||
|
love.graphics.setColor(255, 255, 255)
|
||||||
|
love.graphics.rectangle("fill", -x/scale, -y/scale, love.graphics.getWidth()/scale, love.graphics.getHeight()/scale)
|
||||||
|
map:draw()
|
||||||
|
end)
|
||||||
|
love.graphics.pop()
|
||||||
|
|
||||||
|
end
|
22
examples/vendor/sti/.gitattributes
vendored
Executable file
22
examples/vendor/sti/.gitattributes
vendored
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Custom for Visual Studio
|
||||||
|
*.cs diff=csharp
|
||||||
|
*.sln merge=union
|
||||||
|
*.csproj merge=union
|
||||||
|
*.vbproj merge=union
|
||||||
|
*.fsproj merge=union
|
||||||
|
*.dbproj merge=union
|
||||||
|
|
||||||
|
# Standard to msysgit
|
||||||
|
*.doc diff=astextplain
|
||||||
|
*.DOC diff=astextplain
|
||||||
|
*.docx diff=astextplain
|
||||||
|
*.DOCX diff=astextplain
|
||||||
|
*.dot diff=astextplain
|
||||||
|
*.DOT diff=astextplain
|
||||||
|
*.pdf diff=astextplain
|
||||||
|
*.PDF diff=astextplain
|
||||||
|
*.rtf diff=astextplain
|
||||||
|
*.RTF diff=astextplain
|
215
examples/vendor/sti/.gitignore
vendored
Executable file
215
examples/vendor/sti/.gitignore
vendored
Executable file
@ -0,0 +1,215 @@
|
|||||||
|
#################
|
||||||
|
## Eclipse
|
||||||
|
#################
|
||||||
|
|
||||||
|
*.pydevproject
|
||||||
|
.project
|
||||||
|
.metadata
|
||||||
|
bin/
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# CDT-specific
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# PDT-specific
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
|
||||||
|
#################
|
||||||
|
## Visual Studio
|
||||||
|
#################
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
build/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.log
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
*.pubxml
|
||||||
|
|
||||||
|
# NuGet Packages Directory
|
||||||
|
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||||
|
#packages/
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
sql/
|
||||||
|
*.Cache
|
||||||
|
ClientBin/
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
App_Data/*.mdf
|
||||||
|
App_Data/*.ldf
|
||||||
|
|
||||||
|
#############
|
||||||
|
## Windows detritus
|
||||||
|
#############
|
||||||
|
|
||||||
|
# Windows image file caches
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Mac crap
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
## Python
|
||||||
|
#############
|
||||||
|
|
||||||
|
*.py[co]
|
||||||
|
|
||||||
|
# Packages
|
||||||
|
*.egg
|
||||||
|
*.egg-info
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
eggs/
|
||||||
|
parts/
|
||||||
|
var/
|
||||||
|
sdist/
|
||||||
|
develop-eggs/
|
||||||
|
.installed.cfg
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
.coverage
|
||||||
|
.tox
|
||||||
|
|
||||||
|
#Translations
|
||||||
|
*.mo
|
||||||
|
|
||||||
|
#Mr Developer
|
||||||
|
.mr.developer.cfg
|
56
examples/vendor/sti/framework/corona.lua
vendored
Executable file
56
examples/vendor/sti/framework/corona.lua
vendored
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
local lf = love.filesystem
|
||||||
|
local lg = love.graphics
|
||||||
|
local lm = love.math
|
||||||
|
local lp = love.physics
|
||||||
|
local framework = {}
|
||||||
|
|
||||||
|
framework.version = "Corona"
|
||||||
|
|
||||||
|
function framework.load(file)
|
||||||
|
return assert(lf.load(file), "File not found: " .. file)
|
||||||
|
end
|
||||||
|
|
||||||
|
function framework.newImage(path)
|
||||||
|
local image = lg.newImage(path)
|
||||||
|
image:setFilter("nearest", "nearest")
|
||||||
|
|
||||||
|
return image
|
||||||
|
end
|
||||||
|
|
||||||
|
function framework:newCanvas(w, h)
|
||||||
|
w = w or self.getWidth()
|
||||||
|
h = h or self.getHeight()
|
||||||
|
local canvas = lg.newCanvas(w, h)
|
||||||
|
canvas:setFilter("nearest", "nearest")
|
||||||
|
|
||||||
|
return canvas
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Graphics Calls
|
||||||
|
framework.clear = lg.clear
|
||||||
|
framework.draw = lg.draw
|
||||||
|
framework.getHeight = lg.getHeight
|
||||||
|
framework.getWidth = lg.getWidth
|
||||||
|
framework.line = lg.line
|
||||||
|
framework.newSpriteBatch = lg.newSpriteBatch
|
||||||
|
framework.newQuad = lg.newQuad
|
||||||
|
framework.polygon = lg.polygon
|
||||||
|
framework.rectangle = lg.rectangle
|
||||||
|
framework.setColor = lg.setColor
|
||||||
|
framework.setCanvas = lg.setCanvas
|
||||||
|
framework.origin = lg.origin
|
||||||
|
framework.pop = lg.pop
|
||||||
|
framework.push = lg.push
|
||||||
|
|
||||||
|
-- Math Calls
|
||||||
|
framework.isConvex = lm.isConvex
|
||||||
|
framework.triangulate = lm.triangulate
|
||||||
|
|
||||||
|
-- Physics Calls
|
||||||
|
framework.getMeter = lp.getMeter
|
||||||
|
framework.newBody = lp.newBody
|
||||||
|
framework.newChainShape = lp.newChainShape
|
||||||
|
framework.newFixture = lp.newFixture
|
||||||
|
framework.newPolygonShape = lp.newPolygonShape
|
||||||
|
|
||||||
|
return framework
|
62
examples/vendor/sti/framework/love.lua
vendored
Executable file
62
examples/vendor/sti/framework/love.lua
vendored
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
local lf = love.filesystem
|
||||||
|
local lg = love.graphics
|
||||||
|
local lm = love.math
|
||||||
|
local lp = love.physics
|
||||||
|
local framework = {}
|
||||||
|
|
||||||
|
framework.version = "LOVE"
|
||||||
|
|
||||||
|
assert(lf, "The love.filesystem module is required for this library.")
|
||||||
|
assert(lg, "The love.graphics module is required for this library.")
|
||||||
|
assert(lm, "The love.math module is required for this library.")
|
||||||
|
|
||||||
|
function framework.load(file)
|
||||||
|
return assert(lf.load(file), "File not found: " .. file)
|
||||||
|
end
|
||||||
|
|
||||||
|
function framework.newImage(path)
|
||||||
|
local image = lg.newImage(path)
|
||||||
|
image:setFilter("nearest", "nearest")
|
||||||
|
|
||||||
|
return image
|
||||||
|
end
|
||||||
|
|
||||||
|
function framework:newCanvas(w, h)
|
||||||
|
w = w or self.getWidth()
|
||||||
|
h = h or self.getHeight()
|
||||||
|
local canvas = lg.newCanvas(w, h)
|
||||||
|
canvas:setFilter("nearest", "nearest")
|
||||||
|
|
||||||
|
return canvas
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Graphics Calls
|
||||||
|
framework.draw = lg.draw
|
||||||
|
framework.getCanvas = lg.getCanvas
|
||||||
|
framework.getHeight = lg.getHeight
|
||||||
|
framework.getWidth = lg.getWidth
|
||||||
|
framework.line = lg.line
|
||||||
|
framework.newSpriteBatch = lg.newSpriteBatch
|
||||||
|
framework.newQuad = lg.newQuad
|
||||||
|
framework.polygon = lg.polygon
|
||||||
|
framework.rectangle = lg.rectangle
|
||||||
|
framework.setColor = lg.setColor
|
||||||
|
framework.setCanvas = lg.setCanvas
|
||||||
|
framework.origin = lg.origin
|
||||||
|
framework.pop = lg.pop
|
||||||
|
framework.push = lg.push
|
||||||
|
|
||||||
|
-- Math Calls
|
||||||
|
framework.isConvex = lm.isConvex
|
||||||
|
framework.triangulate = lm.triangulate
|
||||||
|
|
||||||
|
-- Physics Calls
|
||||||
|
if lp then
|
||||||
|
framework.getMeter = lp.getMeter
|
||||||
|
framework.newBody = lp.newBody
|
||||||
|
framework.newChainShape = lp.newChainShape
|
||||||
|
framework.newFixture = lp.newFixture
|
||||||
|
framework.newPolygonShape = lp.newPolygonShape
|
||||||
|
end
|
||||||
|
|
||||||
|
return framework
|
56
examples/vendor/sti/framework/pure.lua
vendored
Executable file
56
examples/vendor/sti/framework/pure.lua
vendored
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
local lf = love.filesystem
|
||||||
|
local lg = love.graphics
|
||||||
|
local lm = love.math
|
||||||
|
local lp = love.physics
|
||||||
|
local framework = {}
|
||||||
|
|
||||||
|
framework.version = "Lua"
|
||||||
|
|
||||||
|
function framework.load(file)
|
||||||
|
return assert(lf.load(file), "File not found: " .. file)
|
||||||
|
end
|
||||||
|
|
||||||
|
function framework.newImage(path)
|
||||||
|
local image = lg.newImage(path)
|
||||||
|
image:setFilter("nearest", "nearest")
|
||||||
|
|
||||||
|
return image
|
||||||
|
end
|
||||||
|
|
||||||
|
function framework:newCanvas(w, h)
|
||||||
|
w = w or self.getWidth()
|
||||||
|
h = h or self.getHeight()
|
||||||
|
local canvas = lg.newCanvas(w, h)
|
||||||
|
canvas:setFilter("nearest", "nearest")
|
||||||
|
|
||||||
|
return canvas
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Graphics Calls
|
||||||
|
framework.clear = lg.clear
|
||||||
|
framework.draw = lg.draw
|
||||||
|
framework.getHeight = lg.getHeight
|
||||||
|
framework.getWidth = lg.getWidth
|
||||||
|
framework.line = lg.line
|
||||||
|
framework.newSpriteBatch = lg.newSpriteBatch
|
||||||
|
framework.newQuad = lg.newQuad
|
||||||
|
framework.polygon = lg.polygon
|
||||||
|
framework.rectangle = lg.rectangle
|
||||||
|
framework.setColor = lg.setColor
|
||||||
|
framework.setCanvas = lg.setCanvas
|
||||||
|
framework.origin = lg.origin
|
||||||
|
framework.pop = lg.pop
|
||||||
|
framework.push = lg.push
|
||||||
|
|
||||||
|
-- Math Calls
|
||||||
|
framework.isConvex = lm.isConvex
|
||||||
|
framework.triangulate = lm.triangulate
|
||||||
|
|
||||||
|
-- Physics Calls
|
||||||
|
framework.getMeter = lp.getMeter
|
||||||
|
framework.newBody = lp.newBody
|
||||||
|
framework.newChainShape = lp.newChainShape
|
||||||
|
framework.newFixture = lp.newFixture
|
||||||
|
framework.newPolygonShape = lp.newPolygonShape
|
||||||
|
|
||||||
|
return framework
|
90
examples/vendor/sti/init.lua
vendored
Executable file
90
examples/vendor/sti/init.lua
vendored
Executable file
@ -0,0 +1,90 @@
|
|||||||
|
--[[
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Simple Tiled Implementation is licensed under the MIT Open Source License.
|
||||||
|
(http://www.opensource.org/licenses/mit-license.html)
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2014 Landon Manning - LManning17@gmail.com - LandonManning.com
|
||||||
|
|
||||||
|
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 STI = {
|
||||||
|
_LICENSE = "STI is distributed under the terms of the MIT license. See LICENSE.md.",
|
||||||
|
_URL = "https://github.com/karai17/Simple-Tiled-Implementation",
|
||||||
|
_VERSION = "0.9.4",
|
||||||
|
_DESCRIPTION = "Simple Tiled Implementation is a Tiled Map Editor library designed for the *awesome* LÖVE framework."
|
||||||
|
}
|
||||||
|
|
||||||
|
local path = ... .. "." -- lol
|
||||||
|
local Map = require(path .. "map")
|
||||||
|
local framework
|
||||||
|
|
||||||
|
if love then
|
||||||
|
framework = require(path .. "framework.love")
|
||||||
|
elseif corona then -- I don't think this works
|
||||||
|
framework = require(path .. "framework.corona")
|
||||||
|
else
|
||||||
|
framework = require(path .. "framework.pure")
|
||||||
|
end
|
||||||
|
|
||||||
|
function STI.new(map)
|
||||||
|
map = map .. ".lua"
|
||||||
|
|
||||||
|
-- Get path to map
|
||||||
|
local path = map:reverse():find("[/\\]") or ""
|
||||||
|
if path ~= "" then
|
||||||
|
path = map:sub(1, 1 + (#map - path))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Load map
|
||||||
|
map = framework.load(map)
|
||||||
|
setfenv(map, {})
|
||||||
|
map = setmetatable(map(), {__index = Map})
|
||||||
|
|
||||||
|
map:init(path, framework)
|
||||||
|
|
||||||
|
return map
|
||||||
|
end
|
||||||
|
|
||||||
|
-- http://wiki.interfaceware.com/534.html
|
||||||
|
function string.split(s, d)
|
||||||
|
local t = {}
|
||||||
|
local i = 0
|
||||||
|
local f
|
||||||
|
local match = '(.-)' .. d .. '()'
|
||||||
|
|
||||||
|
if string.find(s, d) == nil then
|
||||||
|
return {s}
|
||||||
|
end
|
||||||
|
|
||||||
|
for sub, j in string.gmatch(s, match) do
|
||||||
|
i = i + 1
|
||||||
|
t[i] = sub
|
||||||
|
f = j
|
||||||
|
end
|
||||||
|
|
||||||
|
if i ~= 0 then
|
||||||
|
t[i+1] = string.sub(s, f)
|
||||||
|
end
|
||||||
|
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
return STI
|
1085
examples/vendor/sti/map.lua
vendored
Executable file
1085
examples/vendor/sti/map.lua
vendored
Executable file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user