コード例 #1
0
ファイル: Game.cs プロジェクト: usamedin/VP-Game-Exams
 public void moveBulletPosition(Bullet b)
 {
     if (b.position.x < 0 || b.position.x > pbox.Width || b.position.y < 0 || b.position.y > pbox.Height)
     {
         bullets.Remove(b);
     }
     //Witch coordinate to increment
     if (b.moveXorY == 1)
     {
         b.position.x += b.speed * b.moveDir;
         b.position.y = (int)(b.mKoeficient * (b.position.x - b.target.x) + b.target.y);
     }
     else
     {
         b.position.y += b.speed * b.moveDir;
         b.position.x = (int)(b.mKoeficient * (b.position.y - b.target.y) + b.target.x);
     }
     b.centerPosition = new Point(b.position.x + (b.width / 2), b.position.y + (b.height / 2));
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: usamedin/VP-Game-Exams
 public void fireBullet()
 {
     for (int i = 0; i < profesors.Count; i++)
     {
         if (profesors[i].nextBullet <= timer)
         {
             for (int j = 0; j < students.Count; j++)
             {
                 if (profesors[i].nextBullet <= timer)
                 {
                     if (profesors[i].isEnemyInRange(students[j].centerPosition))
                     {
                         Bullet b = new Bullet(new Point(profesors[i].position.x, profesors[i].position.y), 10, 10, 5, students[j].centerPosition, profesors[i].centerPosition, profesors[i].demage);
                         bullets.Add(b);
                         profesors[i].nextBullet = timer + profesors[i].fireRate;
                     }
                 }
             }
         }
     }
 }