Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial port to Löve 11.3 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ function love.conf(t)
t.title = "Not Tetris 2"
t.author = "Maurice"
t.identity = "not_tetris_2"
t.screen.width = 800
t.screen.height = 720
t.screen.fsaa = 0
t.screen.vsync = true
t.window.width = 800
t.window.height = 720
t.window.msaa = 0
t.window.vsync = true
end
49 changes: 27 additions & 22 deletions gameA.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,28 @@ function gameA_load()

tetrikind = {}
wallshapes = {}
wallfixtures = {}
tetrishapes = {}
tetribodies = {}
offsetshapes = {}
tetrishapescopy = {}
data = {}

wallbodies = love.physics.newBody(world, 32, -64, 0, 0) --WALLS
wallshapes[0] = love.physics.newPolygonShape( wallbodies,-8, -64, -8,672, 24,672, 24,-64)
wallshapes[0]:setData({"left"})
wallshapes[0]:setFriction(0.00001)
wallshapes[1] = love.physics.newPolygonShape( wallbodies,352,-64, 352,672, 384,672, 384,-64)
wallshapes[1]:setData({"right"})
wallshapes[1]:setFriction(0.00001)
wallshapes[2] = love.physics.newPolygonShape( wallbodies,24,640, 24,672, 352,672, 352,640)
wallshapes[2]:setData({"ground"})
wallshapes[3] = love.physics.newPolygonShape( wallbodies,-8,-96, 384,-96, 384,-64, -8,-64)
wallshapes[3]:setData({"ceiling"})
wallbodies = love.physics.newBody(world, 32, -64, "static") --WALLS
wallshapes[0] = love.physics.newPolygonShape(-8,-64, -8,672, 24,672, 24,-64)
wallfixtures[0] = love.physics.newFixture(wallbodies, wallshapes[0])
wallfixtures[0]:setUserData({"left"})
wallfixtures[0]:setFriction(0.00001)
wallshapes[1] = love.physics.newPolygonShape(352,-64, 352,672, 384,672, 384,-64)
wallfixtures[1] = love.physics.newFixture(wallbodies, wallshapes[1])
wallfixtures[1]:setUserData({"right"})
wallfixtures[1]:setFriction(0.00001)
wallshapes[2] = love.physics.newPolygonShape(24,640, 24,672, 352,672, 352,640)
wallfixtures[2] = love.physics.newFixture(wallbodies, wallshapes[2])
wallfixtures[2]:setUserData({"ground"})
wallshapes[3] = love.physics.newPolygonShape(-8,-96, 384,-96, 384,-64, -8,-64)
wallfixtures[3] = love.physics.newFixture(wallbodies, wallshapes[3])
wallfixtures[3]:setUserData({"ceiling"})

world:setCallbacks(collideA)
-----------
Expand Down Expand Up @@ -70,49 +75,49 @@ function createtetriA(i, uniqueid, x, y) --creates block, including body, shapes
tetrishapes[uniqueid] = {}

if i == 1 then --I
tetribodies[uniqueid] = love.physics.newBody(world, x, y, 0, blockrot)
tetribodies[uniqueid] = love.physics.newBody(world, x, y, "dynamic"):setInertia(blockrot)
tetrishapes[uniqueid][1] = love.physics.newRectangleShape( tetribodies[uniqueid], -48,0, 32, 32)
tetrishapes[uniqueid][2] = love.physics.newRectangleShape( tetribodies[uniqueid], -16,0, 32, 32)
tetrishapes[uniqueid][3] = love.physics.newRectangleShape( tetribodies[uniqueid], 16,0, 32, 32)
tetrishapes[uniqueid][4] = love.physics.newRectangleShape( tetribodies[uniqueid], 48,0, 32, 32)

elseif i == 2 then --J
tetribodies[uniqueid] = love.physics.newBody(world, x, y, 0, blockrot)
tetribodies[uniqueid] = love.physics.newBody(world, x, y, "dynamic"):setInertia(blockrot)
tetrishapes[uniqueid][1] = love.physics.newRectangleShape( tetribodies[uniqueid], -32,-16, 32, 32)
tetrishapes[uniqueid][2] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,-16, 32, 32)
tetrishapes[uniqueid][3] = love.physics.newRectangleShape( tetribodies[uniqueid], 32,-16, 32, 32)
tetrishapes[uniqueid][4] = love.physics.newRectangleShape( tetribodies[uniqueid], 32,16, 32, 32)

elseif i == 3 then --L
tetribodies[uniqueid] = love.physics.newBody(world, x, y, 0, blockrot)
tetribodies[uniqueid] = love.physics.newBody(world, x, y, "dynamic"):setInertia(blockrot)
tetrishapes[uniqueid][1] = love.physics.newRectangleShape( tetribodies[uniqueid], -32,-16, 32, 32)
tetrishapes[uniqueid][2] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,-16, 32, 32)
tetrishapes[uniqueid][3] = love.physics.newRectangleShape( tetribodies[uniqueid], 32,-16, 32, 32)
tetrishapes[uniqueid][4] = love.physics.newRectangleShape( tetribodies[uniqueid], -32,16, 32, 32)

elseif i == 4 then --O
tetribodies[uniqueid] = love.physics.newBody(world, x, y, 0, blockrot)
tetribodies[uniqueid] = love.physics.newBody(world, x, y, "dynamic"):setInertia(blockrot)
tetrishapes[uniqueid][1] = love.physics.newRectangleShape( tetribodies[uniqueid], -16,-16, 32, 32)
tetrishapes[uniqueid][2] = love.physics.newRectangleShape( tetribodies[uniqueid], -16,16, 32, 32)
tetrishapes[uniqueid][3] = love.physics.newRectangleShape( tetribodies[uniqueid], 16,16, 32, 32)
tetrishapes[uniqueid][4] = love.physics.newRectangleShape( tetribodies[uniqueid], 16,-16, 32, 32)

elseif i == 5 then --S
tetribodies[uniqueid] = love.physics.newBody(world, x, y, 0, blockrot)
tetribodies[uniqueid] = love.physics.newBody(world, x, y, "dynamic"):setInertia(blockrot)
tetrishapes[uniqueid][1] = love.physics.newRectangleShape( tetribodies[uniqueid], -32,16, 32, 32)
tetrishapes[uniqueid][2] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,-16, 32, 32)
tetrishapes[uniqueid][3] = love.physics.newRectangleShape( tetribodies[uniqueid], 32,-16, 32, 32)
tetrishapes[uniqueid][4] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,16, 32, 32)

elseif i == 6 then --T
tetribodies[uniqueid] = love.physics.newBody(world, x, y, 0, blockrot)
tetribodies[uniqueid] = love.physics.newBody(world, x, y, "dynamic"):setInertia(blockrot)
tetrishapes[uniqueid][1] = love.physics.newRectangleShape( tetribodies[uniqueid], -32,-16, 32, 32)
tetrishapes[uniqueid][2] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,-16, 32, 32)
tetrishapes[uniqueid][3] = love.physics.newRectangleShape( tetribodies[uniqueid], 32,-16, 32, 32)
tetrishapes[uniqueid][4] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,16, 32, 32)

elseif i == 7 then --Z
tetribodies[uniqueid] = love.physics.newBody(world, x, y, 0, blockrot)
tetribodies[uniqueid] = love.physics.newBody(world, x, y, "dynamic"):setInertia(blockrot)
tetrishapes[uniqueid][1] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,16, 32, 32)
tetrishapes[uniqueid][2] = love.physics.newRectangleShape( tetribodies[uniqueid], 0,-16, 32, 32)
tetrishapes[uniqueid][3] = love.physics.newRectangleShape( tetribodies[uniqueid], 32,16, 32, 32)
Expand All @@ -125,7 +130,7 @@ function createtetriA(i, uniqueid, x, y) --creates block, including body, shapes
tetribodies[uniqueid]:setBullet(true)

for i, v in pairs(tetrishapes[uniqueid]) do
v:setData({1})
v:setUserData({1})
end
end

Expand Down Expand Up @@ -550,7 +555,7 @@ function removeline(lineno) --Does all necessary things to clear a line. Refines
cotable[var], cotable[var+1] = tetribodies[i-ioffset]:getLocalPoint(cotable[var], cotable[var+1])
end
tetrishapes[i-ioffset][#tetrishapes[i-ioffset]+1] = love.physics.newPolygonShape(tetribodies[i-ioffset], unpack(cotable))
tetrishapes[i-ioffset][#tetrishapes[i-ioffset]]:setData({i-ioffset}) --set the shape name for collision
tetrishapes[i-ioffset][#tetrishapes[i-ioffset]]:setUserData({i-ioffset}) --set the shape name for collision
end
end

Expand Down Expand Up @@ -589,7 +594,7 @@ function removeline(lineno) --Does all necessary things to clear a line. Refines
cotable[var], cotable[var+1] = tetribodies[i-ioffset]:getLocalPoint(cotable[var], cotable[var+1])
end
tetrishapes[highestbody()][#tetrishapes[highestbody()]+1] = love.physics.newPolygonShape(tetribodies[highestbody()], unpack(cotable))
tetrishapes[highestbody()][#tetrishapes[highestbody()]]:setData({highestbody()}) --set the shape name for collision
tetrishapes[highestbody()][#tetrishapes[highestbody()]]:setUserData({highestbody()}) --set the shape name for collision
end
end

Expand Down Expand Up @@ -1186,7 +1191,7 @@ function collideA(a, b, coll) --box2d callback. calls endblock.
tetrishapes[highestbody()] = {}
for i, v in pairs(tetrishapes[1]) do
tetrishapes[highestbody()][i] = tetrishapes[1][i]
tetrishapes[highestbody()][i]:setData({highestbody()})
tetrishapes[highestbody()][i]:setUserData({highestbody()})
tetrishapes[1][i] = nil
end

Expand Down
69 changes: 15 additions & 54 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
function love.load()
-- add debug stuff for zbstudio
if arg[#arg] == "-debug" then require("mobdebug").start() end
-- set nearest neighbor filter before loading anything
love.graphics.setDefaultFilter('nearest', 'nearest')

--requires--
require "controls"
require "gameB"
Expand Down Expand Up @@ -93,7 +98,7 @@ function love.load()
musicoptions:setVolume( 1 )
musicoptions:setLooping( true )

boot = love.audio.newSource( "sounds/boot.ogg")
boot = love.audio.newSource( "sounds/boot.ogg", "stream")
blockfall = love.audio.newSource( "sounds/blockfall.ogg", "stream")
blockturn = love.audio.newSource( "sounds/turn.ogg", "stream")
blockmove = love.audio.newSource( "sounds/move.ogg", "stream")
Expand All @@ -109,7 +114,7 @@ function love.load()
changevolume(volume)

--IMAGES THAT WON'T CHANGE HUE:
rainbowgradient = love.graphics.newImage("graphics/rainbow.png")rainbowgradient:setFilter("nearest", "nearest")
rainbowgradient = love.graphics.newImage("graphics/rainbow.png")

--Whitelist for highscorenames--
whitelist = {}
Expand Down Expand Up @@ -242,7 +247,7 @@ function loadimages()
luigicry2 = newPaddedImage("graphics/versus/luigicry2.png")

--rockets--
rocket1 = newPaddedImage("graphics/rocket1.png");rocket1:setFilter( "nearest", "nearest" )
rocket1 = newPaddedImage("graphics/rocket1.png")
rocket2 = newPaddedImage("graphics/rocket2.png")
rocket3 = newPaddedImage("graphics/rocket3.png")
spaceshuttle = newPaddedImage("graphics/spaceshuttle.png")
Expand Down Expand Up @@ -274,49 +279,6 @@ function loadimages()
tetrisfont = newPaddedImageFont("graphics/font.png", "0123456789abcdefghijklmnopqrstTuvwxyz.,'C-#_>:<! ")
whitefont = newPaddedImageFont("graphics/fontwhite.png", "0123456789abcdefghijklmnopqrstTuvwxyz.,'C-#_>:<!+ ")
love.graphics.setFont(tetrisfont)

--filters!
stabyourselflogo:setFilter("nearest", "nearest")
logo:setFilter( "nearest", "nearest" )
title:setFilter( "nearest", "nearest" )
gametype:setFilter( "nearest", "nearest" )
mpmenu:setFilter( "nearest", "nearest" )
optionsmenu:setFilter( "nearest", "nearest" )
volumeslider:setFilter( "nearest", "nearest" )
gamebackground:setFilter( "nearest", "nearest" )
gamebackgroundcutoff:setFilter( "nearest", "nearest" )
gamebackgroundmulti:setFilter( "nearest", "nearest" )
multiresults:setFilter( "nearest", "nearest" )
number1:setFilter( "nearest", "nearest" )
number2:setFilter( "nearest", "nearest" )
number3:setFilter( "nearest", "nearest" )
gameover:setFilter( "nearest", "nearest" )
gameovercutoff:setFilter( "nearest", "nearest" )
pausegraphic:setFilter( "nearest", "nearest" )
pausegraphiccutoff:setFilter( "nearest", "nearest" )
marioidle:setFilter( "nearest", "nearest" )
mariojump:setFilter( "nearest", "nearest" )
mariocry1:setFilter( "nearest", "nearest" )
mariocry2:setFilter( "nearest", "nearest" )
luigiidle:setFilter( "nearest", "nearest" )
luigijump:setFilter( "nearest", "nearest" )
luigicry1:setFilter( "nearest", "nearest" )
luigicry2:setFilter( "nearest", "nearest" )
rocket2:setFilter( "nearest", "nearest" )
rocket3:setFilter( "nearest", "nearest" )
spaceshuttle:setFilter( "nearest", "nearest" )
rocketbackground:setFilter( "nearest", "nearest" )
bigrocketbackground:setFilter( "nearest", "nearest" )
bigrockettakeoffbackground:setFilter( "nearest", "nearest" )
smoke1left:setFilter( "nearest", "nearest" )
smoke1right:setFilter( "nearest", "nearest" )
smoke2left:setFilter( "nearest", "nearest" )
smoke2right:setFilter( "nearest", "nearest" )
fire1:setFilter( "nearest", "nearest" )
fire2:setFilter( "nearest", "nearest" )
firebig1:setFilter( "nearest", "nearest" )
firebig2:setFilter( "nearest", "nearest" )
congratsline:setFilter( "nearest", "nearest" )
end

function love.update(dt)
Expand Down Expand Up @@ -455,9 +417,8 @@ function newPaddedImageFont(filename, glyphs)
if wp ~= w or hp ~= h then
local padded = love.image.newImageData(wp, hp)
padded:paste(source, 0, 0)
local image = love.graphics.newImage(padded)
image:setFilter("nearest", "nearest")
return love.graphics.newImageFont(image, glyphs)
local extraspacing = 1
return love.graphics.newImageFont(padded, glyphs, extraspacing)
end

return love.graphics.newImageFont(source, glyphs)
Expand Down Expand Up @@ -529,7 +490,7 @@ function loadconfig()
end

function loadoptions()
if love.filesystem.exists("options.txt") then
if love.filesystem.getInfo("options.txt") then
local s = love.filesystem.read("options.txt")
local split1 = s:split("\n")
for i = 1, #split1 do
Expand Down Expand Up @@ -599,7 +560,7 @@ function saveoptions()
end

function autosize()
local modes = love.graphics.getModes()
local modes = love.window.getFullscreenModes()
desktopwidth, desktopheight = modes[1]["width"], modes[1]["height"]
end

Expand Down Expand Up @@ -635,7 +596,7 @@ function loadhighscores()
fileloc = "highscoresB.txt"
end

if love.filesystem.exists( fileloc ) then
if love.filesystem.getInfo( fileloc ) then

highdata = love.filesystem.read( fileloc )
highdata = highdata:split(";")
Expand Down Expand Up @@ -997,8 +958,8 @@ function love.keypressed( key, unicode )
changevolume(volume)
elseif optionsselection == 2 then
hue = 0.08
optionsmenu = newPaddedImage("graphics/options.png");optionsmenu:setFilter( "nearest", "nearest" )
volumeslider = newPaddedImage("graphics/volumeslider.png");volumeslider:setFilter( "nearest", "nearest" )
optionsmenu = newPaddedImage("graphics/options.png")
volumeslider = newPaddedImage("graphics/volumeslider.png")
elseif optionsselection == 3 then
if fullscreen == false then
if scale ~= suggestedscale then
Expand Down
8 changes: 4 additions & 4 deletions menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,17 @@ function menu_update(dt)
if hue < 0 then
hue = 0
end
optionsmenu = newPaddedImage("graphics/options.png");optionsmenu:setFilter( "nearest", "nearest" )
volumeslider = newPaddedImage("graphics/volumeslider.png");volumeslider:setFilter( "nearest", "nearest" )
optionsmenu = newPaddedImage("graphics/options.png")
volumeslider = newPaddedImage("graphics/volumeslider.png")
end
elseif love.keyboard.isDown("right") then
if hue < 1 then
hue = hue + 0.5*dt
if hue > 1 then
hue = 1
end
optionsmenu = newPaddedImage("graphics/options.png");optionsmenu:setFilter( "nearest", "nearest" )
volumeslider = newPaddedImage("graphics/volumeslider.png");volumeslider:setFilter( "nearest", "nearest" )
optionsmenu = newPaddedImage("graphics/options.png")
volumeslider = newPaddedImage("graphics/volumeslider.png")
end
end
end
Expand Down