資源簡介
WinForm只能做一些簡單的游戲,比如:連連看,貪吃蛇等
WinForm游戲的核心就是:人機交互界面,
圖像加載形成靜態圖像,玩家控制游戲坦克,定時頻繁刷新,就完成了行走等命令,形成游戲。

代碼片段和文件信息
using?System.Drawing;
//add
//add
namespace?坦克
{
????internal?class?bullet
????{
????????private?readonly?bool?type;?//己方子彈true敵方子彈false
????????private?int?direct;?//子彈行進方向
????????private?int?height?=?32;
????????private?int?left;
????????private?int?top;?//子彈坐標(TopLeft)
????????private?int?width?=?32;
????????public?bullet(int?type)?//?子彈類構造函數
????????{
????????????if?(type?==?6)?//己方
????????????????this.type?=?true;
????????????else
????????????????this.type?=?false;
????????}
????????public?int?Top?//Top屬性
????????{
????????????get?{?return?top;?}
????????????set?{?top?=?value;?}
????????}
????????public?int?Left?//Left屬性
????????{
????????????get?{?return?left;?}
????????????set?{?left?=?value;?}
????????}
????????public?int?Direct?//Direct屬性(子彈行進方向)
????????{
????????????get?{?return?direct;?}
????????????set?{?direct?=?value;?}
????????}
????????public?void?move()
????????{
????????????switch?(Direct)
????????????{
????????????????case?0:
????????????????????Top--;
????????????????????break;
????????????????case?1:
????????????????????Top++;
????????????????????break;
????????????????case?2:
????????????????????Left--;
????????????????????break;
????????????????case?3:
????????????????????Left++;
????????????????????break;
????????????}
????????}
????????public?void?Draw(Graphics?g)
????????{
????????????Image?bulletImage;
????????????if?(type)?//己方
????????????????bulletImage?=?Image.FromFile(“BMP/missile1.bmp“);
????????????else
????????????????bulletImage?=?Image.FromFile(“BMP/missile2.bmp“);
????????????//得到繪制這個子彈圖形的在游戲面板中的矩形區域
????????????Rectangle?destRect?=?new?Rectangle(left*width?top*height?width?height);
????????????Rectangle?srcRect?=?new?Rectangle(0?0?width?height);
????????????g.DrawImage(bulletImage?destRect?srcRect?GraphicsUnit.Pixel);
????????}
????????public?bool?hitE(int?tanktype)?//是否擊中對方坦克
????????{
????????????if?(type?==?false)?//敵方子彈
????????????????if?(tanktype?>=?2?&&?tanktype?<=?5)
????????????????????//坦克的類型(2---5敵方,6己方)
????????????????????return?false;
????????????????else
????????????????????return?true;
????????????if?(type)?//己方子彈
????????????????if?(tanktype?==?6)?//坦克的類型(2---5敵方,6己方)
????????????????????return?false;
????????????????else
????????????????????return?true;
????????????return?false;
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-08-20?12:35??坦克大戰\
?????目錄???????????0??2012-08-20?12:30??坦克大戰\bin\
?????目錄???????????0??2012-08-20?12:35??坦克大戰\bin\Debug\
?????目錄???????????0??2012-08-20?12:30??坦克大戰\bin\Debug\bmp\
?????文件?????????822??2001-08-14?00:37??坦克大戰\bin\Debug\bmp\DX.BMP
?????文件????????9270??2001-08-15?00:57??坦克大戰\bin\Debug\bmp\ETANK1.BMP
?????文件????????9270??2001-08-15?01:07??坦克大戰\bin\Debug\bmp\ETANK2.BMP
?????文件????????9270??2001-08-15?01:11??坦克大戰\bin\Debug\bmp\ETANK3.BMP
?????文件????????9270??2001-08-15?01:16??坦克大戰\bin\Debug\bmp\ETANK4.BMP
?????文件?????????566??2000-02-07?20:21??坦克大戰\bin\Debug\bmp\explode1.bmp
?????文件????????5174??2000-02-08?21:03??坦克大戰\bin\Debug\bmp\explode2.bmp
?????文件????????2906??2008-08-07?22:12??坦克大戰\bin\Debug\bmp\missile1.bmp
?????文件????????2906??2008-08-08?05:38??坦克大戰\bin\Debug\bmp\missile2.bmp
?????文件????????9270??1999-12-01?17:05??坦克大戰\bin\Debug\bmp\MYTANK.BMP
?????文件???????13970??1999-04-12?15:52??坦克大戰\bin\Debug\bmp\tankD.bmp
?????文件???????14646??1999-04-12?15:52??坦克大戰\bin\Debug\bmp\tankL.bmp
?????文件???????14526??1999-04-12?15:51??坦克大戰\bin\Debug\bmp\tankR.bmp
?????文件???????14654??1999-04-12?15:52??坦克大戰\bin\Debug\bmp\tankU.bmp
?????文件?????????822??2001-08-14?00:39??坦克大戰\bin\Debug\bmp\TQ.BMP
?????目錄???????????0??2012-08-20?12:30??坦克大戰\bin\Debug\sound\
?????文件???????11414??1997-10-26?17:11??坦克大戰\bin\Debug\sound\bob.wav
?????文件????????1977??1998-09-07?08:54??坦克大戰\bin\Debug\sound\DropCell.wav
?????文件???????85420??2000-04-12?08:42??坦克大戰\bin\Debug\sound\Explode.wav
?????文件???????38400??2005-10-27?02:57??坦克大戰\bin\Debug\sound\explode2.WAV
?????文件???????13318??1998-07-22?07:15??坦克大戰\bin\Debug\sound\MOVE.WAV
?????文件????????9851??2001-05-18?20:37??坦克大戰\bin\Debug\sound\Music1.mid
?????文件???????10389??1997-08-05?07:49??坦克大戰\bin\Debug\sound\Music8.MID
?????文件???????11504??2005-10-27?02:57??坦克大戰\bin\Debug\sound\score.wav
?????文件???????48274??2000-04-12?23:54??坦克大戰\bin\Debug\sound\Shoot.wav
?????文件?????????972??2000-03-12?03:09??坦克大戰\bin\Debug\sound\tank.wav
?????文件????????7170??2006-10-29?07:46??坦克大戰\bin\Debug\sound\tie.wav
............此處省略35個文件信息
- 上一篇:C#+數據庫
- 下一篇:KTV點歌系統的設計與實現論文
評論
共有 條評論