diff --git a/Software/qlocktoo/app_ui.py b/Software/qlocktoo/app_ui.py index 0a59178..17d250b 100644 --- a/Software/qlocktoo/app_ui.py +++ b/Software/qlocktoo/app_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file './qlocktoo/app.ui' # -# Created: Wed Dec 4 14:09:58 2013 +# Created: Wed Dec 25 18:46:36 2013 # by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! diff --git a/Software/qlocktoo/assets/assets_rc.py b/Software/qlocktoo/assets/assets_rc.py index 816f9db..85244f4 100644 --- a/Software/qlocktoo/assets/assets_rc.py +++ b/Software/qlocktoo/assets/assets_rc.py @@ -2,8 +2,8 @@ # Resource object code # -# Created: Mi. Dez. 4 14:09:58 2013 -# by: The Resource Compiler for PySide (Qt v4.8.6) +# Created: Mi. Dez. 25 18:46:35 2013 +# by: The Resource Compiler for PySide (Qt v4.7.4) # # WARNING! All changes made in this file will be lost! diff --git a/Software/qlocktoo/connect/connect_ui.py b/Software/qlocktoo/connect/connect_ui.py index ffd475d..bde4a41 100644 --- a/Software/qlocktoo/connect/connect_ui.py +++ b/Software/qlocktoo/connect/connect_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file './qlocktoo/connect/connect.ui' # -# Created: Wed Dec 4 14:09:58 2013 +# Created: Wed Dec 25 18:46:36 2013 # by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! diff --git a/Software/qlocktoo/console/console_ui.py b/Software/qlocktoo/console/console_ui.py index 5a2d35c..4596562 100644 --- a/Software/qlocktoo/console/console_ui.py +++ b/Software/qlocktoo/console/console_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file './qlocktoo/console/console.ui' # -# Created: Wed Dec 4 14:09:58 2013 +# Created: Wed Dec 25 18:46:36 2013 # by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! diff --git a/Software/qlocktoo/demo/demo.ui b/Software/qlocktoo/demo/demo.ui index 308daff..f74e39f 100644 --- a/Software/qlocktoo/demo/demo.ui +++ b/Software/qlocktoo/demo/demo.ui @@ -128,11 +128,11 @@ Qt::ClickFocus - Pong + Pixeltest - :/icons/black32/fa-gamepad.png:/icons/black32/fa-gamepad.png + :/icons/black32/fa-qrcode.png:/icons/black32/fa-qrcode.png diff --git a/Software/qlocktoo/demo/demo_ui.py b/Software/qlocktoo/demo/demo_ui.py index 59c0e95..5db83e2 100644 --- a/Software/qlocktoo/demo/demo_ui.py +++ b/Software/qlocktoo/demo/demo_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file './qlocktoo/demo/demo.ui' # -# Created: Wed Dec 4 14:09:58 2013 +# Created: Wed Dec 25 18:46:36 2013 # by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! @@ -70,7 +70,7 @@ def setupUi(self, demoapp): self.pong.setSizePolicy(sizePolicy) self.pong.setFocusPolicy(QtCore.Qt.ClickFocus) icon3 = QtGui.QIcon() - icon3.addPixmap(QtGui.QPixmap(":/icons/black32/fa-gamepad.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon3.addPixmap(QtGui.QPixmap(":/icons/black32/fa-qrcode.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.pong.setIcon(icon3) self.pong.setIconSize(QtCore.QSize(32, 32)) self.pong.setAutoDefault(False) @@ -161,7 +161,7 @@ def retranslateUi(self, demoapp): self.fade.setText(QtGui.QApplication.translate("demoapp", "Verlauf", None, QtGui.QApplication.UnicodeUTF8)) self.helix.setText(QtGui.QApplication.translate("demoapp", "Helix", None, QtGui.QApplication.UnicodeUTF8)) self.wave.setText(QtGui.QApplication.translate("demoapp", "Welle", None, QtGui.QApplication.UnicodeUTF8)) - self.pong.setText(QtGui.QApplication.translate("demoapp", "Pong", None, QtGui.QApplication.UnicodeUTF8)) + self.pong.setText(QtGui.QApplication.translate("demoapp", "Pixeltest", None, QtGui.QApplication.UnicodeUTF8)) self.pulse.setText(QtGui.QApplication.translate("demoapp", "Puls", None, QtGui.QApplication.UnicodeUTF8)) self.white.setText(QtGui.QApplication.translate("demoapp", "Weiß", None, QtGui.QApplication.UnicodeUTF8)) self.black.setText(QtGui.QApplication.translate("demoapp", "Schwarz", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/Software/qlocktoo/marquee/marquee_ui.py b/Software/qlocktoo/marquee/marquee_ui.py index 3fb2250..bd4471b 100644 --- a/Software/qlocktoo/marquee/marquee_ui.py +++ b/Software/qlocktoo/marquee/marquee_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file './qlocktoo/marquee/marquee.ui' # -# Created: Wed Dec 4 14:09:58 2013 +# Created: Wed Dec 25 18:46:36 2013 # by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! diff --git a/Software/qlocktoo/settings/settings_ui.py b/Software/qlocktoo/settings/settings_ui.py index e65d1a0..41444e8 100644 --- a/Software/qlocktoo/settings/settings_ui.py +++ b/Software/qlocktoo/settings/settings_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file './qlocktoo/settings/settings.ui' # -# Created: Wed Dec 4 14:09:58 2013 +# Created: Wed Dec 25 18:46:36 2013 # by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! diff --git a/Software/qlocktoo/snake/snake.py b/Software/qlocktoo/snake/snake.py index d9a7b64..543dd93 100644 --- a/Software/qlocktoo/snake/snake.py +++ b/Software/qlocktoo/snake/snake.py @@ -34,8 +34,8 @@ def __init__(self, device): self.snake = SnakeModel( width=self.device.columns, height=self.device.rows, - gameOverCallback=self.gameOver, - ateFoodCallback=self.ateFood) + gameover_callback=self.gameOver, + atefood_callback=self.ateFood) self.highscore = 0 self.pause = False @@ -49,13 +49,13 @@ def keyPressEvent(self, event): self.snake.reset() self.stepTimer.start(1000 / self.stepFrequency) elif key == Qt.Key_Left: - self.snake.setSnakeDirection(-1, 0) + self.snake.set_snake_direction(-1, 0) elif key == Qt.Key_Right: - self.snake.setSnakeDirection(1, 0) + self.snake.set_snake_direction(1, 0) elif key == Qt.Key_Down: - self.snake.setSnakeDirection(0, 1) + self.snake.set_snake_direction(0, 1) elif key == Qt.Key_Up: - self.snake.setSnakeDirection(0, -1) + self.snake.set_snake_direction(0, -1) else: QDialog.keyPressEvent(self, event) diff --git a/Software/qlocktoo/snake/snake_model.py b/Software/qlocktoo/snake/snake_model.py index 077f5cf..dc3d890 100644 --- a/Software/qlocktoo/snake/snake_model.py +++ b/Software/qlocktoo/snake/snake_model.py @@ -8,58 +8,78 @@ class SnakeModel(object): """ def __init__(self, width, height, - gameOverCallback, ateFoodCallback): - self._width = width - self._height = height - self._gameover = gameOverCallback - self._ateFood = ateFoodCallback + gameover_callback, atefood_callback): + """ + Initializes the game + + gameover_callback and atefood_callback are callback functions. They + are passed the current player score (length of the snake's tail) as an + integer. + """ + self.width = width + self.height = height + self.gameover_callback = gameover_callback + self.atefood_callback = atefood_callback self.reset() def reset(self): """ - Starts a new game + Starts a new game. + + Sets the starting position, length and direction of the snake as well + as the position of the first food item. """ self._dir = (0, -1) # You can read head, tail and food directly for drawing - self.head = (self._width / 2, self._height - 2) - self.tail = [(self._width / 2, self._height - 1)] - self.food = (self._width / 2, self._height / 3) + self.head = (self.width / 2, self.height - 2) + self.tail = [(self.width / 2, self.height - 1)] + self.food = (self.width / 2, self.height / 3) def step(self): """ - Generates the next game frame + Advances the game one step """ # check for collisions if self.head in self.tail: - self._gameover(len(self.tail)) + self.gameover_callback(len(self.tail)) # eat food if self.head == self.food: self.tail.insert(0, self.head) - self.food = self._newFoodLocation() - self._ateFood(len(self.tail)) + self.food = self._new_food_location() + self.atefood_callback(len(self.tail)) # move snake - self._moveSnake(*self._dir) + self._move_snake() - def setSnakeDirection(self, dx, dy): + def set_snake_direction(self, dx, dy): """ Sets the direction the snake will move on the next step """ self._dir = (dx, dy) - def _moveSnake(self, dx, dy): + def _move_snake(self): + """ + Moves the snake one step in the given direction. + + The snake can move through the game area's borders and comes out on the + other side. + """ x, y = self.head - newX = (x + dx) % self._width - newY = (y + dy) % self._height + dx, dy = self._dir + newX = (x + dx) % self.width + newY = (y + dy) % self.height self.head = (newX, newY) self.tail.insert(0, (x, y)) self.tail.pop() - def _newFoodLocation(self): - game_field = set([(x, y) for x in range(self._width) - for y in range(self._height)]) + def _new_food_location(self): + """ + Returns a new possible food position which is not in the snake. + """ + game_field = set([(x, y) for x in range(self.width) + for y in range(self.height)]) possible = game_field - set(self.tail) - set([self.head]) - newPosition = random.choice(list(possible)) - return newPosition + new_position = random.choice(list(possible)) + return new_position diff --git a/Software/qlocktoo/snake/snake_ui.py b/Software/qlocktoo/snake/snake_ui.py index 00c8d0f..e40781f 100644 --- a/Software/qlocktoo/snake/snake_ui.py +++ b/Software/qlocktoo/snake/snake_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file './qlocktoo/snake/snake.ui' # -# Created: Wed Dec 4 14:09:58 2013 +# Created: Wed Dec 25 18:46:36 2013 # by: pyside-uic 0.2.15 running on PySide 1.2.1 # # WARNING! All changes made in this file will be lost! diff --git a/TODO b/TODO index 366eb61..46f4b2e 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ Firmware: - ☐ Datum - ☐ Matrix + ☐ Datum Laufschrift ☐ Checksumme bei streaming ☐ Blockierender Stream @@ -16,11 +15,11 @@ Wünsche von Marlene: Carsti und Manu´s Wünsche: ☐ GoL direkt auf der Uhr - ☐ Matrix direkt auf der Uhr ☐ Malprogramm - Simulator ___________________ Archive: + ✔ Matrix direkt auf der Uhr @done (13-12-22 22:43) @project(Carsti und Manu´s Wünsche) ✔ Pixeltest @done (13-12-16 15:38) @project(Software) ✔ Temperatur @done (13-12-13 14:32) @project(Firmware) ✔ Matrix Demo @done (13-12-13 14:32) @project(Software)