// // //绘制界面上所有图像 ,避免闪烁 private void DrawGame(Graphics g) { this.BackMove(g); g.DrawImage(images[index], pic_x, pic_y, 420, 630); g.DrawImage(images[index], pic_x, pic_y - 630, 420, 630); //绘制背景 MyPlane.MyPlaneShow(g); //绘制飞机 MyPlane.MyPlaneMove(); //通过键盘控制飞机移动 g.DrawRectangle(new Pen(Color.Black), new Rectangle(10, 100, 100, 10)); //绘制血条矩形 g.FillRectangle(Brushes.Red, 10, 101, MyPlane.health, 9); //填充血条矩形 g.DrawRectangle(new Pen(Color.Blue), new Rectangle(10, 120, 100, 10)); g.FillRectangle(Brushes.Green, 11, 121, MyPlane.score, 9); g.DrawString("Player:ruanyang", new Font("宋体", 9, FontStyle.Bold), Brushes.Yellow, new Point(10, 140)); //显示玩家 g.DrawString("Score:" + MyPlane.score, new Font("宋体", 9, FontStyle.Bold), Brushes.Yellow, new Point(10, 160)); //显示分数 Fighter.ProduceFighter(); Fighter.FighterMove(g); MyBullet.ProduceBullet(); MyBullet.MybulMove(g); MyBullet.isHitEnemy(g); EnemyBullet.ProduceEnbul(); EnemyBullet.Move(g); EnemyBullet.isHitplane(g); this.ProduceShotgun(); if (isDropGun && !MyPlane.isGetGun) //判断是否产生shotgun,并绘制 { g.DrawImage(shotImg, shot_x, shot_y); } if (MyPlane.isGetGun) { g.DrawImage(boomimg, MyPlane.x, MyPlane.y); shot_x = 200; shot_y = -100; MyPlane.health -= 10; MyPlane.isGetGun = false; } this.ProduceBlood(); if (isDropBox && !MyPlane.isGetBlood) //判断是否产生bloodbox,并绘制 { g.DrawImage(bloodImg, blood_x, blood_y); } if (MyPlane.isGetBlood) { blood_y = -50; if (MyPlane.health <= 90) { MyPlane.health += 10; } MyPlane.isGetBlood = false; } }
public static void ProduceEnbul() { for (int i = 0; i < Fighter.fighters.Count; i++) { if (new Random().Next(0, 10) == 5) { EnemyBullet enbullet = new EnemyBullet(Fighter.fighters[i].fighter_x + 25, Fighter.fighters[i].fighter_y + 40, new Random().Next(10, 15), MyPlane.x, MyPlane.y); enbulist.Add(enbullet); } } }