コード例 #1
0
        timeElapsed = pygame.time.get_ticks() - startTime

        wait = max(self.targetDeltaTime - timeElapsed, 0) / 1000
        self.dt = max(self.targetDeltaTime, timeElapsed)
        if self.dt > 16:
            print(self.dt)

        reactor.callLater(wait, self.runClient)

    def setState(self, state, stateName, params=None):
        self.gameState = state(self.targetDeltaTime)
        self.stateName = stateName
        if params != None:
            self.gameState.open(self.surface, params, debug=self.debug)
        else:
            self.gameState.open(self.surface, debug=self.debug)


FILERETRACTS = 2
config = filePath.loadConfig(
    filePath.setPath(filePath.getRootFolder(FILERETRACTS), ["config.txt"]))
SERVER_IP = config["SERVER_IP"]
SERVER_PORT = config["SERVER_PORT"]
RESOLUTION = config["RESOLUTION"]
FPS = config["FPS"]
GRAPHICS = config["GRAPHICS"]
os.environ['SDL_VIDEO_CENTERED'] = '1'
debug = True
gameClient(RESOLUTION, GRAPHICS, debug)
コード例 #2
0
def loadEnemyData():
    contentFolder = filePath.setPath(fileRootPath,
                                     ["data", "content", "enemies.txt"])
    contentData = filePath.loadConfig(contentFolder)
    return contentData
コード例 #3
0
def loadProjectileData():
    contentFolder = filePath.setPath(fileRootPath,
                                     ["data", "content", "projectiles.txt"])
    contentData = filePath.loadConfig(contentFolder)
    return contentData
コード例 #4
0
import pygame, os, math, json
import socket, _thread
from lib import LIMITobjects, contentLoader, filePath
import collision  #experimental

SERVER_IP = socket.gethostbyname(socket.gethostname())
SERVER_PORT = 8080
os.environ['SDL_VIDEO_CENTERED'] = '1'
config = filePath.loadConfig(
    filePath.setPath(filePath.getRootFolder(2), ["config.txt"]))
RESOLUTION = config["RESOLUTION"]
DEBUG = config["DEBUG"]
WIDTHSCALE, LENGTHSCALE = RESOLUTION[0] / 1280, RESOLUTION[
    1] / 720  #Scale game according to default 1280x720 dimensions

networkPacker = {
    "moveForward": 0,
    "turnLeft": 1,
    "turnRight": 2,
    "primaryFire": 3,
}

networkUnPacker = {
    0: "moveForward",
    1: "turnLeft",
    2: "turnRight",
    3: "primaryFire",
}


class server: