diff --git a/animationguiline.lua b/animationguiline.lua index ce90dec..5c12274 100644 --- a/animationguiline.lua +++ b/animationguiline.lua @@ -1233,6 +1233,15 @@ end function animationguiline:unclick(x, y, button) self.downbutton:unclick(x, y, button) self.upbutton:unclick(x, y, button) + + -- Why is it even done this way, and not with "for i = 1, #self.elements do"? + local i = 1 + while i <= #self.elements do + if self.elements[i].gui then + self.elements[i].gui:unclick(x, y, button) + end + i = i + 1 + end end function animationguiline:delete() @@ -1287,4 +1296,4 @@ function animationguiline:haspriority() end return false -end \ No newline at end of file +end diff --git a/editor.lua b/editor.lua index 4db1099..daa7206 100644 --- a/editor.lua +++ b/editor.lua @@ -89,8 +89,7 @@ function editor_load() mtsavehighlighttime = 5 mtsavetimer = 0 - mtjustsaved = false - mtsavecolors = {1, 0.44, 0.44, 0.7} + mtjustsaved = 0 pastingtiles = false pastemode = false -- 1 transparent, 2 opaque @@ -527,14 +526,14 @@ function editor_update(dt) next = "down" end - if mushroomplatform then + if advanceddrawtool == "mushroom" then powerlinedrawtable = { --mushroom platform {"down", "up", 65, false}, {"left", "right", 22, false, hprev, 0, 20, false, (hprev/math.abs(hprev)), 0, 21, false, hprev-(hprev/math.abs(hprev)), 0, 21}, {"right", "left", 20, false, hprev, 0, 22, false, (hprev/math.abs(hprev)), 0, 21, false, hprev-(hprev/math.abs(hprev)), 0, 21}, {"down", "right", 21, false, 0, 1, 43}, {"down", "left", 21, false, 0, 1, 43}} - else + elseif advanceddrawtool == "powerlines" then powerlinedrawtable = { --powerlines {"up", "down", 43, true}, {"down", "up", 43, true}, @@ -590,6 +589,7 @@ function editor_update(dt) elseif love.mouse.isDown("m") and not middlemode[1] then if math.abs(love.mouse.getX() - middlemode[2]) >= 8*scale or math.abs(love.mouse.getY() - middlemode[3]) >= 8*scale then middlemode[1] = true + love.mouse.setVisible(false) end end @@ -894,46 +894,38 @@ function editor_draw() lx2 = math.max(tileselectionclick1x, tileselectionclick2x) ly2 = math.max(tileselectionclick1y, tileselectionclick2y) - love.graphics.setColor(0.67,1,0.67,0.3) - if mtjustsaved then - local r, g, b, a = unpack(mtsavecolors) - if r > 172 then - r = r - math.floor(mtsavetimer*3) - end - if r < 172 then - r = 172 - end - if g < 255 then - g = g + math.floor(mtsavetimer*3) - end - if g > 255 then - g = 255 - end - if b > 172 then - b = b - math.floor(mtsavetimer*3) - end - if b < 172 then - b = 172 - end - if a > 72 then - a = a - math.floor(mtsavetimer*3) - end - if a < 72 then - a = 72 - end - love.graphics.setColor(r / 255, g / 255, b / 255, a / 255) - if r == 172 and g == 255 and b == 172 and a == 72 then - mtsavehighlighttime = 5 - mtsavetimer = 0 - mtjustsaved = false - r = 255 - g = 112 - b = 112 - a = 128 + -- Laziness or cleverness? + local px, py = math.floor((lx1-xscroll-1)*16*scale), ((ly1-yscroll-1)*16+8)*scale + local pw, ph = (lx2-lx1)*16*scale+16*scale, (ly2-ly1)*16*scale+16*scale + + love.graphics.setColor(0.67,1,0.67,0.7) + local timeOscilator = love.timer.getTime() % 2 + timeOscilator = 1 - math.abs( math.cos(timeOscilator * math.pi) ) + + -- Highlight thing + love.graphics.rectangle("fill", px - (2 + timeOscilator*3)*scale, py - (2 + timeOscilator*3)*scale, 5*scale, scale) + love.graphics.rectangle("fill", px - (2 + timeOscilator*3)*scale, py - (1 + timeOscilator*3)*scale, scale, 4*scale) + love.graphics.rectangle("fill", px + pw + (2 + timeOscilator*3 - 5)*scale, py - (2 + timeOscilator*3)*scale, 5*scale, scale) + love.graphics.rectangle("fill", px + pw + (1 + timeOscilator*3)*scale, py - (1 + timeOscilator*3)*scale, scale, 4*scale) + love.graphics.rectangle("fill", px - (2 + timeOscilator*3)*scale, py + ph + (1 + timeOscilator*3)*scale, 5*scale, scale) + love.graphics.rectangle("fill", px - (2 + timeOscilator*3)*scale, py + ph + (1 + timeOscilator*3 - 4)*scale, scale, 4*scale) + love.graphics.rectangle("fill", px + pw + (2 + timeOscilator*3 - 5)*scale, py + ph + (1 + timeOscilator*3)*scale, 5*scale, scale) + love.graphics.rectangle("fill", px + pw + (1 + timeOscilator*3)*scale, py + ph + (1 + timeOscilator*3 - 4)*scale, scale, 4*scale) + + local saveColors = {1, 0.44, 0.44, 0.7} + local selectColors = {0.67, 1, 0.67, 0.3} + love.graphics.setColor(selectColors) + + if mtjustsaved > 0 then + local r, g, b, a = gradient(selectColors, saveColors, mtjustsaved) + love.graphics.setColor(r, g, b, a) + + mtjustsaved = math.max(mtjustsaved - love.timer.getDelta(), 0) + if mtjustsaved == 0 then -- Negative 0 thing + mtjustsaved = 0 end - mtsavecolors = {r, g, b, a} end - love.graphics.rectangle("fill",math.floor((lx1-xscroll-1)*16*scale), ((ly1-yscroll-1)*16+8)*scale, (lx2-lx1)*16*scale+16*scale, (ly2-ly1)*16*scale+16*scale) + love.graphics.rectangle("fill", px, py, pw, ph) end elseif middlemode[1] then love.graphics.push() @@ -1225,6 +1217,38 @@ function editor_draw() rightclickm:draw() end + -- EDITOR UI + local mode = "tiles" + local submode = false + if editorstate == "selection" then + mode = "selection" + elseif editorstate == "lightdraw" then + mode = "advanced draw tool" + submode = "power line draw" + if advanceddrawtool == "mushroom" then + submode = "mushroom platforms" + end + else + submode = "tiles" + if editenemies then + submode = "enemies" + elseif editentities then + submode = "entities" + end + end + love.graphics.setColor(1, 1, .8, .75) + properprint(" editor mode", 10*scale, 10*scale) + if submode then + properprint("tool submode", 10*scale, 18*scale) + end + properprint("f1 for help", (400-10-8*11)*scale, 10*scale) + + love.graphics.setColor(1, 1, 1, .75) + properprint(":" .. mode, (10+12*8)*scale, 10*scale) + if submode then + properprint(":" .. submode, (10+12*8)*scale, 18*scale) + end + if love.keyboard.isDown("f1") and not rightclickm then love.graphics.setColor(0, 0, 0, .85) love.graphics.rectangle("fill", helpui[1]*scale, helpui[2]*scale, (helpui[3]-helpui[1])*scale, (helpui[4]-helpui[2])*scale) @@ -1244,7 +1268,7 @@ function editor_draw() {"ctrl+g","transforms the selected tiles into a|" .. "group bound to the top-left-most tile.", 1}, {"u","on the tile screen, removes the tile group|" .. - "bound to the tile.", 1},-- | + "bound to the highlighted tile.", 1},-- | {"ctrl+z/ctrl+y","undo/redo the last changes.", 0}, {"ctrl+c/ctrl+x/ctrl+v","copy/cut/paste region.", 0}, {"ctrl+a","select the entire level.", 0},-- | @@ -1768,11 +1792,14 @@ function editor_draw() properprint("delete", 10*scale, 210*scale) end elseif editorstate == "lightdrawcustomize" then - love.graphics.setColor(0.5, 0.5, 0.5) - properprint("more coming soon", 5*scale, 55*scale) - guielements["tabtools"].textcolor = {math.random(),math.random(),math.random()} - guielements["tabtools"].fillcolor = {math.random(),math.random(),math.random()} - guielements["tabtools"].bordercolor = {math.random(),math.random(),math.random()} + -- love.graphics.setColor(0.5, 0.5, 0.5) + -- properprint("more coming soon", 5*scale, 55*scale) + + -- I'm cancelling this stroke-inducing nightmare + + -- guielements["tabtools"].textcolor = {math.random(),math.random(),math.random()} + -- guielements["tabtools"].fillcolor = {math.random(),math.random(),math.random()} + -- guielements["tabtools"].bordercolor = {math.random(),math.random(),math.random()} end end end @@ -2080,7 +2107,7 @@ function powerlinestab() v.active = false end - guielements["tabtools"].text = "party" + -- guielements["tabtools"].text = "party" guielements["tabmain"].active = true guielements["tabtiles"].active = true guielements["tabtools"].active = true @@ -2927,10 +2954,13 @@ function savestate() table.remove(savestates, 1) end local t = {} + t.coinmap = {} for x = 1, #map do t[x] = {} + t.coinmap[x] = {} for y = 1, #map[x] do t[x][y] = {} + t.coinmap[x][y] = coinmap[x][y] for i, v in pairs(map[x][y]) do t[x][y][i] = v end @@ -2945,10 +2975,13 @@ function loadstate(s) local v = savestates[s] map = {} + coinmap = {} for x = 1, #v do map[x] = {} + coinmap[x] = {} for y = 1, #v[x] do map[x][y] = {} + coinmap[x][y] = v.coinmap[x][y] for i, w in pairs(v[x][y]) do map[x][y][i] = w end @@ -3234,6 +3267,9 @@ function editor_mousepressed(x, y, button) loadmtobjects() elseif mtbutton == 4 then deleteline("mappacks/" .. mappack .. "/objects.txt", tile+1) + if guielements["renamebar"] and guielements["renamebar"].active then + guielements["renamebar"].active = false + end loadmtobjects() end end @@ -3242,6 +3278,7 @@ function editor_mousepressed(x, y, button) end elseif button == "m" then middlemode = {false, x, y} + love.mouse.setVisible(true) elseif button == "wu" then if not editormenuopen then if love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift") then @@ -3424,14 +3461,16 @@ function editor_mousereleased(x, y, button) elseif button == "m" then if middlemode[1] == false then local cox, coy = getMouseTile(love.mouse.getX(), love.mouse.getY()+8*scale) - print("cox, coy = " .. cox .. ", " .. coy) if inmap(cox, coy) == false then return end - print("Tile selected") if not editentities then tilesall() currenttile = map[cox][coy][1] + + if currenttile == 1 and coinmap[cox][coy] then + currenttile = 116 -- Let's be nice to the map maker, alright? + end elseif not editenemies then tilesentities() generateentitylist() @@ -3450,6 +3489,7 @@ function editor_mousereleased(x, y, button) end end middlemode[1] = false + love.mouse.setVisible(true) end allowdrag = true hprev = 0 @@ -3515,6 +3555,7 @@ function editor_keypressed(key) savemtobject(group, tostring(name), "groups") loadmtgroups() + notice.new("Saved as group!", notice.white, 2) end elseif key == "c" or key == "x" then if tileselectionclick1 == true and tileselectionclick2 == true then @@ -3831,8 +3872,8 @@ function toggleskiplevelscreen(var) end function changepastemode(var) --- pastemode = var --- guielements["pastemodedropdown"].var = var + -- pastemode = var + -- guielements["pastemodedropdown"].var = var if var ~= nil then pastemode = var else @@ -3941,8 +3982,10 @@ function test_level() end function drawpowerlines() - mushroomplatform = false - + advanceddrawtool = "powerlines" + + editenemies = false + editentities = true editorstate = "lightdraw" lightdrawX = nil lightdrawY = nil @@ -3950,8 +3993,10 @@ function drawpowerlines() end function drawmushrooms() - mushroomplatform = true + advanceddrawtool = "mushroom" + editenemies = false + editentities = false editorstate = "lightdraw" lightdrawX = nil lightdrawY = nil @@ -4166,7 +4211,7 @@ function savemtobject(objecttable, name, file) data = string.gsub(data, "mtobjsize", m .. " * " .. n) data = data .. "\n" love.filesystem.write("mappacks/" .. mappack .. "/" .. file .. ".txt", data) - mtjustsaved = true + mtjustsaved = 1 end function objectclipboardcopy(objecttable) diff --git a/emancipationgrill.lua b/emancipationgrill.lua index 396c219..f289581 100644 --- a/emancipationgrill.lua +++ b/emancipationgrill.lua @@ -8,6 +8,8 @@ function emancipationgrill:init(x, y, r) self.active = true self.inputstate = "off" + self.thickness = 4 -- For aabb checks + table.remove(self.r, 1) table.remove(self.r, 1) @@ -135,10 +137,12 @@ function emancipationgrill:draw() parstartleft = math.floor((self.startx-1-xscroll)*16*scale) parstartright = math.floor((self.endx-1-xscroll)*16*scale) if self.active then - love.graphics.setScissor(parstartleft, ((self.y-yscroll-1)*16-2)*scale, self.range - emanceimgwidth*scale, scale*4) + love.graphics.setScissor(parstartleft, ((self.y-yscroll-1)*16-self.thickness/2)*scale, + self.range - emanceimgwidth*scale, self.thickness*scale) love.graphics.setColor(unpack(emancelinecolor)) - love.graphics.rectangle("fill", math.floor((self.startx-1-xscroll)*16*scale), ((self.y-yscroll-1)*16-2)*scale, self.range, scale*4) + love.graphics.rectangle("fill", math.floor((self.startx-1-xscroll)*16*scale), ((self.y-yscroll-1)*16-self.thickness/2)*scale, + self.range, self.thickness*scale) love.graphics.setColor(1, 1, 1) for i, v in pairs(self.particles.i) do @@ -162,10 +166,12 @@ function emancipationgrill:draw() parstartup = math.floor((self.starty-yscroll-1)*16*scale) parstartdown = math.floor((self.endy-yscroll-1)*16*scale) if self.active then - love.graphics.setScissor(math.floor(((self.x-1-xscroll)*16+6)*scale), parstartup-8*scale, scale*4, self.range - emanceimgwidth*scale) + love.graphics.setScissor(math.floor(((self.x-1-xscroll)*16+self.thickness*1.5)*scale), parstartup-8*scale, + self.thickness*scale, self.range - emanceimgwidth*scale) love.graphics.setColor(unpack(emancelinecolor)) - love.graphics.rectangle("fill", math.floor(((self.x-1-xscroll)*16+6)*scale), parstartup-8*scale, scale*4, self.range - emanceimgwidth*scale) + love.graphics.rectangle("fill", math.floor(((self.x-1-xscroll)*16+self.thickness*1.5)*scale), parstartup-8*scale, + self.thickness*scale, self.range - emanceimgwidth*scale) love.graphics.setColor(1, 1, 1) for i, v in pairs(self.particles.i) do @@ -221,4 +227,4 @@ function emancipationgrill:input(t, input) self.inputstate = t end -end \ No newline at end of file +end diff --git a/game.lua b/game.lua index 6cd0481..b70d50e 100644 --- a/game.lua +++ b/game.lua @@ -1021,29 +1021,24 @@ function drawui(hidetime) love.graphics.translate(0, yoffset*scale) end - if not characters[mariocharacter[1]] then - mariocharacter[1] = "mario" - end - printfunction(characters[mariocharacter[1]].name, uispace*.5 - 24*scale, 8*scale) - printfunction(addzeros(marioscore, 6), uispace*0.5-24*scale, 16*scale) - - printfunction("*", uispace*1.5-8*scale, 16*scale) - - love.graphics.draw(coinanimationimg, coinanimationquads[spriteset][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) - printfunction(addzeros(mariocoincount, 2), uispace*1.5-0*scale, 16*scale) - - printfunction("world", uispace*2.5 - 20*scale, 8*scale) - printfunction(marioworld .. "-" .. mariolevel, uispace*2.5 - 12*scale, 16*scale) + if editormode == false then -- No point in showing this in the editor + if not characters[mariocharacter[1]] then + mariocharacter[1] = "mario" + end + printfunction(characters[mariocharacter[1]].name, uispace*.5 - 24*scale, 8*scale) + printfunction(addzeros(marioscore, 6), uispace*0.5-24*scale, 16*scale) + + printfunction("*", uispace*1.5-8*scale, 16*scale) + + love.graphics.draw(coinanimationimg, coinanimationquads[spriteset][coinframe], uispace*1.5-16*scale, 16*scale, 0, scale, scale) + printfunction(addzeros(mariocoincount, 2), uispace*1.5-0*scale, 16*scale) + + printfunction("world", uispace*2.5 - 20*scale, 8*scale) + printfunction(marioworld .. "-" .. mariolevel, uispace*2.5 - 12*scale, 16*scale) - printfunction("time", uispace*3.5 - 16*scale, 8*scale) - if not hidetime then - if editormode then - if linktool then - printfunction("link", uispace*3.5 - 16*scale, 16*scale) - else - printfunction("edit", uispace*3.5 - 16*scale, 16*scale) - end - else + printfunction("time", uispace*3.5 - 16*scale, 8*scale) + + if not hidetime then if type(mariotime) == "number" then printfunction(addzeros(math.ceil(mariotime), 3), uispace*3.5-8*scale, 16*scale) else @@ -4193,7 +4188,7 @@ function shootportal(plnumber, i, sourcex, sourcey, direction, mirrored, bounces local cox, coy, side, tendency, x, y = traceline(sourcex, sourcey, direction) local mirror = false - if cox and tilequads[map[cox][coy]] and tilequads[map[cox][coy][1]]:getproperty("mirror", cox, coy) then + if cox and tilequads[map[cox][coy][1]] and tilequads[map[cox][coy][1]]:getproperty("mirror", cox, coy) then mirror = true end diff --git a/main.lua b/main.lua index 6e1efa9..6a03fb4 100644 --- a/main.lua +++ b/main.lua @@ -2440,4 +2440,14 @@ end function dbprint(x) --debugprint, can easily comment out the "print" thing print(x) -end \ No newline at end of file +end + +function gradient(color1, color2, progress) + local ret = {} + for i = 1, math.max(#color1, #color2) do + local c1 = color1[i] or color2[i] + local c2 = color2[i] or color1[i] + ret[i] = c1 + (c2-c1)*progress + end + return ret +end diff --git a/mario.lua b/mario.lua index cc11679..e21db4f 100644 --- a/mario.lua +++ b/mario.lua @@ -2239,9 +2239,17 @@ function mario:stompenemy(a, b, c, d, side) b:stomp(self.x, self) if b.speedx == 0 or (b.flying and b.small == false) then - addpoints(mariocombo[self.combo], self.x, self.y) if self.combo < #mariocombo then + addpoints(mariocombo[self.combo], self.x, self.y) self.combo = self.combo + 1 + else + if mariolivecount ~= false then + for i = 1, players do + mariolives[i] = mariolives[i]+1 + end + end + table.insert(scrollingscores, scrollingscore:new("1up", self.x, self.y)) + playsound("oneup") end local grav = self.gravity or yacceleration diff --git a/physics.lua b/physics.lua index 0b02ab6..a2656d9 100644 --- a/physics.lua +++ b/physics.lua @@ -215,12 +215,16 @@ function checkforemances(dt, v, speedx, speedy) if u.active then local spx = speedx or v.speedx local spy = speedy or v.speedy + + -- Honestly, why were fizzlers originally done with "inrange" instead of "aabb"? if u.dir == "hor" then - if inrange(v.x+6/16, u.startx-1, u.endx, true) and inrange(u.y-14/16, v.y, v.y+spy*dt, true) then + -- if inrange(v.x+6/16, u.startx-1, u.endx, true) and inrange(u.y-14/16, v.y, v.y+spy*dt, true) then + if aabb(v.x, v.y, v.width, v.height, u.startx - 1, u.y - .5 - u.thickness/16/2, (u.endx - u.startx + 1), u.thickness/16) then if v.emancipate then v:emancipate(h) end end else - if inrange(v.y+6/16, u.starty-1, u.endy, true) and inrange(u.x-14/16, v.x, v.x+spx*dt, true) then + -- if inrange(v.y+6/16, u.starty-1, u.endy, true) and inrange(u.x-14/16, v.x, v.x+spx*dt, true) then + if aabb(v.x, v.y, v.width, v.height, u.x - .5 - u.thickness/16/2, u.starty - 1, u.thickness/16, (u.endy - u.starty + 1)) then if v.emancipate then v:emancipate(h) end end end