function CheckHealth(p1, p2) if p1.health == 0 then HasP2Won = true elseif p2.health == 0 then HasP1Won = true end end function updateGame(dt) TimeToPlaceWall = TimeToPlaceWall - dt if TimeToPlaceWall <= 0 then --place a wall at a random location local ranx = love.math.random(100, 1000) local rany = love.math.random(100, 600) local ranw = love.math.random(100, 500) local ranh = love.math.random(20, 80) local lifetime = love.math.random(4, 10) local wall = Wall(ranx, rany, ranw, ranh, lifetime) table.insert(Walls, wall) TimeToPlaceWall = TIMER --reset the timer end -- Walls Updates for i, v in ipairs(Walls) do v:update(dt) end -- Check the players health CheckHealth(UserPlayer1, UserPlayer2) -- Bullets Updates for i, v in ipairs(Bullets1) do v:update(dt) if v.y < 0 then --top of screen table.remove(Bullets1, i) elseif v.y > love.graphics.getHeight() then --bottom of screen table.remove(Bullets1, i) end end for i, v in ipairs(Bullets2) do v:update(dt) if v.y < 0 then --top of screen table.remove(Bullets2, i) elseif v.y > love.graphics.getHeight() then --bottom of screen table.remove(Bullets2, i) end end -- Player Updates UserPlayer1:update(dt) UserPlayer2:update(dt) end