示例#1
0
def domet_o_trenju():
    Domet = []
    domet = []
    Koef_tr = []
    masa = []
    p1 = prj.Projectile()
    p2 = prj.Projectile()
    C_d = 1
    m_0 = 1
    for i in range(1, 500):  #za tisuću različitih objekata
        C_d += 0.01  #svaki sljedeći CD će biti za 0.01 veći od prethodnog
        m_0 += 0.1  #svaka sljedeća masa bit će za 0.1 kg veća od prethodne
        Koef_tr.append(C_d)
        masa.append(m_0)
    for Cd in Koef_tr:
        p1.init(50, 0, 0, 45, 1.22, Cd, 1, 0.001, 0.01)
        D = p1.range()
        Domet.append(D)
        p1.reset()
    for m in masa:
        p2.init(50, 0, 0, 45, 1.22, 1, m, 0.001, 0.01)
        d = p2.range()
        domet.append(d)
        p2.reset()
    plt.plot(Koef_tr, Domet)
    plt.title("Promjena dometa u odnosu na koeficijent trenja zraka")
    plt.xlabel("Koeficijent trenja zraka")
    plt.ylabel("Domet u metrima [m]")
    plt.show()
    plt.plot(masa, domet)
    plt.title("Promjena dometa u odnosu na masu ispaljenog objekta")
    plt.xlabel("Masa u kilogramima [kg]")
    plt.ylabel("Domet u metrima [m]")
    plt.show()
示例#2
0
	def __init__(self, time_step, window_x, window_y, walls , elas, color, m_win):
		self.time_step = time_step
		self.x_vel = 0.0
		self.y_vel = 0.0
		self.window_x = window_x
		self.window_y = window_y
		# create projectile object
		self.ball = Projectile(2, elas, color, m_win)
		self.walls = walls
		self.x_bnc = False
		self.y_bnc = False
		self.m_win = m_win
示例#3
0
 def update(self,camera,delta,platforms):
     Projectile.update(self,camera,delta,platforms)
     if self.v[0] < 0:
         if(self.animToggle):
             self.image = self.FRAMES[0]
         else:
             self.image = self.FRAMES[1]
     else:
         if(self.animToggle):
             self.image = self.FRAMES[2]
         else:
             self.image = self.FRAMES[3]
     self.animToggle = not self.animToggle
示例#4
0
def createObject(objCount):

    # initialize element set with this TLE
    # 1 05398U 71067E   17237.19596243  .00000191  00000-0  60767-4 0  9996
    # 2 05398  87.6282 147.4622 0065864  59.7371 301.0323 14.33603389412679
    # Semi-major axis
    a = 7157.e3
    # eccentricity
    e = 0.0065864
    # inclination
    if (objCount == 1):
        i = proj.deg2radian(1.0)
    else:
        i = proj.deg2radian(87.6282)

    # argument of perigee
    omega_AP = proj.deg2radian(59.7371)
    # longitude of the acsending node
    if (objCount < 2):
        omega_LAN = proj.deg2radian(147.4622)
    else:
        omega_LAN = proj.deg2radian(147.4622 - 90.0)

    # time of periapse passage
    if (objCount == 3):
        # Object 3 follows Object 2 by 10 degrees
        meanAnomaly = proj.deg2radian(301.0323 - 10)
    else:
        meanAnomaly = proj.deg2radian(301.0323)

    orbitalPeriod = proj.computeOrbitalPeriod(a)
    T = t - orbitalPeriod * (meanAnomaly / 360)

    return a, e, i, omega_AP, omega_LAN, T
    def keyDown(self, key):
        if key == pygame.K_RIGHT:
            self.Player.dx = 2
        elif key == pygame.K_LEFT:
            self.Player.dx = -2
        elif key == pygame.K_SPACE:
            if self.shooting == False:
                self.PlayerProjectile = Projectile(self.Player.imgmid,
                                                   self.Player.y, 0, -10,
                                                   'laser.png')
                self.shooting = True

        else:
            pass
示例#6
0
def aim_z(end_coord, cup_coord):
    # calculate z angle
    h, d = Projectile.convertfrom3D(end_coord, cup_coord)
    theta2 = Projectile.projectile(h, d)

    # adjust to z angle jointset
    # anlges = joint_state[:-1]+[theta2]

    # joint_command = {}
    # for i in range(0,len(anlges)):
    #     joint_command[RJ[i]] = float(anlges[i])
    # RIGHT.set_joint_positions(joint_command)

    return theta2
示例#7
0
 def shoot(self):
     alienpos = self.Wave2pixel(random.choice(self.bottomaliens()))
     x , y = alienpos
     y += self.sqheight
     x += self.sqwidth/2
     self.AlienProjectile = Projectile(x, y, 0, 10, 'enemylaser.png' )
     return self.AlienProjectile
示例#8
0
 def attackPlayer(self):
     if self.owner.arrows > 0:
         self.arrows.append(
             Projectile.Projectile(self.owner.x, self.owner.y,
                                   self.playerPosX, self.playerPosY,
                                   self.damage))
         self.owner.arrows -= 1
示例#9
0
 def attack():
     """
     Generate projectile.
     :return:
     """
     Player.lastAttack = pygame.time.get_ticks()
     Projectile.PlayerProjectile(Player.currentLane)
示例#10
0
  def createProjectile(self, o, projectile_type): 
    if (DEBUG == 1):
      print("[ProjectileFactory]:create")

    # Projectile requires position tuple, not Position object
    p=Projectile((o.getX(),o.getY()), projectile_type, o)
    self.active_p.append(p)
示例#11
0
 def shootDaddy(self):
     if self.numProj > 0:
         if pygame.mixer.music.get_volume():
             pygame.mixer.Sound.play(self.whoosh)
         self.projectile = Projectile(self.daddy.direction, self.daddy.rect)
         self.projectileGroup.add(self.projectile)
         self.projectileGroup.draw(self.image)
         self.numProj -= 1
示例#12
0
 def projectileAttack(self, Game, Target):
     """Spawn Projectile that follows player"""
     self.xvel = 0
     self.yvel = 0
     self.projectiles.append(
         Projectile(self.x, self.y, self.projWidth, 10, Game, Target))
     if (Target.hp <= 0):
         self.target = None
示例#13
0
 def __init__(self,
              picture='models/player.png.png',
              health=3,
              lvl=1,
              ammo=10):
     self.__health_points = health
     self.__attack_level = lvl
     self.image = pygame.image.load(picture).convert()
     self.__inventory = [ammo, Projectile.Projectile()]
示例#14
0
 def shoot(self,player):
     '''Shoots in the direction of the player based on its own position.
     Each time it shoots, each projectile is also checked to see if it is on screen
     Off screen projectiles are removed.'''
     if self.shot_timer > 100:
         dir = 1 if player.rect.x > self.rect.x else 0
         self.projectiles.append(Projectile.Bullet(self.rect.x,self.rect.y+12,dir,"projectile1.png"))
         self.shot_timer = 0
     self.projectiles = [i for i in self.projectiles if 0 < i.rect.x < 1000]
示例#15
0
 def get_projectiles(self, time, x, y, w, h, dir, img):
     '''Creates a new projectile object using the players data
     Returns an empty array if the delay is not fulfilled
     Else returns a projectile for each position it makes'''
     self.get_positions(h)
     if time < self.projectile_delay or self.positions == []: return []
     projectiles = []
     for yoff, yvel in self.positions:
         bullet = Projectile.Bullet(x + w, y + yoff, dir, img, yvel)
         projectiles.append(bullet)
     return projectiles
示例#16
0
def benchmark():
    # Run simulation at this level
    t = 0.0
    prj = proj.Projectile(0, "Satellite" + str(0))
    a, e, i, omega_AP, omega_LAN, T = createObject(0)
    prj.kep_init(a, e, i, omega_AP, omega_LAN, T)
    running = True
    for loop in range(0, 100000):
        r_true, v_true, h_true = prj.propagate(t)
        t = t + 1
    print "time:", t
示例#17
0
def aim_xy(end_coord, base_coord, cup_coord, joint_state):
    # calculate xy angle
    theta1 = Projectile.calc_xy(cup_coord, base_coord, end_coord)
    # go to xy coord with jointset
    # anlges = [theta1]+joint_state[1:]

    # joint_command = {}
    # for i in range(0,len(anlges)):
    #     joint_command[RJ[i]] = float(anlges[i])
    # RIGHT.set_joint_positions(joint_command)

    return theta1
示例#18
0
    def CastSpell(self, projectile_list):
        spell_cast = Projectile.Projectile(self.spell_1, 0, 0)
        spell_cast.rect.y = self.rect.centery - spell_cast.rect.height / 2
        if self.FacingLeft():
            spell_cast.UpdateDirection("left")
            spell_cast.rect.x = self.rect.left
        elif self.FacingRight():
            spell_cast.UpdateDirection("right")
            spell_cast.rect.x = self.rect.right

        projectile_list.append(spell_cast)
        self.current_mana -= 1
示例#19
0
def main():
    angle,vel,h0,time = getInputs()
    shot = Projectile(angle,vel,h0)
    while shot.getY() >=0:
        shot.update(time)
        #print("haha")
    print("\nDistance traveled:%.1fmeters."%shot.getX())
示例#20
0
def main():
    angle,vel,h0,time=getInputs()
    shot=Projectile(angle,vel,h0)
    while shot.gety()>=0:
        shot.update(time)

    print("\nDistance traveled:{0:0.1f}meters".format(shot.getx()))
示例#21
0
    def model(self, t, r_obs, v_obs, h_obs):
        # print "obsCount: ",self.obsCount
        # Collect observations
        self.tObs[self.obsCount] = t
        self.rObs[self.obsCount] = r_obs
        self.vObs[self.obsCount] = v_obs

        self.obsCount = self.obsCount + 1

        # Convert ECI vector to orbital elements
        a, e, i, omega_AP, omega_LAN, T, h = proj.cart_2_kep(t, r_obs, v_obs)

        for j in range(0, self.obsCount - 1):
            # Evaluate range between object and other objects in the catalog
            conjunction = rangeCheck(r_obs, self.rObs[j])
            if conjunction:
                self.conjunctionCount = self.conjunctionCount + 1

        # print "Compare obs to each of the ",self.objCatalogLength," obs in catalog"
        # Compare orbital elements to existing collection
        correlates = False

        for j in range(0, self.objCatalogLength):

            # Compare in this order:
            # - Semi-major axis
            correlates,hDelta,hDeltaMag = compareOrbits(h, self.hCatalog[j],\
                                                        r_obs,self.rCatalog[j])
            if correlates:
                correlatingObs = j
                self.correlatingObsCount = self.correlatingObsCount + 1
                break

        # If correlates, then add to observation list
        if (correlates):
            # Evaluate statistics of collection
            # Report anomalies
            print "Observation correlates with: ", correlates, correlatingObs, self.obsCount
        else:
            # If uncorrelated, create new object
            print "Add observation to catalog:", self.objCatalogLength
            self.aCatalog[self.objCatalogLength] = a
            self.eCatalog[self.objCatalogLength] = e
            self.iCatalog[self.objCatalogLength] = i
            self.omega_APCatalog[self.objCatalogLength] = omega_AP
            self.omega_LANCatalog[self.objCatalogLength] = omega_LAN
            self.TCatalog[self.objCatalogLength] = T
            self.hCatalog[self.objCatalogLength] = h
            self.objCatalogLength = self.objCatalogLength + 1

        return self.objCatalogLength, self.conjunctionCount, \
               self.correlatingObsCount
示例#22
0
 def enemy_attack(self):
     """
     =======================================================================
     Randomly (within range) determine whether enemy should attack.
     =======================================================================
     """
     attack = random.randint(1, self.max_attack_chance)
     if attack <= self.chance_to_attack \
             and pygame.time.get_ticks()\
             - self.last_attack \
             > self.attack_cooldown:
         Projectile.EnemyProjectile(self.lane_key, self)
         self.last_attack = pygame.time.get_ticks()
def main():
    # sample_bullet = pjtl.dictionary_for_bullet(bullet_data["cartridges"][0.223]["PRA223RB"])
    # theta =pjtl.zero_in(sample_bullet, 0.065, 600.0, 0.0001, 0.95)
    # pjtl.plot_trajectories(sample_bullet)
    # plt.savefig("sample_bullet.png", bbox_inches="tight", dpi=240)
    #
    # w308 = pjtl.dictionary_for_bullet(bullet_data["cartridges"][0.308]["R308W1"])
    # theta = pjtl.zero_in(w308, 0.065, 600, 0.0001, 0.95)
    # pjtl.plot_trajectories(w308)
    # plt.savefig("winchester308.png", bbox_inches="tight", dpi=240)

    # Compare the lapua 338 against various models.
    bullet_data = pjtl.load_yamlfile("BulletData.yaml")
    lm338 = pjtl.dictionary_for_bullet(
        bullet_data["cartridges"][0.338]["4318013"])
    compare_models(lm338)

    # Compare the winchester 308 against various models.
    bullet_data = pjtl.load_yamlfile("BulletData.yaml")
    wnchstr338 = pjtl.dictionary_for_bullet(
        bullet_data["cartridges"][0.308]["R308W1"])
    compare_models(wnchstr338)
示例#24
0
def skipToEnd(alpha, beta, x0, y0, v0):
    """
    Initialize and handle the recursive method from Projectile. Then, find 
    the number of times the stone skipped.
    
    param:
        alpha (int) - angle of stone relative to the horizon in radians
        beta (int) - ngle of initial velocity in radians
    
    return:
        skipCount (int) - number of skips that have occured
        x[len(x)-1] (int) - the distance which the stone traveled before 
                reaching the stopping condition in cm
       
    """

    vx0 = v0 * math.cos(beta)
    vy0 = v0 * math.sin(beta)

    x = [x0]
    y = [y0]
    vx = [vx0]
    vy = [vy0]
    counter = 0

    skipCount = 0

    pj.move(x, y, vx, vy, counter, alpha, beta, skipCount)

    #count up the skips (skips are indicated by 0.0 entries in y[])

    for i in range(len(y)):
        if (y[i] <= 0.0):
            skipCount += 1

    #return some stuff so I can analyze the optimization problem
    # number of skips and distance skipped
    return skipCount, x[len(x) - 1]
示例#25
0
    def ranged_attack(self, target_position, explosive_image = None):

        if self.current_healing_cooldown <= 0:
            
            projectile = Projectile(self, self.world, self.projectile_image, explosive_image)

            if explosive_image:
                distance = (self.position - target_position).length()
                projectile.max_range = min(distance, self.projectile_range)
            else:
                projectile.max_range = self.projectile_range
            
            projectile.maxSpeed = self.projectile_speed
            projectile.damage = self.ranged_damage
            projectile.team_id = self.team_id
            projectile.position = Vector2(self.position)
            projectile.origin_position = Vector2(self.position)
            projectile.velocity = target_position - projectile.position
            projectile.velocity.normalize_ip()
            projectile.velocity *= projectile.maxSpeed
            
            self.world.add_entity(projectile)
            self.current_ranged_cooldown = self.ranged_cooldown
示例#26
0
    def shootBullet(self, pos, world):
        mouse_pos = Point.Point(pos[0], pos[1])
        player_pos = self.center()

        # normalized vector between two points
        direction = mouse_pos.normalized_vector(mouse_pos, player_pos)
        speed = 10
        size = 5
        damage = 10

        bullet = Projectile.Projectile(player_pos, direction, speed, size,
                                       damage)
        world.spawn_projectile(bullet)
        return bullet
示例#27
0
def skipPlot(alpha, beta, x0, y0, v0):
    """
    Initialize and handle the recursive method from Projectile. Then, find 
    the number of times the stone skipped and plot the skips.
    
    param:
        alpha (int) - angle of stone relative to the horizon in radians
        beta (int) - ngle of initial velocity in radians
    
    return:
        skipCount (int) - number of skips that have occured
        x[len(x)-1] (int) - the distance which the stone traveled before 
                reaching the stopping condition in cm
       
    """

    vx0 = v0 * math.cos(beta)
    vy0 = v0 * math.sin(beta)

    x = [x0]
    y = [y0]
    vx = [vx0]
    vy = [vy0]
    counter = 0

    skipCount = 0

    pj.move(x, y, vx, vy, counter, alpha, beta, skipCount)

    for i in range(len(y)):
        if (y[i] == 0.0):
            skipCount += 1

    plt.plot(x, y)
    plt.show()

    return skipCount, x[len(x) - 1]
    def bulletSpread(self, n, bulletSpeed):
        if self.bulletCooldown:
            self.bulletCooldown -= 1
            return

        for i in xrange(n):
            angle = ((360 * i / n) + self.bulletOffset) % 360
            """
            xVelocity = bulletSpeed*math.cos(math.radians(angle))
            yVelocity = -bulletSpeed*math.sin(math.radians(angle))"""
            self.world.npcProjectileEntities.append(
                Projectile(self.world, self.xPosition, self.yPosition, angle,
                           self.xVelocity, self.yVelocity))
        self.bulletOffset += 15
        self.bulletOffset = self.bulletOffset % 360
示例#29
0
    def attack(self):
        if self.shoot_loop >= 81:
            self.shoot_loop = 0

        if self.shoot_loop == 0 and not self.dead:
            bul = Projectile.Projectile(round(self.x + self.width // 2 - 15),
                                        round(self.y + self.height // 2 - 85),
                                        4, (3, 53, 252), -30, 5, 32)
            bul.spell_image = self.spell_image
            bul.magic_count_speed = 32
            self.bullets.append(bul)
            self.shoot_loop += 1

        else:
            self.shoot_loop += 1
示例#30
0
def graf_domet_masa():
    m_ = []
    domt_ = []
    p1 = pr.Projectile(0, 0, 0, 0, 0, 0, 0, 0, 0)

    for m in np.arange(0.1, 10, 0.01):
        p1.__init__(60, 15, 0.01, 0, 0, m, 1.29, 1, 1)
        d = p1.Range()
        domt_.append(d)
        m_.append(m)

    plt.plot(m_, domt_, 'r')
    plt.xlabel("masa")
    plt.ylabel("domet")
    plt.title("Ovisnost dometa o masi cestice")
    plt.pause(2)
    plt.close
示例#31
0
def graf_domet_koeficijent_trenja():
    kft_ = []
    domet_ = []
    p1 = pr.Projectile(0, 0, 0, 0, 0, 0, 0, 0, 0)

    for kft in np.arange(0.1, 3.0, 0.01):
        p1.__init__(60, 15, 0.01, 0, 0, 1, 1.29, kft, 1)
        d = p1.Range()
        domet_.append(d)
        kft_.append(kft)
        p1.reset()

    plt.plot(kft_, domet_, 'b')
    plt.xlabel("koeficijent trenja")
    plt.ylabel("domet")
    plt.title("Ovisnost dometa o koeficijentu trenja")
    plt.pause(1)
    plt.close
示例#32
0
def main():
    angle, vel, h0, time = getInputs()
    shot = Projectile(angle, vel, h0)
    while shot.getY() >= 0:
        shot.update(time)
    print('\nDistance traveled:{0:0.1f}meters.'.format(shot.getX()))
示例#33
0
 def draw(self,screen,camera,time):
     Projectile.draw(self,screen,camera,time)
示例#34
0
    
    if key[K_o]:
        break
    
    pygame.display.update()
    pygame.event.pump()

while player.alive:
    counter = counter + 1
    time.sleep(.01)
    
    screen.blit(background, (0, 0+buffer_height))

    if(counter % 10 == 0):
        if player.color == 'red':
            p = Projectile(rshot, player.rect.centerx - 2, player.rect.top - 20, 5, 'red', 9)
        if player.color == 'yellow':
            p = Projectile(yshot, player.rect.centerx - 2, player.rect.top - 20, 5, 'yellow', 9)
        if player.color == 'blue':
            p = Projectile(bshot, player.rect.centerx - 2, player.rect.top - 20, 5, 'blue', 9)
    
    if(counter % 50 == 0):
        fallerWave(random.randint(30,SCREEN_WIDTH - 72))
    
    key = pygame.key.get_pressed()
    
    if key[K_ESCAPE]:
        sys.exit()
        
    if key[K_p]:
        #time.sleep(1)