コード例 #1
0
ファイル: MainGame.py プロジェクト: rfrapp/frogger
    def initCarRow(self, row, width, startX, direction = 0, offset = 0, speed = 0):
        for i in range(4):
            car = GameObject("images/car_sprites_big.png")
            car.clips = []
            car.image.set_colorkey((0, 0, 0))

            # main clip
            car.clips.append(Rect(startX, 0, width, 35))
            car.setPos(i * 150 + offset, self.getYforRow(row))

            if direction == 0:
                car.speed = self.carSpeed 
            else:
                car.speed = -self.carSpeed 

            if speed != 0:
                car.speed = speed 

            self.cars.append(car)
コード例 #2
0
ファイル: MainGame.py プロジェクト: rfrapp/frogger
    def initLogsInRow(self, row, bigLogs = False, croc = False, logSpeed = 2):
        startLogs = self.num_logs
        
        if croc:
            # startLogs -= 1
            self.croc.speed = logSpeed

        if not bigLogs:
            crocX = 0
            crocY = 0

            for i in range(startLogs):
                log = GameObject("images/log_big.png")
                log.image.set_colorkey((0, 0, 0))
                x = self.width / 2 - i * LOG_MARGIN - row * 10
                y = self.getYforRow(row)
                log.setPos(x, y)
                log.speed = logSpeed

                self.logs.append(log)

                if i == startLogs - 1:
                    crocX = self.width / 2 - startLogs * LOG_MARGIN - row * 10
                    crocY = y 

                    self.croc.body_rect.left = crocX
                    self.croc.body_rect.top  = crocY
                    self.croc.head_rect.left = crocX + 80
                    self.croc.head_rect.top  = crocY 
                    self.croc_in_level = True 
        else:
            for i in range(self.num_logs - 1):
                log = GameObject("images/log_bigger.png")
                c = log.image.get_at((0, 0))
                log.image.set_colorkey(c)
                x = self.width / 2 - i * (LOG_MARGIN + log.rect.width) - i * LOG_MARGIN
                y = self.getYforRow(row)
                log.setPos(x, y)
                log.speed = logSpeed - 1

                self.logs.append(log)