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
|
||||||
|
216
raspi/pySejf.py
216
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
|
||||||
@ -230,8 +262,7 @@ def waitForEvents():
|
|||||||
slide = SLIDE_SNAKE_DEAD
|
slide = SLIDE_SNAKE_DEAD
|
||||||
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:
|
||||||
@ -285,7 +316,7 @@ def drawSlide(n):
|
|||||||
screen.blit(slides[n], (0, 0))
|
screen.blit(slides[n], (0, 0))
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
waitForEvents()
|
waitForEvents()
|
||||||
|
|
||||||
def collide(x1, x2, y1, y2, w1, w2, h1, h2):
|
def collide(x1, x2, y1, y2, w1, w2, h1, h2):
|
||||||
if x1+w1>x2 and x1<x2+w2 and y1+h1>y2 and y1<y2+h2:return True
|
if x1+w1>x2 and x1<x2+w2 and y1+h1>y2 and y1<y2+h2:return True
|
||||||
else:return False
|
else:return False
|
||||||
@ -299,7 +330,60 @@ def die(screen, score):
|
|||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
pygame.time.wait(2000)
|
pygame.time.wait(2000)
|
||||||
waitForEvents()
|
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():
|
def main():
|
||||||
global slide
|
global slide
|
||||||
|
|
||||||
@ -308,93 +392,14 @@ def main():
|
|||||||
|
|
||||||
while startonce == 0:
|
while startonce == 0:
|
||||||
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
|
#### show initial start screen
|
||||||
### every while loop for each slide
|
### every while loop for each slide
|
||||||
while slide == SLIDE_START:
|
|
||||||
print("showing slide 0")
|
if slide in slides:
|
||||||
screen.fill(WHITE)
|
slides[slide].render(screen)
|
||||||
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))
|
|
||||||
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,36 +499,7 @@ 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")
|
||||||
checkEvents()
|
checkEvents()
|
||||||
@ -609,7 +585,7 @@ def main():
|
|||||||
while 1:
|
while 1:
|
||||||
print "you win."
|
print "you win."
|
||||||
waitForEvents()
|
waitForEvents()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user