Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [code]
- /* Doom Sneak
- Copyright Johnathan M. Morgan
- This program comes with ABSOLUTELY NO WARRANTY; for details look under the 'credits' menu.
- This is free software, and you are welcome to redistribute it
- under certain conditions; again, look under the 'credits' menu. */
- /* A sincere thanks to the Irrlicht 3D development team and community for making this program possible */
- //Include files
- #include <irrlicht.h>
- #include <iostream>
- #include <string>
- #include <vector>
- //Pragma comments to link up with .dlls
- #ifdef _IRR_WINDOWS_
- #pragma comment(lib, "Irrlicht.lib")
- #endif
- //Namespaces
- using namespace irr;
- //Game loop
- void Loop(video::E_DRIVER_TYPE driverSelect, bool abort)
- {
- if(!abort)
- {
- //Device handler
- IrrlichtDevice* videoDevice = createDevice(driverSelect, core::dimension2d<u32>(1260,720));
- //If device is invalid or failed to load
- if(videoDevice == 0)
- {
- abort = true;
- }
- //Set window caption
- videoDevice->setWindowCaption(L"Doom Sneak");
- //Setup video driver, scene manager, and gui manager
- video::IVideoDriver* driver = videoDevice->getVideoDriver();
- scene::ISceneManager* sceneManager = videoDevice->getSceneManager();
- gui::IGUIEnvironment* guiEvn = videoDevice->getGUIEnvironment();
- //Begin gameloop
- while(videoDevice->run())
- {
- driver->beginScene(true,true,video::SColor(110,100,100,50));
- driver->endScene();
- }
- //cleanup
- videoDevice->drop();
- }
- }
- //Driver Picker
- video::E_DRIVER_TYPE PickDriver(bool validSelect, video::E_DRIVER_TYPE driverSelect, bool abort)
- {
- char userSelect;
- while(!validSelect)
- {
- //Display instructions
- printf("Please select a video driver \n");
- printf("OpenGL: O \n");
- printf("DirectX: X \n");
- printf("Software Default: S \n");
- printf("Abort: A \n");
- //Take input and send it to lowercase
- std::cin >> userSelect;
- userSelect = tolower(userSelect);
- //Switch for picking driver
- switch(userSelect)
- {
- case 'o': driverSelect = video::EDT_OPENGL; validSelect = true; break; //OpenGL picked
- case 'x': driverSelect = video::EDT_DIRECT3D9; validSelect = true; break; //DirectX picked
- case 's': driverSelect = video::EDT_SOFTWARE; validSelect = true; break; //Default driver
- case 'a': printf("Process aborted... \n"); abort = true; validSelect = true; break; //Abort
- default: printf("Error, Input invalid.. \n \n"); //Garbage entered, retry
- }
- }
- return driverSelect;
- }
- //Main app entry point
- int main()
- {
- //Video Driver
- video::E_DRIVER_TYPE driverSelect = video::EDT_NULL;
- //Is the user selection valid input?
- bool validSelect = false;
- //Abort boolean
- bool abort = false;
- //Pick checkpoint
- pick:
- //driverSelect will equal the return of PickDriver
- driverSelect = PickDriver(validSelect, driverSelect, abort);
- //Game loop
- Loop(driverSelect, abort);
- //Input for user
- std::string input;
- //Is the input within our bounds?
- bool validInput = false;
- while(!validInput && !abort)
- {
- //Print instructions
- printf("Play again with a different driver? \n");
- printf("Y/N \n");
- //Get input
- std::getline(std::cin, input);
- //Sanitized input string
- std::string sanitized;
- //Convert input string to sanitized, all lowercase string
- for(int i = 0; i < input.length(); i++)
- {
- sanitized += tolower(input.c_str()[i]);
- }
- if(sanitized == "y" || sanitized == "yes")
- {
- goto pick;
- }
- else if(sanitized == "n" || sanitized == "no")
- {
- validInput = true;
- }
- else
- {
- printf("Invalid input... \n \n");
- }
- }
- //clear up dat buffer
- std::cin.ignore();
- //pause console
- std::cin.get();
- return 0;
- }
- [/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement