Skip to content

Commit

Permalink
More stuffs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleP committed Jan 7, 2016
1 parent 79a9ec7 commit 6e18c12
Show file tree
Hide file tree
Showing 23 changed files with 2,641 additions and 325 deletions.
11 changes: 3 additions & 8 deletions classes/player.lua
Expand Up @@ -256,10 +256,6 @@ function player:respawn()
end

function player:enterObject(entity, name, fade)
if self.speedy ~= 0 then
return false
end

self.doUpdate = false
if fade == nil then
fade = true
Expand Down Expand Up @@ -424,7 +420,6 @@ function player:useItem()
local ret = checkrectangle(self.x + add, self.y, self.item.width, self.item.height, {"exclude", self.item})

if #ret > 0 then
print("Can't place")
table.insert(objects["box"], newBoxGhost(self.x + add, self.y))
return
else
Expand Down Expand Up @@ -457,7 +452,7 @@ function player:setScreen(screen)
end

function player:offscreenCheck()
if self.y > gameFunctions.getHeight() then
if self.y > gameFunctions.getHeight() + mapScroll[self.screen][2] then
self:die()
end
end
Expand Down Expand Up @@ -487,7 +482,7 @@ end
function death:update(dt)
self.rotation = self.rotation + 4 * dt

if self.y > gameFunctions.getHeight() then
if self.y > gameFunctions.getHeight() + mapScroll[self.screen][2] then
local temp = player:new(_PLAYERSPAWNX, _PLAYERSPAWNY)
temp:respawn()
table.insert(objects["player"], temp)
Expand Down Expand Up @@ -534,7 +529,7 @@ end
function hat:update(dt)
self.rotation = self.rotation + 4 * dt

if self.y > gameFunctions.getHeight() then
if self.y > gameFunctions.getHeight() + mapScroll[self.screen][2] then
self.remove = true
end
end
Expand Down
6 changes: 2 additions & 4 deletions classes/sign.lua
Expand Up @@ -133,12 +133,12 @@ function dialog:scrollText()
end

if not self.doScroll then
scrollSound:play()
self.doScroll = true
end
end

function dialog:draw()
pushPop(self, true)
love.graphics.setScreen(self.screen)

if self.activated then
Expand All @@ -154,10 +154,8 @@ function dialog:draw()

love.graphics.print(self.drawText, self.x + 4 + off, self.y + 3 + (self.height / 2) - signFont:getHeight() / 2)

if #self.drawText == #self.text and not self.stop then
if #self.drawText == #self.text and not self.doScroll then
love.graphics.draw(scrollArrow, self.x + off + love.graphics.getWidth() - 18, self.y + (self.height - 4) + math.sin(love.timer.getTime() * 8))
end
end

pushPop(self)
end
2 changes: 1 addition & 1 deletion classes/teleporter.lua
Expand Up @@ -119,7 +119,7 @@ end

function teleporter:draw()
pushPop(self, true)
love.graphics.setScreen(self, true)
love.graphics.setScreen(self.screen)

love.graphics.draw(teleporterImage, teleporterQuads[self.quadi], self.x, self.y)

Expand Down
Binary file added graphics/game/background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphics/game/background2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed graphics/game/undergroundbg.png
Binary file not shown.
3 changes: 1 addition & 2 deletions libraries/3ds.lua
Expand Up @@ -2,14 +2,13 @@ if love.system.getOS() ~= "3ds" then
_SCREEN = "top"

function love.graphics.setScreen(screen)
assert(type(screen) == "string", "String expected, got " .. type(screen))
_SCREEN = screen

if screen == "top" then
love.graphics.setScissor(0, -(mapScrollY * scale), 400 * scale, 240 * scale)
love.graphics.print("FPS: " .. love.timer.getFPS(), love.graphics.getWidth() - signFont:getWidth("FPS: " .. love.timer.getFPS()) - 2, 6 * scale)
elseif screen == "bottom" then
love.graphics.setScissor(40 * scale, (240 * scale) - (mapScrollY * scale), 320 * scale, 240 * scale)
love.graphics.print("FPS: " .. love.timer.getFPS(), love.graphics.getWidth() - signFont:getWidth("FPS: " .. love.timer.getFPS()) - 2, 6 * scale)
end
end

Expand Down
88 changes: 33 additions & 55 deletions libraries/physics.lua
Expand Up @@ -46,15 +46,11 @@ end
function checkPassive(objTable, obj2Table, objData, objName, obj2Name, dt)
for _, obj2Data in pairs(obj2Table) do
if objData.screen == obj2Data.screen then
passiveCollide(objData, objName, obj2Name, obj2Data, dt)
end
end
end
function passiveCollide(objData, objName, obj2Name, obj2Data, dt)
if aabb(objData.x, objData.y + objData.speedy * dt, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) or aabb(objData.x + objData.speedx * dt, objData.y, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then --was vertical
if objData.passiveCollide then
objData:passiveCollide(obj2Name, obj2Data)
if aabb(objData.x, objData.y + objData.speedy * dt, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) or aabb(objData.x + objData.speedx * dt, objData.y, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then --was vertical
if objData.passiveCollide then
objData:passiveCollide(obj2Name, obj2Data)
end
end
end
end
end
Expand All @@ -63,58 +59,39 @@ function checkCollision(objTable, obj2Table, objData, objName, obj2Name, dt)
local hor, ver = false, false
for _, obj2Data in pairs(obj2Table) do
if obj2Data.screen == objData.screen then
checkPhysics(obj2Data, objTable, objData, objName, obj2Name, obj2Table, dt)
end
end
return hor, ver
end
if objData.screen == obj2Data.screen then
if objData ~= obj2Data then
if not obj2Data.passive then
function checkPhysics(obj2Data, objTable, objData, objName, obj2Name, obj2Table, dt)
if objData ~= obj2Data then
if not obj2Data.passive then
if aabb(objData.x + objData.speedx * dt, objData.y + objData.speedy * dt, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then
if aabb(objData.x + objData.speedx * dt, objData.y + objData.speedy * dt, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then
if aabb(objData.x, objData.y + objData.speedy * dt, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then --was vertical
if verticalCollide(objName, objData, obj2Name, obj2Data) then
ver = true
end
elseif aabb(objData.x + objData.speedx * dt, objData.y, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then
if horizontalCollide(objName, objData, obj2Name, obj2Data) then
hor = true
end
end
if aabb(objData.x, objData.y + objData.speedy * dt, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then --was vertical
if verticalCollide(objName, objData, obj2Name, obj2Data) then
ver = true
end
elseif aabb(objData.x + objData.speedx * dt, objData.y, objData.width, objData.height, obj2Data.x, obj2Data.y, obj2Data.width, obj2Data.height) then
if horizontalCollide(objName, objData, obj2Name, obj2Data) then
hor = true
end
else
--Diagnal shit
--[[local g = 15 * 16 * dt
if objData.gravity then
g = objData.gravity
end
if math.abs(objData.speedy - g) < math.abs(objData.speedx) then
if verticalCollide(objName, objData, obj2Name, obj2Data) then
ver = true
end
else
if horizontalCollide(objName, objData, obj2Name, obj2Data) then
hor = true
end
end]]
end
else
checkPassive(objTable, obj2Table, objData, objName, obj2Name, dt)
end
end

else
checkPassive(objTable, obj2Table, objData, objName, obj2Name, dt)
end
end
return hor, ver
end
function checkrectangle(x, y, width, height, check, callback)
local ret = {}
local checkObjects = "list"

local exclude
if type(check) == "table" and check[1] == "exclude" then
checkObjects = "all"
exclude = check[2]
Expand All @@ -136,21 +113,22 @@ function checkrectangle(x, y, width, height, check, callback)
local skip = false
if exclude then
if t.x == exclude.x and t.y == exclude.y then
print("Skip", t, t.x)
skip = true
end
if t.screen ~= exclude.screen then
skipe = true
skip = true
end
end
if not skip then
if callback then
if t.screen ~= callback.screen then
return ret
end
if callback then
if t.screen ~= callback.screen then
skip = true
end

end
if not skip then
if t.active then
if aabb(x, y, width, height, t.x, t.y, t.width, t.height) then
table.insert(ret, {k, t})
Expand Down
20 changes: 20 additions & 0 deletions license.txt
@@ -0,0 +1,20 @@
License Details:

http://creativecommons.org/licenses/by-nc-sa/4.0/

You are free to:

Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material

The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

NonCommercial — You may not use the material for commercial purposes.

ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
7 changes: 7 additions & 0 deletions licenses/ctrulib-LICENSE
@@ -0,0 +1,7 @@
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
This notice may not be removed or altered from any source distribution.

0 comments on commit 6e18c12

Please sign in to comment.