-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
TurtleP
committed
Jan 7, 2016
1 parent
e685e0c
commit 79a9ec7
Showing
61 changed files
with
5,543 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 |
---|---|---|
|
@@ -45,3 +45,4 @@ $RECYCLE.BIN/ | |
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
*.love |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,98 @@ | ||
box = class("box") | ||
|
||
function box:init(x, y, link, screen) | ||
self.x = x | ||
self.y = y | ||
|
||
self.width = 16 | ||
self.height = 16 | ||
|
||
self.active = true | ||
|
||
self.speedx = 0 | ||
self.speedy = 0 | ||
|
||
self.gravity = 300 | ||
self.oldGravity = self.gravity | ||
|
||
self.mask = | ||
{ | ||
["tile"] = true, | ||
["spikes"] = true, | ||
["box"] = true, | ||
["pipe"] = true, | ||
["fan"] = true | ||
} | ||
|
||
self.passive = false | ||
self.friction = 6 | ||
|
||
self.useRectangle = gameAddUseRectangle(self.x, self.y, self.width, self.height, self) | ||
|
||
self.screen = screen | ||
end | ||
|
||
function box:use(player) | ||
self.parent = player | ||
|
||
local active = true | ||
if player then | ||
active = false | ||
end | ||
self.active = active | ||
self.passive = not active | ||
|
||
return self | ||
end | ||
|
||
function box:update(dt) | ||
if self.parent then | ||
self.x = self.parent.x | ||
self.y = self.parent.y - self.height / 1.4 | ||
return | ||
end | ||
|
||
self.useRectangle.x = self.x | ||
self.useRectangle.y = self.y | ||
end | ||
|
||
function box:draw() | ||
pushPop(self, true) | ||
|
||
love.graphics.setScreen(self.screen) | ||
love.graphics.draw(objectSet, objectQuads[4], self.x, self.y) | ||
|
||
pushPop(self) | ||
end | ||
|
||
--BEWARE | ||
function newBoxGhost(x, y) | ||
local box = {} | ||
|
||
box.x = x | ||
box.y = y | ||
|
||
box.width = 16 | ||
box.height = 16 | ||
|
||
box.mask = {} | ||
box.active = false | ||
box.passive = true | ||
|
||
box.fade = 1 | ||
|
||
function box:update(dt) | ||
self.fade = math.max(self.fade - 0.6 * dt, 0) | ||
if self.fade == 0 then | ||
self.remove = true | ||
end | ||
end | ||
|
||
function box:draw() | ||
love.graphics.setColor(255, 0, 0, 255 * self.fade) | ||
love.graphics.draw(objectSet, objectQuads[4], self.x, self.y) | ||
love.graphics.setColor(255, 255, 255, 255) | ||
end | ||
|
||
return box | ||
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,80 @@ | ||
button = class("button") | ||
|
||
function button:init(x, y, r, screen) | ||
self.x = x | ||
self.y = y | ||
self.link = r.link | ||
|
||
self.width = 3 | ||
self.height = 8 | ||
|
||
self.outtable = {} | ||
|
||
local directions = | ||
{ | ||
["right"] = 1, | ||
["left"] = 2 | ||
} | ||
|
||
self.quadi = directions[r.direction] or 1 | ||
self.singleUse = bool(r.singleUse) or false | ||
|
||
if r.direction == "left" then | ||
self.x = x + 13 | ||
end | ||
|
||
|
||
|
||
self.pressi = 1 | ||
self.timer = 0 | ||
|
||
self.useRectangle = gameAddUseRectangle(self.x, self.y, self.width, self.height, self) | ||
|
||
self.screen = screen | ||
end | ||
|
||
function button:addOut(obj) | ||
table.insert(self.outtable, obj) | ||
end | ||
|
||
function button:update(dt) | ||
if not self.singleUse then | ||
if self.used then | ||
self.timer = self.timer + dt | ||
if self.timer > 0.5 then | ||
self.timer = 0 | ||
self.used = false | ||
end | ||
end | ||
end | ||
|
||
if self.used then | ||
self.pressi = 2 | ||
else | ||
self.pressi = 1 | ||
end | ||
end | ||
|
||
function button:use() | ||
if not self.used then | ||
buttonSound:play() | ||
self.used = true | ||
end | ||
|
||
for j = 1, #self.outtable do | ||
local out = "toggle" | ||
if self.singleUse then | ||
out = "on" | ||
end | ||
self.outtable[j]:input(out) | ||
end | ||
end | ||
|
||
function button:draw() | ||
pushPop(self, true) | ||
|
||
love.graphics.setScreen(self.screen) | ||
love.graphics.draw(buttonImage, buttonQuads[self.pressi][self.quadi], self.x, self.y) | ||
|
||
pushPop(self) | ||
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,158 @@ | ||
door = class("door") | ||
|
||
function door:init(x, y, r, screen) | ||
self.x = x | ||
self.y = y | ||
|
||
self.width = 16 | ||
self.height = 32 | ||
|
||
self.quadi = 1 | ||
|
||
self.timer = 0 | ||
|
||
self.isStart = bool(r.start) | ||
|
||
self.isLocked = bool(r.locked) | ||
|
||
self.link = r.link | ||
|
||
self.open = false | ||
self.closeAnimation = false | ||
|
||
self.player = nil | ||
|
||
self.unlocked = false | ||
|
||
if self.isLocked then | ||
self.active = true | ||
self.static = true | ||
self.passive = false | ||
else | ||
self.passive = true | ||
end | ||
|
||
self.playSound = false | ||
|
||
self.screen = screen | ||
end | ||
|
||
function door:use(player) | ||
if self.isStart then | ||
return | ||
end | ||
self.open = true | ||
self.player = player | ||
end | ||
|
||
function door:addLink() | ||
for k, v in pairs(outputs) do | ||
for j, w in pairs(objects[v]) do | ||
if w.addOut then | ||
if w.link == self.link then | ||
w:addOut(self) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
function door:update(dt) | ||
if not self.isLocked then | ||
self:normalDoor(dt) | ||
else | ||
if self.unlocked then | ||
self:unlockDoor(dt) | ||
else | ||
self:lockDoor(dt) | ||
end | ||
end | ||
end | ||
|
||
function door:unlock(player) | ||
if self.link then | ||
return | ||
end | ||
|
||
player.keys = player.keys - 1 | ||
self.unlocked = true | ||
end | ||
|
||
function door:input(t) | ||
if t == "on" then | ||
self.unlocked = true | ||
elseif t == "off" then | ||
print("!") | ||
self.unlocked = false | ||
elseif t == "toggle" then | ||
self.unlocked = not self.unlocked | ||
end | ||
end | ||
|
||
function door:normalDoor(dt) | ||
if self.open then | ||
if self.quadi < 3 then | ||
self.timer = self.timer + 16 * dt | ||
self.quadi = math.floor(self.timer % 3) + 1 | ||
else | ||
if self.player:enterObject(self, "door") then | ||
self.open = false | ||
self.closeAnimation = true | ||
end | ||
end | ||
else | ||
if self.closeAnimation then | ||
if self.quadi > 1 then | ||
self.timer = self.timer - 12 * dt | ||
self.quadi = math.floor(self.timer % 3) + 1 | ||
else | ||
self.closeAnimation = false | ||
self.timer = 0 | ||
end | ||
end | ||
end | ||
end | ||
|
||
function door:unlockDoor(dt) | ||
if not self.playSound then | ||
unlockSound:play() | ||
self.playSound = true | ||
end | ||
|
||
if self.quadi < 3 then | ||
self.timer = self.timer + 16 * dt | ||
self.quadi = math.floor(self.timer % 3) + 1 | ||
else | ||
self.passive = true | ||
end | ||
end | ||
|
||
function door:lockDoor(dt) | ||
if self.quadi > 1 then | ||
self.timer = self.timer - 16 * dt | ||
self.quadi = math.floor(self.timer % 3) + 1 | ||
else | ||
self.passive = false | ||
self.playSound = false | ||
end | ||
end | ||
|
||
function door:draw() | ||
pushPop(self, true) | ||
|
||
love.graphics.setScreen(self.screen) | ||
|
||
if self.isStart or (self.isLocked and self.unlocked) then | ||
love.graphics.setColor(127, 127, 127) | ||
end | ||
|
||
local image = 1 | ||
if self.isLocked then | ||
image = 2 | ||
end | ||
|
||
love.graphics.draw(doorImage, doorQuads[self.quadi][image], self.x, self.y) | ||
love.graphics.setColor(255, 255, 255) | ||
|
||
pushPop(self) | ||
end |
Oops, something went wrong.