-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
100 changed files
with
35,989 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <[email protected]> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
actionblock = class("actionblock") | ||
|
||
function actionblock:init(x, y) | ||
self.cox = x | ||
self.coy = y | ||
self.x = x-1 | ||
self.y = y-1 | ||
self.speedx = 0 | ||
self.speedy = 0 | ||
self.width = 1 | ||
self.height = 1 | ||
self.active = true | ||
self.static = true | ||
self.category = 2 | ||
self.mask = {true} | ||
|
||
self.state = "off" | ||
self.outtable = {} | ||
self.timer = blockbouncetime | ||
end | ||
|
||
function actionblock:addoutput(a, t) | ||
table.insert(self.outtable, {a, t}) | ||
end | ||
|
||
function actionblock:update(dt) | ||
if self.timer < blockbouncetime then | ||
self.timer = math.min(blockbouncetime, self.timer + dt) | ||
end | ||
end | ||
|
||
function actionblock:draw() | ||
local bounceyoffset = 0 | ||
if self.timer < blockbouncetime then | ||
if self.timer < blockbouncetime/2 then | ||
bounceyoffset = self.timer / (blockbouncetime/2) * blockbounceheight | ||
else | ||
bounceyoffset = (2 - self.timer / (blockbouncetime/2)) * blockbounceheight | ||
end | ||
end | ||
|
||
local q = 1 | ||
if self.state == "on" then | ||
q = 2 | ||
end | ||
love.graphics.drawq(actionblockimg, wallindicatorquad[q], math.floor((self.x-xscroll)*16*scale), math.floor((self.y-.5-yscroll-bounceyoffset)*16*scale), 0, scale, scale) | ||
end | ||
|
||
function actionblock:floorcollide(a, b, c, d) | ||
if self.state == "off" then | ||
self.state = "on" | ||
else | ||
self.state = "off" | ||
end | ||
if self.timer == blockbouncetime then | ||
self.timer = 0 | ||
end | ||
|
||
self:out(self.state) | ||
end | ||
|
||
function actionblock:out(t) | ||
for i = 1, #self.outtable do | ||
if self.outtable[i][1].input then | ||
self.outtable[i][1]:input(t, self.outtable[i][2]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
andgate = class("andgate") | ||
|
||
function andgate:init(x, y, r) | ||
self.x = x | ||
self.y = y | ||
self.cox = x | ||
self.coy = y | ||
self.visible = false | ||
self.r = {unpack(r)} | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
|
||
--VISIBLE | ||
if #self.r > 0 and self.r[1] ~= "link" then | ||
self.visible = (self.r[1] == "true") | ||
table.remove(self.r, 1) | ||
end | ||
|
||
self.outtable = {} | ||
self.inputstate = {} | ||
self.outputstate = "off" | ||
end | ||
|
||
function andgate:link() | ||
while #self.r > 3 do | ||
for j, w in pairs(outputs) do | ||
for i, v in pairs(objects[w]) do | ||
if tonumber(self.r[3]) == v.cox and tonumber(self.r[4]) == v.coy then | ||
v:addoutput(self, self.r[2]) | ||
self.inputstate[tonumber(self.r[2])] = "off" | ||
end | ||
end | ||
end | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
end | ||
end | ||
|
||
function andgate:addoutput(a, t) | ||
table.insert(self.outtable, {a, t}) | ||
end | ||
|
||
function andgate:update(dt) | ||
if self.initial then | ||
self.initial = false | ||
end | ||
end | ||
|
||
function andgate:draw() | ||
if self.visible then | ||
love.graphics.setColor(255, 255, 255) | ||
love.graphics.draw(andgateimg, math.floor((self.x-1-xscroll)*16*scale), ((self.y-yscroll-1)*16-8)*scale, 0, scale, scale) | ||
end | ||
end | ||
|
||
function andgate:out(t) | ||
for i = 1, #self.outtable do | ||
if self.outtable[i][1].input then | ||
self.outtable[i][1]:input(t, self.outtable[i][2]) | ||
end | ||
end | ||
end | ||
|
||
function andgate:input(t, input) | ||
if tonumber(input) then | ||
if t == "toggle" then | ||
if self.inputstate[tonumber(input)] == "on" then | ||
self.inputstate[tonumber(input)] = "off" | ||
else | ||
self.inputstate[tonumber(input)] = "on" | ||
end | ||
else | ||
self.inputstate[tonumber(input)] = t | ||
end | ||
|
||
local pass = "on" | ||
for i, v in ipairs(self.inputstate) do | ||
if v ~= "on" then | ||
pass = "off" | ||
end | ||
end | ||
|
||
if self.outputstate ~= pass then | ||
self:out(pass) | ||
self.outputstate = pass | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
animatedquad = class("animatedquad") | ||
|
||
function animatedquad:init(imgpath, s, number) | ||
self.number = number | ||
self.image = love.graphics.newImage(imgpath) | ||
self.imagedata = love.image.newImageData(imgpath) | ||
self.quadlist = {} | ||
for x = 1, math.floor(self.image:getWidth()/17) do | ||
table.insert(self.quadlist, love.graphics.newQuad((x-1)*17, 0, 16, 16, self.image:getWidth(), self.image:getHeight())) | ||
end | ||
self.quadi = 1 | ||
self.properties = {} | ||
for x = 1, #self.quadlist do | ||
self.properties[x] = getquadprops(self.imagedata, x, 1) | ||
end | ||
self.props = self.properties[self.quadi] | ||
self.delays = {} | ||
self.timer = 0 | ||
self.spikes = {} | ||
|
||
self.delays = s:split(",") | ||
|
||
if self.delays[1] == "triggered" then | ||
self.triggered = true | ||
table.remove(self.delays, 1) | ||
end | ||
|
||
for i = 1, #self.delays do | ||
self.delays[i] = tonumber(self.delays[i]) | ||
end | ||
|
||
local delaycount = #self.delays | ||
for j = #self.delays+1, #self.quadlist do | ||
self.delays[j] = self.delays[math.mod(j-1, delaycount)+1] | ||
end | ||
|
||
end | ||
|
||
function animatedquad:updateproperties() | ||
local oldcol = self.collision | ||
local oldportalable = self.portalable | ||
|
||
self.props = self.properties[self.quadi] | ||
|
||
if oldcol ~= self.props.collision then | ||
for x = 1, mapwidth do | ||
for y = 1, mapheight do | ||
if map[x][y][1] == self.number then | ||
if self.props.collision then | ||
objects["tile"][x .. "-" .. y] = tile:new(x-1, y-1) | ||
else | ||
objects["tile"][x .. "-" .. y] = nil | ||
checkportalremove(x, y) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
if oldportalable ~= self.props.portalable then | ||
for x = 1, mapwidth do | ||
for y = 1, mapheight do | ||
if map[x][y][1] == self.number then | ||
if oldportalable ~= self.portalable then | ||
if not self.props.portalable then | ||
checkportalremove(x, y) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
function animatedquad:update(dt) | ||
self.timer = self.timer + dt | ||
while self.timer > self.delays[self.quadi] do | ||
self.timer = self.timer - self.delays[self.quadi] | ||
self.quadi = self.quadi + 1 | ||
if self.quadi > #self.quadlist then | ||
self.quadi = 1 | ||
end | ||
if objects and not self.triggered then | ||
self:updateproperties() | ||
end | ||
end | ||
end | ||
|
||
function animatedquad:quad(x, y) | ||
if self.triggered and x and y and animatedtimers[x][y] then | ||
return self.quadlist[animatedtimers[x][y]:geti()] | ||
else | ||
return self.quadlist[self.quadi] | ||
end | ||
end | ||
|
||
function animatedquad:getproperty(s, x, y) | ||
if self.triggered and x and y and animatedtimers[x] and animatedtimers[x][y] then | ||
if self.properties[animatedtimers[x][y]:geti()] then | ||
return self.properties[animatedtimers[x][y]:geti()][s] | ||
end | ||
end | ||
return self.props[s] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
animatedtiletrigger = class("animatedtiletrigger") | ||
|
||
function animatedtiletrigger:init(x, y, r) | ||
self.x = x | ||
self.y = y | ||
self.r = {unpack(r)} | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
|
||
self.visible = true | ||
|
||
--VISIBLE | ||
if #self.r > 0 and self.r[1] ~= "link" then | ||
self.visible = (self.r[1] == "true") | ||
table.remove( self.r, 1) | ||
end | ||
|
||
--REGION | ||
if #self.r > 0 then | ||
local s = self.r[1]:split(":") | ||
self.regionX, self.regionY, self.regionwidth, self.regionheight = s[2], s[3], tonumber(s[4]), tonumber(s[5]) | ||
if string.sub(self.regionX, 1, 1) == "m" then | ||
self.regionX = -tonumber(string.sub(self.regionX, 2)) | ||
end | ||
if string.sub(self.regionY, 1, 1) == "m" then | ||
self.regionY = -tonumber(string.sub(self.regionY, 2)) | ||
end | ||
|
||
self.regionX = tonumber(self.regionX) + self.x - 1 | ||
self.regionY = tonumber(self.regionY) + self.y - 1 | ||
table.remove(self.r, 1) | ||
end | ||
end | ||
|
||
function animatedtiletrigger:link() | ||
while #self.r > 3 do | ||
for j, w in pairs(outputs) do | ||
for i, v in pairs(objects[w]) do | ||
if tonumber(self.r[3]) == v.cox and tonumber(self.r[4]) == v.coy then | ||
v:addoutput(self, self.r[2]) | ||
end | ||
end | ||
end | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
table.remove(self.r, 1) | ||
end | ||
end | ||
|
||
function animatedtiletrigger:update() | ||
|
||
end | ||
|
||
function animatedtiletrigger:draw() | ||
if self.visible then | ||
love.graphics.draw(animatedtiletriggerimg, math.floor((self.x-1-xscroll)*16*scale), ((self.y-yscroll-1)*16-8)*scale, 0, scale, scale) | ||
end | ||
end | ||
|
||
function animatedtiletrigger:input(t, input) | ||
for x = self.regionX+1, self.regionX + self.regionwidth do | ||
for y = self.regionY+1, self.regionY + self.regionheight do | ||
if animatedtimers[x] and animatedtimers[x][y] then | ||
animatedtimers[x][y]:input(t) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.