All pastes #632376 Raw Edit

Something

public cpp v1 · immutable
#632376 ·published 2007-07-24 20:32 UTC
rendered paste body
/* * Copyright (c) 2007, Wesley Hearn *  * All rights reserved. *  * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: *  *  * Redistributions of source code must retain the above copyright notice, *    this list of conditions and the following disclaimer. *  * Redistributions in binary form must reproduce the above copyright notice, *    this list of conditions and the following disclaimer in the documentation and/or *    other materials provided with the distribution. *  * Neither the name of the product nor the names of its contributors may be *    used to endorse or promote products derived from this software without specific *    prior written permission. *  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * client.cpp - <DATE> - Main client file, sets up the renderer and handles the game state * */ #include <main.hpp> void sleep(unsigned int mseconds){    clock_t goal = mseconds + clock();    while (goal > clock());}void Client::Init(){	GS = LOADING;	input.Init();	// Set up the renderer	// createDevice( E_DRIVER_TYPE, windowSize, uint bits, bool fullscreen,	//	bool stencilbuffer, bool vsync, IEventReceiver* receiver = 0)	device = createDevice( EDT_OPENGL, dimension2d<s32>(640, 480), 16, false, false, false, &input);	// Set the window name	// virtual void setWindowCaption(const wchar_t* text)	device->setWindowCaption(L"Galatic Wars");		// Set up the driver, smgr, guienv pointers	driver = device->getVideoDriver();	smgr = device->getSceneManager();	guienv = device->getGUIEnvironment();	Camera = smgr->addCameraSceneNode();		Splash();	menu.Init();}void Client::Splash(){	// Lets start up with the menu	// TODO: play a movie.. at least a splash screen for irrlicht}void Client::Render(){	while(IsRunning)	{		while(device->run())		{			// Tell Irrlicht that this is a new scene			driver->beginScene(true, true, SColor(255,100,101,140));			// State switches.. BE SURE TO CALL state.Init() and Init will handle changing this			switch (GS)			{				case IN_WORLD:					world.Render();					break;//				case LOADING://					break;				case MAIN_MENU:				default:					menu.Render();					break;			}			// Let Irrlicht know that the frame is over			driver->endScene();		}	}}// b0rk3d... (causes a seg fault in libX11 :/// but in short shut down and start upvoid Client::Reinit(){	driver->endScene();	device->closeDevice();	device->run();	device->drop();	device = NULL;	sleep(5);	Init();}void Client::Shutdown(){	// Clean up	device->drop();	device = NULL;}