程式碼真的太長了不太可能全貼在這裡= =
以下展示球的類別方法及其屬性
遊戲中有道具跟碰撞偵測而且是clr form的程式應該挺容易學的^^"
有興趣的人看看吧
完整程式碼下載
using namespace System::Drawing;
using namespace System::Media;
#pragma once
namespace Breakit{
static int CBallDiameter=20;
static int CheckPointsBrick=20;
static int HitScore;
static int GameBrickCount;
static int GameLife;
static int GameTime;
static int PropsBall=0;
public ref class ball
{
static SoundPlayer ^PongBallHit;
static bool PongBallHitOver;
public:
int WindowRight,WindowDown;
int x,y;
int previousUp,previousDown,previousLeft,previousRight;
int xspeed,yspeed;
System::Random^ rand;
ball()
{
xspeed=12,yspeed=-13;
rand=gcnew System::Random;
PongBallHit=gcnew SoundPlayer("sound\\PongBallHit.wav");
PongBallHitOver=false;
}
public:
void updatePoint()
{
previousUp=y,previousDown=y+CBallDiameter,previousLeft=x,previousRight=x+CBallDiameter;
}
void moving(System::Windows::Forms::PictureBox^ ball)
{
x+=xspeed;
y+=yspeed;
ball->Location = Point(x,y);
..
訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容