如何在 SDL 中实现转义序列

发布于 2024-10-09 11:43:17 字数 1325 浏览 0 评论 0 原文

我正在尝试在 SDL 中使用 STL 库。但它给了我错误
“未声明的标识符” 有什么办法可以使用 "\n" 甚至 cout< 将鼠标光标放置在屏幕上所需位置的函数 SDL_WarpMouse 可以帮助我解决这个问题吗?因为我想在下一个行序列上放置一个图块。
我希望你能明白这个问题。不过,这是一个非常模糊和混乱的问题(对此感到抱歉)。

编辑:

void putMap(SDL_Surface* tile, SDL_Surface* screen)
{
    for(int y = 0; y < 21; y++)
    {
        for(int x = 0; x < 60; x++)
        {
            if(maze[x][y] != '#')
            {
                apply_surface( x*10 , y*10 , tile, screen);
            }
        }
        cout<<endl;
    }
}

c:\documents and settings\administrator\my Documents\visual studio 2008\projects\craptest\craptest\main.cpp(605):错误C2065:'cout':未声明的标识符

c:\documents and settings\administrator\my Documents\visual studio 2008\projects\craptest\craptest\main.cpp(605):错误C2065:'endl':未声明的标识符

是我的 apply_surface 函数。

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
    //Make a temporary rectangle to hold the offsets
    SDL_Rect offset;

    //Give the offsets to the rectangle
    offset.x = x;
    offset.y = y;

    //Blit the surface
    SDL_BlitSurface( source, NULL, destination, &offset );
}

I'm trying to use the STL library inside the SDL. but it gives me the error
"undeclared identifier"
Is there any way I can use "\n"or even cout<<endl;
Can the function SDL_WarpMousewhich places the mouse cursor on a desired location on screen help me with this. Because I want to put a tile on the next line sequence.
I hope you get the Question. Its very vague and messed up question though (sorry for that).

EDIT:

void putMap(SDL_Surface* tile, SDL_Surface* screen)
{
    for(int y = 0; y < 21; y++)
    {
        for(int x = 0; x < 60; x++)
        {
            if(maze[x][y] != '#')
            {
                apply_surface( x*10 , y*10 , tile, screen);
            }
        }
        cout<<endl;
    }
}

c:\documents and settings\administrator\my documents\visual studio 2008\projects\craptest\craptest\main.cpp(605) : error C2065: 'cout' : undeclared identifier

c:\documents and settings\administrator\my documents\visual studio 2008\projects\craptest\craptest\main.cpp(605) : error C2065: 'endl' : undeclared identifier

This is my apply_surface function.

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
    //Make a temporary rectangle to hold the offsets
    SDL_Rect offset;

    //Give the offsets to the rectangle
    offset.x = x;
    offset.y = y;

    //Blit the surface
    SDL_BlitSurface( source, NULL, destination, &offset );
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不及他 2024-10-16 11:43:17

coutendl 位于 std 命名空间中,并且必须经过限定:

std::cout << std::endl;

或者,您可以使用 using 声明:

using std::cout;
using std::endl;

cout << endl;

cout and endl are in the std namespace and must be qualified:

std::cout << std::endl;

Alternatively, you can use a using declaration:

using std::cout;
using std::endl;

cout << endl;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文