構造体
Posted: 2012年12月22日(土) 23:12
はじめまして。3Dと言います。今、自作のインベーダーゲームを作っているのですが、以下のエラーがでて困っています。
game.cpp
struct.h
までがソースコードです。汚くてすいません^^;
いかがエラーです。
いろいろと工夫しましたが、エラーが消えません。
環境は windows XP ,VC++2008 を使用しています。
C言語は初めて3ヶ月程度で、構造体とポインタが若干判らないです^^;
ライブラリはDXライブラリを使っています。
このエラーはどうしたら消えるでしょうか?お教え願います。
game.cpp
#include "DxLib.h"
#include "common.h"
#include "fps.h"
#include "game.h"
#include "struct.h"
player_t Player;
Player.x = 200; //x座標
Player.y = 400; //y座標
Player.shot_flag_key = 0; //ショットは打たれない
Enemy_t Enemy;
Enemy.flag = 0; //死んだら1
Enemy.x = 380;//座標
Enemy.y = 10;//座標
int stage = 0;//
void stage1(){
//計算フェーズ
if(Keyboard_Get(KEY_INPUT_Z)==1)player_t.shot_flag_key = 1;//ショットは出る
tif(player_y.shot_flag_screen == 1)player_t.shot_flag_key = 0;//ショットは出ない3
//自機の移動(計算フェーズ)
if(Keyboard_Get(KEY_INPUT_RIGHT)==1)x+=6; //もし、右が押されたら、6ずつ移動する
if(Keyboard_Get(KEY_INPUT_LEFT) ==1)x-=6; //同上
if(Keyboard_Get(KEY_INPUT_LSHIFT)==1 && Keyboard_Get(KEY_INPUT_RIGHT)==1)x+=3;//低速移動
if(Keyboard_Get(KEY_INPUT_LSHIFT)==1 && Keyboard_Get(KEY_INPUT_LEFT) ==1)x-=3;//低速移動
//描写フェーズ
DrawFormatString(player_t.x,player_t.y,GetColor(255,255,0),"自");
if(player_t.shot_flag_key == 1)DrawFormatString(player_t.x,player_t.y,GetColor(255,255,255),"↑");//ショットを表示
}
void stage2(){
DrawString(0,0,"stage2",GetColor(255,255,255));
clear();
WaitKey();
}
void stage3(){
DrawString(0,0,"stage3",GetColor(255,255,255));
clear();
WaitKey();
}
void stage4(){
DrawString(0,0,"stage4",GetColor(255,255,255));
clear();
WaitKey();
}
void stage5(){
DrawString(0,0,"stage5",GetColor(255,255,255));
clear();
WaitKey();
}
void ending(){
DrawString(0,0,"end",GetColor(255,255,255));
}
void clear(){//クリアしたら
int clear;
DrawBox(30,20,400,450,GetColor(255,255,255),true);
DrawFormatString(100,200,GetColor(255,255,255),"残機 : %d",player_t.zanki);
DrawFormatString(100,250,GetColor(255,255,255),"Bomb : %d",player_t.bomb);
DrawFormatString(100,400,GetColor(255,255,0) ,"Push Z Key!");
if(CheckHitKey(KEY_INPUT_Z)==1){//もし、zキーが押されたら
stage++; //stage に1を足す
if(stage == 1)stage2();
if(stage == 2)stage3();
if(stage == 3)stage4();
if(stage == 4)stage5();
if(stage > 5)ending();
}
}
typedef struct{
int x, y; //プレイヤーの座標
int shot_flag_key; //自機のshot_flag(キー入力)
}player_t;
typedef struct{
int flag; //表示flag
int bomb; //bomb
int zanki; //残機
int idou_houkou; //移動方向
double idou_ryou; //移動量
} Enemy_t;
いかがエラーです。
------ ビルド開始: プロジェクト: インベーダー, 構成: Debug Win32 ------
コンパイルしています...
game.cpp
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(9) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(9) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(9) : error C2371: 'Player' : 再定義されています。異なる基本型です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(7) : 'Player' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(10) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(10) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(10) : error C2371: 'Player' : 再定義されています。異なる基本型です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(7) : 'Player' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(11) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(11) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(11) : error C2371: 'Player' : 再定義されています。異なる基本型です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(7) : 'Player' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(17) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(17) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(17) : error C2371: 'Enemy' : 再定義されています。異なる基本型です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(15) : 'Enemy' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(18) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(18) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(18) : error C2371: 'Enemy' : 再定義されています。異なる基本型です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(15) : 'Enemy' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(19) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(19) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(19) : error C2371: 'Enemy' : 再定義されています。異なる基本型です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(15) : 'Enemy' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(25) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(25) : error C2143: 構文エラー : ';' が '.' の前にありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(26) : error C2065: 'player_y' : 定義されていない識別子です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(26) : error C2228: '.shot_flag_screen' の左側はクラス、構造体、共用体でなければなりません
型は ''unknown-type'' です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(26) : error C2146: 構文エラー : ';' が、識別子 'player_t' の前に必要です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(26) : error C3861: 'tif': 識別子が見つかりませんでした
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(26) : error C2275: 'player_t' : この型は演算子として使用できません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\struct.h(5) : 'player_t' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(28) : error C2065: 'x' : 定義されていない識別子です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(29) : error C2065: 'x' : 定義されていない識別子です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(30) : error C2065: 'x' : 定義されていない識別子です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(31) : error C2065: 'x' : 定義されていない識別子です。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(34) : error C2275: 'player_t' : この型は演算子として使用できません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\struct.h(5) : 'player_t' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(34) : error C2275: 'player_t' : この型は演算子として使用できません
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\struct.h(5) : 'player_t' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(35) : error C2059: 構文エラー : '.'
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(50) : error C2039: 'zanki' : 'player_t' のメンバではありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\struct.h(1) : 'player_t' の宣言を確認してください。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\game.cpp(51) : error C2039: 'bomb' : 'player_t' のメンバではありません。
c:\documents and settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\struct.h(1) : 'player_t' の宣言を確認してください。
ビルドログは "file://c:\Documents and Settings\(ユーザー名)\デスクトップ\game_project\game\game_2\インベーダー\Debug\BuildLog.htm" に保存されました。
インベーダー - エラー 34、警告 0
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
環境は windows XP ,VC++2008 を使用しています。
C言語は初めて3ヶ月程度で、構造体とポインタが若干判らないです^^;
ライブラリはDXライブラリを使っています。
このエラーはどうしたら消えるでしょうか?お教え願います。