日期:2014-05-17 浏览次数:20874 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 面向对象小项目之飞机小游戏
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Plane pla = new Plane();//飞机对象
Bullet bul = new Bullet();//子弹对象
private void Form1_Load(object sender, EventArgs e)
{
pla.StartInit();
bul.StatInit();
}
private void timer1_Tick(object sender, EventArgs e)
{
pla.Move(panel1);
bul.Move(panel1);
this.Invalidate();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
pla.Draw(panel1, panel1.CreateGraphics());
bul.Draw(panel1, panel1.CreateGraphics());
bul.IsHit(pla, panel1);
}
/// <summary>
/// 鼠标点击
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panel1_MouseClick(object sender, MouseEventArgs e)
{
bul.SatrtFire(e, panel1);
}
}
}
//子弹类的代码
namespace 面向对象小项目之飞机小游戏
{
class Bullet:GameObject
{
/// <summary>
///