English 中文(简体)
• 在参与者死亡时转用文字(OpenGL + C++)
原标题:Trying to switch a texture when player dies (OpenGL + C++)

我制造了2D游戏,当参与者死亡时,我想要文本一转向另一种(显示爆炸)时,我也希望游戏暂停第二或二次,以便用户能够看到文本已经改变。

我的案文是正确的,因为我可以把它应用到一种形状中,我可以看到,如果我说它与参与者的原始文本相去。

我认为,这必须只是一个框架,然后消失或像那个时候。 这里是法典。

void Player::die(){
if(Player::lives > 0){

    glPushMatrix();
    glEnable(GL_TEXTURE_2D);    
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBindTexture(GL_TEXTURE_2D, explosionTex);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

    glTranslatef(200, 200, 0.0);
    glRotatef(heading, 0,0,1);
    glColor3f(1.0,0.0,0.0);
        glBegin(GL_POLYGON);
            glTexCoord2f(0.0, 1.0); glVertex2f(-40,40);
            glTexCoord2f(0.0, 0.0); glVertex2f(-40,-40);
            glTexCoord2f(1.0, 0.0); glVertex2f(40,-40);
            glTexCoord2f(1.0, 1.0); glVertex2f(40,40);
        glEnd();


    glDisable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);
    glPopMatrix();

    Sleep ( 1000 );

    *xscroll = 0;
    *yscroll = 0;
    Player::lives--;
    Player::XPos = 0;
    Player::YPos = 0;
    Player::heading = 0;
    Player::speed = 0;
}
}

我怎么能让它改变文字,显示,然后睡觉?

最佳回答

如果你想看到任何事情的话,你就必须向睡觉。

更一般地说,将睡觉改为“ExplodeStart”,由你向目前时代的InMilliseconds(现时)介绍。 然后,每次通过你进行住宿检查,如果是当日收入——出口价值;1000。 如果是的话,则再次向您的经常参与者转稿。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签