Beispiel #1
0
 def make_bubble(self):
     if self.stage == 1:
         for i in range(195):
             if stage1_state.block[i].block_x <= self.x + 20.1 < stage1_state.block[i].block_x + 40.2:
                 if stage1_state.block[i].block_y <= self.y - 3 < stage1_state.block[i].block_y + 40:
                     if stage1_state.block[i].box_color == 0 or stage1_state.block[i].box_color == 9\
                             or stage1_state.block[i].box_color == 10 or stage1_state.block[i].box_color == 11:
                         #stage1_state.block[i].box_color = 8
                         bubble = Bubble(stage1_state.block[i].block_x, stage1_state.block[i].block_y + 10, self.bubble_range, self.stage)
                         game_world.add_object(bubble, 1)
                         self.sound.play()
                         break
     elif self.stage == 2:
         for i in range(195):
             if stage2_state.block[i].block_x <= self.x + 20.1 < stage2_state.block[i].block_x + 40.2:
                 if stage2_state.block[i].block_y <= self.y - 3 < stage2_state.block[i].block_y + 40:
                     if stage2_state.block[i].box_color == 0 or stage2_state.block[i].box_color == 9\
                             or stage2_state.block[i].box_color == 10 or stage2_state.block[i].box_color == 11:
                         #stage1_state.block[i].box_color = 8
                         bubble = Bubble(stage2_state.block[i].block_x, stage2_state.block[i].block_y + 10, self.bubble_range, self.stage)
                         game_world.add_object(bubble, 1)
                         self.sound.play()
                         break
     elif self.stage == 3:
         for i in range(195):
             if boss_stage.block[i].block_x <= self.x + 20.1 < boss_stage.block[i].block_x + 40.2:
                 if boss_stage.block[i].block_y <= self.y - 3 < boss_stage.block[i].block_y + 40:
                     if boss_stage.block[i].box_color == 0 or boss_stage.block[i].box_color == 9\
                             or boss_stage.block[i].box_color == 10 or boss_stage.block[i].box_color == 11:
                         #stage1_state.block[i].box_color = 8
                         bubble = Bubble(boss_stage.block[i].block_x, boss_stage.block[i].block_y + 10, self.bubble_range, self.stage)
                         game_world.add_object(bubble, 1)
                         self.sound.play()
                         break
Beispiel #2
0
class TestBubble(unittest.TestCase):
    def setUp(self):
        self.bubble = Bubble()

    def test_something(self):
        self.bubble.say('hi from first test case')

    def tearDown(self):
        pass
    def create_bubbles():
        bubbles = [
            Bubble(c.SCR_W2 - 120, c.SCR_H2 - 50, 0, 0, 2),
            Bubble(c.SCR_W2 + 120, c.SCR_H2 - 50, 0, 0, 2),
            Bubble(c.SCR_W2, c.SCR_H2 - 50, 0, 0, 2)
        ]
        for bubble in bubbles:
            bubble.vel = 0

        return bubbles
Beispiel #4
0
def _convert(ctx=Bubble(), abspath='', fromtype='json', totype='yaml'):
    new_file = abspath.replace(fromtype, totype)
    ctx.say('converting:' + abspath + '>>>' + new_file, verbosity=10)
    data = get_file(ctx, abspath, False)
    ctx.say('data', stuff=data, verbosity=1000)
    res = put_file(ctx, new_file, data['lod_gen'], remove_first=True)
    return res
Beispiel #5
0
 def fire_bubble(self):
     if self.rest_attack_time != 0:
         return
     bubble = Bubble(self.x, self.y, self.dir * 3)
     game_world.add_object(bubble, 1)
     self.rest_attack_time = 0.5
     self.attack = 1
     self.frame = 0
def fire_bubble(ai_settings, screen, mermaid, bubbles):
    """Fire bubble if limit not reached yet"""
    #Create new bubble and add it to bubble group
    if len(
            bubbles
    ) < ai_settings.bubbles_allowed:  #makes it so only three bubbles can be on the screen at a time
        new_bubble = Bubble(ai_settings, screen, mermaid)
        bubbles.add(new_bubble)
Beispiel #7
0
    def breatheWater(self, screen):
        """Make the fish breathe water and make bubbles"""
        for bubble in self.bubbles:
            bubble.display(screen)
            if bubble.y < 0:
                self.bubbles.remove(bubble)

        if self.getAge() % 5 < 0.2 and len(self.bubbles) < 2:
            self.bubbles.append(Bubble(self.x, self.y, self.size/2))
Beispiel #8
0
 def add_bubbles(self, mob_x, mob_y, bubbles):
     """
     :param mob_x: x coord of dead mob
     :param mob_y: y coord of dead mobs
     :param bubbles: list of the number of bubbles of 3 types: small, medium, big
     """
     for type_marker in range(len(bubbles)):
         for i in range(bubbles[type_marker]):
             angle = uniform(0, 2 * pi)
             self.bubbles.append(
                 Bubble(mob_x, mob_y, angle, self.gravity_radius,
                        type_marker))
Beispiel #9
0
def load(filename):
	arr = []
	print('load', filename)
	try:
		with open('saves/' + filename, 'r') as file:
			columns = list(reversed(list(file)))
	except FileNotFoundError:
		print(filename, 'not found')
		return ([], 0, 0)

	for y, line in enumerate(columns):
		for x, char in enumerate(line.rstrip()):
			if char != ' ':
				arr.append(Bubble((x, y), int(char)))

	height = len(columns)
	width = max(map(len, columns), default=1) - 1 #for \n

	return (arr, width, height)
Beispiel #10
0
    def __init__(self):
        self.x = 40
        self.y = 25
        self.columns = COLUMNS
        self.rows = ROWS
        self.bubble_width = BUBBLE_WIDTH
        self.bubble_height = BUBBLE_WIDTH
        self.row_height = 28
        self.row_offset = 0
        self.radius = self.bubble_width / 2
        self.width = self.columns * self.bubble_width + self.bubble_width / 2
        self.grid = []
        self.matched_bubbles = []
        self.colors_in_level = set()

        for i in range(self.rows):
            new_row = []
            for j in range(self.columns):
                new_row.append(Bubble(i, j, 0, 0, -1, False))
            self.grid.append(new_row)
Beispiel #11
0
def parse_bubble_file(bubble_path, out_dir):
    # make the out_dir if not exists
    if not os.path.exists(out_dir):
        os.mkdir(out_dir)
    with open(bubble_path) as fh:
        total_bubbles = 0
        # initialize the first bubble
        bubble = Bubble(0)
        for record in SeqIO.parse(fh, 'fasta'):
            tokens = record.description.strip().split()
            bubble_num = int(tokens[1])
            if total_bubbles < bubble_num:
                # process the previous bubble
                process_bubble(bubble, out_dir)
                # initialize a new bubble
                bubble = Bubble(bubble_num)
                total_bubbles += 1
            taxa = []
            for taxon in tokens[3::]:
                taxa.append(taxon.replace(',', ''))
            for taxon in taxa:
                bubble.add_path(taxon, record.seq)
Beispiel #12
0
def fire_bubble(dolphingame_settings, screen, dolphin, bubbles):
    '''Wystrzelenie pocisku jeśli nie przekroczono limit'''
    if len(bubbles) < dolphingame_settings.bubble_allowed:
        new_bubble = Bubble(dolphingame_settings, screen, dolphin)
        bubbles.add(new_bubble)
 def _release_bubble(self):
     """Create a new bubble and add it to the bubble."""
     new_bubble = Bubble(self)
     self.bubbles.add(new_bubble)
Beispiel #14
0
    res = put_file(ctx, new_file, data['lod_gen'], remove_first=True)
    return res


def convert(b, from_type, to_type, stage, step_to_convert):
    steps = 'pulled', 'push', 'transformed', 'uniq_pull', 'uniq_push', 'store'
    for step in steps:
        if step == step_to_convert:
            file_name = '%s_%s.%s' % (step, stage, from_type)
            print(_convert(b, file_name, from_type, to_type))


if __name__ == '__main__':
    from bubble.util.cli_misc import utf8_only
    from bubble.cli import STORAGE_TYPES
    b = Bubble()
    b.verbose = 100
    utf8_only(b)
    # print b
    # from_type='json'
    # to_type='sqlite3'
    # print sys.argv
    if len(sys.argv) == 6:
        from_type = sys.argv[1]  # 'json'
        to_type = sys.argv[2]  # 'sqlite3'
        stage = sys.argv[3]  # 'DEV'
        step = sys.argv[4]  # 'pulled'
        verbose = sys.argv[5]  # 100

        b.set_verbose(verbose)
        convert(b, from_type, to_type, stage, step)
Beispiel #15
0
    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
        if n > -250:
            n -= 1

    if keys[pygame.K_RIGHT]:
        if n < 250:
            n += 1

    if keys[pygame.K_SPACE] and clc() - now > 0.3:
        projectiles.append(Projectile(screen, n))
        now = clc()

    for bubble in bubbles:
        bubble.move()
        for bullet in projectiles:
            bubble.collision(bullet)
    bubbles = list(filter(lambda x: x.state(), bubbles))

    while len(bubbles) < 10:
        bubbles.append(Bubble(screen))

    for bullet in projectiles:
        bullet.move()
    projectiles = list(filter(lambda x: x.state(), projectiles))

    g.rotate(n)

    pygame.display.update()
    clock.tick(500)
Beispiel #16
0
 def create(self, canvas, diameter):
     return Bubble(canvas, diameter)
Beispiel #17
0
 def create_bubbles(self):
     n_bubbles = random.randrange(1, 5)
     for _ in range(n_bubbles):
         Bubble(32)
Beispiel #18
0
def game_loop():
    global running, gameDisplay, POPUP, POPUP_COUNTER

    pygame.init()
    pygame.font.init()  # for writing text to pygame
    gameDisplay = pygame.display.set_mode((DISPLAY_X, DISPLAY_Y))
    pygame.display.set_caption('Version 1.0')
    gameDisplay.fill(BACKGROUND_COLOUR)
    clock = pygame.time.Clock()
    running = True
    won = False

    board = Board(gameDisplay)
    board.createWordList()
    board.drawBoard()
    board.drawAllBubbles()
    board.addToBoard()

    while running:
        # if (board.future_bubbles == [] or len(board.board_bubbles) == 22) and not board.shooting: # TODO: check if this is actually right
        #     print("You did not win. Try again!")
        #     running = False

        if board.shooting and board.shoot_pos != []:
            board.shoot_bubble.erase(gameDisplay)
            #pygame.display.update()
            board.shoot_bubble.pos = board.shoot_pos[0]
            board.shoot_bubble.drawAsGrey(gameDisplay)
            board.shoot_pos.pop(0)
        elif board.shooting and board.shoot_pos == [] and board.future_bubbles != []:
            # load in new bubble
            try:
                board.popMatches()
                board.shoot_bubble = Bubble(SHOOT_POSITION[0], SHOOT_POSITION[1], \
                                           board.future_bubbles[0][0], board.future_bubbles[0][1])
                board.shooting = False
                board.drawAllBubbles()
            except IndexError:
                running = False

        if board.board_bubbles.count(0) == len(board.board_bubbles):
            board.won = True
            print("You won! Good job! :)")
            won = True
            running = False
        elif board.future_bubbles == [] and not board.shooting:  # TODO: check if this is actually right
            print("Game over, better luck next time :(")
            running = False

        # board.drawBoard()
        # board.drawAllBubbles()
        # board.addToBoard()
        board.drawShootBubble()
        for event in pygame.event.get():

            # this section handles the erasing of a popup after 5000 ticks
            if POPUP_COUNTER >= 0:
                POPUP_COUNTER += 1
            if POPUP_COUNTER >= 20:
                POPUP_COUNTER = 0
                i = 0  #TODO: find a way for it to find the popup -> board.current_popups.index(popped_bubble)
                #board.current_popups.pop(i).erase()
                board.success_popped = False
            # if not board.success_popped:
            #     for p in board.current_popups:
            #         p.erase()

            if board.future_bubbles == []:
                board.game_over = True
                board.future_bubbles = [(" ", WHITE)]  # TODO: fix this kludge
                print("Game over, better luck next time :(")
                running = False

            if board.board_bubbles == []:
                # print a win message to the screen
                board.won = True
                print("You won! Good job! :)")
                won = True
                running = False

            if event.type == pygame.MOUSEBUTTONDOWN:
                pos = getPos()

                if board.board.collidepoint(pos):
                    board.shooting = True
                    # valid selection for bubble, shoot it
                    e = board.shootBubble(pos)
                    if e == "ValueError" or e == "IndexError" or e == "Game Over":
                        running = False
                        print("Game over, better luck next time :(")

                elif board.help_box.collidepoint(pos):
                    # make help box appear
                    board.displayHelpBox()

                else:
                    # TODO: display an error
                    pass

            if event.type == pygame.QUIT:
                running = False
                quitGame()

        # board.addToBoard()
        pygame.display.update()
        clock.tick(60)

    # make it pretty for the end of the game
    board.drawBoard()

    if won:
        # display a winning message
        p = Popup("Good job! You won!", int(DISPLAY_X * 0.35),
                  int(DISPLAY_Y * 0.30), gameDisplay)
    else:
        board.drawAllBubbles()
        # display a better luck next time message
        p = Popup("Better luck next time! Try again!", int(DISPLAY_X * 0.25),
                  int(DISPLAY_Y * 0.30), gameDisplay)

    p.create()

    exit_message = Popup("Press any key or click to exit game.",
                         int(DISPLAY_X * 0.25), int(DISPLAY_Y * 0.34),
                         gameDisplay)
    exit_message.create()

    pygame.display.update()

    paused = True
    while paused:
        for ev in pygame.event.get():
            if ev.type == pygame.KEYDOWN or ev.type == pygame.MOUSEBUTTONDOWN:
                paused = False
                quitGame()
            elif ev.type == pygame.QUIT:
                paused = False
                quitGame()
def fire(s, screen, sanit, bubbles):
    #fire a bubble if limit not reached
    if len(bubbles) < s.bubbles_allowed:
        new_bubble = Bubble(s, screen, sanit)
        bubbles.add(new_bubble)
Beispiel #20
0
 def Bubble(self):
     bubble = Bubble(self.x, self.y)
     game_world.add_object(bubble, 2)
Beispiel #21
0
 def Bubble(self):
     bubble = Bubble(self.x, self.y)
        if colorkey == -1:
            colorkey = image.get_at((0, 0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image


bubbles = []
for c in COLORS:
    bubbles.append(load_image(c + ".png"))

level = Level()
player = Player()
bubble_to_shoot = Bubble(
    SCREEN_WIDTH / 2 - BUBBLE_WIDTH / 2,
    SCREEN_HEIGHT - 2.5 * BUBBLE_WIDTH,
    500,
    90,
    1,
    False,
)


def get_bubble_coordinate(row, column):
    bubble_x = level.x + column * level.bubble_width
    if (row + level.row_offset) % 2:
        bubble_x += level.bubble_width / 2
    bubble_y = level.y + row * level.row_height
    return bubble_x, bubble_y


def draw_bubble(bubble_color, x, y):
    if bubble_color >= 0 and bubble_color < len(bubbles):
Beispiel #23
0
from bubble import Bubble
from functools import wraps
import settings.flask_settings as local_settings
import settings.global_settings as global_settings
import logging
from assets.streamer import Streamer
from assets.twitchapi import TwitchAPI
from assets.jwtworker import JWTworker
from stats_manager import StatsManager
from assets.profanity_filter import ProfanityFilter

application = Flask(__name__, template_folder='frontend', static_url_path="")
socketio = SocketIO(application)
logger = logging.getLogger('flask_app')
TwitchAPI.generate_oauth()
bubble = Bubble(read_data=True)
stats = StatsManager()


def log_setup(app, logger):
    log_f = logging.FileHandler(local_settings.FLASK_LOG_FILE)
    log_s = logging.StreamHandler()

    if (global_settings.DEBUG):
        logger.setLevel(logging.DEBUG)
        log_f.setLevel(logging.DEBUG)
        log_s.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.INFO)

    # Set formatter for requests
Beispiel #24
0
 def setUp(self):
     self.bubble = Bubble()
 def add_bubble(self):
     x = uniform(0, c.SCR_W)
     y = c.SCR_H + self.BUBBLE_RADIUS
     new_bubble = Bubble(x, y, 0)
     new_bubble.vel = -0.2 - uniform(0, 0.4)
     self.bubbles.append(new_bubble)
Beispiel #26
0

if __name__ == '__main__':
    print(MAGIC)
    MAGIC.BMGC.hello = 'Hello There!'
    print(MAGIC)
    del (MAGIC.BMGC.hello)
    MAGIC.BMGC.goodbye = {}
    MAGIC.BMGC.goodbye['msg'] = 'Goobye too!!'
    MAGIC.BMGC.goodbye['cruel'] = {}
    MAGIC.BMGC.goodbye['cruel']['world'] = 'deep thought'
    MAGIC.BMGC.goodbye['favorite_fruits'] = ['orange', 'pear', 'banana']
    MAGIC.BMGC.something = {}

    # MAGIC.BMGC.something['completely.different'] = 'you can store any kind of thing in this'#but still not finished yet
    # need to do some esccaping also

    MAGIC.BMGC.something['answer'] = 42
    MAGIC.BMGC.something['answer_str'] = 'forty two'
    MAGIC.BMGC.something[
        'not_the_question'] = "I may be a sorry case, but I don't write jokes in base 13. (DNA)"

    print(MAGIC)
    from bubble import Bubble
    save_magic(Bubble(), 'magic.yaml', MAGIC)
    rM = get_magic(Bubble(), 'magic.yaml')
    # print(rM.BMGC.something.completely.different)
    print(rM.BMGC.something.not_the_question)

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4