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;
}
Example #2
0
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; 
}
Example #3
0
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;
}
Example #4
0
int main(int argc, char** argv)
{
	gEngine.init(&argc, argv, "display OBJ model", "off/model.off");
	gEngine.start();
	return 0;
}