Permalink
Browse files

Fix for IE version of lightout game

  • Loading branch information...
1 parent 0d1eeb7 commit 11a3680672a7e39b58e880d711dbdc0cdd045dd7 @rkirov rkirov committed with keesbos Apr 27, 2011
Showing with 18 additions and 27 deletions.
  1. +10 −6 examples/lightout/lightout.py
  2. +6 −5 examples/lightout/public/lightout.css
  3. +2 −16 examples/lightout/public/lightout.html
@@ -15,6 +15,9 @@
from pyjamas import DOM
from pyjamas.ui.FocusWidget import FocusWidget
+
+game = None
+
class GridCell(FocusWidget):
def __init__(self,i,j):
self.i = i
@@ -39,11 +42,10 @@ def toggle(self):
self.light = True
self.redraw()
- def onClick(self, sender):
+ def onClick(self,sender):
if self.i>0:
self.parent.getWidget(self.i-1,self.j).toggle()
if self.i<self.parent.getRowCount()-1:
- print self.i+1, self.j
self.parent.getWidget(self.i+1,self.j).toggle()
if self.j>0:
self.parent.getWidget(self.i,self.j-1).toggle()
@@ -65,9 +67,11 @@ class Game(SimplePanel):
def __init__(self,level):
self.level = level
SimplePanel.__init__(self)
- self.start_game()
+ self.start_game(self.level)
- def start_game(self):
+ def start_game(self, level=None):
+ if level is not None:
+ self.level = level
dim = self.level
grid = Grid(dim,dim)
grid.setStyleName("grid")
@@ -81,10 +85,10 @@ def next_level(self):
self.remove(self.getWidget())
self.level+=1
self.start_game()
-
+
+
if __name__ == '__main__':
pyjd.setup("public/lightout.html")
game = Game(3)
RootPanel('game').add(game)
- #RootPanel().add(game)
pyjd.run()
@@ -1,13 +1,15 @@
.on {
- padding: 10px;
+ height: 20px;
+ width: 20px;
background-color: #C8C506;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
}
.off {
- padding: 10px;
+ height: 20px;
+ width: 20px;
background-color: #111;
-moz-user-select: none;
-webkit-user-select: none;
@@ -21,11 +23,10 @@
margin: 0px;
}
-#footer{
+#footer {
position:relative;
left:-100px;
text-align:right;
color:#555;
font:italic 10px Arial;
- }
-
+}
@@ -1,7 +1,4 @@
<html>
- <!-- auto-generated html - you should consider editing and
- adapting this to suit your requirements
- -->
<head>
<meta name="pygwt:module" content="lightout">
<link rel='stylesheet' href='lightout.css'>
@@ -12,22 +9,11 @@
<h2>Lights Out</h2>
<div id="game"></div>
<p>Click on a cell to turn it off, but watch out the neighbors will follow. Your goal is to turn off all the cells.</p>
- <div id="footer"><p><a href="lightout.zip">Get the Source Code</a><br>Created by <a href="http://www.math.uiuc.edu/~rkirov2/">Radoslav Kirov<a> <br>with <a href="http://pyjs.org">Pyjamas</a> (python port of Google's <a href="http://code.google.com/p/google-web-toolkit/">GWT</a>)<br> <a rel="license"
+ <div id="footer"><p><a href="lightout.zip">Get the Source Code</a><br>Created by <a href="http://radokirov.com">Radoslav Kirov<a> <br>with <a href="http://pyjs.org">Pyjamas</a> (python port of Google's <a href="http://code.google.com/p/google-web-toolkit/">GWT</a>)<br> <a rel="license"
href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">
<img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/us/80x15.png" />
</a>
</p>
-
</div>
-<script type="text/javascript">
-var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
-document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
-</script>
-<script type="text/javascript">
-try {
-var pageTracker = _gat._getTracker("UA-360383-3");
-pageTracker._trackPageview();
-} catch(err) {}</script>
-
- </body>
+</body>
</html>

0 comments on commit 11a3680

Please sign in to comment.