Exemplo n.º 1
0
import threading
import time
import signal
import os

from snake.model.Snake import Snake
from snake.model.GameBoard import GameBoard
from snake.controle.GameManeger import GameManeger
start = time.time()
try:
    pygame.init()
except:
    print("Não foi possivel iniciar o pygame")

gameSurface = pygame.Surface((GameBoard.width, GameBoard.height))
manager = GameManeger(gameSurface)
gameSurface.fill((9, 10, 13))

port = 15000
address = "127.0.0.1"

inputs = []
outputs = []
clientsThreads = []
updateClients = False
data = []
newDataFromClients = False
requireClient = {}
mutex = threading.Lock()
doingLogicOfGame = 0
doingIO = 0
Exemplo n.º 2
0
from snake.model.Snake import Snake
from snake.model.GameBoard import GameBoard
from snake.controle.GameManeger import GameManeger
import threading
import time
import signal
import os
star = time.time()
try:
    pygame.init()
except:
    print("Não foi possivel iniciar o pygame")

gameSurface = pygame.Surface((GameBoard.width, GameBoard.height))
manager = GameManeger(gameSurface)
#gameSurface.fill((9, 10, 13))

port = 15000
address = "127.0.0.1"

inputs = []
outputs = []
updateClients = False
doingLogicOfGame = 0
doingIO = 0
clientesConectados = 0
def interuptionHandler(sig_number, sig_stack):
    print("Servidor Encerrado")
    print("Tempo ativo:", (time.time() - star))
    print("Tempo gasto com o processamento da logica do jogo:", doingLogicOfGame, "segundos.")
Exemplo n.º 3
0
from snake.model.Snake import Snake
from snake.model.GameBoard import GameBoard
from snake.controle.GameManeger import GameManeger

try:
    pygame.init()
except:
    print("falha ao iniciar o pygame")

#abre a janela.
surfaceGame = pygame.display.set_mode((GameBoard.width, GameBoard.height))
exit = True
timer = pygame.time.Clock()
#Testes
snake1 = Snake(0)
maneger = GameManeger()
maneger.addSnakeInGame(snake1)

while exit:
    surfaceGame.fill((9, 10, 13))
    maneger.initGame(surfaceGame)
    for e in pygame.event.get():
        if e.type == pygame.QUIT:
            exit = False
        else:
            maneger.commandToSnake(e, 0)
    maneger.moveSnakes(surfaceGame)
    maneger.checksSnakeEatFood()
    timer.tick(15)
    pygame.display.update()
Exemplo n.º 4
0
import pygame
import sys
#sys.path.append('~/PycharmProjects/pygames')
#print(sys.path)
from snake.model.Snake import Snake
from snake.model.GameBoard import GameBoard
from snake.controle.GameManeger import GameManeger

try:
    pygame.init()
except:
    print("falha ao iniciar o pygame")

#Testes
snake1 = Snake(0)
maneger = GameManeger()
maneger.addSnakeInGame(snake1)
#abre a janela.
surfaceGame = pygame.display.set_mode((GameBoard.width, GameBoard.height))
exit = True
timer = pygame.time.Clock()

while exit:
    for e in pygame.event.get():
        if e.type == pygame.QUIT:
            exit = False
        else:
            maneger.commandToSnake(e, 0)
    maneger.moveSnakes()
    timer.tick(15)
    pygame.display.update()