Пример #1
0
    def __init__(self, position, image = pyglet.image.load(data.getPath("rawr.png"))):
        self.imageSeq = pyglet.image.ImageGrid(image, 1, 2)
        super(Player, self).__init__(self.imageSeq[1])
        self.position = position

        self.cshape = collision_model.AARectShape(self.position, self.width // 2, self.height // 2)

        self.doX = 0
        self.doY = 0
        self.health = 100
        self.killMe = False

        self.doGravity = True
        self.GRAVITY_SPEED = 10

        self.JUMP_SPEED = 7

        self.WALK_SPEED = 10
        self.WALK_SMOOTH = .85
        self.direction = "right"
        self.lastDirection = "right"

        self.BULLET_OFFSET = ((self.width // 2) + 4, -16)
        self.FIRE_RATE = .25
        self.lastShot = time.time() - self.FIRE_RATE

        self.thruster = Thruster((0, -32))
        self.add(self.thruster)
Пример #2
0
    def __init__(self, sceneManager):
        super(MainGameLayer, self).__init__()
        self.sceneManager = sceneManager

        self.freeze = False

        self.keysPressed = set()

        self.schedule(self.update)

        self.MAP_WIDTH = 1536
        self.MAP_HEIGHT = 1024

        self.background = cocos.sprite.Sprite(pyglet.image.load(data.getPath("background.png")))
        self.background.position = (self.MAP_WIDTH // 2, self.MAP_HEIGHT // 2)
        self.add(self.background)


        self.collisionManager = collision_model.CollisionManagerBruteForce()

        self.tempAnimations = set()

        self.dead = False
        self.isSpaceDown = False
        self.hasSpawned = False
Пример #3
0
    def __init__(self, position, image = pyglet.image.load(data.getPath("explosion.png"))):
        self.frames = pyglet.image.ImageGrid(image, 1, 10)
        self.currentFrame = 0
        super(Explosion, self).__init__(self.frames[self.currentFrame])
        self.position = position

        self.ANIMATION_SPEED = .1
        self.lastAnimation = time.time() - self.ANIMATION_SPEED
        self.killMe = False
Пример #4
0
#   along with any FreeEMS software.  If not, see <http://www.gnu.org/licenses/>.
#
#   We ask that if you make any changes to this file you send them upstream to us at [email protected]


import logging, config, data

LEVELS = {
    'debug':    logging.DEBUG,
    'info':     logging.INFO,
    'warning':  logging.WARNING,
    'error':    logging.ERROR,
    'critical': logging.CRITICAL
}

LOG_FILENAME = data.getPath()+'app.log'

def setup():

    global LEVELS, LOG_FILENAME

    # Get log level from config
    config_level = config.load('Logging', 'verboseness')
    level = LEVELS.get(config_level, logging.NOTSET)

    # Setup config
    base = logging.getLogger()
    base.setLevel(level)

    # Setup formatting
    logging._defaultFormatter = formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(name)s - %(message)s')
Пример #5
0
    def __init__(self, position, image = pyglet.image.load(data.getPath("win_block.png"))):
        super(WinBlock, self).__init__(image)
        self.position = position

        self.cshape = collision_model.AARectShape(self.position, self.width // 2, self.height // 2)
Пример #6
0
    def __init__(self, offset, image = pyglet.image.load_animation(data.getPath("flames.gif"))):
        super(Thruster, self).__init__(image)
        self._image = image

        self.moveBy(offset)
Пример #7
0
    def __init__(self, position, rotation, image = pyglet.image.load(data.getPath("bam.png"))):
        super(BulletTrail, self).__init__(image)
        self.position = position
        self.rotation = rotation

        self.cshape = collision_model.AARectShape(self.position, self.width // 2, self.height // 2)
Пример #8
0
 def setSpeed(self, levelDifficulty):
     self.image = pyglet.image.load(data.getPath("bawm.png"))
     self.SPEED = self.DEFAULT_SPEED * levelDifficulty
Пример #9
0
    def __init__(self, position, direction, offset, levelDifficulty = 1, image = pyglet.image.load(data.getPath("bam.png"))):
        super(Bullet, self).__init__(image)
        self.position = position
        self.DIRECTION = direction
        self.OFFSET = offset

        self.cshape = collision_model.AARectShape(self.position, self.width // 2, self.height // 2)

        self.spawnTime = time.time()
        self.killMe = False

        self.doX = 0
        self.doY = 0
        self.rotation = 0
        self.distanceTraveled = 0
        self.lastBulletTrail = 0
        self.damagePlayer = False
        self.DEFAULT_SPEED = 400
        self.LIFETIME = 3

        self.setSpeed(levelDifficulty)
Пример #10
0
    def __init__(self, position, target, patrolX, range = 100, image = pyglet.image.load(data.getPath("badputer.png"))):
        super(Badputer, self).__init__(image)
        self.position = position
        self.target = target
        self.PATROL_X = patrolX
        self.RANGE = range

        self.cshape = collision_model.AARectShape(self.position, self.width // 2, self.height // 2)

        self.SPEED = 50

        self.direction = "left"
        self.doX = -self.SPEED * config.DELTA_TIME
        self.doY = 0
        self.health = 100
        self.killMe = False
        self.bullets = set()
        self.FIRE_RATE = 1
        self.lastShot = time.time() - self.FIRE_RATE
Пример #11
0
def getLevels(sceneManager):
    levels = [
        ################## LEVEL 1 ####################
        scenes.Level(
            cocos.tiles.load(data.getPath("map1.tmx"))["Tile Layer 1"],
            cocos.tiles.load(data.getPath("bullet_map1.tmx"))["Tile Layer 1"],
            MainGameLayer(sceneManager),
            cocos.text.Label(text = "", position = (config.SCREEN_WIDTH // 12, config.SCREEN_HEIGHT // 12)),
            playerSpawn = (300, 600),
            winBlockSpawn = (1536 - 32, 1024 - 32),
            badputerSpawns = ((125, 875), (500, 500), (1000, 700), (1200, 450)),
            levelDifficulty = .75
        ),
        ################## LEVEL 2 ####################
        scenes.Level(
            cocos.tiles.load(data.getPath("map1.tmx"))["Tile Layer 1"],
            cocos.tiles.load(data.getPath("bullet_map1.tmx"))["Tile Layer 1"],
            MainGameLayer(sceneManager),
            cocos.text.Label(text = "", position = (config.SCREEN_WIDTH // 12, config.SCREEN_HEIGHT // 12)),
            playerSpawn = (300, 600),
            winBlockSpawn = (1536 - 32, 1024 - 32),
            badputerSpawns = ((400, 400), (600, 600), (800, 800), (1000, 1000)),
            levelDifficulty = .85
        ),
        ################## LEVEL 3 ####################
        scenes.Level(
            cocos.tiles.load(data.getPath("map2.tmx"))["Tile Layer 1"],
            cocos.tiles.load(data.getPath("bullet_map2.tmx"))["Tile Layer 1"],
            MainGameLayer(sceneManager),
            cocos.text.Label(text = "", position = (config.SCREEN_WIDTH // 12, config.SCREEN_HEIGHT // 12)),
            playerSpawn = (896, 480),
            winBlockSpawn = (0 + 32, 1024 - 32),
            badputerSpawns = ((300, 300), (64, 830), (640, 980), (1300, 650)),
            levelDifficulty = 1
        ),
        ################## LEVEL 4 ####################
        scenes.Level(
            cocos.tiles.load(data.getPath("map3.tmx"))["Tile Layer 1"],
            cocos.tiles.load(data.getPath("bullet_map3.tmx"))["Tile Layer 1"],
            MainGameLayer(sceneManager),
            cocos.text.Label(text = "", position = (config.SCREEN_WIDTH // 12, config.SCREEN_HEIGHT // 12)),
            playerSpawn = (0 + 32, 1024),
            winBlockSpawn = (1536 - 32, 64 + 32),
            badputerSpawns = ((64, 130), (500, 350), (350, 950), (1300, 700), (900, 220)),
            levelDifficulty = 1
        ),
        ################## LEVEL 5 ####################
        scenes.Level(
            cocos.tiles.load(data.getPath("map2.tmx"))["Tile Layer 1"],
            cocos.tiles.load(data.getPath("bullet_map2.tmx"))["Tile Layer 1"],
            MainGameLayer(sceneManager),
            cocos.text.Label(text = "", position = (config.SCREEN_WIDTH // 12, config.SCREEN_HEIGHT // 12)),
            playerSpawn = (896, 480),
            winBlockSpawn = (0 + 32, 1024 - 32),
            badputerSpawns = ((64, 130), (500, 350), (350, 950), (1300, 700), (900, 220)),
            levelDifficulty = 1.3
        )
    ]

    '''
            scenes.Level(
                cocos.tiles.load(data.getPath("map2.tmx"))["Tile Layer 1"],
                cocos.tiles.load(data.getPath("bullet_map2.tmx"))["Tile Layer 1"],
                MainGameLayer(sceneManager),
                cocos.text.Label(text = "", position = (config.SCREEN_WIDTH // 12, config.SCREEN_HEIGHT // 12)),
                playerSpawn = (0, 0),
                winBlockSpawn = (0 - 32, 0 - 32),
                badputerSpawns = ((0, 0), (0, 0), (0, 0), (0, 0)),
                levelDifficulty = 1
            )
    '''

    return levels
Пример #12
0
#   along with any FreeEMS software.  If not, see <http://www.gnu.org/licenses/>.
#
#   We ask that if you make any changes to this file you send them upstream to us at [email protected]


import logging, config, data

LEVELS = {
    "debug": logging.DEBUG,
    "info": logging.INFO,
    "warning": logging.WARNING,
    "error": logging.ERROR,
    "critical": logging.CRITICAL,
}

LOG_FILENAME = data.getPath() + "app.log"


def setup():

    global LEVELS, LOG_FILENAME

    # Get log level from config
    config_level = config.get("Logging", "verboseness")
    level = LEVELS.get(config_level, logging.NOTSET)

    # Setup config
    base = logging.getLogger()
    base.setLevel(level)

    # Setup formatting