Commits

James McMahon committed 19c7040

Comments and better variable name for player pace

  • Participants
  • Parent commits 719726c

Comments (0)

Files changed (1)

 bullets = {}
 
 function love.update(dt)
+	-- Handle Pause
 	if love.keyboard.isDown('p') then
 		paused = not paused
 	end
-
 	if paused then return end
 
-	local pace = speed * dt
+	-- Update Player
+	local playerPace = speed * dt
 	if love.keyboard.isDown('w') then
-		y = y - pace
+		y = y - playerPace
 	elseif love.keyboard.isDown('s') then
-		y = y + pace
+		y = y + playerPace
+	end
+	if love.keyboard.isDown('a') then
+		x = x - playerPace
+	elseif love.keyboard.isDown('d') then
+		x = x + playerPace
 	end
 
-	if love.keyboard.isDown('a') then
-		x = x - pace
-	elseif love.keyboard.isDown('d') then
-		x = x + pace
-	end
-
+	-- Create Bullets
 	-- TODO support for 8 axis bullets (up + left etc)
 	local bulletDirection = nil
 	if love.keyboard.isDown('up') then
 		table.insert(bullets, b)
 	end
 	
+	-- Update Bullets
 	local bulletPace = bulletSpeed * dt
 	for _, b in ipairs(bullets) do
 		local newX = b.x