まず第一に、私はプログラミングに堪能ではないので、寛容にしてください。 :)
「スタックオーバーフロー」というエラーの原因は何か不思議でした。私はVisual C++ 2010 Expressを使用しています。「スタックオーバーフロー」エラー。おそらくリストの中のポインタ
struct elem
{
BITMAP * colltile;
elem * next;
};
/*ここではいくつかのコードを置く*/
int collision_map (unsigned int poz_x, unsigned int poz_y)
{
elem * wsk = this->where_the_head_of_list_is;
int x,y;
x = poz_x%64; //coord x on tile (0-63px)
y = poz_y%64; //coord y on tile (0-63px)
poz_x /= 64; //preparing poz_x and poz_y to point on a tile on a grid
poz_y /= 64; //integers do not have to be floored
//for (int j=(poz_y*(this->size_x)+poz_x); j>0; j--) //normally works... but
for (int j=0; j<1000; j++) //this version is not
{
if ((!(wsk = wsk->next)) ||
((poz_x+1) > this->size_x) ||
((poz_y+1) > this->size_y))
{ //should check if there is no new pointer or just out of map
return -1;
}
}
return getpixel(wsk->colltile, x, y);
}
j
は、リストの長さの値に達したときに条件が動作しないのはなぜ?あなたが/しなければならないことができます
このコードはスタックオーバーフローを引き起こすだけです。 'getpixel'は' collision_map'をもう一度呼び出します。 –
あなたは答えを求めてgoogledしてこのサイトを見つけました... – CashCow
wskはelem型で、elemにはcalltileというメンバはありません。 – CashCow