This are some changes to inkspill. Once you've made a click on a
color, clicking on "Reset" restarts the game so you can try it again.
When you haven't made a move already, clicking on "Reset" generates a
new game. My python experience is still limited, maybe someone could
comment my changes.
Furtheron I removed the "fsoraw -r Display" from
/usr/share/applications/inkspill.desktop to save battery.
--- /usr/lib/python2.6/site-packages/inkspill/main.py.orig 2010-11-06 19:15:09.000000000 +0100
+++ /usr/lib/python2.6/site-packages/inkspill/main.py 2010-11-07 00:49:11.000000000 +0100
@@ -20,6 +20,7 @@
import math
import pygame
from pygame.locals import *
+from copy import deepcopy
from Button import Button
@@ -72,6 +73,7 @@
def main(options):
global MAINCLOCK, MAINSURF, WINDOWWIDTH, WINDOWHEIGHT
global mainBoard, life, lastPaletteClicked
+ global mainBoardSaved
pygame.display.init()
MAINCLOCK = pygame.time.Clock()
@@ -97,15 +99,33 @@
resetGame()
else:
redrawMain()
+
settingsButton = Button(SETTINGSBUTTONIMAGE, (70, 70), settingsHandler)
def resetGame():
global mainBoard, life, lastPaletteClicked
+ global mainBoardSaved
mainBoard = generateRandomBoard(COLS, ROWS, DIFFICULTY)
+ mainBoardSaved = deepcopy(mainBoard)
life = MAXLIFE
lastPaletteClicked = None
redrawMain()
- resetButton = Button(RESETBUTTONIMAGE, (70, 20), resetGame)
+
+ def restartGame():
+ global mainBoard, life, lastPaletteClicked
+ global mainBoardSaved
+
+ if life == MAXLIFE:
+ mainBoard = generateRandomBoard(COLS, ROWS, DIFFICULTY)
+ mainBoardSaved = deepcopy(mainBoard)
+ else:
+ mainBoard = deepcopy(mainBoardSaved)
+
+ life = MAXLIFE
+ lastPaletteClicked = None
+ redrawMain()
+
+ resetButton = Button(RESETBUTTONIMAGE, (70, 20), restartGame)
resetGame()
_______________________________________________
Shr-devel mailing list
[email protected]
http://lists.shr-project.org/mailman/listinfo/shr-devel