Update stuff
This commit is contained in:
parent
82aadf6034
commit
bf08a808a1
@ -3,6 +3,7 @@
|
||||
become_user: root
|
||||
tasks:
|
||||
- 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=sejf.desktop dest=/etc/xdg/autostart
|
||||
- apt: name=python-flask state=present
|
||||
|
202
raspi/pySejf.py
202
raspi/pySejf.py
@ -22,6 +22,27 @@ from math import cos
|
||||
import time
|
||||
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()
|
||||
|
||||
#gameplay
|
||||
@ -155,7 +176,19 @@ SLIDE_SNAKE_DEAD = 10 #to nie slajd, tylko wartosc potrzebna do resetowania snak
|
||||
global slide
|
||||
#slajd poczatkowy
|
||||
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():
|
||||
@ -222,7 +255,6 @@ def waitForEvents():
|
||||
slide = SLIDE_KEYBOARD
|
||||
print("mouse event")
|
||||
return
|
||||
|
||||
elif event.type == pygame.KEYDOWN:
|
||||
if slide != SLIDE_SNAKE:
|
||||
slide = SLIDE_SNAKE
|
||||
@ -231,7 +263,6 @@ def waitForEvents():
|
||||
print("keydown event")
|
||||
return
|
||||
|
||||
|
||||
def checkEvents():
|
||||
global slide
|
||||
if GPIO.input(PIN_SET1) == 0 and slide != SLIDE_KEY:
|
||||
@ -300,6 +331,59 @@ def die(screen, score):
|
||||
pygame.time.wait(2000)
|
||||
waitForEvents()
|
||||
|
||||
############# old main
|
||||
######## CONSTANTS
|
||||
WINSIZE = [WINSIZEX,WINSIZEY]
|
||||
BLOCKSIZE = [18,18]
|
||||
UP = 1
|
||||
DOWN = 3
|
||||
RIGHT = 2
|
||||
LEFT = 4
|
||||
WHITE = [255, 255, 255]
|
||||
|
||||
MINX = 100
|
||||
MAXX = WINSIZEX - MINX
|
||||
MINY = 100
|
||||
MAXY = WINSIZEY - MINY
|
||||
|
||||
|
||||
SNAKESTEP = 20
|
||||
TRUE = 1
|
||||
FALSE = 0
|
||||
|
||||
|
||||
######## VARIABLES
|
||||
direction = RIGHT # 1=up,2=right,3=down50,4=left
|
||||
snakexy = [300,400]
|
||||
snakelist = [[300,400],[280,400],[260,400]]
|
||||
counter = 0
|
||||
score = 0
|
||||
appleonscreen = 0
|
||||
applexy = [0,0]
|
||||
newdirection = RIGHT
|
||||
snakedead = FALSE
|
||||
gameregulator = 6
|
||||
gamepaused = 0
|
||||
growsnake = 0 # added to grow tail by two each time
|
||||
snakegrowunit = 2 # added to grow tail by two each time
|
||||
clock = pygame.time.Clock()
|
||||
screen = pygame.display.set_mode(WINSIZE, pygame.NOFRAME)
|
||||
pygame.display.set_caption('PozySejf')
|
||||
dynamoValSPI = [0,0,0]
|
||||
dynamoRectY = [50, 50, 50]
|
||||
dynamoRectX = 50
|
||||
dynamoXpos = [-100, 0, 100]
|
||||
distanceDynamoRect = 300
|
||||
textInputDotNumber = 0
|
||||
pushButtonNumber = 100
|
||||
|
||||
valueSound = 100
|
||||
|
||||
passwordLetter = ''
|
||||
|
||||
############# old main
|
||||
|
||||
|
||||
def main():
|
||||
global slide
|
||||
|
||||
@ -308,92 +392,13 @@ def main():
|
||||
|
||||
while startonce == 0:
|
||||
startonce = 0
|
||||
######## CONSTANTS
|
||||
WINSIZE = [WINSIZEX,WINSIZEY]
|
||||
BLOCKSIZE = [18,18]
|
||||
UP = 1
|
||||
DOWN = 3
|
||||
RIGHT = 2
|
||||
LEFT = 4
|
||||
WHITE = [255, 255, 255]
|
||||
|
||||
MINX = 100
|
||||
MAXX = WINSIZEX - MINX
|
||||
MINY = 100
|
||||
MAXY = WINSIZEY - MINY
|
||||
|
||||
|
||||
SNAKESTEP = 20
|
||||
TRUE = 1
|
||||
FALSE = 0
|
||||
|
||||
|
||||
######## VARIABLES
|
||||
direction = RIGHT # 1=up,2=right,3=down50,4=left
|
||||
snakexy = [300,400]
|
||||
snakelist = [[300,400],[280,400],[260,400]]
|
||||
counter = 0
|
||||
score = 0
|
||||
appleonscreen = 0
|
||||
applexy = [0,0]
|
||||
newdirection = RIGHT
|
||||
snakedead = FALSE
|
||||
gameregulator = 6
|
||||
gamepaused = 0
|
||||
growsnake = 0 # added to grow tail by two each time
|
||||
snakegrowunit = 2 # added to grow tail by two each time
|
||||
clock = pygame.time.Clock()
|
||||
screen = pygame.display.set_mode(WINSIZE, pygame.NOFRAME)#FULLSCREEN)
|
||||
#screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
||||
pygame.display.set_caption('PozySejf')
|
||||
pygame.FULLSCREEN
|
||||
#screen = display.set_mode([1024,768], FULLSCREEN)
|
||||
#screen.fill(BLACK)
|
||||
dynamoValSPI = [0,0,0]
|
||||
dynamoRectY = [50, 50, 50]
|
||||
dynamoRectX = 50
|
||||
dynamoXpos = [-100, 0, 100]
|
||||
distanceDynamoRect = 300
|
||||
textInputDotNumber = 0
|
||||
pushButtonNumber = 100
|
||||
|
||||
valueSound = 100
|
||||
|
||||
passwordLetter = ''
|
||||
#### show initial start screen
|
||||
### 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:
|
||||
print("showing slide 1 - key")
|
||||
screen.fill(WHITE)
|
||||
screen.blit(IMG_KEY, (0, 0))
|
||||
if slide in slides:
|
||||
slides[slide].render(screen)
|
||||
pygame.display.flip()
|
||||
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
|
||||
print("snake is starting...")
|
||||
@ -494,35 +499,6 @@ def main():
|
||||
while slide == SLIDE_SNAKE_DEAD:
|
||||
print("resetting 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
|
||||
#print("checking events")
|
||||
|
Loading…
x
Reference in New Issue
Block a user