void MainWindow::gameRedy() { gamemod=redy; createFloor(); createBird(); createPipe(); }
ann::gles::SceneNode* buildDungeonNode(const model::Dungeon& dungeon) { ann::gles::SceneNode* dungeonNode = new ann::gles::SceneNode(); ann::gles::SceneNode* floorNode = createFloor(); ann::gles::SceneNode* roofNode = createRoof(); ann::gles::SceneNode* farWallNode = createFarWall(); ann::gles::SceneNode* backWallNode = createBackWall(); ann::gles::SceneNode* leftWallNode = createLeftWall(); ann::gles::SceneNode* rightWallNode = createRightWall(); int width = dungeon.getWidth(); int height = dungeon.getHeight(); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { if (!dungeon.floorCell(x, y)) { continue; } ann::gles::SceneNode* cellNode = new ann::gles::SceneNode(); cellNode->translate(helpers::glPoint(x, y)); dungeonNode->attachNode(cellNode); ann::gles::SceneNode* floor = new ann::gles::SceneNode(*floorNode); cellNode->attachNode(floor); ann::gles::SceneNode* roof = new ann::gles::SceneNode(*roofNode); cellNode->attachNode(roof); if (y == 0 || (y > 0 && !dungeon.floorCell(x, y - 1))) { ann::gles::SceneNode* leftWall = new ann::gles::SceneNode(*leftWallNode); cellNode->attachNode(leftWall); } if (y == height - 1 || (y < height - 1 && !dungeon.floorCell(x, y + 1))) { ann::gles::SceneNode* rightWall = new ann::gles::SceneNode(*rightWallNode); cellNode->attachNode(rightWall); } if (x == 0 || (x > 0 && !dungeon.floorCell(x - 1, y))) { ann::gles::SceneNode* backWall = new ann::gles::SceneNode(*backWallNode); cellNode->attachNode(backWall); } if (x == width - 1 || (x < width - 1 && !dungeon.floorCell(x + 1, y))) { ann::gles::SceneNode* farWall = new ann::gles::SceneNode(*farWallNode); cellNode->attachNode(farWall); } } } delete floorNode; delete roofNode; delete farWallNode; delete backWallNode; delete leftWallNode; delete rightWallNode; return dungeonNode; }
void load_scene(void){ objects[0] = load_object("objects/table.obj"); objects[1] = load_object("objects/clock.obj"); objects[2] = load_object("objects/clock-minutehand.obj"); objects[3] = load_object("objects/clock-hourhand.obj"); objects[4] = load_object("objects/vase.obj"); objects[5] = createFloor(500.0, 500, 1); }
void Game::start(void) { if (_gameState != Uninitialized) return; game_victory = 0; _mainWindow.create(sf::VideoMode(1024, 768, 32), "Anne McLaughlin Demo"); _view.reset(sf::FloatRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); _view.setViewport(sf::FloatRect(0, 0, 1.0f, 1.0f)); /*if (!font->loadFromFile("C:/Users/Anne/Documents/Visual Studio 2013/Projects/MyGame/Graphics/AGENTORANGE.TTF")) { std::cout << "error" << std::endl; } coinstring->setFont(*Game::font); coinstring->setString("Coins: "); coinstring->setCharacterSize(72); coinstring->setColor(sf::Color::Black); coinstring->setStyle(sf::Text::Regular); sf::FloatRect textRect = coinstring->getLocalBounds(); coinstring->setOrigin(textRect.width / 2, textRect.height / 2); coinstring->setPosition(sf::Vector2f(SCREEN_WIDTH / 2.0f, SCREEN_HEIGHT / 2.0f));*/ initObject(new PlayerCharacter, sf::Vector2f(/*SCREEN_WIDTH / 4*/ 9*SCREEN_WIDTH/10, 1000), "PlayerCharacter"); Background * bg = new Background(); level_width = bg->getSprite().getGlobalBounds().width; level_height = bg->getSprite().getGlobalBounds().height; createFloor(); _gameObjectManager.add("Background", bg); createLevelBlocks(); rigidBodyCoords = findRigidBodies(); _gameState = Game::ShowingSplash; while (!isExiting()) { gameLoop(); } _mainWindow.close(); }
Floor::Floor(int idNum) : id(idNum), floor(0), map(0), upStairs(0), scoreCounter(0), mineCounter(10), mineCounterTally(0), scoreRoom(false), numberOfCreatedRooms(0), downStairs(0), mapHeight(Tile::TILE_HEIGHT*(MAP_TILES_VISIBLE*2+1)), mapWidth(Tile::TILE_WIDTH*(MAP_TILES_VISIBLE*2+1)), stairCounter(0){ createFloor(); createMap(); }
void PairCollisionFilter::initHk() { memoryRouter = hkMemoryInitUtil::initDefault(hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo(1024 * 1024)); hkBaseSystem::init(memoryRouter, errorReport); createWorld(); m_world->lock(); hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher()); hkpPairCollisionFilter* filter = createPairCollisionFilter(); createFloor(); hkpRigidBody* floor = create2ndFloor(); movingBox = createMovingBox(); //disable collisions between moving box and the upper floor filter->disableCollisionsBetween(floor, movingBox); m_world->unlock(); }
bool SceneLoader::init() { // Create all walls based on the matrix Ogre::Vector3 vecPos; for(int i = 0; i < mMatrixSize.x; i++) { for (int j = 0; j < mMatrixSize.y; j++) { if(mSceneMatrix[i][j] == 1) { vecPos = matrixCoordToSceneCoord(Ogre::Vector2(i*1.0f,j*1.0f)); createWall(vecPos, mWallCubeScale); } } } createFloor(mMatrixSize.x*mWallCubeScale, mMatrixSize.y*mWallCubeScale); createWalkArray(); // mSceneRootNode->roll(Ogre::Degree(-90)); return true; }
//----------------------------------------------------------------------------- // create buffers, ready to send to display void GuiTestAll::appCreateBuffers() { createCube(); createFloor(); }
int main(void) { sgLoadModule("SDL"); sgLoadModule("OpenGL"); sgLoadModule("STB-Image"); sgLoadModule("Chipmunk"); sgLoadModule("STB-TrueType"); sgInit(0); sgWindowOpen(640, 480, 32, 0); sgWindowSetTitle("SIEGE Physics Demo - Press F1 for debug overlay"); sgWindowSetFPSLimit(60.0f); space = sgPhysicsSpaceGetDefault(); sgPhysicsSpaceSetIterations(space, 10); sgPhysicsSpaceSetDamping(space, 0.75); sgPhysicsSpaceSetGravity(space, 0.0, 25.0); sprCrateSmall = sgSpriteCreateFile("data/sprites/CrateSmall.png"); sprFloorMetalPlate = sgSpriteCreateFile("data/sprites/FloorMetalPlate.png"); sprHazardWall = sgSpriteCreateFile("data/sprites/HazardWall.png"); sprPacman = sgSpriteCreateFile("data/sprites/Pacman.png"); sprStrongboxSmall = sgSpriteCreateFile("data/sprites/StrongboxSmall.png"); sprSupportBar = sgSpriteCreateFile("data/sprites/SupportBar.png"); SGFont* font = sgFontCreate("data/fonts/DejaVuSans.ttf", 7.0, 0, 127); SGuint i; for(i = 32; i < 640; i += 64) createFloor(sprFloorMetalPlate, i, 448); for(i = 224; i < 448; i += 64) createFloor(sprSupportBar, i, 384); for(i = 224; i < 448; i += 64) createFloor(sprHazardWall, i, 320); controller = sgEntityCreate(); controller->evMouseButtonLeftPress = evMouseButtonLeftPress; controller->evMouseButtonRightPress = evMouseButtonRightPress; controller->evKeyboardKeyPress = evKeyboardKeyPress; controller->evKeyboardKeyRepeat = evKeyboardKeyRepeat; SGlong accum = SG_NANOSECONDS_IN_A_SECOND, origin = sgGetTime(); SGfloat fps = 0.0; while(sgLoop(NULL)) { accum += sgGetTime() - origin; if(overlay) for(i = 0; i < numboxes; i++) boxDrawDBG(boxes[i]); if(accum >= SG_NANOSECONDS_IN_A_SECOND) { accum = 0; origin = sgGetTime(); fps = sgWindowGetFPS(); } sgFontPrintf(font, 1.0, 10.0, "FPS: %.2f", fps); sgWindowSwapBuffers(); sgDrawClear(); } sgSpriteDestroy(sprCrateSmall); sgSpriteDestroy(sprFloorMetalPlate); sgSpriteDestroy(sprHazardWall); sgSpriteDestroy(sprPacman); sgSpriteDestroy(sprStrongboxSmall); sgSpriteDestroy(sprSupportBar); sgFontDestroy(font); sgDeinit(); free(boxes); return 0; }
int main(){ //random number generator seeded srand(time(NULL)); //sdl screen info and sprite data SDLDrawMetaData sdl; SpriteData sprites; //setup camera cam = new camera(); camBoundingBox = createCamBB(); //move above floor! cam->Location[1]+=0.2; //camera forces we will use. Keyboard input will modify these values and move us shared_ptr<Force> UpForce = cam->addForce(cam->Up,0); shared_ptr<Force> ForwardForce = cam->addForce(cam->Target,0); shared_ptr<Force> RightForce = cam->addForce(cam->Right,0); draw_AABB=true; draw_SOM=true; draw_HGrid=true; //create 10 random objects to test hierarchal bounding tree MyObjects = createObjects(); //add floor to scene MyObjects->insert(createFloor()); MyGrid.Add(*MyObjects); //self organizing map creation TSPFileReader trainingVectorFactory; vector<neuron> TrainingNeurons; //we will use 3d vectors and a colour array to demo TrainingNeurons = trainingVectorFactory.retrieveTrainingVectors("./maps/RGB.tsp"); //SOM will eventually be scaled between 0 and 1. here we define 20x20 grid float meshSize = 0.05; mySOM = initializeNewSOM(meshSize,0.0,255.0); //SOM training counter int trainingIterations = 100; int iTrain = trainingIterations; SOMbricks = createSOMBricks(meshSize); //add our som bricks to our spatial partitioning structure (collision detection) MyGrid.Add(*SOMbricks); MyGrid.Add(camBoundingBox); init(sdl.screen_w,sdl.screen_h); //cube texture SDL_Surface* cobblestoneFloor; SDL_Render::loadimage("./sprites/6903.jpg" ,&cobblestoneFloor); //transfer SDL surface into openGL texture nOfColors = cobblestoneFloor->format->BytesPerPixel; if(nOfColors == 4){ if(cobblestoneFloor->format->Rmask = 0x000000ff){ texture_format = GL_RGBA; }else{ texture_format = GL_BGRA; } }else if(nOfColors == 3){ if(cobblestoneFloor->format->Rmask = 0x000000ff){ texture_format = GL_RGB; }else{ texture_format = GL_BGR; } } //openGL texturing and depth map configuration glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glDepthRange(0.0f,1.0f); glBindTexture(GL_TEXTURE_2D,1); glPixelStorei(GL_UNPACK_ALIGNMENT,1); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT); glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); glTexImage2D( GL_TEXTURE_2D,0,nOfColors,cobblestoneFloor->w,cobblestoneFloor->h,0,texture_format,GL_UNSIGNED_BYTE,cobblestoneFloor->pixels); //sdl cursor initialization mouseX=0; mouseY=0; SDL_Event event; SDL_ShowCursor(0); SDL_WM_GrabInput(SDL_GRAB_ON); bool quit = false; //game loop while(!quit){ //keyboard/mouse handler while(SDL_PollEvent(&event)){ if(event.type==SDL_QUIT){ quit=true; }else if(event.type == SDL_KEYDOWN){ switch(event.key.keysym.sym){ case SDLK_w:ForwardForce->magnitude += 0.1 ; break; case SDLK_s:ForwardForce->magnitude -= 0.1 ; break; case SDLK_d:RightForce->magnitude -= 0.1 ; break; case SDLK_a:RightForce->magnitude += 0.1 ; break; case SDLK_e:UpForce->magnitude -= 0.1 ; break; case SDLK_q:UpForce->magnitude +=0.1 ; break; case SDLK_i:cam->rotateX(5) ; break; case SDLK_k:cam->rotateX(-5) ; break; case SDLK_j:cam->rotateY(5) ; break; case SDLK_l:cam->rotateY(-5) ; break; case SDLK_o:cam->rotateZ(5) ; break; case SDLK_u:cam->rotateZ(-5) ; break; case SDLK_b:draw_AABB=!draw_AABB ; break; case SDLK_n:draw_SOM=!draw_SOM ; break; case SDLK_m:draw_HGrid=!draw_HGrid ; break; case SDLK_z:quit=true; break; } }else if(event.type == SDL_KEYUP){ switch(event.key.keysym.sym){ case SDLK_w:ForwardForce->magnitude -= 0.1 ; break; case SDLK_s:ForwardForce->magnitude += 0.1 ; break; case SDLK_d:RightForce->magnitude += 0.1 ; break; case SDLK_a:RightForce->magnitude -= 0.1 ; break; case SDLK_e:UpForce->magnitude += 0.1 ; break; case SDLK_q:UpForce->magnitude -=0.1 ; break; } }else if(event.type == SDL_MOUSEMOTION ){ // MouseMove(event.motion.xrel, event.motion.yrel, sdl.screen_h/2,sdl.screen_w/2); } } update(); if(iTrain>0){ iTrain--; mySOM = train(mySOM,TrainingNeurons,iTrain,trainingIterations,false); } render(); } return 0; }
//----------------------------------------------------------------------------- // create buffers, ready to send to display void TestCube::appCreateBuffers() { createCube(); createFloor(); }