Skip to content

Commit

Permalink
Update submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinW1998 committed Nov 14, 2015
1 parent 0d46e71 commit 97fee28
Show file tree
Hide file tree
Showing 6 changed files with 506 additions and 44 deletions.
107 changes: 107 additions & 0 deletions LuaScriptsLibExt/apc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
--Advanced Player Collisions API (WIP - Not reccomended for personal use)
--Created by Sambo
--Requires Colliders and Vectors libraries

--API values
local apc = {}
colliders = loadSharedAPI("colliders")
local r = 0
local ropeCheck = 0
local ropeBox = {}

function apc.onInitAPI()
registerEvent(apc, "onLoop")
end

function apc.onLoop()
--Player 1
local p1hitbox = colliders.getAABB(player) --Load P1's hitbox
--Create a 8 px thick collision sensor on each side of the player
p1colliders = {
top = colliders.Box(player.x, player.y - 8, p1hitbox.width, 8),
left = colliders.Box(player.x - 8, player.y, 8, p1hitbox.height),
right = colliders.Box(player.x + p1hitbox.width, player.y, 8, p1hitbox.height),
bottom = colliders.Box(player.x, player.y + p1hitbox.height, p1hitbox.width, 8),
}
if apc.debug then
p1colliders["top"]:Draw(0xff000099)
p1colliders["left"]:Draw(0x00ff0099)
p1colliders["right"]:Draw(0x0000ff99)
p1colliders["bottom"]:Draw(0xffff0099)
end
if ropeBlocks then
for k,v in pairs(ropeBlocks) do
for a,b in pairs(Block.get(v)) do
if (b:collidesWith(player) == 1) and (player.downKeyPressing) then
player.y = player.y + 2 --Move the player down 2 pixels. This effectively causes the player to "fall through" a cloud block, but is too small to glitch solid blocks. :)
end
end
end
end
if bouncySpikes then
for k,v in pairs(bouncySpikes) do
for a,b in pairs(Block.get(v)) do
if (b:collidesWith(player) == 1) then
if player:mem(0x50, FIELD_WORD) == -1 then
colliders.bounceResponse(player)
else
player:harm()
end
end
end
end
end
--Player 2 (if there is one)
if player2 then
local p2hitbox = colliders.getAABB(player2) --Load P2's hitbox
--Create a 8 px thick collision sensor on each side of player2
p2colliders = {
top = colliders.Box(player2.x, player2.y - 8, p2hitbox.width, 8),
left = colliders.Box(player2.x - 8, player2.y, 8, p2hitbox.height),
right = colliders.Box(player2.x + p2hitbox.width, player2.y, 8, p2hitbox.height),
bottom = colliders.Box(player2.x, player2.y + p2hitbox.height, p2hitbox.width, 8),
}
if apc.debug then
p2colliders["top"]:Draw(0xff000099)
p2colliders["left"]:Draw(0x00ff0099)
p2colliders["right"]:Draw(0x0000ff99)
p2colliders["bottom"]:Draw(0xffff0099)
end
if ropeBlocks then
for k,v in pairs(ropeBlocks) do
for a,b in pairs(Block.get(v)) do
if (b:collidesWith(player2) == 1) and (player2.downKeyPressing) then
player2.y = player2.y + 2 --Move the player2 down 2 pixels. This effectively causes the player2 to "fall through" a cloud block, but is too small to glitch solid blocks. :)
end
end
end
end
if bouncySpikes then
for k,v in pairs(bouncySpikes) do
for a,b in pairs(Block.get(v)) do
if (b:collidesWith(player2) == 1) then
if player2:mem(0x50, FIELD_WORD) == -1 then
colliders.bounceResponse(player2)
else
player2:harm()
end
end
end
end
end
end
end

--This function makes a block behave like a "rope-type" block. If you play SMW hacks, you may have seen these. A "rope-type" block behaves like a cloud block, but you can go through it if you press DOWN. This only works if used on a cloud-type block.
function apc.rope(ids) --Argument must be a table of integers between 1 and 638
ropeBlocks = ids
end

--This function makes a block act like an upward pointing spike block, but spinjumping on it will bounce
--the player instead of harming him. The block must NOT already harm the player, or it won't work.
--It is not reccomended to place this block on a moving layer, as it may not work correctly.
function apc.bouncySpike(ids) --Argument must be a table of integers between 1 and 638
bouncySpikes = ids
end

return apc
23 changes: 12 additions & 11 deletions LuaScriptsLibExt/hudoftime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
--------------------------------Created by Hoeloe - 2015--------------------------------
----------------------------Open-Source Zelda HUD Framework-----------------------------
---------------------------------For Super Mario Bros X---------------------------------
----------------------------------------v1.0.1------------------------------------------
----------------------------------------v1.0.2------------------------------------------

local zelda = {}

Expand All @@ -31,7 +31,7 @@ zelda.TRIFORCE = Graphics.loadImage(getSMBXPath().."\\LuaScriptsLib\\hudoftime\\
zelda.FAIRY = Graphics.loadImage(getSMBXPath().."\\LuaScriptsLib\\hudoftime\\lives.png");

zelda.hearts = 0;
zelda.maxhearts = 3;
zelda.maxhearts = 6;

zelda.magic = 1;

Expand Down Expand Up @@ -68,9 +68,6 @@ zelda.auto_navi = true;
--Automatically enables and disables the HUD based on whether the player is Link.
zelda.auto_enable = true;

--Keep powerups when hurt and have more than one heart.
zelda.keep_powerups = true;

--HUD show flags.
zelda.show_hearts = true;
zelda.show_magic = true;
Expand Down Expand Up @@ -171,11 +168,7 @@ local function UpdateHearts()
end

if (player.powerup == PLAYER_SMALL) and (zelda.hearts >= 2) then
if(zelda.keep_powerups) then
player.powerup = powercache;
else
player.powerup = PLAYER_BIG;
end
player.powerup = powercache;
end
end
end
Expand Down Expand Up @@ -314,7 +307,15 @@ local function DrawMagic(y)
pts[8] = 16+158*zelda.magic; pts[9] = y;
pts[10] = 16+158*zelda.magic; pts[11] = y+16;

Graphics.glDrawTriangles(pts, {0,0,0,1,1,0,1,0,0,1,1,1}, 6);
local tx = {};
tx[0] = 0; tx[1] = 0;
tx[2] = 1; tx[3] = 0;
tx[4] = 0; tx[5] = 1;
tx[6] = 0; tx[7] = 1;
tx[8] = 1; tx[9] = 0;
tx[10] = 1; tx[11] = 1;

Graphics.glDrawTriangles(pts, tx, 6);
Graphics.glSetTextureRGBA(nil, 0xFFFFFFFF);
end

Expand Down
179 changes: 179 additions & 0 deletions LuaScriptsLibExt/inputs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
--***************************************************************************************
-- *
-- inputs.lua *
-- v1.1 *
-- *
--***************************************************************************************


--[[
Vars:
inputs.locked[keystr] -- if true, SMBX does not process this input, but the state
is still recorded by this library.
inputs.state[keystr] -- the current state of that key (read-only)
keystrings are same as the respective fields, all lowercase
(I.E. player.leftKeyPressing --> "left", player.dropItemKeyPressing --> "dropItem")
state constants are inputs.UP
inputs.PRESS
inputs.HOLD
inputs.RELEASE
--]]



local inputs = {} --Package table

function inputs.onInitAPI()
registerEvent(inputs, "onLoop", "onLoop", true)
registerEvent(inputs, "onInputUpdate", "onInputUpdate", true)
end



--***********************************************************************************
-- *
-- State constants *
-- *
--***********************************************************************************

do
inputs.UP = 0
inputs.PRESS = 1
inputs.HOLD = 2
inputs.RELEASE = 3
end



--***********************************************************************************
-- *
-- State table *
-- *
--***********************************************************************************

do
inputs.state = {}
inputs.state["up"] = inputs.UP
inputs.state["down"] = inputs.UP
inputs.state["left"] = inputs.UP
inputs.state["right"] = inputs.UP
inputs.state["jump"] = inputs.UP
inputs.state["altjump"] = inputs.UP
inputs.state["run"] = inputs.UP
inputs.state["altrun"] = inputs.UP
inputs.state["dropitem"] = inputs.UP
inputs.state["pause"] = inputs.UP
end



--***********************************************************************************
-- *
-- Lock table *
-- *
--***********************************************************************************

do
inputs.locked = {}
inputs.locked["up"] = false
inputs.locked["down"] = false
inputs.locked["left"] = false
inputs.locked["right"] = false
inputs.locked["jump"] = false
inputs.locked["altjump"] = false
inputs.locked["run"] = false
inputs.locked["altrun"] = false
inputs.locked["dropitem"] = false
inputs.locked["pause"] = false
end


inputs.key = {}


inputs.debug = false


--***********************************************************************************
-- *
-- Update input *
-- *
--***********************************************************************************


function inputs.onLoop ()
i = 0

for k,v in pairs(inputs.state) do

-- Debug
if inputs.debug == true then
local debugStr = tostring(k)..": "..tostring(inputs.state[k])

if inputs.locked[k] == true then
debugStr = debugStr.." (L)"
end

Text.print (debugStr, 20, 80 + 20*i)
end
i = i+1
end
end



function inputs.onInputUpdate ()
inputs.key["up"] = player.upKeyPressing
inputs.key["down"] = player.downKeyPressing
inputs.key["left"] = player.leftKeyPressing
inputs.key["right"] = player.rightKeyPressing
inputs.key["jump"] = player.jumpKeyPressing
inputs.key["altjump"] = player.altJumpKeyPressing
inputs.key["run"] = player.runKeyPressing
inputs.key["altrun"] = player.altRunKeyPressing
inputs.key["dropitem"] = player.dropItemKeyPressing
inputs.key["pause"] = player.pauseKeyPressing


-- STORE INPUT STATE FOR EACH KEY
local i = 0

for k,v in pairs(inputs.state) do
if inputs.state[k] == inputs.UP then
if inputs.key[k] == true then
inputs.state[k] = inputs.PRESS
end

elseif inputs.state[k] == inputs.PRESS then
inputs.state[k] = inputs.HOLD

elseif inputs.state[k] == inputs.HOLD then
if inputs.key[k] == false then
inputs.state[k] = inputs.RELEASE
end

elseif inputs.state[k] == inputs.RELEASE then
inputs.state[k] = inputs.UP

end
end


-- Disable locked keys
if inputs.locked["up"] == true then player.upKeyPressing = false; end
if inputs.locked["down"] == true then player.downKeyPressing = false; end
if inputs.locked["left"] == true then player.leftKeyPressing = false; end
if inputs.locked["right"] == true then player.rightKeyPressing = false; end
if inputs.locked["jump"] == true then player.jumpKeyPressing = false; end
if inputs.locked["altjump"] == true then player.altJumpKeyPressing = false; end
if inputs.locked["run"] == true then player.runKeyPressing = false; end
if inputs.locked["altrun"] == true then player.altRunKeyPressing = false; end
if inputs.locked["dropitem"] == true then player.dropItemKeyPressing = false; end
if inputs.locked["pause"] == true then player.pauseKeyPressing = false; end

end

return inputs
7 changes: 3 additions & 4 deletions LuaScriptsLibExt/multipoints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
-----------With help from Rednaxella-----------
--------Open-Source Checkpoint Library---------
------------For Super Mario Bros X-------------
-------------------v3.0.4----------------------
-------------------v3.0.6----------------------
local multipoints = {}

local playerMP = { sec = 0, x = 0, y = 0, act = nil }
Expand Down Expand Up @@ -75,7 +75,7 @@ local function getMP(i)
if(player:mem(0x112,FIELD_WORD) < p and player:mem(0x122,FIELD_WORD) ~= 1 and player:mem(0x122,FIELD_WORD) ~= 2) then
player:mem(0x112,FIELD_WORD, p);
end
if(player2:mem(0x112,FIELD_WORD) < p and player2:mem(0x122,FIELD_WORD) ~= 1 and player2:mem(0x122,FIELD_WORD) ~= 2) then
if(player2 ~= nil and player2:mem(0x112,FIELD_WORD) < p and player2:mem(0x122,FIELD_WORD) ~= 1 and player2:mem(0x122,FIELD_WORD) ~= 2) then
player2:mem(0x112,FIELD_WORD, p);
end
elseif(plyr:mem(0x112,FIELD_WORD) < p and plyr:mem(0x122,FIELD_WORD) ~= 1 and plyr:mem(0x122,FIELD_WORD) ~= 2) then
Expand Down Expand Up @@ -312,8 +312,7 @@ function multipoints.update()

for k,v in pairs(mpLuaTrigs) do
if(not v.spawnAt and not multipoints.getCheckpointStatus(k) and v.obj.visible) then

Graphics.placeSprite(2,multipoints.IMG,v.x,v.y,"",2);
Graphics.drawImageToScene(multipoints.IMG,v.x,v.y);
if(player.x < v.x+multipoints.IMG_SIZE.width and player.x+player:mem(0xD8, FIELD_DFLOAT) > v.x and player.y < v.y+multipoints.IMG_SIZE.height and player.y + player:mem(0xD0, FIELD_DFLOAT) > v.y)then
v.func(player);
end
Expand Down
Loading

0 comments on commit 97fee28

Please sign in to comment.