创建星环(星图)

Creating a Loop of Stars (Star Map)

本文关键字:星图 创建      更新时间:2023-10-16

嘿,所以我正在尝试从一个文件中读取,并基本上创建一个很酷的星图。我完全是个新手,这是我第一次玩SFML。我正在CLion上工作。

我已经使用了调试器,可以看到所有东西都被正确地放置在它的位置,但当我运行程序时,窗口最终会冻结,没有绘制任何东西。我不确定是我的循环出了问题,还是有其他东西在起作用。我认为我不需要使用向量,因为Vector2f似乎已经足够了。。。非常感谢您的帮助!!!

CircleShape star;
star.setRadius(2);
while(!fileIn.eof()){
fileIn >> xPixel >> yPixel >> brightStar;
star.setPosition( Vector2f(xPixel, yPixel) );
window.draw(star);
}
fileIn.close();

Draw Window只是有死亡之轮,并且"没有反应">

哦,现在我把这个放在…中

CircleShape star;
star.setRadius(2);
while(!fileIn.eof()){
fileIn >> xPixel >> yPixel >> brightStar;
star.setPosition( Vector2f(xPixel, yPixel) );
window.draw(star);
CircleShape star;
star.setRadius(2);
}
fileIn.close();

星图显示了一秒钟,然后消失了

明白了耶:

CircleShape star;
star.setRadius(2);
while(!fileIn.eof()){
{
fileIn >> xPixel >> yPixel >> brightStar;
star.setPosition( Vector2f(xPixel, yPixel) );
window.draw(star);
CircleShape star;
star.setRadius(2);}
window.display();
}
fileIn.close();