本文整理汇总了C++中CIndieLib::end方法的典型用法代码示例。如果您正苦于以下问题:C++ CIndieLib::end方法的具体用法?C++ CIndieLib::end怎么用?C++ CIndieLib::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIndieLib
的用法示例。
在下文中一共展示了CIndieLib::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IndieLib
/*
==================
Main
==================
*/
int IndieLib()
{
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
// ----- Main Loop -----
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input Update ----
mI->_input->update();
// -------- Render -------
mI->_render->clearViewPort(60, 60, 60);
mI->_render->beginScene();
mI->_render->endScene();
//mI->_render->showFpsInWindowTitle();
}
// ----- Indielib End -----
mI->end();
return 0;
}
示例2: IndieLib
/*
==================
Main
==================
*/
int IndieLib()
{
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
// ----- Spriter animation loading -----
if (!mI->_spriterManager->addSpriterFile(NULL,"Example.SCML")) return 0;
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input update ----
mI->_input->update();
// ----- Text -----
// strcpy(mText, "Press space to see the grid in action. This is really cool, isn't it?");
// mTextSmallWhite->setText(mText);
// ----- Input ----
// for future use ...
if (mI->_input->onKeyPress(IND_SPACE))
{
}
// ----- Updating entities attributes -----
// ----- Render -----
mI->_render->beginScene();
mI->_render->clearViewPort(0, 0, 0);
// mI->_entity2dManager->renderEntities2d();
mI->_render->endScene();
}
// ----- Free -----
mI->end();
return 0;
}
示例3: IndieLib
/*
==================
Main
==================
*/
int IndieLib()
{
//Sets the working path as the 'exe' directory. All resource paths are relative to this directory
if (!WorkingPathSetup::setWorkingPathFromExe(NULL)) {
std::cout<<"\nUnable to Set the working path !";
}
SoundManager * mSm = SoundManager::instance();
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
Game * mGame = new Game();
bool quit = false;
while (!quit && !mI->_input->quit())
{
// ----- Input update ----
Sleep(10); // Take it easy, computer
mI->_input->update();
quit = mGame->run();
// ----- Render -----
mI->_render->beginScene();
mI->_render->clearViewPort(0, 0, 0);
mI->_entity2dManager->renderEntities2d();
//mI->_entity2dManager->renderCollisionAreas(255, 0, 0, 255);
mI->_render->endScene();
}
// ----- Free -----
mSm->shutdown();
mI->end();
return 0;
}
示例4: IndieLib
int IndieLib() {
#ifdef PLATFORM_WIN32
//memory leaks for win32 creation
FINDMEMLEAK(-1); //When you find a mem. leak, refer to the number displayed in the console and put it here to break when it is created
#endif
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
//Sets the working path as the 'exe' directory. All resource paths are relative to this directory
if (!WorkingPathSetup::setWorkingPathFromExe(NULL)) {
std::cout<<"\nUnable to Set the working path !";
}
// ----- Fcn pointer tests initialization -----
initTests();
testsvectoriterator itr;
//LOOP - Prepare Permanent tests
for (itr = g_permanenttests.begin(); itr != g_permanenttests.end(); ++itr) {
(*itr)->prepareTests();
}//LOOP END
//LOOP - Prepare Temporary tests
for (itr = g_tests.begin(); itr != g_tests.end(); ++itr) {
(*itr)->prepareTests();
}//LOOP END
// ----- Main Loop -----
g_mainTimer.start();
double ticks = g_mainTimer.getTicks();
double pastticks = g_mainTimer.getTicks();
testsvectoriterator currentTest = g_tests.begin();
(*currentTest)->setActive(true);
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit()) {
// ----- Input Update ----
mI->_input->update();
// -------- Render -------
mI->_render->clearViewPort(0,0,0);
mI->_render->beginScene();
//LOOP - Permanent Tests
for (itr = g_permanenttests.begin(); itr != g_permanenttests.end(); ++itr) {
(*itr)->performTests(static_cast<float>(ticks - pastticks));
}//LOOP END
//LOOP - Tests
for (itr = g_tests.begin(); itr != g_tests.end(); ++itr) {
(*itr)->performTests(static_cast<float>(ticks - pastticks));
}//LOOP END
mI->_entity2dManager->renderEntities2d(); //Entities rendering
mI->_entity2dManager->renderGridAreas(g_gridcolorR,g_gridcolorG,g_gridcolorB,g_gridcolorA); //Grid areas rendering (on top of it) can be disabled per entity
mI->_entity2dManager->renderCollisionAreas(g_collisionColorR,g_collisionColorG,g_collisionColorB,g_collisionColorA); //Collision areas rendering (on top of it) can be disabled per entity
mI->_render->endScene();
//mI->_render->showFpsInWindowTitle();
pastticks = ticks;
ticks += g_mainTimer.getTicks();
//Perform next test setup (if needed) Arrow keys change current temporary test using
if (mI->_input->onKeyPress(IND_KEYRIGHT) && !mI->_input->onKeyPress(IND_KEYLEFT)){
//Current test is not active
(*currentTest)->setActive(false);
currentTest++;
//IF - Check limits
if(currentTest == g_tests.end()){
currentTest = g_tests.begin();
}
//Next test is active
(*currentTest)->setActive(true);
} else if (mI->_input->onKeyPress(IND_KEYLEFT) && !mI->_input->onKeyPress(IND_KEYRIGHT)){
//Current test is not active
(*currentTest)->setActive(false);
//Decrement (taking into account limits)
if(currentTest == g_tests.begin()){
currentTest = g_tests.end();
}
currentTest--;
//Next test is active
(*currentTest)->setActive(true);
}
}
// ----- Indielib End -----
releaseTests();
mI->end();
return 0;
}
示例5: IndieLib
//.........这里部分代码省略.........
mI->_entity2dManager->add(mBeetle);
mBeetle->setSurface(mSurfaceBeetle);
mBeetle->setHotSpot(0.5f, 0.5f);
mBeetle->setPosition(150, 150, 2);
// Octopus
IND_Entity2d *mOctopus = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mOctopus);
mOctopus->setSurface(mSurfaceOctopus);
mOctopus->setHotSpot(0.5f, 0.5f);
mOctopus->setPosition(450, 150, 2);
// But
IND_Entity2d *mBug = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mBug);
mBug->setSurface(mSurfaceBug);
mBug->setHotSpot(0.5f, 0.5f);
mBug->setPosition(700, 150, 2);
// ----- Camera ------
// Camera for the viewport 1
IND_Camera2d *mCamera1 = new IND_Camera2d(mI->_window->getWidth () / 2, mI->_window->getHeight() / 4);
// Camera for the viewport 2
IND_Camera2d *mCamera2 = new IND_Camera2d(mI->_window->getWidth () / 2, mI->_window->getHeight() / 4);
// ----- Main Loop -----
float mZoom = 1.0f;
float mCameraAngle = 0;
float mBugAngle = 0;
char mText [2048];
mText [0] = 0;
float mSpeedRotation = 50;
float mDelta;
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input update ----
mI->_input->update();
// ----- Text -----
strcpy (mText, "Use mouse wheel for zooming in/out\n");
strcat (mText, "Use mouse buttons for rotating the camera");
mTextSmallWhite->setText(mText);
// ----- Input ----
mDelta = mI->_render->getFrameTime() / 1000.0f;
// Camera Zoom in / out
if (mI->_input->isMouseScroll()) {
mZoom += mI->_input->getMouseScrollY() * K_ZOOMSPEED;
}
// Camera angle
if (mI->_input->isMouseButtonPressed(IND_MBUTTON_LEFT)) mCameraAngle += mSpeedRotation * mDelta;
if (mI->_input->isMouseButtonPressed(IND_MBUTTON_RIGHT)) mCameraAngle -= mSpeedRotation * mDelta;
// ----- Updating entities attributes -----
// Rotation of the beetle and bug
mBugAngle += mSpeedRotation * mDelta;
mBeetle->setAngleXYZ(0, 0, mBugAngle);
mBeetle->setAngleXYZ(0, 0, mBugAngle);
mBug->setAngleXYZ(0, 0, -mBugAngle);
mBug->setAngleXYZ(0, 0, -mBugAngle);
// Zooming and rotating the camera
if (mZoom < 0.1f) mZoom = 0.1f;
mCamera2->setAngle(mCameraAngle);
mCamera2->setZoom(mZoom);
// ----- Render -----
// ----- Upper viewport -----
mI->_render->beginScene();
mI->_render->clearViewPort(60, 60, 60);
mI->_render->setViewPort2d(0, 0, mI->_window->getWidth(), mI->_window->getHeight() / 2);
mI->_render->setCamera2d(mCamera1);
mI->_entity2dManager->renderEntities2d();
// ----- Lower viewport -----
mI->_render->setViewPort2d(0, mI->_window->getHeight() / 2, mI->_window->getWidth(), mI->_window->getHeight() / 2);
mI->_render->setCamera2d(mCamera2);
mI->_entity2dManager->renderEntities2d();
mI->_render->endScene();
}
// ----- Free -----
mI->end();
return 0;
}
示例6: IndieLib
int IndieLib() // main
{
char TempText[30];
// ----- Sound Library --------------
// ----- new engine instance ------------
CIndieLib *mI = CIndieLib::instance(); // engine
if (!mI->init()) return 0;
GameControll controller = GameControll(mI); // createing a game controller and initialize
controller.sceneGenerator();
//<------ DELTA TIME ------>
double *delta = new double(0.1);
double *deltaAverage = new double(0.001);
double *mDeltaSum = new double(0.001);
int count = 0;
// time
int gameTime = 125;
// Create and start the timer;
IND_Timer *mTimer = new IND_Timer();
mTimer->start();
bool play = false;
float animationDelay = 30; // 30 fps animation refresh
// ----- Main Loop -----
while (!mI->_input->onKeyPress(IND_F12) && !mI->_input->quit() && !controller.isExitSelected())
{
gameTime = (int)(mTimer->getTicks() / 1000.0f); //time in seconds
// ------ Average delta time ---------
*delta = mI->_render->getFrameTime() / 1000.0f;
count++;
*mDeltaSum += *delta;
if (count == 100){
count = 0;
*deltaAverage = *mDeltaSum / 100;
*mDeltaSum = 0;
}
// ----- Input Update ----
mI->_input->update();
// ------ Game controller update ---------------
controller.Update(gameTime, deltaAverage);
// ---- Update rarely -----
// creating delay for animation
//animationDelay -= 1000 * (*deltaAverage);
animationDelay -= mI->_render->getFrameTime();
if (animationDelay < 0)
{
animationDelay = 30;
controller.AnimationsUpdate();
}
// -------- Render -------
mI->_render->clearViewPort(0, 0, 60);
mI->_render->beginScene();
mI->_entity2dManager->renderEntities2d();
// mI->_entity2dManager->renderCollisionAreas(255, 0, 0, 255); // for tests
mI->_render->endScene();
mI->_render->showFpsInWindowTitle(); //FPS
//mI->_entity2dManager->renderGridAreas(255, 255, 0, 255);
}
// ----- Indielib End -----
mI->end();
return 0;
}
示例7: IndieLib
/*
==================
Main
==================
*/
int IndieLib()
{
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
// ----- Map loading -----
// TODO: map loading goes here...
IND_TmxMap *map = new IND_TmxMap();
if (!mI->_tmxMapManager->add(map, "example.tmx")) return 0;
// Get a tileset.
//const Tmx::Tileset *tileset = map->getTmxMapHandle()->GetTileset(0);
// Print tileset information.
printf("Name: %s\n", map->getTmxMapHandle()->GetTileset(0)->GetName().c_str());
printf("Margin: %d\n", map->getTmxMapHandle()->GetTileset(0)->GetMargin());
printf("Spacing: %d\n", map->getTmxMapHandle()->GetTileset(0)->GetSpacing());
printf("Image Width: %d\n", map->getTmxMapHandle()->GetTileset(0)->GetImage()->GetWidth());
printf("Image Height: %d\n", map->getTmxMapHandle()->GetTileset(0)->GetImage()->GetHeight());
printf("Image Source: %s\n", map->getTmxMapHandle()->GetTileset(0)->GetImage()->GetSource().c_str());
printf("Transparent Color (hex): %s\n", map->getTmxMapHandle()->GetTileset(0)->GetImage()->GetTransparentColor().c_str());
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input update ----
mI->_input->update();
// ----- Text -----
// strcpy(mText, "Press space to see the grid in action. This is really cool, isn't it?");
// mTextSmallWhite->setText(mText);
// ----- Input ----
// Show / Hide the grid pressing "space"
if (mI->_input->onKeyPress(IND_SPACE))
{
// if (mShowGrid){
// }else{
// }
}
// ----- Updating entities attributes -----
// ----- Render -----
mI->_render->beginScene();
mI->_render->clearViewPort(0, 0, 0);
// mI->_entity2dManager->renderEntities2d();
// if (mShowGrid) mI->_entity2dManager->renderGridAreas(0, 0, 0, 255);
mI->_render->endScene();
}
// ----- Free -----
mI->end();
return 0;
}
示例8: IndieLib
int IndieLib()
{
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
// ----- Get Window Dimensions
int winWidth = mI->_window->getWidth();
int winHeight = mI->_window->getHeight();
srand(static_cast<unsigned int>(time(0)));
// ----- Surface loading -----
IND_Surface *mSurfaceBack = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mSurfaceBack, "../SpaceGame/resources/Backgrounds/18.jpg", IND_OPAQUE, IND_32)) return 0;
/*IND_Animation* mTestA = IND_Animation::newAnimation();
if (!mI->_animationManager->addToSurface(mTestA, "resources/animations/dust.xml", IND_ALPHA, IND_32, 255, 0, 255)) return 0;
mTestA->getActualFramePos(0);*/
// Loading 2D Entities
// Background
IND_Entity2d* mBack = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mBack);
mBack->setSurface(mSurfaceBack);
mBack->setScale((float)winWidth / mSurfaceBack->getWidth(), (float)winHeight / mSurfaceBack->getHeight());
Controls* controls = new Controls();
controls->loadSettings();
ErrorHandler* error = new ErrorHandler();
error->initialize(mI);
Hud* mHud = new Hud();
mHud->createHud(mI);
Menu* mMenu = new Menu();
mMenu->createMenu(mI);
Save* quickSave = new Save();
if (!SoundEngine::initialize())
{
error->writeError(200, 100, "Error", "SoundEngine");
}
vector<Planet*> mPlanets;
Ship* mShip = NULL;
bool loadSave = false;
float mDelta = 0.0f;
IND_Timer* mTimer = new IND_Timer;
mTimer->start();
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit() && !mMenu->isExit())
{
// get delta time
mDelta = mI->_render->getFrameTime() / 1000.0f;
if (mI->_input->isKeyPressed(controls->getMenu()))
{
mMenu->show();
SoundEngine::getSoundEngine()->setAllSoundsPaused(true);
}
if (!mMenu->isHidden())
{
mMenu->updateMenu(mHud, quickSave, mPlanets, mShip);
loadSave = mHud->getLoadingText()->isShow();
}
else
{
if (loadSave)
{
mDelta = 0.0;
loadSave = false;
SoundEngine::getSoundEngine()->setAllSoundsPaused(true);
mHud->getLoadingText()->setShow(false);
quickSave->loadSave(mI, mShip, mPlanets);
mHud->showHud();
}
if (mShip != NULL)
{
if (mI->_input->onKeyPress(controls->getQuickSave()))
{
quickSave->makeSave(mI, mShip, mPlanets);
}
mHud->updateHud(mShip);
if (mI->_input->onKeyPress(controls->getQuickLoad()))
{
deleteObjects(mHud, mShip, mPlanets);
loadSave = true;
}
//.........这里部分代码省略.........
示例9: IndieLib
int IndieLib()
{
//Sets the working path as the 'exe' directory. All resource paths are relative to this directory
if (!WorkingPathSetup::setWorkingPathFromExe(NULL)) {
std::cout<<"\nUnable to Set the working path !";
}
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
// ----- Surface loading -----
// Font
IND_Font *mFontBig = new IND_Font();
if (!mI->_fontManager->add(mFontBig, "../../resources/font_big.png", "../../resources/font_big.xml", IND_ALPHA, IND_32)) return 0;
// Loading draco
IND_Surface *mSurfaceDraco = new IND_Surface();
if (!mI->_surfaceManager->add(mSurfaceDraco, "../../resources/draco.png", IND_ALPHA, IND_32)) return 0;
// ----- Entities -----
// Title text
IND_Entity2d *mTextTime = new IND_Entity2d();
mI->_entity2dManager->add(mTextTime); // Entity adding
mTextTime->setFont(mFontBig); // Set the font into the entity
// Creating 2d entity for the draco
IND_Entity2d *mDraco = new IND_Entity2d();
mI->_entity2dManager->add(mDraco); // Entity adding
mDraco->setSurface(mSurfaceDraco); // Set the surface into the entity
mDraco->setHotSpot(0.5f, 0.5f);
mDraco->setPosition(400, 330, 1);
// ----- Changing the attributes of the 2d entities -----
// Text showing the time
mTextTime->setLineSpacing(18);
mTextTime->setCharSpacing(-8);
mTextTime->setPosition(280, 20, 1);
mTextTime->setAlign(IND_LEFT);
// ----- Main Loop -----
char mTimeString[128];
mTimeString[0] = 0;
char mTempTime[1024];
// Create and start the timer;
IND_Timer *mTimer = new IND_Timer();
mTimer->start();
int mX = 0;
int mSecond;
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input update ----
mI->_input->update();
// ----- Input ----
// Pause / Restart time when pressing space
if (mI->_input->onKeyPress(IND_SPACE))
{
if (mTimer->isPaused()){
mTimer->unpause();
}
else{
mTimer->pause();
}
}
// ----- Updating entities attributes -----
mSecond = (int) (mTimer->getTicks() / 1000.0f);
// Show the time passing in seconds
mI->_math->itoa(mSecond,mTempTime);
strcpy (mTimeString, "Seconds: ");
strcat (mTimeString, mTempTime);
mTextTime->setText(mTimeString);
// Update Draco position each second
mDraco->setAngleXYZ(0, 0, mSecond + 10);
// ----- Render -----
mI->_render->beginScene();
mI->_render->clearViewPort(60, 60, 60);
mI->_entity2dManager->renderEntities2d();
mI->_render->endScene();
}
// ----- Free -----
//.........这里部分代码省略.........
示例10: IndieLib
/*
==================
Main
==================
*/
int IndieLib()
{
// ----- IndieLib intialization -----
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
// ----- Set the primitives into 2d entities -----
// Pixel
IND_Entity2d *mPixel = new IND_Entity2d();
mI->_entity2dManager->add(mPixel);
mPixel->setPrimitive2d(IND_PIXEL);
mPixel->setPosition(200, 75, 0);
mPixel->setTint(255, 255, 255);
// Regular poly
IND_Entity2d *mRegularPoly = new IND_Entity2d();
mI->_entity2dManager->add(mRegularPoly);
mRegularPoly->setPrimitive2d(IND_REGULAR_POLY);
mRegularPoly->setPosition(200, 75, 0);
mRegularPoly->setNumSides(5);
mRegularPoly->setRadius(50);
mRegularPoly->setTint(255, 0, 0);
// Line
IND_Entity2d *mLine = new IND_Entity2d();
mI->_entity2dManager->add(mLine);
mLine->setPrimitive2d (IND_LINE);
mLine->setLine(100, 100, 50, 50);
mLine->setTint(0, 255, 0);
// Rectangle
IND_Entity2d *mRectangle = new IND_Entity2d();
mI->_entity2dManager->add(mRectangle);
mRectangle->setPrimitive2d(IND_RECTANGLE);
mRectangle->setRectangle(350, 50, 400, 100);
mRectangle->setTint(0, 0, 255);
// Filled rectangle
IND_Entity2d *mFillRectangle = new IND_Entity2d();
mI->_entity2dManager->add(mFillRectangle);
mFillRectangle->setPrimitive2d(IND_FILL_RECTANGLE);
mFillRectangle->setRectangle(550, 40, 650, 110);
mFillRectangle->setTint(255, 0, 0);
mFillRectangle->setTransparency(50);
// 2d Poly
IND_Entity2d *mPoly2d = new IND_Entity2d();
mI->_entity2dManager->add(mPoly2d);
mPoly2d->setPrimitive2d(IND_POLY2D);
IND_Point mVertPoly2 [] = { {440, 200}, {480, 100}, {450, 10}, {470, 220} }; // Poly points
mPoly2d->setPolyPoints(mVertPoly2);
mPoly2d->setNumLines(3); // Number of edges - 1
mPoly2d->setTint(255, 128, 255);
// ----- Main Loop -----
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input update -----
mI->_input->update();
// ----- Render -----
mI->_render->clearViewPort (0, 0, 0);
mI->_render->beginScene();
// Direct bliting of primitives
for (int i = 0; i < 400; i += 5)
{
mI->_render->blitLine(70, 150, i * 2, 500, i, 255 -i, 255, 255);
mI->_render->blitRegularPoly(600, 600, i, 70, 0, 255 - i, i, i*4, 255);
}
mI->_entity2dManager->renderEntities2d();
mI->_render->endScene();
}
// ----- Free -----
mI->end();
return 0;
}
示例11: IndieLib
//.........这里部分代码省略.........
// ----- Loading of the original image and making 4 duplicates -----
IND_Image *mImageBugOriginal = IND_Image::newImage();
if (!mI->_imageManager->add(mImageBugOriginal, "../../resources/Enemy Bug.png")) return 0;
IND_Image *mImageBugGaussian = IND_Image::newImage();
if (!mI->_imageManager->clone(mImageBugGaussian, mImageBugOriginal)) return 0;
IND_Image *mImageBugPixelize = IND_Image::newImage();
if (!mI->_imageManager->clone(mImageBugPixelize, mImageBugOriginal)) return 0;
IND_Image *mImageBugContrast = IND_Image::newImage();
if (!mI->_imageManager->clone(mImageBugContrast, mImageBugOriginal)) return 0;
// ----- Applying filters -----
mImageBugGaussian->gaussianBlur(5);
mImageBugPixelize->pixelize(5);
mImageBugContrast->contrast(60);
// ----- Surface creation -----
// Loading Background
IND_Surface *mSurfaceBack = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mSurfaceBack, "../../resources/blue_background.jpg", IND_OPAQUE, IND_32)) return 0;
// Creating the "Original Bug" surface from the IND_Image
IND_Surface *mOriginalSurface = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mOriginalSurface, mImageBugOriginal, IND_ALPHA, IND_32)) return 0;
// Creating the "Gaussian bug" surface from the IND_Image
IND_Surface *mGaussianSurface = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mGaussianSurface, mImageBugGaussian, IND_ALPHA, IND_32)) return 0;
// Creating the "Pixelize bug" surface from the IND_Image
IND_Surface *mPixelizeSurface = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mPixelizeSurface, mImageBugPixelize, IND_ALPHA, IND_32)) return 0;
// Creating the "Contrast bug" surface from the IND_Image
IND_Surface *mContrastSurface = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mContrastSurface, mImageBugContrast, IND_ALPHA, IND_32)) return 0;
// ----- Deleting of images -----
mI->_imageManager->remove(mImageBugOriginal);
mI->_imageManager->remove(mImageBugGaussian);
mI->_imageManager->remove(mImageBugPixelize);
mI->_imageManager->remove(mImageBugContrast);
// ----- Set the surfaces into the 2d entities -----
// Creating 2d entity for the background
IND_Entity2d *mBack = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mBack); // Entity adding
mBack->setSurface(mSurfaceBack); // Set the surface into the entity
// Creating 2d entity for the "Original bug"
IND_Entity2d *mOriginal = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mOriginal); // Entity adding
mOriginal->setSurface(mOriginalSurface); // Set the surface into the entity
// Creating 2d entity for the "Gaussian bug"
IND_Entity2d *mGaussian = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mGaussian); // Entity adding
mGaussian->setSurface(mGaussianSurface); // Set the surface into the entity
// Creating 2d entity for the "pixelize bug"
IND_Entity2d *mPixelize = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mPixelize); // Entity adding
mPixelize->setSurface(mPixelizeSurface); // Set the surface into the entity
// Creating 2d entity for the "Contrast bug"
IND_Entity2d *mContrast = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mContrast); // Entity adding
mContrast->setSurface(mContrastSurface); // Set the surface into the entity
// ----- Changing the attributes of the 2d entities -----
mOriginal->setPosition(290, 90, 0);
mGaussian->setPosition( 50, 230, 0);
mPixelize->setPosition(290, 230, 0);
mContrast->setPosition(520, 230, 0);
// ----- Main Loop -----
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
mI->_input->update();
mI->_render->beginScene();
mI->_entity2dManager->renderEntities2d();
mI->_render->endScene();
}
// ----- Free -----
mI->end();
return 0;
}
示例12: IndieLib
/*
==================
Main
==================
*/
int IndieLib()
{
//Sets the working path as the 'exe' directory. All resource paths are relative to this directory
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
AnimatedGameEntity* shipExplotion = new AnimatedGameEntity(mI, Position3D(0, 0, 1), "../SpaceGame/resources/animations/Ship_Explotion.xml");
shipExplotion->Draw();
AnimatedGameEntity* shipRotate = new AnimatedGameEntity(mI, Position3D(0, 0, 0), "../SpaceGame/resources/animations/kali/three_oclock.xml");
shipExplotion->Draw();
//mDelta = mI->_render->getFrameTime() / 1000.0f;
IND_Surface *mSurfaceBeetleship = IND_Surface::newSurface();
if (!mI->_surfaceManager->add(mSurfaceBeetleship, "../../SpaceGame/resources/beetleship.png", IND_ALPHA, IND_32)) return 0;
//ufo->setSequence(0);
// Font
IND_Font *mFontSmall = IND_Font::newFont();
if (!mI->_fontManager->add(mFontSmall, "../../SpaceGame/resources/font_small.png", "../../resources/font_small.xml", IND_ALPHA, IND_32)) return 0;
// Creating 2d entity for the bettleship
IND_Entity2d *mBeetleship = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mBeetleship); // Entity adding
mBeetleship->setSurface(mSurfaceBeetleship); // Set the surface into the entity
// ----- Font creation -----
IND_Entity2d *mTextSmallWhite = IND_Entity2d::newEntity2d();
mI->_entity2dManager->add(mTextSmallWhite); // Entity adding
mTextSmallWhite->setFont(mFontSmall); // Set the font into the entity
mTextSmallWhite->setLineSpacing(18);
mTextSmallWhite->setCharSpacing(-8);
mTextSmallWhite->setPosition(5, 5, 1);
mTextSmallWhite->setAlign(IND_LEFT);
mBeetleship->setHotSpot(0.5f, 0.5f);
GameEntity* space = new Space(mI, Position3D(0, 0, 0), "../SpaceGame/resources/planetki new/space.jpg");
space->Draw();
//GameEntity* planet1 = new Planet(mI, Position3D(0, 0, 1), "../SpaceGame/resources/a4203_planetes_g.png");
//planet1->DrawRegion(new Region(100, 220, 140, 150));
//GameEntity* planet2 = new Planet(mI, Position3D(300, 0, 1), "../SpaceGame/resources/a4203_planetes_g.png");
//planet1->setPosition(Position3D(300, 0, 1));
//planet1->DrawRegion(new Region(100, 220, 140, 150));
//GameEntity* ship = new Ship(mI, Position3D(300, 200, 1), "../SpaceGame/resources/rocket.png");
//ship->Draw();
float mAngle = 0;
float mPos = 400;
int mSpeed = 200;
float mDelta;
char mText[2048];
mText[0] = 0;
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
strcat(mText, "Use left and right arrow keys for moving the ships\n");
strcat(mText, "Press CTRL + X or ESC key to quit");
mTextSmallWhite->setText(mText);
mDelta = mI->_render->getFrameTime() / 1000.0f;
// Move entities when pressing right
if (mI->_input->isKeyPressed(IND_KEYRIGHT)){
mPos += mSpeed * mDelta;
}
// Move entities when pressing left
if (mI->_input->isKeyPressed(IND_KEYLEFT)){
mPos -= mSpeed * mDelta;
}
// If CTRL + X pressed then exit
if (mI->_input->isKeyPressed(IND_LCTRL) && mI->_input->isKeyPressed(IND_X)){
mI->_render->endScene();
mI->end();
exit(0);
}
mAngle += (mSpeed / 4) * mDelta;
mBeetleship->setPosition((float)mPos, 140, 1);
mBeetleship->setAngleXYZ(0, 0, (float)mPos);
mI->_input->update();
mI->_render->beginScene();
//.........这里部分代码省略.........
示例13: IndieLib
int IndieLib()
{
//Executable path
//Sets the working path as the 'exe' directory. All resource paths are relative to this directory
//TCHAR NPath[MAX_PATH];
//GetCurrentDirectory(MAX_PATH, NPath);
//std::basic_string<TCHAR> strName = NPath;
//new std::string(strName.c_str());
//std::string path = "D:\Vs2012 Project\C++ game development course\ShipGame\GameDevelopmentC-Cource\MyGame\SpaceGame";
//ConfigurationReader* reader = new ConfigurationReader((path + "\GameConfiguration.ini").c_str());
//std::string token = reader->getSetting("Token");
//InstanceManager* iM = new InstanceManager();
//iM->getPlayer(token, iM->getMachineName());
CIndieLib *mI = CIndieLib::instance();
if (!mI->init()) return 0;
_engine = new GameEngine(mI);
_engine->initializeFonts();
_engine->initializeEntities();
_firstInitializationTimer.start();
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit()) //idle
{
mI->_input->update();
_engine->processUserInput();
if (!_firstInitializationTimer.isStarted() || _firstInitializationTimer.getTicks() > 2)
{
_engine->manageCollisions();
}
else
{
if (_firstInitializationTimer.isStarted())
_firstInitializationTimer.stop();
}
_engine->update();
mI->_input->update();
mI->_render->beginScene();
mI->_entity2dManager->renderEntities2d();
mI->_entity2dManager->renderCollisionAreas(255, 0, 0, 255);
mI->_render->endScene();
}
//sound->drop();
mI->end();
return 0;
}
示例14: IndieLib
//.........这里部分代码省略.........
int mMiddleScreenX = mI->_window->getWidth() / 2;
int mMiddleScreenY = mI->_window->getHeight() / 2;
float mPosXCamera0 = (float) mMiddleScreenX;
float mPosXCamera1 = (float) mMiddleScreenX;
float mPosXCamera2 = (float) mMiddleScreenX;
IND_Camera2d *mCamera0 = new IND_Camera2d((int) mPosXCamera0, mMiddleScreenY);
IND_Camera2d *mCamera1 = new IND_Camera2d((int) mPosXCamera1, mMiddleScreenY);
IND_Camera2d *mCamera2 = new IND_Camera2d((int) mPosXCamera2, mMiddleScreenY);
int mSpeedLayer0 = 50;
int mSpeedLayer1 = 162;
int mSpeedLayer2 = 250;
// --- Camera for showing the text that explain the input controls ---
IND_Camera2d *mCameraText = new IND_Camera2d((int) mI->_window->getWidth() / 2, mI->_window->getHeight() / 2);
// --- Some variables ---
char mText [2048];
mText [0] = 0;
float mDelta;
while (!mI->_input->onKeyPress(IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input update ----
mI->_input->update();
// ----- Text -----
strcpy (mText, "Use right and left arrow keys for moving the camera\n");
mTextSmallWhite->setText(mText);
// ----- Input ----
mDelta = mI->_render->getFrameTime() / 1000.0f;
// Move cameras when pressing right key
if (mI->_input->isKeyPressed(IND_KEYRIGHT))
{
// Check limits
if (mPosXCamera2 < mSurfaceCaveFirstPlane->getWidth() - mMiddleScreenX)
{
mPosXCamera0 += mSpeedLayer0 * mDelta;
mPosXCamera1 += mSpeedLayer1 * mDelta;
mPosXCamera2 += mSpeedLayer2 * mDelta;
}
}
// Move cameras when pressing left key
if (mI->_input->isKeyPressed(IND_KEYLEFT))
{
// Check limits
if (mPosXCamera2 > mMiddleScreenX)
{
mPosXCamera0 -= mSpeedLayer0 * mDelta;
mPosXCamera1 -= mSpeedLayer1 * mDelta;
mPosXCamera2 -= mSpeedLayer2 * mDelta;
}
}
// ----- Updating cameras-----
mCamera0->setPosition((int) mPosXCamera0, mMiddleScreenY);
mCamera1->setPosition((int) mPosXCamera1, mMiddleScreenY);
mCamera2->setPosition((int) mPosXCamera2, mMiddleScreenY);
// ----- Render -----
mI->_render->clearViewPort(60, 60, 60);
mI->_render->beginScene();
// Render sky (Layer 0)
mI->_render->setCamera2d(mCamera0);
mI->_entity2dManager->renderEntities2d(0);
// Render cave (Layer 1)
mI->_render->setCamera2d(mCamera1);
mI->_entity2dManager->renderEntities2d(1);
// Render the first plane cave (Layer 2)
mI->_render->setCamera2d(mCamera2);
mI->_entity2dManager->renderEntities2d(2);
// Render the text explaining the controls plane cave (Layer 3)
mI->_render->setCamera2d(mCameraText);
mI->_entity2dManager->renderEntities2d(3);
mI->_render->endScene();
}
// ----- Free -----
mI->end();
return 0;
}
示例15: IndieLib
//.........这里部分代码省略.........
IND_Entity2d *mBeetleship = new IND_Entity2d();
mI->_entity2dManager->add(mBeetleship); // Entity adding
mBeetleship->setSurface(mSurfaceBeetleship); // Set the surface into the entity
// Creating 2d entity for the octopus
IND_Entity2d *mOctopus = new IND_Entity2d();
mI->_entity2dManager->add(mOctopus); // Entity adding
mOctopus->setSurface(mSurfaceOctopus); // Set the surface into the entity
// Creating 2d entity for the planet
IND_Entity2d *mPlanet = new IND_Entity2d();
mI->_entity2dManager->add(mPlanet); // Entity adding
mPlanet->setSurface(mSurfacePlanet); // Set the surface into the entity
// ----- Changing the attributes of the 2d entities -----
mBack->setHotSpot(0.5f, 0.5f);
mBack->setPosition(400, 300, 0);
mBack->setScale(1.7f, 1.7f);
mBeetleship->setHotSpot(0.5f, 0.5f);
mOctopus->setMirrorX(true);
mOctopus->setHotSpot(0.5f, 0.5f);
mPlanet->setHotSpot(0.5f, 0.5f);
// ----- Main Loop -----
float mAngle = 0;
float mPos = 400;
int mSpeed = 200;
float mDelta;
char mText [2048];
mText [0] = 0;
while (!mI->_input->onKeyPress (IND_ESCAPE) && !mI->_input->quit())
{
// ----- Input update -----
mI->_input->update();
// ----- Text -----
strcpy (mText, "Use the mouse for moving the planet\n");
strcat (mText, "Use left and right arrow keys for moving the ships\n");
strcat (mText, "Press CTRL + X or ESC key to quit");
mTextSmallWhite->setText(mText);
// ----- Input -----
mDelta = mI->_render->getFrameTime() / 1000.0f;
// Move entities when pressing right
if (mI->_input->isKeyPressed(IND_KEYRIGHT)){
mPos += mSpeed * mDelta;
}
// Move entities when pressing left
if (mI->_input->isKeyPressed(IND_KEYLEFT)){
mPos -= mSpeed * mDelta;
}
// If CTRL + X pressed then exit
if (mI->_input->isKeyPressed(IND_LCTRL) && mI->_input->isKeyPressed(IND_X)){
mI->_render->endScene();
mI->end();
exit(0);
}
mAngle += (mSpeed / 4) * mDelta;
// ----- Updating entities attributes -----
// Back
mBack->setAngleXYZ(0, 0, mAngle);
// Beetle
mBeetleship->setPosition((float) mPos, 140, 1);
mBeetleship->setAngleXYZ(0, 0, (float) mPos);
// Planet
mPlanet->setPosition((float) mI->_input->getMouseX(), 300, 2);
// Octopus
mOctopus->setPosition(800 - (float) mPos, 480, 3);
// ----- Render -----
mI->_render->beginScene();
mI->_entity2dManager->renderEntities2d();
mI->_render->endScene();
}
// ----- Free -----
mI->end();
return 0;
}