日期:2014-05-20  浏览次数:20769 次

急!!求教大神!VC++.NET在做贪吃蛇游戏时遇到困难(菜鸟)。
本帖最后由 youdangkong 于 2013-03-26 23:44:38 编辑
#pragma once
#define ROWS 40
#define COLUMNS 40
#define FOODCOUNT 3
enum direction{UP=0,DOWN,LEFT,RIGHT};
enum gameState{GAMESTART,GAMERUN,GAMEPAUSE};

namespace 贪吃蛇 {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


/// <summary>
/// Form1 摘要
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: 在此处添加构造函数代码
//
}
System::Int32 x0,y0;
    System::Int32 width;
    System::Int32 score;
    System::Random^ranX,^ranY,^ranF;
    array<System::Drawing::Color>^foodColor;
    gameState gamestate;
    direction dirt;
array<System::Int32,2>^table;
table=gcnew array<System::Int32,2>(40,40);
    width=12;
    score=0;
    ranX=gcnew System::Random((int)System::DateTime::Now.ToBinary());
    ranY=gcnew System::Random((int)System::DateTime::Now.ToBinary()+1);
    ranF=gcnew System::Random((int)System::DateTime::Now.ToBinary()+2);
    foodColor=gcnew array<System::Drawing::Color>(FOODCOUNT);
    foodColor[0]=System::Drawing::Color::Red;
    foodColor[1]=System::Drawing::Color::Blue;
    foodColor[2]=System::Drawing::Color::Yellow;
    gamestate=GAMESTART;
    dirt=UP;
..................................
为什么出现如下错误啊?
c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(207): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(207): error C3845: “贪吃蛇::Form1::width”: 只有静态数据成员才可以在 ref 类 或值类型内部初始化
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(208): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(208): error C3845: “贪吃蛇::Form1::score”: 只有静态数据成员才可以在 ref 类 或值类型内部初始化
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(209): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(209): error C3845: “贪吃蛇::Form1::ranX”: 只有静态数据成员才可以在 ref 类 或值类型内部初始化
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(210): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(210): error C3845: “贪吃蛇::Form1::ranY”: 只有静态数据成员才可以在 ref 类 或值类型内部初始化
1>c:\users\asus\documents\visual studio 2010\projects\贪吃蛇\贪吃蛇\Form1.h(211): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int