int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLineArgs, int nInitialWinShowState) { Receiver recv; //define a structure for your settings DeviceConfig cfg; cfg.hInstance = hInstance; //pass through the win main parameters cfg.hPrevInstance = hPrevInstance; cfg.initialWindowShowState = nInitialWinShowState; cfg.windowSize = EWR_DEFAULT; //default screen size cfg.windowTitle = L"DirectX Game Scene - Jake O'Connor"; //window title cfg.receiver = &recv; cfg.showConsole = true; cfg.resourcePath = "./game_files"; // any file will be loaded with this as the base path cfg.windowSize = E_WINDOW_SIZE::EWR_MEDIUM; //create a device object Device * device = createDevice(cfg); //grab a pointer to the video driver VideoDriver * driver = device->getVideoDriver(); //grab pointer to audio driver AudioDriver * aDriver = device->getAudioDriver(); //grab pointer to scene manger SceneManager* smgr = device->getSceneManager(); TerrainSceneNode* terrain = smgr->addTerrainSceneNode(".\\file_store/terrain/heightmap.hmf", driver->getTexture(L".\\file_store/terrain/Terrain.png"), 64.0f, 8.0f, 961); SkyDomeSceneNode* skyDome = smgr->addSkyDomeSceneNode(driver->getTexture(L".\\file_store/sky.jpg"), 10); //SkyBoxSceneNode* skyBox = smgr->addSkyBoxSceneNode(L".\\file_store/sky/Top.bmp", //L".\\file_store/sky/Bottom.bmp", //L".\\file_store/sky/Left.bmp", //L".\\file_store/sky/Right.bmp", //L".\\file_store/sky/Front.bmp", //L".\\file_store/sky/Back.bmp" //); std::vector<MapItem> mapData; loadMapIndex(mapData); Font* font = driver->getDefaultFont(); for (auto &m : mapData) { LoadObject(m.id, m.x, m.y, m.f, driver, smgr, terrain); } Texture * guiTex = driver->getTexture(L".\\file_store/gui.png"); AudioClip* music = aDriver->getAudioClip(".\\file_store/track.mp3"); aDriver->playSound(music); CameraSceneNode * camera = smgr->getCamera(); camera->setPosition(vector3df(54176, 1749, 29847)); camera->setYaw(-10); //run the device while (device->run()) { if (recv.keyDown[K_DOWN_ARROW]) { f32 leftMove = -700.0f * device->deltaTime(); camera->addPosition(vector3df(0, leftMove, 0)); } if (recv.keyDown[K_UP_ARROW]) { f32 leftMove = 700.0f * device->deltaTime(); camera->addPosition(vector3df(0, leftMove, 0)); } if (recv.keyDown[K_RIGHT_ARROW]) { camera->addYaw(-90.0f * device->deltaTime()); } if (recv.keyDown[K_LEFT_ARROW]) { camera->addYaw(90.0f * device->deltaTime()); } if (recv.keyDown[K_W]) { f32 XMove = camera->getPosition().x - camera->target.x; f32 ZMove = camera->getPosition().z - camera->target.z; vector2df addPos = Math::normalize(XMove, ZMove); camera->addPosition(vector3df(-addPos.x * 10.0f, 0, -addPos.y * 10.0f)); } if (recv.keyDown[K_S]) { f32 XMove = camera->getPosition().x - camera->target.x; f32 ZMove = camera->getPosition().z - camera->target.z; vector2df addPos = Math::normalize(XMove, ZMove); camera->addPosition(vector3df(addPos.x * 10.0f, 0, addPos.y * 10.0f)); } if (recv.buttonPressed(K_P)) { //print camera position cout << "Camera position " << camera->getPosition().x << " " << camera->getPosition().y << " " << camera->getPosition().z << endl; } if (recv.buttonPressed(K_Z)) { if (camera->getPosition().x != 794 * 64) camera->setPosition(vector3df(794*64, 1400, 484*64)); } //clear the screen to a color driver->beginScene(SKYBLUE); //draw all objects in the scenemanager smgr->drawAll(); driver->draw2DImage(*guiTex, vector2df(-10, 0)); wstring fps = L"Frames per second: "; fps += std::to_wstring(device->getFPS()); driver->drawText(font, fps, vector2df(10, 10), YELLOW); wstring mouse = L"Mouse Position x: "; mouse += to_wstring(recv.mouseposx); mouse += L" y: "; mouse += to_wstring(recv.mouseposy); driver->drawText(font, mouse, vector2df(10, 30), YELLOW); //present the new frame driver->endScene(); } //release all game memory device->drop(); }