Skip to content

Commit

Permalink
Mari0 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Stabyourself committed Mar 16, 2012
1 parent ac87163 commit 3ee77a3
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 46 deletions.
2 changes: 1 addition & 1 deletion conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function love.conf(t)
t.author = "Maurice"
t.identity = "mari0"
t.console = false
t.screen = false
--t.screen = false
t.modules.physics = false
t.version = "0.8.0"
end
4 changes: 2 additions & 2 deletions game.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function game_load(suspended)
scrollfactor = 0
backgroundcolor = {}
backgroundcolor[1] = {92, 148, 252}
backgroundcolor[2] = {0, 0, 0}
Expand Down Expand Up @@ -121,6 +122,7 @@ function game_load(suspended)
custommusic = "mappacks/" .. mappack .. "/music.mp3"
music:load(custommusic)
end
print(custommusic)

--FINALLY LOAD THE DAMN LEVEL
levelscreen_load("initial")
Expand Down Expand Up @@ -2481,8 +2483,6 @@ function loadmap(filename)
end
end

scrollfactor = 0

--MORE STUFF
for i = 2, #s2 do
s3 = s2[i]:split("=")
Expand Down
1 change: 0 additions & 1 deletion hammerbro.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function hammerbro:init(x, y)
self.active = true
self.category = 20
self.mask = {true, false, false, false, false, true, false, false, false, true}
self.emancipatecheck = true
self.autodelete = true
self.gravity = 40

Expand Down
50 changes: 35 additions & 15 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
]]

function love.load()
marioversion = 1005
versionstring = "version 1.5"
marioversion = 1006
versionstring = "version 1.6"
shaderlist = love.filesystem.enumerate( "shaders/" )
dlclist = {"dlc_a_portal_tribute", "dlc_acid_trip", "dlc_escape_the_lab", "dlc_scienceandstuff", "dlc_smb2J", "dlc_the_untitled_game"}

local rem
for i, v in pairs(shaderlist) do
Expand All @@ -28,7 +29,11 @@ function love.load()

hatcount = #love.filesystem.enumerate("graphics/SMB/hats")

loadconfig()
if not pcall(loadconfig) then
players = 1
defaultconfig()
end

saveconfig()
width = 25
fsaa = 0
Expand Down Expand Up @@ -68,6 +73,7 @@ function love.load()
require "shaders"
require "variables"
require "class"
require "sha1"

require "intro"
require "menu"
Expand Down Expand Up @@ -729,6 +735,10 @@ function love.load()
shaders:set(1, shaderlist[currentshaderi1])
shaders:set(2, shaderlist[currentshaderi2])

for i, v in pairs(dlclist) do
delete_mappack(v)
end

intro_load()
end

Expand Down Expand Up @@ -854,7 +864,10 @@ function saveconfig()
end

for i = 1, #mariohats do
s = s .. "mariohats:" .. i .. ":"
s = s .. "mariohats:" .. i
if #mariohats[i] > 0 then
s = s .. ":"
end
for j = 1, #mariohats[i] do
s = s .. mariohats[i][j]
if j == #mariohats[i] then
Expand All @@ -863,6 +876,10 @@ function saveconfig()
s = s .. ","
end
end

if #mariohats[i] == 0 then
s = s .. ";"
end
end

s = s .. "scale:" .. scale .. ";"
Expand Down Expand Up @@ -926,7 +943,7 @@ function loadconfig()
for j = 1, #s3 do
s4 = s3[j]:split("-")
controls[tonumber(s2[2])][s4[1]] = {}
for k = 2, #s3[4]+1 do
for k = 2, #s4 do
if tonumber(s4[k]) ~= nil then
controls[tonumber(s2[2])][s4[1]][k-1] = tonumber(s4[k])
else
Expand All @@ -951,19 +968,22 @@ function loadconfig()
portalhues[tonumber(s2[2])] = {tonumber(s3[1]), tonumber(s3[2])}

elseif s2[1] == "mariohats" then
if mariohats[tonumber(s2[2])] == nil then
mariohats[tonumber(s2[2])] = {}
end
s3 = s2[3]:split(",")
for i = 1, #s3 do
local hatno = tonumber(s3[i])
if hatno > hatcount then
hatno = hatcount
local playerno = tonumber(s2[2])
mariohats[playerno] = {}

if s2[3] == "mariohats" then --SAVING WENT WRONG OMG

elseif s2[3] then
s3 = s2[3]:split(",")
for i = 1, #s3 do
local hatno = tonumber(s3[i])
if hatno > hatcount then
hatno = hatcount
end
mariohats[playerno][i] = hatno
end
mariohats[tonumber(s2[2])][i] = hatno
end


elseif s2[1] == "scale" then
scale = tonumber(s2[2])

Expand Down
106 changes: 83 additions & 23 deletions menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ function menu_draw()
love.graphics.rectangle("fill", 21*scale, 16*scale, 218*scale, 200*scale)
love.graphics.setColor(255, 255, 255, 255)
properprint("a little patience..|downloading " .. currentdownload .. " of " .. downloadcount, 50*scale, 30*scale)
drawrectangle(50, 55, 152, 10)
love.graphics.rectangle("fill", 50*scale, 55*scale, 152*((currentfiledownload-1)/(filecount-1))*scale, 10*scale)
else
love.graphics.translate(-round(mappackhorscrollsmooth*scale*mappackhorscrollrange), 0)

Expand Down Expand Up @@ -488,8 +490,13 @@ function menu_draw()
if outdated then
love.graphics.setColor(255, 0, 0, 255)
properprint("version outdated!|you have an old|version of mari0!|mappacks could not|be downloaded.|go to|stabyourself.net|to download latest", 244*scale, 130*scale)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.setColor(255, 255, 255, 255)
elseif downloaderror then
love.graphics.setColor(255, 0, 0, 255)
properprint("download error!|something went|wrong while|downloading|mappacks.|press left and|right to try|again. sorry.", 244*scale, 130*scale)
love.graphics.setColor(255, 255, 255, 255)
end

love.graphics.setScissor(21*scale, 16*scale, 218*scale, 200*scale)

--scrollbar offset
Expand Down Expand Up @@ -1143,7 +1150,6 @@ function loadbackground(background)
end

--add custom tiles
local bla = love.timer.getTime()
if love.filesystem.exists("mappacks/" .. mappack .. "/tiles.png") then
customtiles = true
customtilesimg = love.graphics.newImage("mappacks/" .. mappack .. "/tiles.png")
Expand All @@ -1164,7 +1170,6 @@ function loadbackground(background)
customtiles = false
customtilecount = 0
end
print("Custom tileset loaded in: " .. round(love.timer.getTime()-bla, 5))

--MAP ITSELF
local t = s2[1]:split(",")
Expand Down Expand Up @@ -1261,7 +1266,7 @@ function loadmappacks()

local delete = {}
for i = 1, #mappacklist do
if love.filesystem.exists( "mappacks/" .. mappacklist[i] .. "/version.txt") then
if love.filesystem.exists( "mappacks/" .. mappacklist[i] .. "/version.txt") or not love.filesystem.exists( "mappacks/" .. mappacklist[i] .. "/settings.txt") then
table.insert(delete, i)
end
end
Expand Down Expand Up @@ -1343,7 +1348,7 @@ function loadonlinemappacks()

local delete = {}
for i = 1, #onlinemappacklist do
if not love.filesystem.exists( "mappacks/" .. onlinemappacklist[i] .. "/version.txt") then
if not love.filesystem.exists( "mappacks/" .. onlinemappacklist[i] .. "/version.txt") or not love.filesystem.exists( "mappacks/" .. onlinemappacklist[i] .. "/settings.txt") then
table.insert(delete, i)
end
end
Expand Down Expand Up @@ -1416,11 +1421,14 @@ function loadonlinemappacks()
end

function downloadmappacks()
local onlinedata, code = http.request("http://server.stabyourself.net/mari0/?mode=mappacks")
downloaderror = false
local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks")

if code ~= 200 then
downloaderror = true
return false
elseif not onlinedata then
downloaderror = true
return false
end

Expand All @@ -1445,6 +1453,8 @@ function downloadmappacks()
return false
end

success = true

--download all mappacks
for i = 1, #maplist do
--check if current version is equal or newer
Expand All @@ -1462,32 +1472,77 @@ function downloadmappacks()
--draw
currentdownload = i
downloadcount = #maplist
loadingonlinemappacks = true
love.graphics.clear()
love.draw()
love.graphics.present()
loadingonlinemappacks = false

if love.filesystem.exists("mappacks/" .. maplist[i] .. "/") then
love.filesystem.remove("mappacks/" .. maplist[i] .. "/")
end

love.filesystem.mkdir("mappacks/" .. maplist[i])
local onlinedata, code = http.request("http://server.stabyourself.net/mari0/?mode=getmap&get=" .. maplist[i])
local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i])

if code ~= 200 then
return false
if code == 200 then
filecount = 0
local checksums = {}

local split1 = onlinedata:split("<")
for j = 2, #split1 do
local split2 = split1[j]:split(">")
if split2[1] == "asset" then
filecount = filecount + 1
elseif split2[1] == "checksum" then
table.insert(checksums, split2[2])
end
end

currentfiledownload = 1

local split1 = onlinedata:split("<")
for j = 2, #split1 do
local split2 = split1[j]:split(">")
if split2[1] == "asset" then
loadingonlinemappacks = true
love.graphics.clear()
love.draw()
love.graphics.present()
loadingonlinemappacks = false

local target = "mappacks/" .. maplist[i] .. "/" .. split2[2]:match("([^/]-)$")

local tries = 0
success = false
while not success and tries < 3 do
success = downloadfile(split2[2], target, checksums[currentfiledownload])
tries = tries + 1
end

if not success then
break
end
currentfiledownload = currentfiledownload + 1
end
end
if success then
love.filesystem.write( "mappacks/" .. maplist[i] .. "/version.txt", versionlist[i])
end
else
success = false
end

local split1 = onlinedata:split("<")
for j = 2, #split1 do
local split2 = split1[j]:split(">")
if split2[1] == "asset" then
local target = "mappacks/" .. maplist[i] .. "/" .. split2[2]:match("([^/]-)$")
downloadfile(split2[2], target)
end

--Delete stuff and stuff.
if not success then
if love.filesystem.exists("mappacks/" .. maplist[i] .. "/") then
local list = love.filesystem.enumerate("mappacks/" .. maplist[i] .. "/")
for j = 1, #list do
love.filesystem.remove("mappacks/" .. maplist[i] .. "/" .. list[j])
end

love.filesystem.remove("mappacks/" .. maplist[i] .. "/")
end
love.filesystem.write( "mappacks/" .. maplist[i] .. "/version.txt", versionlist[i])
downloaderror = true
break
else
print("Download succeeded.")
end
end

Expand Down Expand Up @@ -2069,13 +2124,18 @@ function keypromptstart()
end
end

function downloadfile(url, target)
function downloadfile(url, target, checksum)
local data, code = http.request(url)

if code ~= 200 then
return false
end

if checksum ~= sha1(data) then
print("Checksum doesn't match!")
return false
end

if data then
love.filesystem.write(target, data)
return true
Expand Down
2 changes: 2 additions & 0 deletions musicloader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ function music:update()
source:setPitch(self.pitch)
end
end
local err = self.thread:get("error")
if err then print(err) end
end

function music:onLoad(name, source)
Expand Down
2 changes: 2 additions & 0 deletions musicloader_thread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local this = love.thread.getThread()
require("love.filesystem")
require("love.sound")
require("love.audio")
require("love.timer")

love.filesystem.setIdentity("mari0")

Expand Down Expand Up @@ -49,4 +50,5 @@ end
while true do
getmusiclist()
loadmusic()
love.timer.sleep(1/60)
end
2 changes: 1 addition & 1 deletion physics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function checkcollision(v, t, h, g, j, i, dt, passed) --v: b1table | t: b2table
local hadhorcollision = false
local hadvercollision = false

if true then --math.abs(v.x-t.x)+math.abs(v.y-t.y) < 5 then
if math.abs(v.x-t.x) < math.max(v.width, t.width)+1 and math.abs(v.y-t.y) < math.max(v.height, t.height)+1 then
--check if it's a passive collision (Object is colliding anyway)
if not passed and aabb(v.x, v.y, v.width, v.height, t.x, t.y, t.width, t.height) then --passive collision! (oh noes!)
if passivecollision(v, t, h, g, j, i, dt) then
Expand Down
Loading

0 comments on commit 3ee77a3

Please sign in to comment.