Beispiel #1
0
def main():
    # def Mmain():
    pygame.init()
    screen = pygame.display.set_mode((480, 852), 0, 32)
    background = pygame.image.load("../img/Mbj.jpg")
    # mouse_cursor = pygame.image.load('feiji/plane.png')
    #设置窗口标题
    pygame.display.set_caption('飞机大战')
    #创建按钮区域

    while 1:
        #加入背景图
        screen.blit(background, (0, 0))
        x, y = pygame.mouse.get_pos()
        for event in pygame.event.get():
            if event.type == QUIT:
                exit()
            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    exit()
                if event.key == K_1:
                    mold1.main()
            if event.type == MOUSEBUTTONDOWN:
                if 116 <= x <= 370 and 409 <= y <= 475:
                    mold1.main()  #1
            #109 360  560 620
                elif 109 <= x <= 360 and 560 <= y <= 620:
                    mole2.main()  #2
            #44 190 732 785     254 436  733 785
                elif 44 <= x <= 190 and 732 <= y <= 785:
                    backgrounds = pygame.image.load("../img/option.png")
                    screen.blit(backgrounds, (50, 250))
                    print('1')
                    #刷新窗口
                    pygame.display.update()
                    #写判断点击改变item_s
                    item = True
                    while item:
                        x, y = pygame.mouse.get_pos()
                        for event in pygame.event.get():
                            if event.type == KEYDOWN:
                                if event.key == K_ESCAPE:
                                    main()

                            if event.type == MOUSEBUTTONDOWN:
                                print('anjia')
                                print(x, y)
                                if 389 <= x <= 413 and 264 <= y <= 290:
                                    item = not item
                                    print('qujian')

                    #刷新窗口
                    pygame.display.update()
                elif 254 <= x <= 436 and 733 <= y <= 785:
                    exit()
        #加入背景图
        screen.blit(background, (0, 0))
        #刷新画面
        pygame.display.update()
Beispiel #2
0
def event_handler():
    for event in pygame.event.get():
        if event.type == QUIT:
            Tools.OnExit()
        elif event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                Tools.OnExit()
            if event.key == K_r:
                # RàZ du jeu
                Tools.GameInit()
            if event.key == K_SPACE:
                Config.Sounds['intro'].stop()
                Config.Sounds['intro-2'].play()
                # on lance les balles
                Ball.Ballsmoving()
                if Config.player.laserMode:
                    Config.player.laserFire()
            if event.key == K_LEFT:
                Config.player.moveLeft()
            if event.key == K_RIGHT:
                Config.player.moveRight()
            if (event.key == K_PLUS
                    or event.key == K_KP_PLUS) and Config.godMode:
                # cheat code, on change de niveau
                Tools.NextLevel()
            if (event.key == K_MINUS
                    or event.key == K_KP_MINUS) and Config.godMode:
                # cheat code, on change de niveau
                if Config.level > 1:
                    Config.level -= 1
                else:
                    # on boucle
                    Config.level = Config.maxlevel
                Level.LoadLevel(Config.level)
                if Config.bossLevel:
                    # niveau d'un boss
                    Boss.doBossLevel()
                else:
                    Tools.InitBG()
                Bonus.initBonus()
                Config.player.reset()
                Ball.Ballsreset()
        elif event.type == KEYUP:
            if event.key == K_LEFT or event.key == K_RIGHT:
                Config.player.state = "still"
        elif event.type == USEREVENT:
            # MàJ des fps toutes les secondes
            pygame.display.set_caption(
                Config.titre +
                ' (fps: {0:.0f})'.format(Config.clock.get_fps()))
        elif event.type == (USEREVENT + 1):
            # génération d'ennemis (toutes les 10s)
            if not Config.Perdu and not Level.FinishedLevel():
                Enemys.randomGen()
        elif event.type == (USEREVENT + 2):
            # génération des bombes et missiles du boss (déclenché toutes les 5s)
            if Config.bossLevel:
                Config.boss.attack()
Beispiel #3
0
	def load_map(self):
		counter = str(self.counter)
		for letter in counter:
			self.map = MAP_level[letter]
		file = open(self.map, 'r')
		for i, line in enumerate(file):  # y
			for j, letter in enumerate(line):  # x
				if letter == 'B':
					boss = Boss(j * TILE_SIZE, i * TILE_SIZE)
					boss.add(self.allBlocks)
					boss.add(self.boss)
					boss.add(self.enemy)
				if letter == 'G':
					monster = Monster(j * TILE_SIZE, i * TILE_SIZE, JIIINGO)
					monster.add(self.jiiingo)
					monster.add(self.allBlocks)
					monster.add(self.enemy)
				if letter in MAP_KEYS.keys():
					block_temp = Block(j * TILE_SIZE, i * TILE_SIZE, MAP_KEYS[letter])
					block_temp.add(self.allBlocks)
					if letter in SOLID_BLOCKS:
						block_temp.add(self.solidBlocks)
					if letter in Enemy:
						block_temp.add(self.enemy)
					if letter in HEAL_BLOCKS:
						block_temp.add(self.heal)
					if letter in KEYS:
						block_temp.add(self.keys)
					if letter in NPC:
						block_temp.add(self.npc)
					if letter in DOORS:
						block_temp.add(self.door)
					if letter in CRISTRAJ:
						block_temp.add(self.cristraj)
						self.boss_health += 1
				if letter in LOOT_BLOCKS:
					money = Money(j * TILE_SIZE, i * TILE_SIZE)
					money.add(self.allBlocks)
					money.add(self.lootBlocks)
				if letter == 'Q':
					npc = Npc1(j * TILE_SIZE, i * TILE_SIZE)
					npc.add(self.allBlocks)
					npc.add(self.npc1)
				if letter =='P':
					plevaka = Plevaka(j * TILE_SIZE, i * TILE_SIZE)
					plevaka.add(self.allBlocks)
					plevaka.add(self.enemy)
					plevaka.add(self.plev)
				if letter == 's':
					self.player.start_x = j * TILE_SIZE
					self.player.start_y = i * TILE_SIZE
					self.start_x = j * TILE_SIZE
					self.start_y = i * TILE_SIZE
					self.ret()
		self.m_counter = self.counter
		self.BACKGROUND = background_key[str(self.m_counter)]
		self.background = pygame.image.load(self.BACKGROUND["texture"])
		self.background = pygame.transform.scale(self.background, (MAP_RIGHT,MAP_BOTTOM))
		self.background.convert()
Beispiel #4
0
def NextLevel():
    if not Config.testMode:
        Config.level += 1
        if Config.level > Config.maxlevel:
            # on boucle
            Config.level = 1
    Level.LoadLevel(Config.level)
    if Config.bossLevel:
        # niveau d'un boss
        Boss.doBossLevel()
    else:
        InitBG()
    Bonus.initBonus()
    Config.player.reset()
    Ball.BallInit()
Beispiel #5
0
def spawn():
    if wave%10 == 0:
        enemy = Boss(10,10,height)
        enemies.append(enemy)
    elif wave%5 == 0:
        picture = "Enemy.png"
        columns = 7
        for y in range(50, 500, 150):
            for x in range(50, 850, 150):
                enemy = Enemy(x,y,wave,picture,columns)
                enemies.append(enemy )
        
    elif wave%2 == 1:
        picture = "curtn.png"
        columns =3
        for y in range(50, 500, 150):
            for x in range(50, 850, 150):
                enemy = Enemy(x,y,wave,picture,columns)
                enemies.append(enemy)
    elif wave%2 == 0:
        picture = "sone.png"
        columns = 4
        for y in range(50, 500, 150):
            for x in range(50, 850, 150):
                enemy = Enemy(x,y,wave,picture,columns)
                enemies.append(enemy)
Beispiel #6
0
def boss_url_task(url):
    urls = Boss.main(url)
    if urls:
        for _url in urls:
            boss_info_task.apply_async(args=[_url], queue='boss')
        return 'Success(boss)'
    else:
        return 'Fail(boss)'
Beispiel #7
0
def update():
    global character, monsters
    global character_projectile
    global kill_counter
    global clear
    global boss_comeup
    global boss
    global map

    character.update()
    map.update()
    for i in range(30):
        if character_projectile[i] != None:
            character_projectile[i].update()
            if character_projectile[i].delete:
                character_projectile[i] = None
    for i in range(1000):
        if monster_projectile[i] != None:
            monster_projectile[i].update()
            if monster_projectile[i].delete:
                monster_projectile[i] = None

    kill_counter = 0
    if clear == False:
        for monster in monsters:
            if monster.dead == False:
                monster.update()
            else:
                kill_counter += 1
        if kill_counter == 60:
            for item in items:
                item.comeup = True
                items[0].x = character.x - 100
                items[0].y = character.y
                items[0].type = 1
                items[1].x = character.x + 100
                items[1].y = character.y
                items[1].type = 2
            clear = True

    for item in items:
        if item.comeup:
            item.update()

    if boss_comeup == 2:
        boss = Boss.Boss()
        boss_comeup += 1

    if boss_comeup == 3:
        boss.update()
Beispiel #8
0
class TestBoss(ut.TestCase):
    def setUp(self):
        self.boss = Boss(1000, 60, 60)

    def testShow_up(self):
        self.boss.show_up()
        self.assertEqual(self.boss.state, 1)
        self.assertEqual(self.boss.x, 85)
        self.assertEqual(self.boss.y, 30)

    def testMove(self):
        self.boss.show_up()
        self.boss.move()
        self.assertEqual(self.boss.x, 86)

    def testReset(self):
        self.boss.reset(1000)
        self.assertEqual(self.boss.state, 0)
        self.assertEqual(self.boss.life, 1000)
Beispiel #9
0
    def deploy(self):
        """
        Method to perform the main deployment run.
        """

        # Loop through the hostnames for this project, environment and context.
        for hostname in self.hosts:
            # Transfer and run the scripts
            try:
                # Connect to the remote host
                remotehost = Boss.client(hostname, self.user)
            except Exception, e:
                raise Exception("""There was an error connecting to host "{0}": {1}""".format(hostname, e))
            else:
                # Pass through the basedir, environment, project and context to the client object
                remotehost.environment = self.environment
                remotehost.project = self.project
                remotehost.context = self.context
                remotehost.varmap = self.varmap

                # Send the main configuration templates, config values and pkg/ data
                try:
                    remotehost.configure(self.path)
                except Exception, e:
                    raise Exception("There was a problem configuring the remote client, {0}: {1}".format(hostname, e))

                Boss.bosslog.info(remotehost)

                # Run the detokenisation process
                remotehost.detoken()

                # Run the common scripts
                remotehost.deploy(self.common_scriptdir)

                # Run the project specific scripts
                remotehost.deploy()

                del remotehost
Beispiel #10
0
def create_enemy(frame_time):
    global player, boss, background
    NormalEnemy.CreateTime += frame_time
    MiddleEnemy.CreateTime += frame_time
    HighEnemy.CreateTime += frame_time

    if player.StageTime >= 30:
        count = 3
    elif player.StageTime >= 10:
        count = 2
    else:
        count = 1

    if NormalEnemy.CreateTime >= 2.0:
        for i in range(count):
            enemy = NormalEnemy()
            EnemyList.append(enemy)
        NormalEnemy.CreateTime = 0.0
    if player.StageTime > 20:
        if MiddleEnemy.CreateTime >= 5.0:
            for i in range(count - 1):
                enemy = MiddleEnemy()
                EnemyList.append(enemy)
            MiddleEnemy.CreateTime = 0.0
    if player.StageTime > 50:
        if HighEnemy.CreateTime >= 5.0:
            enemy = HighEnemy()
            EnemyList.append(enemy)
            HighEnemy.CreateTime = 0.0

    # boss create
    if Boss.Create and boss == None:
        background.bossBgm.repeat_play()
        boss = Boss()
    elif Boss.CreateTime >= 110:
        Boss.Create = True
    else:
        Boss.CreateTime += frame_time
Beispiel #11
0
class BossKiller:
    def __init__(self):
        self.__boss = Boss()
        self.__name = "BossKiller"

    def affronterBoss(self, thisPathHistory, completeEventsHistory,
                      passwordHistory):
        stringToPrint = ""
        stringToPrint += "\nÉvènement Boss\n"

        stringToPrint += "a . "
        for each in self.__boss.getRightPath():
            stringToPrint += each + ", "
        stringToPrint = stringToPrint[:-2]

        stringToPrint += "\nb . " + "".join(passwordHistory) + " P={"

        if self.__boss.getRightPath() == thisPathHistory:

            self.__boss.genererAutomate()

            if self.__boss.thisPasswordIsValid(
                (''.join(passwordHistory) + "PorteBoss").split("Porte")[0]):
                for each in self.__boss.getProductions():
                    if "Boss" in each[1]:
                        stringToPrint += each[0] + "->" + each[1][:-4] + ", "
                    else:
                        stringToPrint += each[0] + "->" + each[1] + ", "
                stringToPrint = stringToPrint[:-2] + "}"
                stringToPrint += "\nc . L'agent vainc le Boss .\n"
            else:
                stringToPrint += "...}"
                stringToPrint += "\nc . Le Boss vainc l'agent . Retour a la Porte1 .\n"

        else:
            stringToPrint += "...}"
            stringToPrint += "\nc . Le Boss vainc l'agent . Retour a la Porte1 .\n"

        print(stringToPrint)
        completeEventsHistory += stringToPrint
Beispiel #12
0
from Boss import *
from Player import *

p1 = Player()
b = Boss()

print("Player Health: ", p1.getHealth())
print("Boss Health: ", b.getHealth())

turn = 1
while (p1.getHealth() > 0):
    print("\nTurn: ", turn)
    p1.takeDamage(b.attack())
    b.takeDamage(p1.attack())
    print("Player Health: ", p1.getHealth())
    print("Boss Health: ", b.getHealth())
Beispiel #13
0
def boss_info_task(url):
    return Boss.info(url)
Beispiel #14
0
import pygame
from pygame import mixer
import sys
import os
import time
import random
from Player import *
from Enemy import *
from Boss import *

os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"

player = Player()
bullet = Bullet()
boss = Boss()
extralife = Life()


class Game:
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((800, 600))
        self.background = pygame.image.load("data/background.png")
        self.FPS = 60
        mixer.music.load("data/background.wav")
        self.explosionSound = mixer.Sound("data/explosion.wav")
        self.explosionSound.set_volume(0.1)
        mixer.music.set_volume(0.3)
        mixer.music.play(-1)
        self.mute = False
        self.clock = pygame.time.Clock()
Beispiel #15
0
def game(difficulty, score, debug_state=False):
    lasers = []  # List of all the lasers
    game_quit = False  # Does the user want to quit?
    game_running = True  # Is the game running?
    game_state = ''
    frame_count = 0
    spray_toggle = False
    timers = {
        'time_start': time.time(),
        'last_spray_toggle': time.time(),
        'last_bomb_toggle': time.time(),
        'last_nocollide_toggle': time.time(),
        'last_ring_toggle': time.time(),
        'last_tinyman_toggle': time.time(),
        'last_bigbullets_toggle': time.time(),
        'last_slowtime_toggle': time.time(),
        'last_fasttime_toggle': time.time(),
        'last_debug_toggle': time.time(),
        'last_time_change': time.time()
    }
    debug_powerups = {
        'ring': False,
        'bomb': False,
        'nocollide': False,
        'tinyman': False,
        'bigbullets': False,
        'slowtime': False,
        'fasttime': False,
        'spray': False,
    }

    time_change = 0
    powerups = []
    # score = score
    score_thresh = 10

    pygame.event.clear()  # Good for the environment

    player_obj = Player.Player(WINDOW_X / 2, WINDOW_Y / 2, [], [])
    player_obj.debug = debug_state
    player_obj.refresh_debug()

    if difficulty % 5 == 0:
        boss_obj = Boss.Boss(difficulty * 5, (difficulty / 5.0) / FRAMERATE)
    else:
        boss_obj = False

    while game_running:
        frame_count += 1

        CLOCK.tick(FRAMERATE)
        SCREEN.fill(COLOR_SCREEN)

        if difficulty % 5 == 0:
            update_shots(boss_obj.shots, time_change)
            update_boss(boss_obj, player_obj, time_change)
            score = boss_obj.health
            check_collisions(lasers, player_obj, difficulty,
                             boss_obj)  # Do things touch other things?
        else:
            update_lasers(lasers, time_change)
            make_lasers(
                lasers,
                difficulty)  # If lasers despawn, make more to replace them
            check_time(debug_state, timers, score, score_thresh)
            score += check_collisions(
                lasers, player_obj, difficulty,
                boss_obj)  # Do things touch other things?
            if score >= score_thresh:
                score = score_thresh

        update_mouse(player_obj)

        game_running, game_state, game_quit = \
            update_events(game_running, game_state, game_quit, lasers)

        debug_state, last_spray_toggle, spray_toggle, time_change, debug_powerups = \
            update_keyboard(debug_state, timers, spray_toggle, player_obj, time_change, debug_powerups)

        update_bombs(player_obj)

        update_shots(player_obj.shots, time_change)

        time_change, powerup_display = \
            update_player(player_obj, debug_state)

        spawn_powerups(
            POWERUP_CHANCE,
            powerups)  # Chance that a powerup will spawn on any given second

        update_powerups(powerups, player_obj, debug_powerups)  # Draw powerups

        draw_gui(timers, difficulty, powerup_display, score, score_thresh
                 )  # Show the powerups being used, the level, time, etc.

        pygame.display.flip(
        )  # This is required by pygame to render the screen.
    return game_state, game_quit
Beispiel #16
0
# coding:utf-8
import Lagou, Boss
from RedisQueue import RedisQueue
import time

if __name__ == '__main__':
    rq = RedisQueue()
    while True:
        try:
            task_type, task = rq.pop_task(
                ['boss_basic', 'lagou_basic', 'boss_info', 'lagou_info'])
            print task_type
            if 'boss_basic' in task_type:
                Boss.main(task)
            elif 'lagou_basic' in task_type:
                pass
            elif 'boss_info' in task_type:
                Boss.info(task)
            elif 'lagou_info' in task_type:
                pass
        except Exception, e:
            print e
        time.sleep(5)
Beispiel #17
0
 def setup(self, bg, mc):
     self.Played = False
     self.bg = bg
     if self.minimap == "":
         self.minimap = minimap((0, 0), self)
         self.minimap = minimap(
             (self.width -
              self.bg.w / self.minimap.ratio * self.RATIO / 100 - 5,
              self.height -
              self.bg.h / self.minimap.ratio * self.RATIO / 100 - 5), self)
     #sprite group
     self.mobs = pygame.sprite.Group()
     self.mobs_0 = pygame.sprite.Group()
     self.mobs_4 = pygame.sprite.Group()
     self.mobs_1 = pygame.sprite.Group()
     self.mobs_2 = pygame.sprite.Group()
     self.mobs_3 = pygame.sprite.Group()
     self.Bullet_Main = pygame.sprite.Group()
     self.Bullet_Mobs = pygame.sprite.Group()
     self.Blade_mc = pygame.sprite.Group()
     self.Boss = pygame.sprite.Group()
     #mobs spawn
     tmp = mob0()
     Fish0 = []
     for i in range(number_of_mob_0):
         Fish0.append(
             mob0(self.spawn(bg, mc, tmp), "mob0\\ca01", self, bg,
                  MOB_MAX_HEALTH))
     tmp = mob1()
     Fish1 = []
     for i in range(number_of_mob_1):
         Fish1.append(
             mob1(self.spawn(bg, mc, tmp), "mob1\\ca12", self, bg,
                  MOB_MAX_HEALTH))
     tmp = mob2()
     Fish2 = []
     for i in range(number_of_mob_2):
         Fish2.append(
             mob2(self.spawn(bg, mc, tmp), "mob2\\ca21", self, bg,
                  MOB_MAX_HEALTH))
     tmp = mob3()
     Fish3 = []
     for i in range(number_of_mob_3):
         Fish3.append(
             mob3(self.spawn(bg, mc, tmp), "mob3\\cas31", self, bg,
                  MOB_MAX_HEALTH))
     tmp = mob4()
     Fish4 = []
     for i in range(number_of_mob_4):
         Fish4.append(
             mob4(self.spawn(bg, mc, tmp), "mob4\\ca41", self, bg,
                  MOB_MAX_HEALTH))
     tmp = Boss()
     BOSS = []
     for i in range(number_of_boss_1):
         BOSS.append(
             Boss(self.spawn(bg, mc, tmp), "boss\\ca100", self, bg,
                  MOB_MAX_HEALTH))
     for fish in Fish0:
         self.mobs_0.add(fish)
         self.mobs.add(fish)
     for fish in Fish1:
         self.mobs_1.add(fish)
         self.mobs.add(fish)
     for fish in Fish2:
         self.mobs_2.add(fish)
         self.mobs.add(fish)
     for fish in Fish3:
         self.mobs_3.add(fish)
         self.mobs.add(fish)
     for fish in Fish4:
         self.mobs_4.add(fish)
         self.mobs.add(fish)
     for fish in BOSS:
         self.Boss.add(fish)
         self.mobs.add(fish)
Beispiel #18
0
import Char
import Boss

Jacob = Char.Player("Jacob")
Snugs = Char.Warrior("Snugs")
Nui = Char.Archmage("Nui")
Cinder = Char.Necromancer("Cinder")
Ragnaros = Boss.Boss("Ragnaros", 5, 100, 5, 5, 5)

Ragnaros.take_damage(5)
Ragnaros.take_damage(96)
Snugs.greet()
Snugs.attack()
Beispiel #19
0
def init_singleplayer(screen, width, height, clock):
    small_font = pygame.font.SysFont('Corbel', 35)
    big_font = pygame.font.SysFont('Corbel', 100)

    team = choose_team(screen, width, height, clock)
    print(team)
    if team == "Republic":
        pass
    elif team == "Empire":
        pass
    else:
        return

    pygame.display.flip()
    display_star_wars_cinematic(screen, width, height, clock)

    player = Player.Player(team=team)
    enemies = create_all_enemies(team)

    level = 10
    global background_loop
    background_loop = True

    boss = Boss.Boss(Bullet.Bullet(100, 200))

    level_display_time = 0

    cooldown_on_spawn = 255
    first_spawn = True

    thread_background = threading.Thread(target=background,
                                         args=(screen, height, clock))
    thread_background.start()

    render_index = []
    render_index = generate_enemies(level, render_index)

    enemy_picked = random_enemy_fire(enemies, render_index)
    xwing_sound = pygame.mixer.Sound(constants.xwing_sound)

    while True:

        clock.tick(constants.FPS)
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_LEFT:
                    player.change_x = -7
                if event.key == pygame.K_RIGHT:
                    player.change_x = 7
                if event.key == pygame.K_UP:
                    player.change_y = -7
                if event.key == pygame.K_DOWN:
                    player.change_y = 7
                if event.key == pygame.K_SPACE:
                    if player.bullet.state == "Ready":
                        xwing_sound.play()
                        player.bullet.y = player.y
                        player.bullet.x = player.x + (
                            player.image.get_rect().width /
                            2) - (player.bullet.image.get_rect().width / 2)
                        player.bullet.state = player.fire(screen)
                if event.key == pygame.K_ESCAPE:
                    background_loop = False
                    thread_background.join()
                    return

            if event.type == pygame.KEYUP:
                if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                    player.change_x = 0
                if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
                    player.change_y = 0

        player.x += player.change_x
        player.y += player.change_y

        player.stay_in_screen(width, height)
        player.verif_bullet(screen)

        if not first_spawn and level < 10:
            enemy_picked.fire(screen)

        if is_collision(player, enemy_picked.bullet):
            enemy_picked.bullet.player_contact = True
            player.health -= 20
            player.x = width / 2 - player.image.get_rect().width / 2
            player.y = height - 150

        if level < 10:
            if enemy_picked.verif_bullet() == 0:
                enemy_picked = random_enemy_fire(enemies, render_index)

        if len(render_index) == 0 and level < 10:
            level += 1
            render_index = generate_enemies(level, render_index)
            level_display_time = 0

        if level == 10:
            boss.constant_move(screen)
            boss.fire(screen)

            if is_collision(boss, player.bullet):
                player.bullet.state = "Ready"
                player.bullet.y = player.y
                player.score += 1
                boss.hp -= 20
                if boss.hp == 0:
                    background_loop = False
                    thread_background.join()
                    lose_win(screen, width, height, clock, "Win")
                    return

            if is_collision(player, boss):
                player.x = width / 2 - player.image.get_rect().width / 2
                player.y = height - 150
                player.health -= 20

            if is_collision(player, boss.bullet):
                boss.bullet.player_contact = True
                player.health -= 20
                player.x = width / 2 - player.image.get_rect().width / 2
                player.y = height - 150

            boss.verif_bullet()

        if level < 10:
            for enemy in enemies:
                if enemies.index(enemy) in render_index:
                    if is_collision(enemy, player.bullet):
                        player.bullet.state = "Ready"
                        player.bullet.y = player.y
                        player.score += 1
                        render_index.remove(enemies.index(enemy))

                    if is_collision(player, enemy):
                        player.health -= 20
                        player.x = width / 2 - player.image.get_rect().width / 2
                        player.y = height - 150

        level_display_time += 1
        if level_display_time < 100:
            display_level(screen, level, width, height, big_font)
        display_score(screen, player.score, height, small_font)
        display_health(screen, player.health, height, small_font)

        if player.health == 0:
            background_loop = False
            thread_background.join()
            lose_win(screen, width, height, clock, "Lose")
            return

        if first_spawn:
            player.image.set_alpha(255 - cooldown_on_spawn)
            player.display_player(screen)
            cooldown_on_spawn -= 1
            if cooldown_on_spawn == 0:
                first_spawn = False
                player.image.set_alpha(255)
        else:
            player.display_player(screen)
        if not first_spawn and level < 10:
            for enemy in enemies:
                if enemies.index(enemy) in render_index:
                    enemy.display_enemy(screen)

        pygame.display.flip()
Beispiel #20
0
#!/usr/bin/env python

from classzs import Employee
from Boss import *
emp1 = Employee("Zara", 2200)
emp2 = Employee("Xile", 3350)
emp1.displayEmployee()
boss = Boss("Arma", "cccia")
boss.displayBoss()
emp1.displayCount()
del emp2
# emp2.displayEmployee()
emp1.displayCount()
Beispiel #21
0
        print self.rect.center

    def fire(self, spritelist, image, screen):
        print "VUUR!"
        if self.timer < pygame.time.get_ticks():
            spritelist.add(Fireball(image, self.rect, screen))
            self.timer = pygame.time.get_ticks() + 500

screen, background = init_screen(PANDORA)
pygame.display.flip()
dragon_img, boss_img, boss_hit_img, fireball_img, demon_img, baby_img = init_images()
boss_hit_snd = init_sound()
rendering = pygame.sprite.RenderUpdates()

dragon = Dragon(dragon_img, screen)
boss = Boss(boss_img, boss_hit_img, boss_hit_snd, screen)
rendering.add(dragon)
rendering.add(boss)
fireballs = pygame.sprite.RenderUpdates()
demons = pygame.sprite.RenderUpdates()
babies = pygame.sprite.RenderUpdates()

while True:
    clock.tick(30)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()

        elif event.type == DEMON_EVENT:
            boss.release_demon(demons, demon_img, screen)
Beispiel #22
0
def main():

    # ____________ VARIABLE DECS _________________________

    pygame.init()
    global display_surf

    global BASIC_FONT, BASIC_FONT_SIZE, BASIC_FONT_1

    BASIC_FONT_SIZE = 15
    BASIC_FONT = pygame.font.Font('freesansbold.ttf', BASIC_FONT_SIZE)
    BASIC_FONT_1 = pygame.font.Font('freesansbold.ttf', 15)
    COMMAND_FONT = pygame.font.Font('freesansbold.ttf', 10)

    fps_clock = pygame.time.Clock()
    display_surf = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
    pygame.display.set_caption('Platformer')

    player = Player.Player(WINDOW_WIDTH, WINDOW_HEIGHT, LINE_THICKNESS)

    finished = False

    current_text_lines = []

    # current_text = ""

    enemies = []

    multiplier = 1

    move_up = False
    move_down = False
    move_left = False
    move_right = False

    e_spawn_counter = 0

    is_dead = False

    last_is_on = 0

    platform_vel = 1

    start_ticks = pygame.time.get_ticks()

    level_type = "vertical"

    game_started = False

    command_displayed = False

    newline_counter = 1
    line_counter = 1

    current_text = "%s::~>> " % str(newline_counter)

    level_complete = False
    challenge_complete = False

    current_level = 1

    problem_displayed = False
    problem_solved = False

    # _______ IMAGE STUFF __________________

    blood_right = GIFImage.GIFImage("blood_anim_right.gif")
    blood_left = GIFImage.GIFImage("blood_anim_2.gif")

    # image example
    # pentagram = pygame.image.load('pentagram.png').convert()

    # ____________ SOUND STUFF ____________

    #music = pygame.mixer.Sound("generic_metal.wav")
    #channel = music.play()      # Sound plays at full volume by default
    #music.set_volume(0.9)

    # ________ LEVEL GENERATION ___________

    ground = 0

    # level 1

    for i in range(52):

        rand = random.randint(10, 300)
        rand_width = random.randint(30, 100)
        rand_type = random.randint(1, 5)
        if rand_type == 2:
            t = "moving"
        else:
            t = "static"

        if i > 0 and i < 10:
            platforms.append(
                Platform.Platform(
                    rand,
                    WINDOW_HEIGHT / 2 - LINE_THICKNESS / 2 + 100 - 50 * (i),
                    rand_width, 10, t, 1))
        elif i >= 10 and i < 20:
            platforms.append(
                Platform.Platform(
                    rand,
                    WINDOW_HEIGHT / 2 - LINE_THICKNESS / 2 + 100 - 50 * (i),
                    rand_width, 10, t, 1))
        elif i >= 20 and i < 51:
            platforms.append(
                Platform.Platform(
                    rand,
                    WINDOW_HEIGHT / 2 - LINE_THICKNESS / 2 + 100 - 50 * (i),
                    rand_width, 10, t, 1))
        elif i == 0:
            platforms.append(
                Platform.Platform(
                    10,
                    WINDOW_HEIGHT / 2 - LINE_THICKNESS / 2 + 100 - 50 * (i),
                    50, 10, "static", 1))
        elif i == 51:
            platforms.append(
                Platform.Platform(
                    10, WINDOW_HEIGHT / 2 - LINE_THICKNESS / 2 +
                    (100 - 50 * (i)) - 50, 2000, 10, "static", 1))
            ground = WINDOW_HEIGHT / 2 - LINE_THICKNESS / 2 + (100 - 50 *
                                                               (i)) - 50

    # level 2 ______

    for i in range(50):
        rand = random.randint(100, 300)
        rand_width = random.randint(30, 100)
        platforms.append(
            Platform.Platform(400 + (i * 100), ground - (i * 100), rand_width,
                              10, "static", 0))

    # Draws the starting position of the Arena

    #draw_arena()

    #player.draw(display_surf, WHITE)

    #for i in platforms:
    #i.draw(display_surf, blue)

    draw_title_screen()

    is_on = -1

    pygame.mouse.set_visible(0)  # make cursor invisible

    mouse_x = 0
    mouse_y = 0

    gravity = 5

    boss_can_spawn = False
    boss_is_active = False

    boss = Boss(platforms[51].rect.x + 100, platforms[51].rect.y - 10,
                LINE_THICKNESS)

    text_flicker_counter = 0

    screen_flicker_counter = 0

    # ________________ START GAME LOOP ____________________________

    while True:  # main game loop
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if event.type == MOUSEMOTION:
                mouse_x, mouse_y = event.pos
                player.aim_move(mouse_x, mouse_y)

            if event.type == pygame.KEYDOWN:
                if command_displayed:
                    if len(current_text) <= 30:
                        if event.key == pygame.K_a:
                            current_text += "a"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_b:
                            current_text += "b"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_c:
                            current_text += "c"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_d:
                            current_text += "d"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_e:
                            current_text += "e"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_f:
                            current_text += "f"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_g:
                            current_text += "g"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_h:
                            current_text += "h"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_i:
                            current_text += "i"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_j:
                            current_text += "j"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_k:
                            current_text += "k"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_l:
                            current_text += "l"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_m:
                            current_text += "m"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_n:
                            current_text += "n"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_o:
                            current_text += "o"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_p:
                            current_text += "p"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_q:
                            current_text += "q"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_r:
                            current_text += "r"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_s:
                            current_text += "s"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_t:
                            current_text += "t"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_u:
                            current_text += "u"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_v:
                            current_text += "v"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_w:
                            current_text += "w"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_x:
                            current_text += "x"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_y:
                            current_text += "y"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_z:
                            current_text += "z"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_EQUALS:
                            current_text += "="
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_SLASH:
                            current_text += "/"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_PLUS:
                            current_text += "+"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_KP_PLUS:
                            current_text += "+"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_MINUS:
                            current_text += "-"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_ASTERISK:
                            current_text += "*"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_0:
                            current_text += "0"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_1:
                            current_text += "1"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_2:
                            current_text += "2"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_3:
                            current_text += "3"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_4:
                            current_text += "4"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_5:
                            current_text += "5"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_6:
                            current_text += "6"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_7:
                            current_text += "7"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_8:
                            current_text += "8"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_9:
                            current_text += "9"
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_SPACE:
                            current_text += " "
                            text = BASIC_FONT.render(current_text, True, green)
                        elif event.key == pygame.K_BACKSPACE:
                            current_text = current_text[:-1]
                            text = BASIC_FONT.render(current_text, True, green)

                        elif event.key == pygame.K_RETURN:
                            commands.append(
                                Textbox(current_text, green, BASIC_FONT,
                                        newline_counter))
                            if input_command(current_text):
                                output = input_command(current_text)
                                if level_complete:
                                    if output == 10:
                                        problem_solved = True
                                        command_displayed = False
                                        game_started = True
                                        current_level = 2
                                newline_counter += 1
                                commands.append(
                                    Textbox(str(output), green, BASIC_FONT,
                                            newline_counter))
                            newline_counter += 1
                            line_counter += 1

                            current_text = "%s::~>> " % str(line_counter)
                            # submit current_text to lang and move to next line
                            pass

                if event.key == pygame.K_BACKQUOTE:
                    if command_displayed == False:
                        display_surf.fill((0, 0, 0))
                        newline_counter = 1
                        line_counter = 1
                        game_started = False
                        command_displayed = True
                        display_command_prompt(current_text, newline_counter)
                    else:
                        if level_complete != True:
                            game_started = True
                            problem_solved = True
                            command_displayed = False
                        else:
                            command_displayed = False

                if command_displayed:
                    display_command_prompt(current_text, newline_counter)

                if event.key == pygame.K_a:
                    if player.can_move_left:
                        move_left = True
                if event.key == pygame.K_d:
                    if player.can_move_right:
                        move_right = True
                if event.key == pygame.K_LSHIFT:
                    multiplier = 2
                if event.key == pygame.K_SPACE:
                    if player.can_jump:
                        # can_jump = False
                        player.is_jumping = True
                        player.can_jump = False
                        if last_is_on < 51:
                            player.jump(50)
                        else:
                            player.jump(100)
                    if player.can_wall_jump:
                        # can_wall_jump = False
                        player.is_wall_jumping = True
                        player.can_wall_jump = False
                        if last_is_on < 51:
                            player.wall_jump(30)
                        else:
                            player.wall_jump(60)
                if event.key == pygame.K_f:
                    if player.can_slash:
                        player.slash()
                    player.can_slash = False
                    pass

            if event.type == pygame.KEYUP:
                if event.key == pygame.K_w:
                    move_up = False
                if event.key == pygame.K_a:
                    move_left = False
                if event.key == pygame.K_s:
                    move_down = False
                if event.key == pygame.K_d:
                    move_right = False
                if event.key == pygame.K_LSHIFT:
                    while (float(multiplier) > 1):
                        multiplier -= .05
                if event.key == pygame.K_SPACE:
                    pass
                if event.key == pygame.K_f:
                    player.slash_revert()
                    player.can_slash = True
                    pass
                if event.key == pygame.K_RETURN:
                    if (game_started == False and command_displayed == False):
                        game_started = True
                    elif (game_started == False and command_displayed == True):
                        for i in commands:
                            i.draw(display_surf)
                    if (is_dead):
                        display_surf.fill((0, 0, 0))
                        player.is_falling = False
                        platforms.clear()
                        main()

        if pygame.mouse.get_pressed()[0]:
            # player.shoot(mouse_x, mouse_y)
            pass

        # _______________ IF RETURN PRESSED, START GAME ________________

        if game_started:

            # _______ ENEMY SPAWNING _________________

            if platforms[is_on].type != "last" and current_level == 1:

                e_spawn_counter += 1

                if e_spawn_counter > 100:

                    enemies.append(Enemy.Enemy())

                    e_spawn_counter = 0

            # _______ PLAYER MOVEMENT _________________

            if move_right:
                if level_type == "vertical":
                    if (player.rect.right < right_side_rect.left - 2):
                        player.move_right(multiplier)
                    else:
                        player.rect.x = right_side_rect.x - 11
                        player.hit_rect.x = right_side_rect.x - 11
                        player.can_move_right = False
                        if not player.is_wall_jumping:
                            player.can_wall_jump = True
                if level_type == "horizontal":
                    for i in platforms:
                        i.move_left(4 * multiplier)
                    left_side_rect.x -= (4 * multiplier)

                    if (player.rect.x < 300):
                        player.move_right(multiplier)

            if move_left:
                if level_type == "vertical":
                    if (player.rect.left > left_side_rect.right + 2):
                        player.move_left(multiplier)
                    else:
                        player.rect.x = left_side_rect.x + 11
                        player.hit_rect.x = left_side_rect.x + 11
                        player.can_move_left = False
                        if not player.is_wall_jumping:
                            player.can_wall_jump = True
                if level_type == "horizontal":
                    for i in platforms:
                        i.move_right(4 * multiplier)
                    left_side_rect.x += (4 * multiplier)
                    if (player.rect.x > 100):
                        player.move_left(multiplier)

            if player.rect.left > left_side_rect.right + 2:
                player.can_move_left = True
            if player.rect.right < right_side_rect.left - 2:
                player.can_move_right = True
            if player.rect.left > left_side_rect.right + 2 and player.rect.right < right_side_rect.left - 2:
                player.can_wall_jump = False

            # _______________ RANDOM DRAWING _________________________

            draw_arena()
            draw_sides()
            player.draw(display_surf, WHITE)

            # _______ BOSS STUFF _____________

            if boss_is_active:
                boss.move(right_side_rect, left_side_rect)
                boss.draw_health(display_surf, red, grey)
                if player.check_slash_collision(boss.rect):
                    boss.health -= 1

            if (boss.health > 0):
                boss.draw(display_surf, red)
            else:
                boss_is_active = False
                boss.draw_health(display_surf, BLACK, BLACK)
                level_complete = True

            boss.rect.y = platforms[51].rect.y - (LINE_THICKNESS + 10)

            #________ IF LEVEL HAS COMPLETED __________

            if level_complete:
                game_started = False
                if problem_displayed == False and problem_solved == False:
                    display_surf.fill((0, 0, 0))
                    draw_problem_screen(current_level)
                    problem_displayed = True
                if problem_solved:
                    problem_displayed = False
                    command_displayed = False
                    current_level = 2
                    level_complete = False
                    game_started = True

            # draw you win stuff

            # ____________ ENEMY STUFF ________________

            for i in enemies:
                i.move(player.rect.x, player.rect.y)
                i.draw(display_surf)
                if player.check_slash_collision(i.rect):
                    enemies.remove(i)
                if player.check_enemy_collision(i.rect):
                    player.health -= 1
                if i.rect.top < platforms[51].rect.bottom:
                    enemies.remove(i)

            # __________ PLATFORM STUFF ______________

            for i in range(len(platforms)):

                if platforms[i].rect.y > player.rect.y + 300:
                    platforms[i].type = "inactive"

                if platforms[i].type is not "inactive":

                    platforms[i].draw(display_surf, blue)
                    platforms[i].rect.y += platforms[i].vel

                    if platforms[i].type == "moving":
                        platforms[i].side_move()

                    if player.check_plat_collision(platforms[i].rect):
                        is_on = i
                        last_is_on = i
                        player.is_falling = False
                        player.is_jumping = False
                        player.rect.y = platforms[i].rect.y - platforms[
                            i].height - 1
                        player.hit_rect.y = platforms[i].rect.y - platforms[
                            i].height - 1
                        player.can_jump = True
                        player.on_ground = True

            if (is_on > -1):
                if player.is_jumping == False:
                    if platforms[is_on].type is not "inactive":
                        if player.rect.right < platforms[
                                is_on].rect.left or player.rect.left > platforms[
                                    is_on].rect.right:
                            player.is_falling = True
                            is_on = -1
                            player.can_jump = False

            # Increase platform speed

            if last_is_on >= 10 and last_is_on <= 20:
                for i in platforms:
                    i.vel = 1
            elif last_is_on >= 21 and last_is_on < 50:
                for i in platforms:
                    i.vel = 2
            elif last_is_on >= 49:
                if platforms[50].rect.y < platforms[51].rect.y + 250:
                    platforms[51].vel = 1
                else:
                    if current_level == 1:
                        #if last_is_on == 51:
                        for i in range(len(platforms)):
                            if i > 51:
                                platforms[i].set_plat_vel(0)
                                platforms[i].type = "last"
                        # platforms[51:].set_plat_vel(0)
                        platforms[51].set_plat_vel(0)
                        # platforms[51:].type = "last"
                        platforms[51].type = "last"
                        boss_is_active = True

            else:
                platform_vel = 0

            # Jumping stuff ---------------------------------

            if (player.is_falling):
                if (player.rect.y < player.max_height + 10):
                    gravity = 3
                if (player.rect.y < player.max_height + 30):
                    gravity = 5

                for i in platforms:
                    if i.type != "last":
                        i.rect.y -= gravity + 1
                for i in enemies:
                    i.rect.y -= gravity + 1
                player.rect.y += gravity
                player.hit_rect.y += gravity

            if (player.is_wall_jumping):
                player.can_wall_jump = False
                if (player.rect.y > player.max_height):
                    if (player.rect.y < player.max_height + 30):
                        gravity = 3
                    if (player.rect.y < player.max_height + 10):
                        gravity = 1

                    for i in platforms:
                        if i.type != "last":
                            i.rect.y += gravity + 2
                    for i in enemies:
                        i.rect.y += gravity + 2
                    player.rect.y -= gravity
                    player.hit_rect.y -= gravity
                else:
                    player.is_wall_jumping = False
                    player.is_falling = True

            if (player.is_jumping == True):
                player.can_jump = False
                if (player.rect.y > player.max_height):
                    if (player.rect.y < player.max_height + 30):
                        gravity = 3
                    if (player.rect.y < player.max_height + 10):
                        gravity = 1

                    for i in platforms:
                        if i.type != "last":
                            i.rect.y += gravity + 2
                    for i in enemies:
                        i.rect.y += gravity + 2
                    player.rect.y -= gravity
                    player.hit_rect.y -= gravity
                else:
                    player.is_jumping = False
                    player.is_falling = True

            if (player.is_jumping == False and player.is_falling == False):
                player.can_jump = True
                player.rect.y += platforms[is_on].vel
                player.hit_rect.y += platforms[is_on].vel

            if (player.is_falling == True):
                player.can_jump = False
                player.is_jumping = False
                player.is_wall_jumping = False

            # --------------------------------------------

            # ________ LEVEL 2 ______________

            if game_started and problem_solved:
                #problem_solved = False
                current_level = 2
                level_type = "horizontal"
                right_side_rect.x += 2000
                for i in platforms:
                    i.type = "static"

            if game_started:
                if problem_displayed:
                    pass
                else:
                    if player.health > 0:
                        display_health(player.health, green, grey)
                    else:
                        display_surf.fill((0, 0, 0))
                        display_death(current_text)
                        is_dead = True
                        game_started = False

            # check death

            if (platforms[last_is_on].rect.y < -200):
                display_surf.fill((0, 0, 0))
                display_death(current_text)
                is_dead = True
                game_started = False

            # -----------------------------------------

        pygame.display.update()

        fps_clock.tick(FPS)
Beispiel #23
0
    # Get the command line options
    parser = optparse.OptionParser()
    parser.add_option("-p", "--project", dest="project", help="The project scripts to execute.")
    parser.add_option("-e", "--env", dest="environment", help="The environment to deploy to.")
    parser.add_option("-c", "--context", dest="context", help="The context of the project.")
    parser.add_option("-l", "--loglevel", dest="loglevel", help="The loglevel of the project.  e.g. DEBUG, INFO, WARN, ERROR")
    (options, args) = parser.parse_args()

    # Ensure all three 'options' are provided
    if (not options.project or not options.environment or not options.context):
        Boss.bosslog.error(parser.print_help())
        sys.exit(1)

    # Set the logging level, if provided
    if options.loglevel:
        try:
            loglevel = eval("logging." + options.loglevel.upper())
            Boss.bosslog.setLevel(loglevel)
        except AttributeError:
            raise Exception("""No such logging level as "{0}".""".format(options.loglevel))

    # GO!
    try:
        system = Boss.server(options.project, options.environment, options.context)
        system.deploy()
    except Exception, e:
        Boss.bosslog.error("There was an error: {0}".format(e))
        if Boss.bosslog.getEffectiveLevel() == logging.DEBUG:
            # Print a traceback to help work out any issues
            traceback.print_exc(file=sys.stdout)
Beispiel #24
0
def spawn_Boss():
    for x in range(0, 1):
        bosses.append(Boss(x * 200, 0))
    def generate(self):
        self.timer += 1

        if self.level == 1:

            if self.next_wave():
                self.generate_wave_1(6, 0)

            self.next_level()

        if self.level == 2:
            if self.next_wave():
                self.generate_wave_1(8, 0)

            self.next_level()

        if self.level == 3:
            if self.next_wave():
                self.generate_wave_1(4, 1)
                self.generate_wave_1(4, 2)

            self.next_level()

        if self.level == 4:

            if not self.check_for_enemy():
                Mediator.all_game_objects.append(
                    Boss(100, -20, 0, 'boss', self.screen))

            if self.check_for_boss():
                self.skip_level()

        if self.level == 5:
            if self.next_wave():
                self.generate_wave_1(10, 1)
            self.next_level()

        if self.level == 6:
            if self.next_wave():
                self.generate_wave_1(8, 0)
                self.generate_wave_1(8, 1)
            self.next_level()

        if self.level == 7:
            if self.next_wave():
                self.generate_wave_1(8, 0)
                self.generate_wave_1(8, 1)
                self.generate_wave_1(8, 2)
            self.next_level()

        if self.level == 8:
            if self.next_wave():
                self.generate_wave_1(10, 0)
                self.generate_wave_1(10, 1)
                self.generate_wave_1(10, 2)
            self.next_level()

        if self.level == 9:
            #if self.next_wave():
            #self.generate_wave_1(4,0)
            #self.generate_wave_1(4,1)
            #self.generate_wave_1(4,2)

            if not self.check_for_enemy():
                Mediator.all_game_objects.append(
                    Boss(100, -20, 0, 'boss', self.screen, 2))

            if self.check_for_boss():
                self.skip_level()

        if self.level == 10:
            self.game_completed = True
Beispiel #26
0
 def setUp(self):
     self.boss = Boss(1000, 60, 60)
Beispiel #27
0
def main():
    # Initialisation de la fenêtre d'affichage
    pygame.init()
    Config.screen = pygame.display.set_mode(
        (Config.screenWidth, Config.screenHeight), HWSURFACE | DOUBLEBUF)
    pygame.display.set_caption(Config.titre)

    # le son
    pygame.mixer.init(44100, -16, 2, 4096)

    # le logo d'hommage ^^
    Config.logo, Config.logo_r = Tools.load_png('logo.png')

    # les bords de la surface de jeu
    Config.bords = Border.Border()

    # le niveau
    Level.LoadLevel(Config.level)

    if Config.bossLevel:
        # niveau d'un boss
        Boss.doBossLevel()
    else:
        # le fond
        Tools.InitBG()

    Tools.ReadHighScore()

    # la zone d'info
    Config.zinfo = pygame.Surface([(Config.screenWidth - Config.bords.width),
                                   Config.screenHeight])
    Config.zinfo.fill(THECOLORS["black"])

    # Le joueur (la raquette)
    Config.player = Player.Bat('player-bat-02.png', 'player-bat-02-L.png',
                               'player-bat-02-S.png')

    # La première balle
    Ball.BallInit()

    # les ennemis
    Enemys.init()

    # les sons
    Tools.InitSounds()
    pygame.mixer.music.set_volume((Config.Volume / 100))

    # Affichage
    Config.screen.blit(Config.bg, (0, 0))
    Config.bords.draw()
    Tools.MsgInfo()
    Level.DrawLevel()
    Config.player.draw()
    Ball.Ballsdraw()
    Enemys.draw()
    pygame.display.flip()

    # Initialisation de l'horloge
    Config.clock = pygame.time.Clock()

    # timer user pour la màj des fps (déclenché 1 fois/seconde)
    pygame.time.set_timer(USEREVENT, 1000)
    # timer pour la génération des ennemis (déclenché toutes les 10s)
    pygame.time.set_timer((USEREVENT + 1), 10000)
    # timer pour la génération des bombes et missiles du boss (déclenché toutes les 5s)
    pygame.time.set_timer((USEREVENT + 2), 5000)

    Config.Sounds['intro'].play()

    # Boucle d'évènements
    while True:
        event_handler()

        dt = Config.clock.tick(Config.FPS) / 1000

        Ball.Ballsupdate()

        if Config.Perdu:
            Config.life -= 1
            if Config.life > 0:
                Tools.MsgCenter("Oops...", 28,
                                Config.zinfo.get_rect().centery, "cyan", True)
                pygame.display.flip()
                # petite tempo
                pygame.time.wait(1500)
                Config.Perdu = False
                Bonus.initBonus()
                Config.player.reset()
                Ball.BallInit()
            else:
                # perdu...
                Tools.GameOver()
        else:
            if Config.bossLevel:
                if Config.boss.update():
                    Config.life -= 1
                    if Config.life <= 0:
                        # perdu...
                        Tools.GameOver()
            Config.player.update()
            Bonus.update()
            Enemys.update()

        if Config.bossLevel:
            if Config.boss.isDead:
                # niveau suivant
                Tools.MsgCenter("!! Bravo !!", 28,
                                Config.zinfo.get_rect().centery, "blue", True)
                pygame.display.flip()
                # petite tempo
                pygame.time.wait(5000)
                Tools.NextLevel()

        if Level.FinishedLevel():
            # niveau suivant
            Tools.MsgCenter("Level UP!", 28,
                            Config.zinfo.get_rect().centery, "green", True)
            pygame.display.flip()
            # petite tempo
            pygame.time.wait(1500)
            Tools.NextLevel()

        # affichages
        Config.screen.blit(Config.bg, (0, 0))
        Config.bords.draw()
        Tools.MsgInfo()
        Level.DrawLevel()
        Config.player.draw()
        Ball.Ballsdraw()
        Bonus.draw()
        Bonus.drawAdds()
        Enemys.draw()
        pygame.display.flip()
Beispiel #28
0
 def __init__(self):
     self.__boss = Boss()
     self.__name = "BossKiller"
Beispiel #29
0
    def read(self, mc, bg):
        bg.read()
        self.bg = bg
        f = open("saves\\game_save.txt", "r")
        read = f.readlines()
        count1 = int(read[0])
        count2 = int(read[1])
        count3 = int(read[2])
        self.mobs = pygame.sprite.Group()
        self.mobs_0 = pygame.sprite.Group()
        self.mobs_4 = pygame.sprite.Group()
        self.mobs_1 = pygame.sprite.Group()
        self.mobs_2 = pygame.sprite.Group()
        self.mobs_3 = pygame.sprite.Group()
        self.Bullet_Main = pygame.sprite.Group()
        self.Bullet_Mobs = pygame.sprite.Group()
        self.Blade_mc = pygame.sprite.Group()
        self.Boss = pygame.sprite.Group()
        for i in range(count1):
            Fish = fish()
            Fish.read(i)
            if Fish.mob == 0:
                tmp = Fish.rpos
                Fish = mob0(Fish.pos, Fish.name, self, bg, Fish.health)
                Fish.rpos = tmp
                self.mobs_0.add(Fish)
                self.mobs.add(Fish)
            if Fish.mob == 1:
                tmp = Fish.rpos
                Fish = mob1(Fish.pos, Fish.name, self, bg, Fish.health)
                Fish.rpos = tmp
                self.mobs_1.add(Fish)
                self.mobs.add(Fish)
            if Fish.mob == 2:
                tmp = Fish.rpos
                Fish = mob2(Fish.pos, Fish.name, self, bg, Fish.health)
                Fish.rpos = tmp
                self.mobs_2.add(Fish)
                self.mobs.add(Fish)
            if Fish.mob == 3:
                tmp = Fish.rpos
                Fish = mob3(Fish.pos, Fish.name, self, bg, Fish.health)
                Fish.rpos = tmp
                self.mobs_3.add(Fish)
                self.mobs.add(Fish)
            if Fish.mob == 4:
                tmp = Fish.rpos
                Fish = mob4(Fish.pos, Fish.name, self, bg, Fish.health)
                Fish.rpos = tmp
                self.mobs_4.add(Fish)
                self.mobs.add(Fish)
            if Fish.mob == 100:
                tmp = Fish.rpos
                Fish = Boss(Fish.pos, Fish.name, self, bg, Fish.health)
                Fish.rpos = tmp
                self.Boss.add(Fish)
                self.mobs.add(Fish)
        for i in range(count2):
            Bullet = bullet()
            Bullet.read(i, "mob")
            Bullet = bullet(Bullet.pos, self, bg, Bullet.name, Bullet.vx,
                            Bullet.vy)
            self.Bullet_Mobs.add(Bullet)

        for i in range(count3):
            Bullet = bullet()
            Bullet.read(i, "main")
            Bullet = bullet(Bullet.pos, self, bg, Bullet.name, Bullet.vx,
                            Bullet.vy)
            self.Bullet_Main.add(Bullet)
        self.stage = int(read[3])
        self.RATIO = int(read[4])
        mc.read(self)
        self.updated = True
        self.minimap = minimap((0, 0), self)
        self.minimap = minimap(
            (self.width - self.bg.w / self.minimap.ratio * self.RATIO / 100 -
             5, self.height -
             self.bg.h / self.minimap.ratio * self.RATIO / 100 - 5), self)
Beispiel #30
0
import Boss

Boss.bad_boss("Bill Steves")
def keyboard(text):
    # Башня
    if text.lower() == "Войти в башню".lower():
        keyboard_show = Tower.initiate_bashnya()
        return keyboard_show
    elif text.lower() == "Где я могу найти их?".lower():
        keyboard_show = Tower.dialog_answer_buttons_3()
        return keyboard_show
    elif text.lower() == "По рукам!".lower():
        keyboard_show = Tower.end_room_buttons()
        return keyboard_show
    elif text.lower(
    ) == "Дверь за спиной мастера Торхилда, ведет в кабинет лорда".lower():
        keyboard_show = LordsRoom.dialog_answer_buttons_1()
        return keyboard_show
    elif text.lower() == "Дверь справа – в Библиотеку".lower():
        keyboard_show = Library.initiate()
        return keyboard_show
    # Библиотека
    if text.lower() == "Библиотека".lower():
        keyboard_show = Library.initiate()
        return keyboard_show
    elif text.lower() == "Подойти к человеку".lower():
        keyboard_show = Library.dialog_answer_buttons_1()
        return keyboard_show
    elif text.lower(
    ) == "Я расследую исчезновение лорда. А ты случайно не Ри?".lower():
        keyboard_show = Library.dialog_answer_buttons_2()
        return keyboard_show
    elif text.lower(
    ) == "Эти байки для стражи можешь и оставить, а мне расскажи-ка лучше про это *кладете перед ним книгу в черной обложке*".lower(
    ):
        keyboard_show = Library.dialog_answer_buttons_3()
        return keyboard_show
    elif text.lower(
    ) == "Тише-тише, я даже не понимаю, что здесь написано.".lower():
        keyboard_show = Library.dialog_end_buttons()
        return keyboard_show
    elif text.lower() == "Хм.. ну ладно".lower():
        keyboard_show = Library.end_room_buttons()
        return keyboard_show
    # Кабинки Лорда
    if text.lower() == "Кабинет лорда".lower():
        keyboard_show = LordsRoom.dialog_answer_buttons_1()
        return keyboard_show
    elif text.lower(
    ) == "Я расследую пропажу лорда Винздора *показываете ему бумагу от мастера Торхилда*".lower(
    ):
        keyboard_show = LordsRoom.find_1()
        return keyboard_show
    elif text.lower() == "Осмотреть стол".lower():
        keyboard_show = LordsRoom.find_2()
        return keyboard_show
    elif text.lower() == "Осмотреть книжный шкаф".lower():
        keyboard_show = LordsRoom.find_4()
        return keyboard_show
    elif text.lower() == "Осмотреть внимательно".lower():
        keyboard_show = LordsRoom.find_3()
        return keyboard_show
    elif text.lower() == "Перейти к изучению шкафа".lower():
        keyboard_show = LordsRoom.find_4()
        return keyboard_show
    elif text.lower() == "Надеть амулет".lower():
        keyboard_show = LordsRoom.end_room_buttons()
        return keyboard_show
    elif text.lower() == "Спрятать амулет в карман и перейти к шкафу".lower():
        keyboard_show = LordsRoom.find_4()
        return keyboard_show
    elif text.lower() == "Положить книгу в карман и выйти из кабинета".lower():
        keyboard_show = LordsRoom.end_room_buttons()
        return keyboard_show
    elif text.lower() == "В библиотеку".lower():
        keyboard_show = Library.initiate()
        return keyboard_show
    elif text.lower() == "На площадь".lower():
        if rand == 2:
            keyboard_show = randomroom.initiate()
            return keyboard_show
        else:
            keyboard_show = Library.end_room_buttons()
            return keyboard_show
    elif text.lower() == "Пройти в переулок".lower():
        keyboard_show = Boss.run_buttons()
        return keyboard_show

    # Таверна
    if text.lower() == "Здесь же расположена таверна Кровавый кабан".lower():
        keyboard_show = tavern.initiate()
        return keyboard_show
    elif text.lower() == "Вернуться на площадь".lower():
        keyboard_show = Library.end_room_buttons()
        return keyboard_show
    elif text.lower() == "Подойти к мужчине за столом".lower():
        keyboard_show = tavern.dialog_answer_buttons_1()
        return keyboard_show
    elif text.lower() == "Воу-воу! Палехчи, приятель!".lower():
        keyboard_show = tavern.dialog_answer_buttons_2()
        return keyboard_show
    elif text.lower() == "Ясно. не переживай, я никому не скажу тоже".lower():
        keyboard_show = Elaniya.dialog_answer_buttons_1()
        return keyboard_show
    elif text.lower(
    ) == "Подойти к красивой барышне за дальним столиком".lower():
        keyboard_show = tavern.dialog_women_buttons()
        return keyboard_show
    elif text.lower() == "Может поднимимся наверх?".lower():
        keyboard_show = tavern.dialog_women_buttons2()
        return keyboard_show
    elif text.lower() == "Ну ее. Я не ищу продажной любви".lower():
        keyboard_show = tavern.initiate()
        return keyboard_show
    elif text.lower() == "Бежать!!!".lower():
        keyboard_show = Library.end_room_buttons()
        return keyboard_show
    #Дом Элании
    if text.lower(
    ) == "Я по поручению мастера Торхилда, расследую дело об исчезновении лорда-протектора Винздора *показываете депешу*".lower(
    ):
        keyboard_show = Elaniya.dialog_answer_buttons_2()
        return keyboard_show
    elif text.lower() == "А что за праздник-то?".lower():
        keyboard_show = Elaniya.dialog_answer_buttons_3()
        return keyboard_show
    elif text.lower() == "Оооок".lower():
        keyboard_show = Elaniya.dialog_answer_buttons_4()
        return keyboard_show
    elif text.lower() == "подойти к Элании".lower():
        keyboard_show = Elaniya.dialog_answer_buttons_5()
        return keyboard_show
    elif text.lower(
    ) == "Я хочу поговорить о пропаже вашего жениха. Скажите, леди, он не рассказывал вам что ни будь странное или пугающее о своих планах?".lower(
    ):
        keyboard_show = Elaniya.dialog_answer_buttons_6()
        return keyboard_show
    elif text.lower() == "Можете не переживать на этот счет!".lower():
        keyboard_show = Elaniya.end_room_buttons()
        return keyboard_show
    #Дорога
    if text.lower() == "Теперь я кажется понимаю о чем вы..".lower():
        keyboard_show = temple.initiate()
        return keyboard_show
    elif text.lower(
    ) == "Да, кажется я знаю о каком месте идет речь, по южной дороге есть некий храм, последний раз лорда видели именно у него.".lower(
    ):
        keyboard_show = temple.dialog_answer_buttons_1()
        return keyboard_show
    #Храм
    if text.lower() == "Осмотреть храм".lower():
        keyboard_show = Boss.dialog_answer_buttons_3()
        return keyboard_show
    elif text.lower() == """Осмотреть более внимательно""".lower():
        keyboard_show = Boss.statui_asnwer()
        return keyboard_show
    elif text.lower() == "Солнце в зените, Полумесяц, Восход, Закат".lower():
        keyboard_show = Boss.dialog_answer_buttons_4()
        return keyboard_show
    elif text.lower() == "Восход, Закат, Солнце в зените, Полумесяц".lower():
        keyboard_show = Boss.statui_asnwer()
        return keyboard_show
    elif text.lower() == "Полумесяц, Закат, Солнце в зените, Восход".lower():
        keyboard_show = Boss.statui_asnwer()
        return keyboard_show
    elif text.lower() == "Закат, Восход, Полумесяц, Солнце в зените".lower():
        keyboard_show = Boss.statui_asnwer()
        return keyboard_show
    elif text.lower() == "Подойти к порталу".lower():
        keyboard_show = Boss.dialog_answer_buttons_5()
        return keyboard_show
    elif text.lower() == "Незаметно подкрасться к входу".lower():
        keyboard_show = Boss.dialog_answer_buttons_6()
        return keyboard_show
    elif text.lower() == "Войти в крипту".lower():
        keyboard_show = Boss.decide_butons()
        return keyboard_show
    elif text.lower() == "Бежать".lower():
        keyboard_show = Boss.run_buttons()
        return keyboard_show
    elif text.lower() == "Подставить ученика".lower():
        keyboard_show = Boss.apprentice_buttons()
        return keyboard_show
    elif text.lower() == "Драться".lower():
        keyboard_show = Boss.draka()
        return keyboard_show
    elif text.lower(
    ) == "Вы победили приспешников. Отдышавшись, продолжаете путь".lower():
        keyboard_show = Boss.dialog_answer_buttons_8()
        return keyboard_show
    elif text.lower() == "Подбежать к лорду".lower():
        keyboard_show = Boss.bitva_boss()
        return keyboard_show
    elif text.lower() == "В бой!".lower():
        keyboard_show = Boss.rest()
        return keyboard_show
    elif text.lower() == "Вы переводите дыхание и осматриваетесь".lower():
        keyboard_show = Boss.dialog_answer_buttons_10()
        return keyboard_show
    elif text.lower() == """Подойти к алтарю""".lower():
        keyboard_show = Boss.dialog_answer_buttons_11()
        return keyboard_show
    elif text.lower() == """Помочь лорду встать""".lower():
        keyboard_show = Boss.end_room_buttons()
        return keyboard_show
    #Финал 1
    if text.lower(
    ) == "Рассказать лорду о том, что он пытался принести в жертву свою невесту, чуть не убил своего слугу.".lower(
    ):
        keyboard_show = FinalOne.dialog_answer_buttons_1()
        return keyboard_show
    elif text.lower() == "Выйти на поверхность".lower():
        keyboard_show = FinalOne.dialog_answer_buttons_2()
        return keyboard_show
        # Финал 2
    if text.lower(
    ) == "Ничего не говорить и попытаться увести лорда в город".lower():
        keyboard_show = FinalTwo.dialog_answer_buttons_1()
        return keyboard_show
    if text.lower(
    ) == "Рассказать правду о том, что вам удалось выяснить и что произошло в крипте".lower(
    ) or text.lower(
    ) == "Солгать и выставить лорда борцом с культистами".lower(
    ) or text.lower() == "Помочь лорду идти до города.".lower():
        keyboard = ReplyKeyboardMarkup(keyboard=[[
            KeyboardButton(
                text=
                "Ну, дальше будет дальше, а пока с победой! Начинай с начала!")
        ]])
        return keyboard