Update stuff
This commit is contained in:
parent
82aadf6034
commit
bf08a808a1
@ -3,6 +3,7 @@
|
|||||||
become_user: root
|
become_user: root
|
||||||
tasks:
|
tasks:
|
||||||
- synchronize: src=../.. dest=/home/pi/sejf
|
- synchronize: src=../.. dest=/home/pi/sejf
|
||||||
|
- file: path=/etc/xdg/autostart/pprompt.desktop state=absent
|
||||||
- copy: src=autostart dest=/home/pi/.config/lxsession/LXDE-pi/autostart
|
- copy: src=autostart dest=/home/pi/.config/lxsession/LXDE-pi/autostart
|
||||||
- copy: src=sejf.desktop dest=/etc/xdg/autostart
|
- copy: src=sejf.desktop dest=/etc/xdg/autostart
|
||||||
- apt: name=python-flask state=present
|
- apt: name=python-flask state=present
|
||||||
|
124
raspi/pySejf.py
124
raspi/pySejf.py
@ -22,6 +22,27 @@ from math import cos
|
|||||||
import time
|
import time
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
|
||||||
|
class Slide(object):
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def render(self, screen):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def handle(self, ev):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ImageSlide(Slide):
|
||||||
|
def __init__(self, image):
|
||||||
|
self.image = image
|
||||||
|
|
||||||
|
def render(self, screen):
|
||||||
|
screen.fill(WHITE)
|
||||||
|
screen.blit(self.image, (0, 0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
#gameplay
|
#gameplay
|
||||||
@ -155,7 +176,19 @@ SLIDE_SNAKE_DEAD = 10 #to nie slajd, tylko wartosc potrzebna do resetowania snak
|
|||||||
global slide
|
global slide
|
||||||
#slajd poczatkowy
|
#slajd poczatkowy
|
||||||
slide = SLIDE_START
|
slide = SLIDE_START
|
||||||
slides = [SLIDE_START,SLIDE_KEY,SLIDE_POT,SLIDE_FOAMBTN,SLIDE_SNAKE,SLIDE_KEYPAD,SLIDE_MAZE,SLIDE_MP3,SLIDE_KEYBOARD,SLIDE_CONGRATS]
|
slides = {
|
||||||
|
SLIDE_START: ImageSlide(IMG_HELLO),
|
||||||
|
SLIDE_KEY: ImageSlide(IMG_KEY),
|
||||||
|
SLIDE_POT: ImageSlide(IMG_POT),
|
||||||
|
SLIDE_FOAMBTN: ImageSlide(IMG_FOAMBTN),
|
||||||
|
#SLIDE_SNAKE,
|
||||||
|
SLIDE_DYNAMO: ImageSlide(IMG_DYNAMO),
|
||||||
|
SLIDE_KEYPAD: ImageSlide(IMG_KEYPAD),
|
||||||
|
SLIDE_MAZE: ImageSlide(IMG_KEYPAD),
|
||||||
|
SLIDE_MP3: ImageSlide(IMG_MP3),
|
||||||
|
#SLIDE_KEYBOARD,
|
||||||
|
#SLIDE_CONGRATS: ImageSlide(IMG_WIN)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def win():
|
def win():
|
||||||
@ -222,7 +255,6 @@ def waitForEvents():
|
|||||||
slide = SLIDE_KEYBOARD
|
slide = SLIDE_KEYBOARD
|
||||||
print("mouse event")
|
print("mouse event")
|
||||||
return
|
return
|
||||||
|
|
||||||
elif event.type == pygame.KEYDOWN:
|
elif event.type == pygame.KEYDOWN:
|
||||||
if slide != SLIDE_SNAKE:
|
if slide != SLIDE_SNAKE:
|
||||||
slide = SLIDE_SNAKE
|
slide = SLIDE_SNAKE
|
||||||
@ -231,7 +263,6 @@ def waitForEvents():
|
|||||||
print("keydown event")
|
print("keydown event")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def checkEvents():
|
def checkEvents():
|
||||||
global slide
|
global slide
|
||||||
if GPIO.input(PIN_SET1) == 0 and slide != SLIDE_KEY:
|
if GPIO.input(PIN_SET1) == 0 and slide != SLIDE_KEY:
|
||||||
@ -300,14 +331,7 @@ def die(screen, score):
|
|||||||
pygame.time.wait(2000)
|
pygame.time.wait(2000)
|
||||||
waitForEvents()
|
waitForEvents()
|
||||||
|
|
||||||
def main():
|
############# old main
|
||||||
global slide
|
|
||||||
|
|
||||||
startonce = 0
|
|
||||||
showstartscreen = 0
|
|
||||||
|
|
||||||
while startonce == 0:
|
|
||||||
startonce = 0
|
|
||||||
######## CONSTANTS
|
######## CONSTANTS
|
||||||
WINSIZE = [WINSIZEX,WINSIZEY]
|
WINSIZE = [WINSIZEX,WINSIZEY]
|
||||||
BLOCKSIZE = [18,18]
|
BLOCKSIZE = [18,18]
|
||||||
@ -343,12 +367,8 @@ def main():
|
|||||||
growsnake = 0 # added to grow tail by two each time
|
growsnake = 0 # added to grow tail by two each time
|
||||||
snakegrowunit = 2 # added to grow tail by two each time
|
snakegrowunit = 2 # added to grow tail by two each time
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
screen = pygame.display.set_mode(WINSIZE, pygame.NOFRAME)#FULLSCREEN)
|
screen = pygame.display.set_mode(WINSIZE, pygame.NOFRAME)
|
||||||
#screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
|
||||||
pygame.display.set_caption('PozySejf')
|
pygame.display.set_caption('PozySejf')
|
||||||
pygame.FULLSCREEN
|
|
||||||
#screen = display.set_mode([1024,768], FULLSCREEN)
|
|
||||||
#screen.fill(BLACK)
|
|
||||||
dynamoValSPI = [0,0,0]
|
dynamoValSPI = [0,0,0]
|
||||||
dynamoRectY = [50, 50, 50]
|
dynamoRectY = [50, 50, 50]
|
||||||
dynamoRectX = 50
|
dynamoRectX = 50
|
||||||
@ -360,40 +380,25 @@ def main():
|
|||||||
valueSound = 100
|
valueSound = 100
|
||||||
|
|
||||||
passwordLetter = ''
|
passwordLetter = ''
|
||||||
|
|
||||||
|
############# old main
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global slide
|
||||||
|
|
||||||
|
startonce = 0
|
||||||
|
showstartscreen = 0
|
||||||
|
|
||||||
|
while startonce == 0:
|
||||||
|
startonce = 0
|
||||||
#### show initial start screen
|
#### show initial start screen
|
||||||
### every while loop for each slide
|
### every while loop for each slide
|
||||||
while slide == SLIDE_START:
|
|
||||||
print("showing slide 0")
|
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_HELLO, (0, 0))
|
|
||||||
pygame.display.flip()
|
|
||||||
pygame.time.wait(5000)
|
|
||||||
waitForEvents()
|
|
||||||
break
|
|
||||||
|
|
||||||
while slide == SLIDE_KEY:
|
if slide in slides:
|
||||||
print("showing slide 1 - key")
|
slides[slide].render(screen)
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_KEY, (0, 0))
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
waitForEvents()
|
waitForEvents()
|
||||||
break
|
|
||||||
|
|
||||||
while slide == SLIDE_POT:
|
|
||||||
print("showing slide 2 - pot")
|
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_POT, (0, 0))
|
|
||||||
pygame.display.flip()
|
|
||||||
waitForEvents()
|
|
||||||
break
|
|
||||||
|
|
||||||
while slide == SLIDE_FOAMBTN:
|
|
||||||
print("showing slide 3 - foam button")
|
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_FOAMBTN, (0, 0))
|
|
||||||
pygame.display.flip()
|
|
||||||
waitForEvents()
|
|
||||||
break
|
|
||||||
|
|
||||||
while slide == SLIDE_SNAKE: ## snake
|
while slide == SLIDE_SNAKE: ## snake
|
||||||
print("snake is starting...")
|
print("snake is starting...")
|
||||||
@ -494,35 +499,6 @@ def main():
|
|||||||
while slide == SLIDE_SNAKE_DEAD:
|
while slide == SLIDE_SNAKE_DEAD:
|
||||||
print("resetting snake.")
|
print("resetting snake.")
|
||||||
slide = SLIDE_SNAKE
|
slide = SLIDE_SNAKE
|
||||||
while slide == SLIDE_DYNAMO:
|
|
||||||
print("showing slide 5 - dynamo")
|
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_DYNAMO, (0, 0))
|
|
||||||
pygame.display.flip()
|
|
||||||
waitForEvents()
|
|
||||||
break
|
|
||||||
while slide == SLIDE_KEYPAD:
|
|
||||||
print("showing slide 6 - drawer keypad")
|
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_KEYPAD, (0, 0))
|
|
||||||
pygame.display.flip()
|
|
||||||
waitForEvents()
|
|
||||||
break
|
|
||||||
while slide == SLIDE_MAZE:
|
|
||||||
print("showing slide 7 - maze")
|
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_MAZE, (0, 0))
|
|
||||||
pygame.display.flip()
|
|
||||||
waitForEvents()
|
|
||||||
break
|
|
||||||
|
|
||||||
while slide == SLIDE_MP3:
|
|
||||||
print("showing slide 8 - mp3 player")
|
|
||||||
screen.fill(WHITE)
|
|
||||||
screen.blit(IMG_MP3, (0, 0))
|
|
||||||
pygame.display.flip()
|
|
||||||
waitForEvents()
|
|
||||||
break
|
|
||||||
|
|
||||||
while slide == SLIDE_KEYBOARD: ## keyboard
|
while slide == SLIDE_KEYBOARD: ## keyboard
|
||||||
#print("checking events")
|
#print("checking events")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user