Example #1
0
    def tick(self):
        rx, ry, dx, dy = self.orientation()
        if self.flipped:
            rx = -rx
            ry = -ry

        if self.invulnerable:
            self.invulnerable -= 1

        if self.turnfrenzy:
            if self.turnfrenzy > 1:
                self.dx += self.jumpx
                self.dy += self.jumpy
            self.turnfrenzy -= 1
        else:
            self.dx -= rx * 0.3
            self.dy -= ry * 0.3

        self.angle = 180 * math.atan2(-dx, dy) / math.pi

        if random.randint(0, 60 * 10) == 0:
            self.flipped = not self.flipped
            self.turnfrenzy = 15
            self.jumpx = self.dx * 0.2
            self.jumpy = self.dy * 0.2

        Animated.tick(self)
        Orb.tick(self)
Example #2
0
 def __init__(self, x, y, r):
     if self.frames == None:
         self.frames = []
         for frame in range(1, 9):
             self.frames.append(Picture("items/spring%04d" % frame))
     self.frame = 0
     self.animating = 0
     self.movey = -1
     Orb.__init__(self, x, y, r)
Example #3
0
    def __init__(self, x, y, r):
        Orb.__init__(self, x, y, r)

        if self.frames == None:
            self.frames = []
            for frame in range(1, 9):
                self.frames.append(Picture("items/lever%04d" % frame))
        self.frame = 7
        self.anim = 0
        self.laser = 0
Example #4
0
 def __init__(self, x, y, r):
     if self.frames == None:
         self.frames = []
         for frame in range(1, 9):
             self.frames.append(Picture("items/cogwheel%04d" % frame))
     self.frame = 0
     self.stuck = 0
     self.revolve = 0
     self.movex = 1
     Orb.__init__(self, x, y, r)
Example #5
0
    def __init__(self, x, y, r):
        Orb.__init__(self, x, y, r)

        if self.frames == None:
            self.frames = []
            for frame in range(1, self.framecount + 1):
                self.frames.append(Picture(self.files % frame))
        self.frame = random.randint(0, self.framecount - 1)
        self.anim = 0
        self.flipped = False
Example #6
0
 def __init__(self, master, pos, dir=(0, 1), starting_orbs=15):
     Orb.__init__(self, master, pos, dir,
                  [random.randrange(100, 255) for i in range(3)])
     self.speed = self.defaultspeed
     self.tracer = tracer.Tracer(self.pos, self.dir, self.dashing_f)
     self.radius = 15
     self.children = [
         Orb(self, self.pos, self.dir, self.color)
         for i in range(starting_orbs)
     ]
     self.state = state.Flight_state(**{"head": self})
     self.action = False
Example #7
0
    def script4(game, x, y, dx, dy):
        prev = None
        r = game.new_size
        for i in range(40):
            orb = Orb(x, y, r)
            orb.spawn(game.spatialhash)
            game.orbs.append(orb)

            x += dx * game.new_size * 2
            y += dy * game.new_size * 2
            if prev:
                orb.append(prev)
            prev = orb
Example #8
0
 def __init__(self, x, y, r):
     Orb.__init__(self, x, y, r)
     self.frames = []
     for frame in range(1, 17):
         self.frames.append(Picture("allefant/run/%04d" % frame))
     self.frames.append(Picture("allefant/jump/0001"))
     self.frame = 0
     self.runcycle = 0
     self.flipped = False
     self.kx = 0
     self.ky = 0
     self.jumping = 0
     self.health = 100
     self.coins = 0
Example #9
0
 def dragTable(self):
     """
     Returns the drag table that is assigned to this record item.
     
     :return     <subclass of orb.Table> || None
     """
     return Orb.instance().model(self.dragData("application/x-table"))
Example #10
0
 def dragTable(self):
     """
     Returns the drag table that is assigned to this record item.
     
     :return     <subclass of orb.Table> || None
     """
     return Orb.instance().model(self.dragData('application/x-table'))
Example #11
0
    def tick(self):
        rx, ry, dx, dy = self.orientation()

        falling = self.sameway(dx, dy)

        ground = self.get_colliders(dx * 2, dy * 2)

        if self.movex > 0:
            self.frame += 1
            if self.frame == 8:
                self.frame = 0
                self.revolve += 1
        else:
            self.frame -= 1
            if self.frame == -1:
                self.frame = 7
                self.revolve += 1

        if self.revolve >= 1:
            self.revolve = 0
            run.run.wood3.play(0.5, self)

        if ground:
            if falling > 0:
                self.dx -= falling * dx
                self.dy -= falling * dy
            self.dx -= dx * 0.4
            self.dy -= dy * 0.4
        else:
            self.dx += dx * 0.4
            self.dy += dy * 0.4

        self.dx += self.movex * rx * 0.35
        self.dy += self.movex * ry * 0.35

        ox = self.x
        oy = self.y
        Orb.tick(self)
        ox -= self.x
        oy -= self.y
        if ox ** 2 + oy ** 2 < 0.2 * 0.2:
            self.stuck += 1
            if self.stuck > 10:
                self.stuck = 0
                self.movex = -self.movex
Example #12
0
    def __orb_init(self) -> List:
        if not uData.setting['orb']:
            return []

        lst = list()
        for i in range(1, 4):
            if str(i) in uData.setting['orb'] and self.id == uData.setting[
                    'orb'][str(i)]['wave_N']:
                lst.append(Orb(str(i)))
        return lst
Example #13
0
def fill_board(gameBoard, orb_pics):
    """
    Fills the board with random orb objects.
    Arguments:
        gameBoard(list): Gets the state of the board in which case is a blank board.
        orb_pics(list):  List of orb pictures.
    Returns:
        gameBoard(list): Returns a filled board.
    """
    same = False
    orb_pic = orb_pics
    playing_board = gameBoard

    for x in range(board_width):
        for y in range(board_height):
            orb_color = str(random.randrange(6) + 1)
            orb_type = Orb(orb_pic[orb_color], orb_color)
            playing_board[x][y] = orb_type


            if y > 1: #check if there are 3 of same color for vertical
                if (playing_board[x][y].type == playing_board[x][y - 1].type and
                    playing_board[x][y].type == playing_board[x][y - 2].type):
                    same = True
                    while same:
                        orb_color = str(random.randrange(5) + 1)
                        playing_board[x][y] = Orb(orb_pic[str(orb_color)], orb_color)
                        if (playing_board[x][y].type != playing_board[x][y - 1].type and
                            playing_board[x][y].type != playing_board[x][y - 2].type):
                            same = False

            if x > 1: #check if there are 3 of same color for horizontal
                if (playing_board[x][y].type == playing_board[x - 1][y].type and
                    playing_board[x][y].type == playing_board[x - 2][y].type):
                    same = True
                    while same:
                        orb_color = str(random.randrange(5) + 1)
                        playing_board[x][y] = Orb(orb_pic[str(orb_color)], orb_color)
                        if (playing_board[x][y].type != playing_board[x - 1][y].type and
                        playing_board[x][y].type != playing_board[x - 2][y].type):
                            same = False
    return playing_board
Example #14
0
    def __init__(self, parent=None):
        super(XOrbSchemaBox, self).__init__(parent)

        # define custom properties
        self._schemas = []

        if (Orb):
            self.setSchemas(Orb.instance().schemas())

        # create connections
        self.currentIndexChanged.connect(self.emitCurrentChanged)
Example #15
0
 def tableType( self ):
     """
     Returns the table type for this instance.
     
     :return     <subclass of orb.Table> || None
     """
     if not self._tableType:
         if self._tableTypeName:
             self._tableType = Orb.instance().model(nstr(self._tableTypeName))
         
     return self._tableType
Example #16
0
 def tableType( self ):
     """
     Returns the table type for this instance.
     
     :return     <subclass of orb.Table> || None
     """
     if not self._tableType:
         if self._tableTypeName:
             self._tableType = Orb.instance().model(str(self._tableTypeName))
         
     return self._tableType
Example #17
0
 def __init__( self, parent = None ):
     super(XOrbSchemaBox, self).__init__( parent )
     
     # define custom properties
     self._schemas       = []
     
     if ( Orb ):
         self.setSchemas(Orb.instance().schemas())
     
     # create connections
     self.currentIndexChanged.connect( self.emitCurrentChanged )
Example #18
0
    def __init__(self):
        super().__init__()
        self.window = tk.Tk()
        self.window.title("RAY Tracing ON")
        self.window.geometry("1600x850")
        self.walls = []

        #function related to left frame of GUI
        self.leftFrame = Frame(self.window, width=800)
        self.leftFrame.pack(side=LEFT)

        self.rayCan = Canvas(self.leftFrame, width=800, height=800)
        self.rayCan.pack()

        self.buttonFrame = Frame(self.leftFrame, bg='grey', width=800)
        self.buttonFrame.pack(fill=X)

        self.Draw_walls()
        self.add_buttons()

        self.rayCan.bind('<Motion>', self.Mouse_move)  #mouse move event
        self.window.bind('<a>', lambda x: self.Left_press())  #key press event
        self.window.bind('<d>', lambda y: self.Right_press())  #key press event

        #functions related to Right side of binder
        self.rightFrame = Frame(self.window, width=800)
        self.rightFrame.pack(side=LEFT)

        self.wallCan = Canvas(self.rightFrame,
                              width=800,
                              height=800,
                              bg="light grey")
        self.wallCan.pack()

        self.orb = Orb(750, 50, self.rayCan, self.wallCan, self.window,
                       self.walls)
Example #19
0
File: join.py Project: SPRIME01/orb
    def database(self):
        """
        Returns the database instance that is linked to this join.
        
        :return     <orb.Database> || None
        """
        if self._database:
            return self._database

        # use the first database option based on the tables
        for option in self.options():
            if isinstance(option, orb.Table):
                return option.database()

        from orb import Orb

        return Orb.instance().database()
Example #20
0
def get_falling_orbs(gameBoard):
    """
    Gets dropped orbs to fill the board when match is done.
    Arguments:
        gameBoard(list): Gets the state of the game board and fills it up with new orb objects.
    Returns:
        gameBoard(list): Returns a filled game board.
    """
    # boardCopy = copy.deepcopy(gameBoard)
    drop_orbs(gameBoard)

    # fallingOrbs = []
    for x in range(board_width):
        for y in range(board_height):
            if gameBoard[x][y] == empty_space:
                orb_color = str(random.randrange(6) + 1)
                orb_type = Orb(orb_pic[orb_color], orb_color)
                gameBoard[x][y] = orb_type
    return gameBoard
Example #21
0
def main():
    """
    The main method there the game runs in.
    """
    pygame.mixer.pre_init(44100, 16, 2, 4096)
    pygame.init()
    pygame.mixer.music.set_volume(.3)
    pygame.mixer.music.load('bgm.wav')
    pygame.mixer.music.play(-1)

    window_size = (window_width, window_height)
    global screen, held, turn, stage, empty_space, fps, fps_clock, element, hit, orb_movement
    fps = 30
    fps_clock = pygame.time.Clock()
    timer = 180
    held = False
    turn = 1
    stage = 1
    hit = pygame.mixer.Sound('hit.wav')
    hit.set_volume(1)
    orb_movement = pygame.mixer.Sound('orb_movement.wav')
    game_over = pygame.mixer.Sound('gameover.wav')

    screen = pygame.display.set_mode(window_size)
    pygame.display.set_caption("Project")

    screen.fill(WHITE)

    empty_space = Orb('BlankOrb.png', -1)

    # making units
    unit_row1_x = 150
    unit_row1_y = [50, 110, 170]
    unit_row2_x = 90
    unit_row2_y = [80, 140]

    unit_list = []
    hp = [4534, 6236, 6082, 5125, 4300]
    attack = [2540, 2710, 3810, 2700, 2960]
    recovery = [511, 295, 191, 372, 356]
    typing = [1, 2, 3, 4, 5]
    sprite = ['unit1.png', 'unit2.png', 'unit3.png', 'unit4.png', 'unit5.png']

    for x in range(5):
        unit_list.append(Unit(hp[x], attack[x], recovery[x],
                              typing[x], sprite[x]))

    # making enemies
    enemy_list = []
    hp = [1007988, 752364, 824658, 1048752, 1289554]
    attack = [7012, 15025, 9487, 10451, 17487]
    typing = [3, 4, 2, 1, 5]
    turns = [1,2,1,1,2]
    sprite = ['enemy1.png', 'enemy2.png', 'enemy3.png', 'enemy4.png', 'enemy5.png']

    for x in range(5):
        enemy_list.append(Monsters(hp[x], attack[x], typing[x], turns[x], sprite[x], x + 1))

    # background
    stage_list = []
    background_list = ['EmbodimentSDM.png', 'SMD.png', 'SDMLobby.png']
    for enemy in enemy_list:
        # print(enemy.stage)
        if enemy.stage == 1:
            stage_list.append(Stage(enemy.stage, background_list[0]))
        elif enemy.stage == 2 or enemy.stage == 3:
            stage_list.append(Stage(enemy.stage, background_list[1]))
        elif enemy.stage == 4 or enemy.stage == 5:
            stage_list.append(Stage(enemy.stage, background_list[2]))


    gameBoard = get_blank_board()
    gameBoard = fill_board(gameBoard, orb_pic)
    current_selected_orb = None

    # multipliers
    #--------------------------------------------------------#
    combo = 0
    combo_multiplier = .5
    extra_orb_multiplier = 1
    recovery_multiplier = .25
    leader_skill_multiplier = 25

    total_hp = 0
    for unit in unit_list:
        total_hp += unit.hp
    current_hp = total_hp

    fire = 0
    water = 0
    wood = 0
    light = 0
    dark = 0
    for unit in unit_list:
        if unit.type == 1:
            fire += unit.attack
        elif unit.type == 2:
            water += unit.attack
        elif unit.type == 3:
            wood += unit.attack
        elif unit.type == 4:
            light += unit.attack
        else:
            dark += unit.attack

    total_recovery = 0
    for unit in unit_list:
        total_recovery += unit.recovery


    # game loop
    # --------------------------------------------------------------------#
    while True:
        total_attacks = [0,0,0,0,0,0]
        swapping_orb = None
        combo = 0

        screen.fill(BLACK)
        mouse_coordinates = pygame.mouse.get_pos()
        for x in range(board_width):
            if x % 2 == 0:
                for y in range(board_height):
                    if y % 2 == 0:
                        pygame.draw.rect(screen, (110, 57, 58), board_rectangles[x][y], 0)
                    else:
                        pygame.draw.rect(screen, (150, 90, 91), board_rectangles[x][y], 0)
            elif x % 2 == 1:
                for y in range(board_height):
                    if y % 2 == 1:
                        pygame.draw.rect(screen, (110, 57, 58), board_rectangles[x][y], 0)
                    else:
                        pygame.draw.rect(screen, (150, 90, 91), board_rectangles[x][y], 0)

        # display background
        for background in stage_list:
            if background.stage == stage:
                display_background(stage, stage_list)


        for event in pygame.event.get():
            if event.type == QUIT:  # QUIT event to exit the game
                pygame.quit()
                sys.exit()

            # -----------Mouse Events----------- #
            if event.type == MOUSEBUTTONUP:
                num_orbs = 0
                held = False
                element = []
                match_orbs = check_match(gameBoard)
                num_orb_list = []
                if match_orbs == []: # no matching orbs
                    dmg_taken = enemy_list[stage - 1].attack_return(turn)
                    current_hp = update_hp_dmg(current_hp, dmg_taken)
                else:
                    while match_orbs != []:
                        for orb_set in match_orbs:
                            for orb in orb_set:
                                num_orbs += 1
                                draw_board(gameBoard)
                                pygame.display.update()
                                pygame.time.delay(30)
                            num_orb_list.append(num_orbs)
                            num_orbs = 0
                        gameBoard = get_falling_orbs(gameBoard)
                        match_orbs = check_match(gameBoard)

                    #---------------------------------------------------------------#
                    index = 0
                    for typing in element:
                        combo += 1
                        if typing == '1':
                            total_attacks[0] += fire + (fire * (num_orb_list[index]
                                                                * extra_orb_multiplier))
                            index += 1
                        elif typing == '2':
                            total_attacks[1] += water + (water * (num_orb_list[index]
                                                                  * extra_orb_multiplier))
                            index += 1
                        elif typing == '3':
                            total_attacks[2] += wood + (wood * (num_orb_list[index]
                                                                * extra_orb_multiplier))
                            index += 1
                        elif typing == '4':
                            total_attacks[3] += light + (light * (num_orb_list[index]
                                                                  * extra_orb_multiplier))
                            index += 1
                        elif typing == '5':
                            total_attacks[4] += dark + (dark * (num_orb_list[index]
                                                                * extra_orb_multiplier))
                            index += 1
                        else:
                            total_attacks[5] += total_recovery + (total_recovery
                                             * (num_orb_list[index] * extra_orb_multiplier))
                            index += 1


                    for x in range(6):
                        if x == 0:
                            total_attacks[x] += (combo_multiplier * combo) * total_attacks[x]
                        elif x == 1:
                            total_attacks[x] += (combo_multiplier * combo) * total_attacks[x]
                        elif x == 2:
                            total_attacks[x] += (combo_multiplier * combo) * total_attacks[x]
                        elif x == 3:
                            total_attacks[x] += (combo_multiplier * combo) * total_attacks[x]
                        elif x == 4:
                            total_attacks[x] += (combo_multiplier * combo) * total_attacks[x]
                        else:
                            total_attacks[x] += (combo_multiplier * combo) * total_attacks[x]

                    enemy_list[stage - 1].update_hp(total_attacks)
                    current_hp = update_hp_rcv(current_hp, total_hp, total_attacks[5])
                    if enemy_list[stage - 1].current_hp != 0:
                        dmg_taken = enemy_list[stage - 1].attack_return(turn)
                        current_hp = update_hp_dmg(current_hp, dmg_taken)



                    for x in range(6):
                        print(total_attacks[x])



            elif event.type == MOUSEBUTTONDOWN:
                held = True
                timer = 180
                current_selected_orb = check_orb_clicked(mouse_coordinates)

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

        # if holding down mouse 1
        if held:
            timer -= 1
            if timer == 0:
                held = False # 6 seconds to make move
                gameBoard[current_selected_orb['x']][current_selected_orb['y']] = current_orb_copy

            if timer == 179:
                current_orb_copy = gameBoard[current_selected_orb['x']][current_selected_orb['y']]

            gameBoard[current_selected_orb['x']][current_selected_orb['y']] = empty_space
            current_orb_copy.update(screen)
            if current_selected_orb['x']+1 < 6 and current_selected_orb['y']+1 < 5:
                if(board_rectangles[current_selected_orb['x']+1]
                   [current_selected_orb['y']].collidepoint(mouse_coordinates[0],
                                                            mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']-1]
                     [current_selected_orb['y']].collidepoint(mouse_coordinates[0],
                                                              mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']]
                     [current_selected_orb['y']-1].collidepoint(mouse_coordinates[0],
                                                                mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']]
                     [current_selected_orb['y']+1].collidepoint(mouse_coordinates[0],
                                                                mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)

            elif current_selected_orb['x'] == 5 and current_selected_orb['y'] == 4:
                if(board_rectangles[current_selected_orb['x']-1]
                   [current_selected_orb['y']].collidepoint(mouse_coordinates[0],
                                                            mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']]
                     [current_selected_orb['y']-1].collidepoint(mouse_coordinates[0],
                                                                mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)

            elif current_selected_orb['x'] == 5:
                if(board_rectangles[current_selected_orb['x']-1]
                   [current_selected_orb['y']].collidepoint(mouse_coordinates[0],
                                                            mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']]
                     [current_selected_orb['y']+1].collidepoint(mouse_coordinates[0],
                                                                mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']]
                     [current_selected_orb['y']-1].collidepoint(mouse_coordinates[0],
                                                                mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)

            elif current_selected_orb['y'] == 4:
                if(board_rectangles[current_selected_orb['x']+1]
                   [current_selected_orb['y']].collidepoint(mouse_coordinates[0],
                                                            mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']-1]
                     [current_selected_orb['y']].collidepoint(mouse_coordinates[0],
                                                              mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)
                elif(board_rectangles[current_selected_orb['x']]
                     [current_selected_orb['y']-1].collidepoint(mouse_coordinates[0],
                                                                mouse_coordinates[1])):
                    swapping_orb = check_orb_clicked(mouse_coordinates)
                    gameBoard = swap_orbs(gameBoard, current_selected_orb, swapping_orb)
                    current_selected_orb = check_orb_clicked(mouse_coordinates)
                    pygame.mixer.Sound.play(orb_movement)


        # displays unit sprites on the screen
        #---------------------------------------------------------#
        k = 0
        for unit in unit_list:
            unit.update(screen, (unit_row1_x, unit_row1_y[k]))
            k += 1
            if k == 3:
                k = 0
                break

        l = 0
        m = 0
        for unit in unit_list:
            l += 1
            if l > 3:
                unit.update(screen, (unit_row2_x, unit_row2_y[m]))
                m += 1

        #---------------------------------------------------------#
        if enemy_list[stage - 1].current_hp <= 0:
            stage += 1
            font = pygame.font.SysFont('arialblack', 15)
            text = font.render(str(stage), True, BLACK)
            screen.blit(text, (window_width/2.4 , y_margin - 200))
            pygame.time.delay(60)


        display_enemy(screen, stage, turn, enemy_list)

        draw_hp(screen, current_hp, total_hp)

        draw_board(gameBoard)

        if current_hp < 0:
            pygame.mixer.Sound.play(game_over)
            pygame.mixer.music.pause()
            pygame.display.update()
            current_hp = 0

        if current_hp == 0:
            display_message()


        if held:
            font = pygame.font.SysFont('arialblack', 12)
            text = font.render(str(int(timer / 30) + 1), True, BLACK)
            screen.blit(text, (mouse_coordinates[0] - 10, mouse_coordinates[1] - 10))
        pygame.display.update()  # Update the display when all events have been processed
        fps_clock.tick(fps)
 def _fire_orb(self):
     """update the position of the orb"""
     new_orb = Orb(self)
     self.orbs.add(new_orb)
Example #23
0
class Window:
    def __init__(self):
        super().__init__()
        self.window = tk.Tk()
        self.window.title("RAY Tracing ON")
        self.window.geometry("1600x850")
        self.walls = []

        #function related to left frame of GUI
        self.leftFrame = Frame(self.window, width=800)
        self.leftFrame.pack(side=LEFT)

        self.rayCan = Canvas(self.leftFrame, width=800, height=800)
        self.rayCan.pack()

        self.buttonFrame = Frame(self.leftFrame, bg='grey', width=800)
        self.buttonFrame.pack(fill=X)

        self.Draw_walls()
        self.add_buttons()

        self.rayCan.bind('<Motion>', self.Mouse_move)  #mouse move event
        self.window.bind('<a>', lambda x: self.Left_press())  #key press event
        self.window.bind('<d>', lambda y: self.Right_press())  #key press event

        #functions related to Right side of binder
        self.rightFrame = Frame(self.window, width=800)
        self.rightFrame.pack(side=LEFT)

        self.wallCan = Canvas(self.rightFrame,
                              width=800,
                              height=800,
                              bg="light grey")
        self.wallCan.pack()

        self.orb = Orb(750, 50, self.rayCan, self.wallCan, self.window,
                       self.walls)

    def add_buttons(self):
        explainLbl = Label(self.buttonFrame,
                           bg='grey',
                           text="Select how many rays to emit")
        explainLbl.pack(side=LEFT, padx=10, pady=10)

        thirtyB = Button(self.buttonFrame,
                         text='30',
                         width=10,
                         command=self.callback30)
        thirtyB.pack(side=LEFT, padx=10, pady=10)

        sixtyB = Button(self.buttonFrame,
                        text='60',
                        width=10,
                        command=self.callback60)
        sixtyB.pack(side=LEFT, padx=10, pady=10)

        ninteyB = Button(self.buttonFrame,
                         text='90',
                         width=10,
                         command=self.callback90)
        ninteyB.pack(side=LEFT, padx=10, pady=10)

        oneeightyB = Button(self.buttonFrame,
                            text='180',
                            width=10,
                            command=self.callback180)
        oneeightyB.pack(side=LEFT, padx=10, pady=10)

        threesixB = Button(self.buttonFrame,
                           text='360',
                           width=10,
                           command=self.callback360)
        threesixB.pack(side=LEFT, padx=10, pady=10)

        seventwentB = Button(self.buttonFrame,
                             text='720',
                             width=10,
                             command=self.callback720)
        seventwentB.pack(side=LEFT, padx=10, pady=10)

    #functions for related buttons
    def callback30(self):
        self.orb.update_rays(30)

    def callback60(self):
        self.orb.update_rays(60)

    def callback90(self):
        self.orb.update_rays(90)

    def callback180(self):
        self.orb.update_rays(180)

    def callback360(self):
        self.orb.update_rays(360)

    def callback720(self):
        self.orb.update_rays(720)

    #event handlers
    def Mouse_move(self, event):
        self.window.after(15, self.orb.Redraw(event.x, event.y))

    def Left_press(self):
        self.orb.rotate_left()

    def Right_press(self):
        self.orb.rotate_right()

    def Draw_walls(self):
        #basic border walls
        self.create_border(-50, 0, 800, 0)
        self.create_border(-50, 800, 850, 800)
        self.create_border(800, 850, 800, -50)
        self.create_border(1, 850, 0, -50)

        # for wall in range(5):
        #     points = []
        #     for point in range(4):
        #         points.append(rand.randint(0,800))
        #     self.create_border(points[0],points[1],points[2],points[2],)

        self.create_border(300, 300, 500, 300)
        self.create_border(500, 300, 500, 500)
        self.create_border(500, 500, 300, 500)
        self.create_border(300, 500, 300, 300)

    def create_border(self, x1, y1, x2, y2):
        self.rayCan.create_line(x1, y1, x2, y2, width=3)
        self.walls.append([x1, y1, x2, y2])
Example #24
0
 def __init__(self, x, y, r):
     Orb.__init__(self, x, y, r)
     self.pic = Picture("items/spikes0001")
Example #25
0
    def tick(p):
        game = run.run.game
        kx = p.kx
        ky = p.ky
        rx = game.rightx
        ry = game.righty
        dx = game.downx
        dy = game.downy
        gx = game.gravityx
        gy = game.gravityy

        if p.jumping: p.jumping -= 1

        jumpx = 0
        jumpy = 0

        ground = p.get_colliders(dx * 2, dy * 2)
        falling = p.sameway(dx, dy)

        # If we are falling right into the ground, handle it in the next tick
        # after we bounce. Also a fudge factor of 3 pixels to make it all work
        # smooth :P
        if falling > 3: ground = []

        if ground:
            if falling < -1:
                v = falling / -6.0
                if v > 1.0: v = 1.0
                #run.run.wood2.play(v, p)
            if p.frame == 16: p.frame = 0
            gx = 0
            gy = 0
            if ky < 0 and p.jumping == 0:
                if kx == 0:
                    p.frame = 16
                    jumpx = -15 * dx
                    jumpy = -15 * dy
                    v = 1.0
                else:
                    jumpx = -12 * dx + kx * 2 * rx
                    jumpy = -12 * dy + kx * 2 * ry
                    v = 0.8
                p.jumping = 20
                run.run.jump.play(v, p)
        else:
            pass

        for g in ground:
            g.touch(p, 0)

        if ky > 0:
            for g in ground:
                g.interact()

        if kx and ground: # jump a bit up when going sideways
            # If we are actually falling down (no more than 2 pixels due to
            # check earlier) - cancel it away to move smoother.
            if falling > 0:
                p.dx -= falling * dx
                p.dy -= falling * dy
            p.dx -= 0.45 * dx
            p.dy -= 0.45 * dy

        p.dx += kx * 0.4 * rx + jumpx + gx * 0.2
        p.dy += kx * 0.4 * ry + jumpy + gy * 0.2

        if kx > 0:
            p.flipped = True
        if kx < 0:
            p.flipped = False

        if p.frame == 16 and falling > 1:
            p.frame = 0
        
        if kx and p.frame < 16:
            p.runcycle += 8
            p.runcycle %= 256
            p.frame = p.runcycle / 16

        if not kx and p.frame < 16:
            p.runcycle = 0
            p.frame = 0

        Orb.tick(p)
Example #26
0
 def colliders(self, x, y, r):
     orb = Orb(x, y, r)
     orb.hash = self.spatialhash
     return [x for x in orb.colliders() if not x.__class__ == InverseOrb]
Example #27
0
 def __init__(self, master, pos, direction):
     Orb.__init__(self, master, pos, direction)
     self.color
Example #28
0
 def __init__(self, x, y, r):
     Orb.__init__(self, x, y, r)
     self.pic = Picture("items/wall10001")
Example #29
0
 def __init__(self, x, y, r):
     Orb.__init__(self, x, y, r)
     self.pic = Picture("items/laser0001")
     self.id = 0
Example #30
0
 def __init__(self, x, y, r):
     Orb.__init__(self, x, y, r)
     if self.pic == None: self.pic = Picture("items/ball10001")
Example #31
0
 def insert_action(game, x, y):
     orb = Orb(x, y, game.new_size)
     orb.spawn(game.spatialhash)
     game.orbs.append(orb)