コード例 #1
0
def init(data):
    #player
    data.scrollMargin = 30
    data.me = Player("Player1",data.width-data.scrollMargin,data.height-200)
    data.isJumping = False
    data.isAcceleratingRight = False
    data.isAcceleratingLeft = False
    data.isFalling = False
    data.start = False
    data.myBullet = None
    data.fired = False
    data.canFire = True
    data.fireCount = 0
    data.isPlaying = False
    data.isLobby = True
    data.isDeadSplash = False
    data.instructions = False
    data.nameChange = ""
    data.score = data.me.score + data.height - 200

    #platforms
    data.testPlatform = Platform(data.width-(2*data.scrollMargin),data.height-250,40)
    data.bottomPlatform = Platform(data.width-(2*data.scrollMargin),data.height-205,40)
    data.platforms = [data.bottomPlatform,data.testPlatform]
    data.currentPlatform = data.bottomPlatform
    
    #other people
    data.otherStrangers = dict()
    data.greatestY = "Player1"
    data.isHit = False
    data.hitCount = 0
    data.bullet = dict()
    
    #scrolling
    data.scrollY = 0
    data.setScrollY = 0
    data.scrollYSpeed = 0
    
    #lobby
    data.isReady = False
    data.isMulti = False
    data.isSingle = False
    
    #images
    data.lobbyButton = None
    data.redButton = None
    data.greenButton = None
    data.readyButton = None
    data.img = None
    data.p1Img = None
    data.p2Img = None
    data.p3Img = None
    data.p4Img = None
    data.mountain = None
    data.instr = None
コード例 #2
0
ファイル: run.py プロジェクト: mgcai/15112-Term-Project
def init(data):
    data.scrollMargin = 30
    data.player = Player(data.width - data.scrollMargin, data.height - 10)
    data.scrollY = data.height - data.player.y - 50
    data.testPlatform = Platform(data.width - (2 * data.scrollMargin),
                                 data.height - 15, 40)
    data.bottomPlatform = Platform(0, data.height - 5, data.width)
    data.platforms = [data.testPlatform, data.bottomPlatform]
    data.isJumping = False
    data.isAcceleratingRight = False
    data.isAcceleratingLeft = False
    data.isFalling = False
    data.scrollY = 0
    data.start = False
    data.currentPlatform = data.bottomPlatform
コード例 #3
0
ファイル: runGod.py プロジェクト: mgcai/15112-Term-Project
def init(data):
    # load data.xyz as appropriate
    data.gameWeather = weather(0)
    data.scrollMargin = 30
    data.player = Player(data.width - data.scrollMargin, data.height - 10)
    data.testPlatform = Platform(data.width - (2 * data.scrollMargin),
                                 data.height - 30, 40)
    data.bottomPlatform = Platform(0, data.height - 5, data.width)
    data.platforms = [data.testPlatform, data.bottomPlatform]
    data.canRain = True
    data.canLightning = True
    data.willLightning = False
    data.isLightning = False
    data.lightning = None
    data.lightningCounter = 0
    data.timeCount = 0
コード例 #4
0
def init(data):
    data.finishPlatform = Platform(0, 5, 40)
    data.bottomPlatform = Platform(0, data.height - 5, data.width)
    data.platforms = [data.bottomPlatform, data.finishPlatform]
    data.powerPlatform = Platform(data.width - 40, 5, 40)
    data.otherPlatforms = [data.bottomPlatform, data.powerPlatform]
    data.scrollMargin = 30
    data.player = Player(data.width - data.scrollMargin, data.height - 10)
    data.scrollx = 0
    data.scrolly = 0
    data.testPlatform = Platform(data.width - (2 * data.scrollMargin),
                                 data.height - 30, 40)
    data.bottomPlatform = Platform(0, data.height - 5, data.width * 3)
    data.isJumping = False
    data.isAcceleratingRight = False
    data.isAcceleratingLeft = False
    data.isFalling = False
    data.currentPlatform = data.bottomPlatform
コード例 #5
0
def init(data):
    data.scrollMargin = 30
    data.player = Player(data.width - data.scrollMargin, data.height - 10)
    data.scrollx = 0
    data.scrolly = 0
    data.testPlatform = Platform(data.width - (2 * data.scrollMargin),
                                 data.height - 30, 40)
    data.bottomPlatform = Platform(0, data.height - 5, data.width * 3)
    data.p1 = Platform(data.width - (3 * data.scrollMargin), data.height - 60,
                       40)
    data.p2 = Platform(data.width - (4 * data.scrollMargin), data.height - 80,
                       40)
    data.p3 = Platform(data.width + (3 * data.scrollMargin), data.height - 60,
                       40)
    data.p4 = Platform(data.width + (4 * data.scrollMargin), data.height - 80,
                       40)
    data.platforms = [
        data.testPlatform, data.bottomPlatform, data.p1, data.p2, data.p3,
        data.p4
    ]
    data.isJumping = False
    data.isAcceleratingRight = False
    data.isAcceleratingLeft = False
    data.isFalling = False
    data.currentPlatform = data.bottomPlatform
コード例 #6
0
def generatePlatform(platforms, stopY, width, startY):
    lastPlatform = platforms[-1]
    if lastPlatform.y < stopY:
        return platforms
    else:
        while platforms[0].y > startY:
            platforms.pop(0)
        y = lastPlatform.y

        rX = random.randrange(10, width - 40)
        rY = random.randrange(-70, -10)
        platforms += [Platform(rX, y + rY)]
        return generatePlatform(platforms, stopY, width, startY)
コード例 #7
0
def generatePlatformPowerUp(platforms):
    bottom = platforms[0]
    lastPlatform = platforms[-1]
    if lastPlatform.y > bottom.y + 20:
        return platforms
    else:
        x = lastPlatform.x
        y = lastPlatform.y
        rX = 0
        rY = 0
        while abs(rX) < 5:
            rX = random.randrange(-30, 10)
        while abs(rY) < 5:
            rY = random.randrange(-10, 30)
        platforms += [Platform(x + rX, y + rY)]
        return generatePlatformPowerUp(platforms)
コード例 #8
0
def init(data):
    #Lobby init
    data.me = User("Me")
    data.nameChange = ""
    data.otherStrangers = dict()
    data.isLobby = True
    data.isPlaying = False

    #scrolling
    data.scrollMargin = 30
    data.scrollX = 0
    data.scrollY = 0

    #platforms (will be randomly generated)
    data.testPlatform = Platform(data.width - (2 * data.scrollMargin),
                                 data.height - 30, 40)
    data.bottomPlatform = Platform(0, data.height - 5, data.width * 3)
    data.p1 = Platform(data.width - (3 * data.scrollMargin), data.height - 60,
                       40)
    data.p2 = Platform(data.width - (4 * data.scrollMargin), data.height - 80,
                       40)
    data.p3 = Platform(data.width + (3 * data.scrollMargin), data.height - 60,
                       40)
    data.p4 = Platform(data.width + (4 * data.scrollMargin), data.height - 80,
                       40)
    data.platforms = [
        data.testPlatform, data.bottomPlatform, data.p1, data.p2, data.p3,
        data.p4
    ]

    #Runner init
    data.player = Player(data.scrollMargin, data.height - 10)
    data.isJumping = False
    data.isAcceleratingRight = False
    data.isAcceleratingLeft = False
    data.isFalling = False
    data.canMove = True
    data.currentPlatform = data.bottomPlatform
    data.stunCount = 0

    #God init
    data.gameWeather = weather(0)
    data.canRain = True
    data.canLightning = True
    data.willLightning = False
    data.isLightning = False
    data.lightning = None
    data.lightningEnd = data.height
    data.lightningCounter = 0
コード例 #9
0
teleport_platform = 2
policeman_platform = 3
keys_platform = 4
locks_platform = 5
putin_platform = 6

##############названия платформ
#- обычные
#x убиваторские
#числа - телепорты
#p - policeman
##############цикл по созданию платформ
for row in level:
    for col in row:
        if col == '-':
            pl = Platform(x, y, classical_platform)
            sprite_group.add(pl)
            platforms.append(pl)

        if col == 'k':
            pl = Platform(x, y, keys_platform)
            sprite_group.add(pl)
            keys.append(pl)

        if col == 'x':
            pl = Platform(x, y, killer_platform)
            sprite_group.add(pl)
            killers.append(pl)

        if col == 'p':
            pl = Platform(x, y, policeman_platform)
コード例 #10
0
def timerFired(data):
    # timerFired receives instructions and executes them
    while (serverMsg.qsize() > 0):
        msg = serverMsg.get(False)
        try:
            print("received: ", msg, "\n")
            msg = msg.split()
            command = msg[0]
            
            if command == "myIDis":
                myPID = msg[1]
                data.me.changePID(myPID)
            
            elif command == "newPlayer":
                newPID = msg[1]
                x = data.width/2
                y = data.height/2
                data.otherStrangers[newPID] = Player(newPID, x, y)
                
            elif command == "playerReady":
                PID = msg[1]
                data.otherStrangers[PID].mode = msg[2]
                status = not data.otherStrangers[PID].isReady
                data.otherStrangers[PID].isReady = status
                if msg[2] == "single":
                    data.otherStrangers[PID].y = 10000
    
            elif command == "playerCoords":
                PID = msg[1]
                x = int(msg[2])
                y = int(msg[3])
                score = int(msg[4])
                dmg = int(msg[5])
                data.otherStrangers[PID].x = x
                data.otherStrangers[PID].y = y
                data.otherStrangers[PID].score = score
                data.otherStrangers[PID].damage = dmg
                
            elif command == "mapGen":
                #will be in the form of "123,321;789,987;"
                PID = msg[1]
                msg[2] = msg[2][0:-1] #remove the last ';'
                l = msg[2].split(";") #['123,321','789,987']
                data.platforms = []
                for c in l:
                    coords = c.split(",")
                    x = int(coords[0])
                    y = int(coords[1])
                    data.platforms += [Platform(x,y)]
                    
            elif command == "bullet":
                PID = msg[1]
                x = int(msg[2])
                y = int(msg[3])
                lX = int(msg[4])
                lY = int(msg[5])
                dirX = int(msg[6])
                dirY = int(msg[7])
                data.bullet[PID] = Bullet(x,y)
                data.bullet[PID].lastX = lX
                data.bullet[PID].lastY = lY
                data.bullet[PID].direction = (dirX,dirY)
            
            elif command == "doggoDied":
                PID = msg[1]
                height = msg[2]
                data.otherStrangers[PID].score = height
                data.otherStrangers[PID].alive = False
                
            elif command == "left":
                PID = msg[1]
                del data.otherStrangers[PID]
        except:
            print("Failed")
        serverMsg.task_done()
コード例 #11
0
    '----------------', '-              -', '-              -',
    '-     ---      -', '-              -', '-              -',
    '-       ---    -', '-              -', '- --           -',
    '-              -', '-              -', '----------------'
]

sprite_group = pygame.sprite.Group()
sprite_group.add(hero)
platfroms = []

x = 0
y = 0
for row in level:
    for col in row:
        if col == '-':
            pl = Platform(x, y)
            sprite_group.add(pl)
            platfroms.append(pl)
        x += 40
    y += 40
    x = 0

# открываем игровой цикл
done = True
timer = pygame.time.Clock()
while done:
    # блок управления событиями
    for e in pygame.event.get():
        if e.type == pygame.QUIT:
            done = False
コード例 #12
0
def update_platforms(platforms, screen):
    pl = Platform(0, 665, 50, 50, screen)
    platforms.add(pl)
    pl2 = Platform(90, 665, 50, 50, screen)
    platforms.add(pl2)