Commits

Anonymous committed 7dde8b8

fixing pause

Comments (0)

Files changed (19)

doc/files/classes/board.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/classes/object.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/classes/sensor.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/conf.html

 	</li>
 
 	<li>
+		<a href="../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/lib/SECS.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/lib/SaveTableToFile.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/lib/gamestate.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/main.html

 	</li>
 
 	<li>
+		<a href="../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/states/game.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/states/gameover.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/states/intro.html

 	</li>
 
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/states/menu.html

 	<li><strong>states/menu.lua</strong></li>
 	
 	<li>
+		<a href="../../files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="../../files/utils.html">utils.lua</a>
 	</li>
 

doc/files/states/pause.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+    <title>Reference</title>
+    <link rel="stylesheet" href="../../luadoc.css" type="text/css" />
+	<!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
+</head>
+
+<body>
+<div id="container">
+
+<div id="product">
+	<div id="product_logo"></div>
+	<div id="product_name"><big><b></b></big></div>
+	<div id="product_description"></div>
+</div> <!-- id="product" -->
+
+<div id="main">
+
+<div id="navigation">
+
+
+<h1>LuaDoc</h1>
+<ul>
+	
+	<li><a href="../../index.html">Index</a></li>
+	
+</ul>
+
+
+<!-- Module list -->
+
+
+
+<!-- File list -->
+
+<h1>Files</h1>
+<ul>
+
+	<li>
+		<a href="../../files/classes/board.html">classes/board.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/classes/object.html">classes/object.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/classes/sensor.html">classes/sensor.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/conf.html">conf.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/lib/SECS.html">lib/SECS.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/lib/SaveTableToFile.html">lib/SaveTableToFile.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/lib/gamestate.html">lib/gamestate.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/main.html">main.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/states/game.html">states/game.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/states/gameover.html">states/gameover.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/states/intro.html">states/intro.lua</a>
+	</li>
+
+	<li>
+		<a href="../../files/states/menu.html">states/menu.lua</a>
+	</li>
+
+	<li><strong>states/pause.lua</strong></li>
+	
+	<li>
+		<a href="../../files/utils.html">utils.lua</a>
+	</li>
+
+</ul>
+
+
+
+
+
+
+</div> <!-- id="navigation" -->
+
+<div id="content">
+
+<h1>File <code>states/pause.lua</code></h1>
+
+
+
+
+
+
+
+
+
+
+
+
+<br/>
+<br/>
+
+
+
+
+
+
+
+
+
+
+</div> <!-- id="content" -->
+
+</div> <!-- id="main" -->
+
+<div id="about">
+	<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
+</div> <!-- id="about" -->
+
+</div> <!-- id="container" -->	
+</body>
+</html>

doc/files/utils.html

 		<a href="../files/states/menu.html">states/menu.lua</a>
 	</li>
 
+	<li>
+		<a href="../files/states/pause.html">states/pause.lua</a>
+	</li>
+
 	<li><strong>utils.lua</strong></li>
 	
 </ul>
 	</li>
 
 	<li>
+		<a href="files/states/pause.html">states/pause.lua</a>
+	</li>
+
+	<li>
 		<a href="files/utils.html">utils.lua</a>
 	</li>
 
 	</tr>
 
 	<tr>
+		<td class="name"><a href="files/states/pause.html">states/pause.lua</a></td>
+		<td class="summary"></td>
+	</tr>
+
+	<tr>
 		<td class="name"><a href="files/utils.html">utils.lua</a></td>
 		<td class="summary"></td>
 	</tr>
 require("states/intro")
 require("states/menu")
 require("states/game")
+require("states/pause")
 require("states/gameover")
 
 --- love.load 
     state.level = 0
     state.speed = 0
     state.trans_y = 300
+
+    state:newLevel(state.level)
+    
+  elseif action == "from_pause" then
+  	-- nothing
   else
   	-- other init action?
   end
   -- graphics
   love.graphics.setBackgroundColor(0, 0, 0)
 
-  state:newLevel(state.level)
-
   -- enable input
   state.inputenabled = true
 
   love.graphics.setColor(255, 255, 255, 255)
   love.graphics.setFont(state.font20)
   love.graphics.print("Astertris", 20, 60, -0.3)
-  --love.graphics.printf("GAME PLACEHOLDER", 100,300,600,'center')
-  --love.graphics.printf("esc to exit and return to menu", 100,320,600,'center')
   if state.next then
   	state.next:draw()
   end
     debug.debug()
   elseif key == "escape" then
     Gamestate.switch(Gamestate.menu)
+  elseif key == "p" then
+    Gamestate.switch(Gamestate.pause)
   end
 end
 
+--- pause gamestate
+Gamestate.pause = Gamestate.new()
+local state = Gamestate.pause
+
+-- constant
+
+-- state variables
+Gamestate.pause.screenshot = nil
+Gamestate.pause.font10 = nil
+Gamestate.pause.font20 = nil
+Gamestate.pause.pre_gamestate = nil
+
+function state:enter(pre)
+  
+  state.pre_gamestate = pre
+  state.screenshot = newPaddedImage(nil,love.graphics.newScreenshot())
+  
+  -- fonts
+  if not state.font10 then state.font10 = love.graphics.newFont(10) end
+  if not state.font20 then state.font20 = love.graphics.newFont(20) end
+
+  -- graphics
+  love.graphics.setBackgroundColor(0, 0, 0)
+
+end
+
+function state:leave()
+end
+
+function state:update(dt)
+end
+
+function state:draw()
+	-- last screenshot
+  if state.screenshot ~= nil then
+  	love.graphics.draw(state.screenshot,0,0)
+  end
+  -- gui
+  --
+  --
+  love.graphics.setColor(255, 255, 255, 255)
+  love.graphics.setFont(state.font20)
+  love.graphics.print("Astertris", 20, 60, -0.3)
+  love.graphics.printf("PAUSED", 100,300,600,'center')
+  love.graphics.printf("esc or mouse click to exit", 100,320,600,'center')
+  
+end
+
+function state:keypressed(key, unicode)
+  if key == "rctrl" then
+    debug.debug()
+  elseif key == "escape" then
+    Gamestate.switch(self.pre_gamestate, "from_pause")
+  end
+end
+
+function state:mousepressed(x, y, button)
+	Gamestate.switch(self.pre_gamestate, "from_pause")
+end
+
+function state:mousereleased(x, y, button)
+end
+
 
     return str 
 end 
+
+-- taken from http://love2d.org/wiki/ImageData
+function newPaddedImage(filename,imagedata)
+	  local source 
+	  if filename ~= nil and filename ~= "" then
+      source = love.image.newImageData(filename)
+    else
+    	source = imagedata
+    end
+    local w, h = source:getWidth(), source:getHeight()
+    
+    -- Find closest power-of-two.
+    local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
+    local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
+    
+    -- Only pad if needed:
+    if wp ~= w or hp ~= h then
+        local padded = love.image.newImageData(wp, hp)
+        padded:paste(source, 0, 0)
+        return love.graphics.newImage(padded)
+    end
+    
+    return love.graphics.newImage(source)
+end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.