ページ 11

龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 00:12
by Hanchan
--- shot.cpp (のinclude文の直後) に以下を追加 ---

extern void shot_bullet_H000(int);

void (*shot_bullet[SHOT_KND_MAX])(int) ={
shot_bullet_H000,
};

//n番目のショットを登録した敵と自機との角度を返す
double shotatan2(int n){
return atan2(ch.y-enemy[shot[n].num].y,ch.x-enemy[shot[n].num].x);
}

//空いている弾を探す
int shot_search(int n){
int i;
for(i=0;i<SHOT_BULLET_MAX;i++){
if(shot[n].bullet.flag==0){
return i;
}
}
return -1;
}



↑ の部分は分かるのですが


--- shot.cpp のshot_main()関数を以下のように修正 ---

void shot_main(){
int i;
for(i=0;i<SHOT_MAX;i++){//弾幕データ計算
//フラグが立っていて、設定した種類が間違っていなければ(オーバーフロー対策)
if(shot.flag!=0 && 0<=shot.knd && shot.knd<SHOT_KND_MAX){
shot_bullet[shot.knd](i);//.kndの弾幕計算関数を呼ぶ関数ポインタ
shot_calc(i);//i番目の弾幕を計算
shot.cnt++;
}
}
}


↑ の部分がよく分からないのですが shot_main() というのは shot.cpp のどこら辺にあるのですか?


ヘルプ お願いします~

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 00:42
by softya(ソフト屋)
codeタグ使ってくださいね。 codeタグについてはフォーラムルールを。 → http://dixq.net/board/board.html
たぶん新規の記入ミスだと思いますので追加しちゃって下さい。
作者のDixqさんには連絡しておきます。

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 00:47
by naohiro19
Visual Studio の「定義へ移動」(もしくはCtrl+F12を押す)とshot_mainがどこにあるのかわかります。

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 01:39
by Hanchan
見つからないよ~ T____T

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 11:51
by へにっくす
Hanchan さんが書きました:見つからないよ~ T____T
いや
1章から12章まで、見てみましたがshot_main関数は出てこないので、
softya(ソフト屋) さんが書きました:たぶん新規の記入ミスだと思いますので追加しちゃって下さい。
作者のDixqさんには連絡しておきます。
とある通り
修正ではなく、追加でいいと思います。

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 13:15
by Dixq (管理人)
皆様仰っているように、12章までに何も書いてないので、「追加」ですね。
本館を作った頃は徹夜しまくりで作業してたので、こういうミスはいくつかあると思います・・。
ご迷惑をおかけしました。修正してアップしました。

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 18:46
by Hanchan
softya(ソフト屋) さんが書きました:codeタグ使ってくださいね。 codeタグについてはフォーラムルールを。 → http://dixq.net/board/board.html
たぶん新規の記入ミスだと思いますので追加しちゃって下さい。
作者のDixqさんには連絡しておきます。

ああ~ すいません 急いでたので てへへ..

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 18:52
by Hanchan

コード:

#include "../include/GV.h"

extern void shot_bullet_H000(int);

void shot_main(){
        int i;
        for(i=0;i<SHOT_MAX;i++){//弾幕データ計算
                //フラグが立っていて、設定した種類が間違っていなければ(オーバーフロー対策)
                if(shot[i].flag!=0 && 0<=shot[i].knd && shot[i].knd<SHOT_KND_MAX){
                        shot_bullet[shot[i].knd](i);//.kndの弾幕計算関数を呼ぶ関数ポインタ
                        shot_calc(i);//i番目の弾幕を計算
                        shot[i].cnt++;
                }
        }
}

void (*shot_bullet[SHOT_KND_MAX])(int) ={
        shot_bullet_H000,
};

//n番目のショットを登録した敵と自機との角度を返す
double shotatan2(int n){
        return atan2(ch.y-enemy[shot[n].num].y,ch.x-enemy[shot[n].num].x);
}

//空いている弾を探す
int shot_search(int n){
        int i;
        for(i=0;i<SHOT_BULLET_MAX;i++){
                if(shot[n].bullet[i].flag==0){
                        return i;
                }
        }
        return -1;
}

void shot_calc(int n){
        int i,max=0;
        if(enemy[shot[n].num].flag!=1)//敵が倒されたら
                shot[n].flag=2;//それ以上ショットを登録しないフラグに変える
        for(i=0;i<SHOT_BULLET_MAX;i++){//n番目の弾幕データの弾を計算
                if(shot[n].bullet[i].flag>0){//その弾が登録されていたら
                        shot[n].bullet[i].x+=cos(shot[n].bullet[i].angle)*shot[n].bullet[i].spd;
                        shot[n].bullet[i].y+=sin(shot[n].bullet[i].angle)*shot[n].bullet[i].spd;
                        shot[n].bullet[i].cnt++;
                        if(shot[n].bullet[i].x<-50 || shot[n].bullet[i].x>FIELD_MAX_X+50 ||
                                shot[n].bullet[i].y<-50 || shot[n].bullet[i].y>FIELD_MAX_Y+50){//画面から外れたら
                                if(shot[n].bullet[i].till<shot[n].bullet[i].cnt)//最低消えない時間より長ければ
                                        shot[n].bullet[i].flag=0;//消す
                        }
                }
        }
        //現在表示中の弾が一つでもあるかどうか調べる
        for(i=0;i<SHOT_BULLET_MAX;i++)
                if(shot[n].bullet[i].flag>0)
                        return;
        if(enemy[shot[n].num].flag!=1){
                shot[n].flag=0;//終了
                enemy[shot[n].num].flag=0;
        }
}

↑ やっぱり こんな風に追加してもエラーが出るのですが どこら辺が間違ってるのでしょうか?

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月02日(土) 18:59
by softya(ソフト屋)
エラーを書いてもらわないと断片的な情報だけでは判断出来ないのでお願いします。

ヒント:今回の場合は変数定義の前に参照しているのが問題だと思います。
龍神録(C言語の文法)をちゃんと理解するために、エラーの原因についてよく考えてみましょう。

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月03日(日) 00:24
by Hanchan
Shot.cppで

error C2065: 'shot_bullet' : undeclared identifier
error C3861: 'shot_calc': identifier not found

graph.cppで

warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
error C3861: 'graph_bullet': identifier not found
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data

のようなエラーが出たのですが...

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月03日(日) 09:16
by softya(ソフト屋)
エラー原因の推測もお願いしたはずですが?

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月03日(日) 10:19
by へにっくす
Hanchan さんが書きました:Shot.cppで

error C2065: 'shot_bullet' : undeclared identifier
error C3861: 'shot_calc': identifier not found

graph.cppで

warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
error C3861: 'graph_bullet': identifier not found
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data

のようなエラーが出たのですが...
えーとすでに
softya(ソフト屋) さんが書きました:ヒント:今回の場合は変数定義の前に参照しているのが問題だと思います。
とレスされてますけど。
エラーのC2065、C3861に関しては上記の修正でなおります。自分で考えてください。
警告のC4244に関しては、doubleからfloatの変数に入れてるので、出ている警告です。floatをdoubleに変えるだけでいけるかな?

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月04日(月) 03:31
by Hanchan
softya(ソフト屋) さんが書きました:エラー原因の推測もお願いしたはずですが?
ごめんなさい ハーフな外人なので難しい日本語分からないw ま~別に無理に返信しなくてもおk~です。 迷惑かけてすみません....

後は自分で何とかやってみます.

アドバイスありがとうございます~ ~Peace~

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月04日(月) 09:33
by softya(ソフト屋)
Hanchan さんが書きました:
softya(ソフト屋) さんが書きました:エラー原因の推測もお願いしたはずですが?
ごめんなさい ハーフな外人なので難しい日本語分からないw ま~別に無理に返信しなくてもおk~です。 迷惑かけてすみません....

後は自分で何とかやってみます.

アドバイスありがとうございます~ ~Peace~
わからない言葉があれば聞いてください。
どこまでわかるかとか想像できませんので。
あと、解決したら解決!チェックをお願いします。

Re: 龍神録13章について質問~ ヘルプ~

Posted: 2012年6月07日(木) 01:20
by Hanchan
ソフト屋さん~ ありがとうございます~
ま~分からない言葉といっても難しい漢字とかですかねw ま~そこら辺はググって翻訳とかを調べてます。 
これは後でやってみます今は学校で忙しいのでw