1. Samuel Jackson
  2. Tetris

Commits

Samuel Jackson  committed 43e8b6f

Stopped blocks being forced to the bottom when off screen. Made more randomness.

  • Participants
  • Parent commits 7625cce
  • Branches default

Comments (0)

Files changed (2)

File main.lua

View file
 Game.displayMenu = true
 Game.paused = false
 Game.EOG = false
+
 ----------------------------
 --Requirements
 ----------------------------
 end
 
 function love.update(dt)
+	math.randomseed(os.time() + dt)
 	tmr = tmr + dt
 
 	if Game.paused == false and Game.EOG == false then
 		local linesThisDelta = checkLine()
 		Game.lineCount = Game.lineCount + linesThisDelta
 		Game.EOG = checkGameOver()
-		print(Game.EOG)
 		Game.score = Game.score + (linesThisDelta * 10)
 		
 		if Game.lineCount % 5 == 0 and linesThisDelta ~= 0 then
 	end
 	
 	if e == "down" then
-		local flag = false
-		while flag == false do
-			if currentBlock:checkHitFloor() == false and checkHitBlock() == false then
-				currentBlock:down()
-			else
-				makeNewBlock()
-				flag = true
+		if currentBlock:checkOnScreen() == true then
+			local flag = false
+			while flag == false do
+				if currentBlock:checkHitFloor() == false and checkHitBlock() == false then
+					currentBlock:down()
+				else
+					makeNewBlock()
+					flag = true
+				end
 			end
 		end
 	end
 	for i,v in ipairs(currentBlock.blockArray) do
 		table.insert(DrawList, v)
 	end
-	math.randomseed(os.time())
 	currentBlock = Shape:new()
 	currentBlock:initShape()
 end

File shape.lua

View file
 	
 end
 
+function Shape:checkOnScreen()
+	for i,v in ipairs(self.blockArray) do
+		if v.row > 0 then
+			return true
+		end
+	end
+	return false
+end
+
 function Shape:move(e)
 
 	if e == "left" then