コード例 #1
0
ファイル: missiles.py プロジェクト: crocanura/magic_game
    def update_fins(self):
        vec = pgmath.Vector2(
            *math_tools.cartesian_from_polar(10.0 + self.power, 180 +
                                             self.direction))
        self.back = self.position + vec
        vec = pgmath.Vector2(
            *math_tools.cartesian_from_polar(5.0, 90 + self.direction))
        self.port_corner = self.back + vec
        self.starboard_corner = self.back - vec

        self.collidables[1] = collidables.Collision_segment(
            self.position, self.port_corner)
        self.collidables[2] = collidables.Collision_segment(
            self.position, self.starboard_corner)
コード例 #2
0
ファイル: missiles.py プロジェクト: crocanura/magic_game
    def __init__(self,
                 position=(0, 0),
                 direction=0,
                 bounds=[0, 0, 0, 0],
                 power=1,
                 a=0,
                 b=0):
        Base_spell.__init__(self, power, a, b, types[2]['missile'], position)

        self.direction = direction
        self.min_x = bounds[0]
        self.min_y = bounds[1]
        self.max_x = bounds[2]
        self.max_y = bounds[3]

        self.port_corner = None
        self.starboard_corner = None
        self.back = self.position + pgmath.Vector2(
            *math_tools.cartesian_from_polar(10.0 + self.power, 180 +
                                             self.direction))

        self.previous_position = self.back
        self.collidables = [
            collidables.Collision_segment(self.previous_position,
                                          self.position), None, None
        ]

        self.update_fins()

        self.velocity = pgmath.Vector2
        self.update_velocity()
コード例 #3
0
	def __init__(self, position=(0,0), power=1, a=0, b=0):
		Base_spell.__init__(self, power, a, b, types[2]['charge'], position)

		self.radius = 3+power

		self.collidables = [collidables.Collision_circle(self.position, self.radius)]

		self.ticks = 0
		m = np.sqrt(power)
		self.arm_data = [(rn.uniform(0, 360), rn.uniform(0,360), rn.uniform(m/4.0,m/6.0), rn.uniform(m/4.0,m/6.0), rn.uniform(m/30.0,m/60.0)) for i in range(power)]
		# arm tuple: (polar_phase, radial_phase, polar_frequency, radial_frequency, polar_overcycle_frequency)
		self.arms = [collidables.Collision_segment(self.position, self.position) for i in range(power)]
		# self.collidables.extend(self.arms)
		self.arm_update()
コード例 #4
0
    def __init__(self, position=(0, 0), direction=0, power=1, a=0, b=0):
        Base_spell.__init__(self, power, a, b, types[2]['lightning'], position)

        # self.tree = {self.position}
        self.direction = direction

        d = np.radians(self.direction + rn.uniform(-45, 45))
        l = rn.uniform(25, 100)
        move = pgmath.Vector2(l * np.cos(d), l * np.sin(d))
        next_point = self.position + move

        segment = collidables.Collision_segment(self.position, next_point)

        self.collidables = [segment]
        self.branches = [[segment]]
コード例 #5
0
    def tick_update(self):
        if self.status == 'dead':
            return

        if self.status == 'dying':
            self.death_animation -= 1
            if self.death_animation <= 0:
                self.kill()
            return

        current_depth = len(self.branches)

        m = int(current_depth * 0.5)
        M = int(current_depth * 1.2)
        branch_start = min(rn.randint(m, M), current_depth - 1)
        # M = current_depth - 0.0001
        # branch_start = int((rn.uniform(0, 1)**(1/2)*M)

        starting_point = rn.choice(
            [segment.p2 for segment in self.branches[branch_start]])

        # print branch_start
        if branch_start >= 3 + self.power:
            self.kill()
            self.death_animation = clock.GOAL_FPS / 4
            return

        d = np.radians(self.direction + rn.uniform(-45, 45))
        l = rn.uniform(25, 100)
        move = pgmath.Vector2(l * np.cos(d), l * np.sin(d))
        next_point = starting_point + move

        segment = collidables.Collision_segment(starting_point, next_point)
        self.collidables.append(segment)
        if branch_start == len(self.branches) - 1:
            self.branches.append([])

        self.branches[branch_start + 1].append(segment)