本文整理汇总了C++中TextInput::drawText方法的典型用法代码示例。如果您正苦于以下问题:C++ TextInput::drawText方法的具体用法?C++ TextInput::drawText怎么用?C++ TextInput::drawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextInput
的用法示例。
在下文中一共展示了TextInput::drawText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** args)
{
srand(time(0));
SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();
SDL_WM_SetCaption(W_TITLE, 0);
SDL_Surface* screen = SDL_SetVideoMode(W_WIDTH, W_HEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_Surface* bground = IMG_Load("bground.bmp");
//Create new Text objects.
Text* scoreTxt = new Text("Score: 0", 0, 0, {0, 255, 0}, 20);
Text* livesTxt = new Text("Lives: 24", 520, 0, {0, 255, 0}, 20);
Text* bulletTxt = new Text("Bullets: 199", 160, 0, {0, 255, 0}, 20);
Text* rocketTxt = new Text("Rockets: 100", 320, 0, {0, 255, 0}, 20);
Text* gameTxt = new Text("Game Over", 150, 220, {255, 0, 0}, 60);
Text* msgTxt = new Text("Enter Name: ", 130, 120, {255, 0, 0}, 22);
//Create new SpaceShip object.
SpaceShip* objShip = new SpaceShip("rocket.bmp", SHIP_X, SHIP_Y);
objShip->setColorKey(0, 0, 0);
//Create new Meteor objects.
meteorVec.push_back(new Meteor("meteor1.bmp", 50, rand()%300));
meteorVec.push_back(new Meteor("meteor2.bmp", 100, rand()%300));
meteorVec.push_back(new Meteor("meteor3.bmp", 150, rand()%300));
meteorVec.push_back(new Meteor("meteor1.bmp", 200, rand()%300));
meteorVec.push_back(new Meteor("meteor2.bmp", 250, rand()%300));
meteorVec.push_back(new Meteor("meteor3.bmp", 300, rand()%300));
//Create new Bullet objects.
for(int i = 0; i < 200; i++) {
bulletVec.push_back(new Bullet("bullet.bmp"));
}
for(int i = 0; i < 100; i++) {
rocketVec.push_back(new Bullet("rckt.bmp"));
}
for(int i = 0; i < 100; i++) {
rocketVec2.push_back(new Bullet("rckt.bmp"));
}
Intro(screen);
//Start drawing the game.
SDL_BlitSurface(bground, NULL, screen, NULL);
for(unsigned i = 0; i < meteorVec.size(); i++) {
meteorVec[i]->setColorKey(255, 255, 255);
meteorVec[i]->setSpeed((rand()%8 - 4), (1 + rand()%5));
meteorVec[i]->drawObject(screen, bground);
}
// bonusVec.push_back(new Meteor("rBonus.bmp", 350, rand()%300));
// for(unsigned i = 0; i < bonusVec.size(); i++) {
// bonusVec[i]->setColorKey(255, 0, 255);
// bonusVec[i]->setSpeed((rand()%8 - 4), (1 + rand()%5));
// bonusVec[i]->drawObject(screen, bground);
// }
// Text* tt = new Text("TIME: 0", 100, 190, {255, 0, 0}, 22);
//Start timer for bonuses
tb.start();
objShip->drawObject(screen, bground);
scoreTxt->drawText(screen);
// tt->drawText(screen);
bulletTxt->drawText(screen);
//rocketTxt->drawText(screen);
livesTxt->drawText(screen);
SDL_UpdateRect(screen, 0, 0, 0, 0);
bool keysHold[323] = {false};
SDL_Event event;
//Start the game.
while(true) {
if(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT) {
break;
}
if(objShip->isColision(bonusVec,screen)){
bonus=true;
rocketTxt->drawText(screen);
}
if(tb.getTicks()/1000 >= 10){
tb.stop();
bonusState=true;
tb.start();
}
else if(tb.getTicks()/1000 < 10){bonusState=false;}
if(bonusState==true && bonus==false){
bonusVec.push_back(new Meteor("rBonus.bmp", 350, rand()%300));
for(unsigned i = 0; i < bonusVec.size(); i++) {
bonusVec[i]->setColorKey(255, 0, 255);
bonusVec[i]->setSpeed((rand()%8 - 4), (1 + rand()%5));
bonusVec[i]->drawObject(screen, bground);
}
//.........这里部分代码省略.........