本文整理汇总了C++中Render::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Render::init方法的具体用法?C++ Render::init怎么用?C++ Render::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Render
的用法示例。
在下文中一共展示了Render::init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char* args[] )
{
Render render;
render.init();
int i = 0;
while(render.running)
{
render.event();
render.draw();
if((render.checkNow)&&(i == render.speed))
{
render.check();
}
i++;
if(i > render.speed) i = 0;
}
//Quit SDL
SDL_Quit();
return 0;
}
示例2: main
int main()
{
TCPBridge bridge = TCPBridge("127.0.0.1", 4242);
Render render = Render(&bridge);
bridge.getItemInfos(&render);
/*
int size = env->GetArrayLength(stringArrays);
for (int i = 0; i < size; ++i)
{
jstring string = (jstring)env->GetObjectArrayElement(stringArrays, i);
const char* myarray = env->GetStringUTFChars(string, 0);
env->ReleaseStringUTFChars(string, myarray);
env->DeleteLocalRef(string);
}
*/
render.init();
return 0;
}
示例3: main
int main() {
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
// direction for player auto-moving
int direction = ObjectWay::undefined;
// init logic configuration
Config config;
initConfig(&config);
// init render object
Render* render = new Render(config.screen_width, config.screen_height);
if(!render->init()) {
delete render;
return EXIT_FAILURE;
}
// init logic object
Logic* logic = new Logic();
logic->flush(config);
logic->init(config);
sf::Clock clock;
sf::Event event;
while (render->getWindow()->isOpen()) {
sf::Int32 msec = clock.getElapsedTime().asMilliseconds();
logic->setTime(msec);
// check in loop for events
while(render->getWindow()->pollEvent(event)) {
if(event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
render->close();
if(event.type == sf::Event::KeyReleased)
if (event.key.code == sf::Keyboard::Right || event.key.code == sf::Keyboard::Left)
direction = ObjectWay::undefined;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
logic->spawnRocket(); // launch rocket
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
direction = ObjectWay::right;
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
direction = ObjectWay::left;
if(direction != ObjectWay::undefined) {
ObjectPosition pos = logic->getPlayer().position;
if(direction == ObjectWay::right)
pos.x += config.speed_player;
else
pos.x -= config.speed_player;
if(pos.x > 0 && pos.x < (float)config.screen_width-25.0f)
logic->setPlayerPosition(pos);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return) && logic->getLifes() <= 0) {
logic->clearObjects();
logic->flush(config);
}
}
// clear screen
render->clear();
if(logic->getLifes() > 0) {
if(logic->getEnemiesCount() == 0) {
// set new round and respawn enemies
logic->setNewRound();
logic->spawnEnemies(0.0f, 40.f, 10, 3);
}
logic->spawnBomb(); // fire bomb randomly
logic->moveEnemies(); // move enemies
logic->moveRockets(); // move rockets
logic->moveBombs(); // move bombs
logic->collideEnemies(); // collide with enemies
logic->collideRockets(); // collide with rockets
logic->collideBombs(); // collide with bombs
// draw logic objects
drawObjects(logic, render);
} else {
// logic is over, draw score
render->drawFarewell(logic->getScore());
logic->clearObjects();
}
// render screen
render->display();
}
delete logic;
delete render;
return EXIT_SUCCESS;
}
示例4: main
int main(int argc, char** argv)
{
gEngine.init(&argc, argv, "display OBJ model", "off/model.off");
gEngine.start();
return 0;
}