From e0b4ed025148558365edcf330fcdbcf90414402d Mon Sep 17 00:00:00 2001 From: frank Date: Wed, 30 Nov 2022 20:16:12 -0500 Subject: [PATCH] add event to calendar, only import GPIO if necessary --- .gitignore | 1 + NS.py | 24 ++++++++++++++++++++++-- config | 6 +++--- www/index.php | 16 ++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5e7a9e7..4523dc5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ lib/python3.9/ pyvenv.cfg lib/python* stat/ +www/scrapeboard_new.gif diff --git a/NS.py b/NS.py index 383581a..28175fc 100644 --- a/NS.py +++ b/NS.py @@ -31,7 +31,6 @@ from pygame.draw import aalines, lines from pygame.gfxdraw import aapolygon, arc, polygon, aaellipse, ellipse, filled_ellipse, filled_circle from pygame.locals import * -import gpio from lib.pgfw.pgfw.Game import Game from lib.pgfw.pgfw.GameChild import GameChild from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite, BlinkingSprite @@ -239,6 +238,8 @@ class NS(Game, Animation): # init Pi if self.pi_enabled(): + import gpio + # Initialize GPIO interface gpio.initialize_gpio() @@ -1045,12 +1046,25 @@ class Logo(Sprite): class Title(Animation): """ - Handles displaying and drawing the title screen. + Handles displaying and drawing the title screen. It draws the high scores, creates and updates an attract mode video pop-up, tracks + the player's moves and checks if they are doing the start game pattern, and updates the background logo and giant Tony sprite. + + Notes + ----- + + * It should be directed to draw scores when a new score is added (and only then), and it will store the score surfaces and only blit + them once when activated (unless the scores are updated). This way it only blits that section of the screen once. """ + # Sequence of moves the player must do to start the game UNLOCK_MOVES = NS.NW, NS.N, NS.NE, NS.S def __init__(self, parent): + """ + Create an object for the attract mode video pop-up. + + @param parent GameChild object that will connect this GameChild object to the overall tree and root Game object + """ Animation.__init__(self, parent) ds = self.get_display_surface() dsr = ds.get_rect() @@ -1062,12 +1076,18 @@ class Title(Animation): self.score_sprites = [] def reset(self): + """ + Set the unlock progress back to zero. Start glowing the first move in the unlock pattern. Halt all animations. Unhide video. + """ self.unlock_index = 0 self.get_game().platform.set_glowing(self.get_game().platform.get_buttons_from_edges([self.UNLOCK_MOVES[0]])) self.halt() self.show_video() def activate(self): + """ + Activate platform, Tony, and player objects as well. Start playing the BGM. + """ self.active = True platform = self.get_game().platform platform.activate() diff --git a/config b/config index afafbd6..4129450 100644 --- a/config +++ b/config @@ -22,7 +22,7 @@ data-exclude = local/, *.pyc, .git*, README, build/, dist/, *.egg-info, *.py, MA [display] caption = Scrapeboard -show-framerate = yes +show-framerate = yes dimensions = 800, 450 fullscreen = no attract-gif-alpha = 1.0 @@ -60,9 +60,9 @@ volume = 1.0 [input] buffer = 0 arduino-port = /dev/ttyACM0 -serial = no +serial = no pi = no -confirm-quit = no +confirm-quit = no [time] timer-max-time = 10000 diff --git a/www/index.php b/www/index.php index c32f5b7..db7b219 100644 --- a/www/index.php +++ b/www/index.php @@ -302,6 +302,8 @@ + +