Update api
This commit is contained in:
parent
4ce40ee01d
commit
8cba94e081
4 changed files with 17 additions and 21 deletions
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
import socket, json, time
|
||||
import pygame
|
||||
|
@ -76,22 +77,22 @@ def handleControls(event, gameId):
|
|||
|
||||
def main():
|
||||
gameInit = newGame()
|
||||
gameId = gameInit['ID']
|
||||
gameId = gameInit['id']
|
||||
up = gameInit
|
||||
initSize=len(up['SNAKE'])
|
||||
initSize=len(up['snake'])
|
||||
continuer = True
|
||||
|
||||
while continuer:
|
||||
afficher(ecran, up['SNAKE'], up['FOOD'])
|
||||
ecran.blit(myfont.render('Score {}'.format(len(up['SNAKE'])-initSize), False, (0, 0, 0)),(0,0))
|
||||
afficher(ecran, up['snake'], up['food'])
|
||||
ecran.blit(myfont.render('Score {}'.format(len(up['snake'])-initSize), False, (0, 0, 0)),(0,0))
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
continuer = False
|
||||
elif event.type == pygame.KEYDOWN:
|
||||
updateTmp = handleControls(event, gameId)
|
||||
print(updateTmp)
|
||||
if updateTmp != None and 'TYPE' in updateTmp:
|
||||
if updateTmp['TYPE'] != 'error':
|
||||
if updateTmp != None and 'type' in updateTmp:
|
||||
if updateTmp['type'] != 'error':
|
||||
up = updateTmp
|
||||
time.sleep(0.3)
|
||||
pygame.display.flip()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue