예제 #1
0
TerrainBlock::TerrainBlock(MapIO::BlockData &data):
m_mapPosition(Ogre::Vector3(Ogre::Real(data.gridX), Ogre::Real(data.gridY), Ogre::Real(data.gridZ))),
m_blockType(data.blockType), m_terrainType(data.blockTerrain)
{
	createSceneNode();
	loadContent();
}
예제 #2
0
//init SDL, OpenGL and game stuff here
bool initGame()
{
	//Initialize SDL
    if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
    {
        return false;
    }

    //Create Window
    if( SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL ) == NULL )
    {
        return false;
    }

    //Initialize OpenGL
    if( initOpenGL() == false )
    {
        return false;
    }
	
	if (loadContent() == false)
	{
		return false;
	}

    //Set caption
    SDL_WM_SetCaption( "Dragon City", NULL );

	return true;
}
/**
	Importe l'element decrit dans un document XML. Si une position est
	precisee, les elements importes sont positionnes de maniere a ce que le
	coin superieur gauche du plus petit rectangle pouvant les entourant tous
	(le bounding rect) soit a cette position.
	@param xml_document un document XML decrivant l'element
	@param position La position des parties importees
	@param consider_informations Si vrai, les informations complementaires
	(dimensions, hotspot, etc.) seront prises en compte
	@param content_ptr si ce pointeur vers un ElementContent est different de 0,
	il sera rempli avec le contenu ajoute a l'element par le fromXml
	@return true si l'import a reussi, false sinon
*/
void ElementScene::fromXml(
	const QDomDocument &xml_document,
	const QPointF &position,
	bool consider_informations,
	ElementContent *content_ptr
) {
	QString error_message;
	bool state = true;
	
	// prend en compte les informations de l'element
	if (consider_informations) {
		state = applyInformations(xml_document, &error_message);
	}
	
	// parcours des enfants de la definition : parties de l'element
	if (state) {
		ElementContent loaded_content = loadContent(xml_document, &error_message);
		if (position != QPointF()) {
			addContentAtPos(loaded_content, position, &error_message);
		} else {
			addContent(loaded_content, &error_message);
		}
		
		// renvoie le contenu ajoute a l'element
		if (content_ptr) {
			*content_ptr = loaded_content;
		}
	}
}
예제 #4
0
BlobGame::BlobGame() :
	m_CurrentState(None),
	m_TotalPower(0),
	m_TotalEnergy(0){
	loadContent();
	reset();
}
예제 #5
0
파일: main.cpp 프로젝트: gouki04/AutoTile
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    hge = hgeCreate(HGE_VERSION);

    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
    hge->System_SetState(HGE_TITLE, "EasyAutoTile Editor");
    hge->System_SetState(HGE_SCREENWIDTH, screenWidth);
    hge->System_SetState(HGE_SCREENHEIGHT, screenHeight);
    hge->System_SetState(HGE_FPS, 60);
    hge->System_SetState(HGE_HIDEMOUSE, false);
    hge->System_SetState(HGE_WINDOWED, true);
    hge->System_SetState(HGE_USESOUND, false);
    hge->System_SetState(HGE_LOGFILE, "AutoTileEditor.log");
    hge->System_SetState(HGE_SHOWSPLASH, false);

    if(hge->System_Initiate())
    {
        loadContent();
        hge->System_Start();
    }
    else
    {	
        MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
    }

    unLoadContent();
    hge->System_Shutdown();

    hge->Release();

    return 0;
}
예제 #6
0
GUIMenu::GUIMenu(GameData &data)
	: data(data),
	  text(),
	  items()
{
	initialize();
	loadContent();
}
void TexturedObjectScrollView::loadContent(const vector<TexturedObject*>& textures_){

	vector<TexturedObjectTexture> tots;
	for(size_t i = 0; i < textures_.size(); i++){
		TexturedObjectTexture texObjTex;
		texObjTex.texIndex = 0;
		texObjTex.texObj = textures_[i];
		tots.push_back(texObjTex);
	}
	loadContent(tots);
}
예제 #8
0
GameEngine::GameEngine()
	: data(),
	  world(data.settings),
	  menu(NULL),
	  window(NULL)
{
	logLevel = LOG_DEBUG;

	data.state = UNINITIALIZED;
	
	initialize();
	loadContent();
}
/**
	@param xml_document un document XML decrivant un element
	@return le boundingRect du contenu de l'element
*/
QRectF ElementScene::boundingRectFromXml(const QDomDocument &xml_document) {
	// charge les parties depuis le document XML
	ElementContent loaded_content = loadContent(xml_document);
	if (loaded_content.isEmpty()) return(QRectF());
	
	// calcule le boundingRect
	QRectF bounding_rect = elementContentBoundingRect(loaded_content);
	
	// detruit les parties chargees
	qDeleteAll(loaded_content);
	
	return(bounding_rect);
}
예제 #10
0
bool Application::initialize(){
	
	if(SDL_Init(SDL_INIT_EVERYTHING) != 0){
		this->displaySurface = NULL;
		return false;
	}
	SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), NULL);
	SDL_WM_SetCaption("TankField", NULL);
	this->displaySurface = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT , 32, SDL_SWSURFACE);

	SDL_EnableUNICODE(SDL_ENABLE);

	if(SDLNet_Init() < 0){
		return false;
	}
	
	loadContent();
	SDL_ShowCursor(0);
	if(this->displaySurface == NULL){
		return false;
	}

	if(TTF_Init() == -1){
        return false;
    }

	font = TTF_OpenFont("arial.ttf", 40);

	textColor.r = 255;
	textColor.g = 0;
	textColor.b = 0;
	
	loadMenuContent();

	menu->invertToCheckCollisionAll();
	menu->setToCheckCollision(false);

	memset(this->keyState, false, sizeof(this->keyState));
	srand(time(NULL));
	leftMouseButton = false;
	showMenu = true;

	server = NULL;
	client = NULL;
	player2 = NULL;
	dummyBot = NULL;

	return true;

}
예제 #11
0
 inline NinePatchGame() noexcept
 {
     m_Game.onLoadContent = [this]()
     {
         loadContent();
     };
     m_Game.onUpdate = [this](float ft)
     {
         update(ft);
     };
     m_Game.onDraw = [this](sf::RenderTarget& target)
     {
         draw(target);
     };
 }
예제 #12
0
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <pathname>\n", argv[0]);
    exit(1);
  }

  char *contentPath = argv[1];
  u8* contentBuffer;
  size_t contentSize;
  createContentBuffer(contentPath, &contentBuffer, &contentSize);

  for(int i=0; i<10; ++i) {
    loadContent(contentPath, contentBuffer, contentSize);
    decodeContent(contentBuffer, contentSize);
  }
}
예제 #13
0
void MainWindow::onLoadActivated()
{
	switch (checkForUnsavedChanges()) {
		case QMessageBox::Save:
			onSaveActivated();
			return;
		case QMessageBox::Discard:
			break;
		default :
			return;
	}

	QString path = QFileDialog::getOpenFileName(this, Editor::Strings::OpenFileDialog, QString(), Editor::Strings::ContentFiles);
	if (loadContent(path))
		startEditing();
}
예제 #14
0
파일: Game.cpp 프로젝트: amit9oct/PlAI
void Game::start()
{
	loadContent();

	initialise();

	sf::Clock clk;
	clk.restart();

	while (window.isOpen())
	{
		Time elapsedTime = clk.getElapsedTime();
		if (clk.getElapsedTime().asMilliseconds()!=0) gettingFPS = 1000 / clk.getElapsedTime().asMilliseconds();

		clk.restart();
		update(elapsedTime);
		draw(elapsedTime);
		playSounds();
	}
}
예제 #15
0
void FSWebViewController::viewDidLoad()
{
    _size = this->getView()->getBounds().size;
    //CAScrollView *srv = CAScrollView::createWithFrame(this->getView()->getBounds());
    m_webView = CAWebView::createWithFrame(this->getView()->getBounds());
    
    this->getView()->addSubview(m_webView);
    
    
    
    loadContent();
    
    //    CC_PROPERTY_IS(bool, m_bShowsHorizontalScrollIndicator, ShowsHorizontalScrollIndicator);
    //
    //    CC_PROPERTY_IS(bool, m_bShowsVerticalScrollIndicator, ShowsVerticalScrollIndicator);
    //
    //    CC_PROPERTY_IS(bool, m_bShowsScrollIndicators, ShowsScrollIndicators);
    

}
예제 #16
0
void StartScreen::init() {
    loadContent();
    label = LinkLabel(font);
    label.setText("Press bugista nappia to begin");
    label.setFocused(true);
    label.setTabStop(true);
    int w, h;
    TTF_SizeText(font, label.getText().c_str(), &w, &h);
    Vector position((game->getWidth() - w )/ 2, (game->getHeight()-h)/2);
    label.setPosition(position);
    controlManager.add(&label);

    passwordLabel = LinkLabel(font);
    passwordLabel.setText("Password");
    passwordLabel.setFocused(false);
    passwordLabel.setTabStop(true);
    TTF_SizeText(font, passwordLabel.getText().c_str(), &w, &h);
    position.y += 50;
    passwordLabel.setPosition(position);
    controlManager.add(&passwordLabel);
}
예제 #17
0
void run()
{
	if(!initialize())
		shutdown("Failed to initialize");

	if(!loadContent())
		shutdown("Failed to load resources");	

	Mesh cubeMesh = Mesh::genUnitColoredCube();
	MeshBuffer cubeBuffer(cubeMesh);
	Model cube(cubeBuffer);

	Mesh waterMesh = Mesh::genUnitColoredPlane(Color(0.57f, 0.63f, 0.98f));
	MeshBuffer waterBuffer(waterMesh);
	Model water(waterBuffer);

	BufferObject quadVbo;
	float quadVertices[] = {
		-1.0f, -1.0f, 0.0f, 0.0f,
		+1.0f, -1.0f, 1.0f, 0.0f,
		+1.0f, +1.0f, 1.0f, 1.0f,
		+1.0f, +1.0f, 1.0f, 1.0f,
		-1.0f, +1.0f, 0.0f, 1.0f,
		-1.0f, -1.0f, 0.0f, 0.0f
	};
	quadVbo.create(GL_ARRAY_BUFFER, GL_STATIC_DRAW, sizeof(quadVertices), quadVertices);

	Mesh gridMesh;
	for(int i = 0; i <= 8; ++i)
	{
		float f = (i / 8.0) * 2.0f - 1.0f;
		int j = gridMesh.getPositionCount();
		gridMesh.addPosition(f * 3.0f, 0.0f, -3.0f);
		gridMesh.addPosition(f * 3.0f, 0.0f, +3.0f);
		gridMesh.addPosition(-3.0f, 0.0f, f * 3.0f);
		gridMesh.addPosition(+3.0f, 0.0f, f * 3.0f);
		gridMesh.addColor(Colors::White);
		gridMesh.addColor(Colors::White);
		gridMesh.addColor(Colors::White);
		gridMesh.addColor(Colors::White);
		gridMesh.addIndex(j + 0); gridMesh.addIndex(j + 1);
		gridMesh.addIndex(j + 2); gridMesh.addIndex(j + 3);
	}
	MeshBuffer gridBuffer(gridMesh);
	Model grid(gridBuffer);

	VertexArray vao;
	vao.create();
	vao.bind();

	mat4 perspectiveMatrix = glm::perspective(45.0f, windowWidth / float(windowHeight), 0.05f, 50.0f);
	
	// The geometry to be refracted and reflected are stored in these
	// In addition to RGB values, the world-space height is stored in the alpha-channel
	// of the refraction texture.
	// Fresnel equations is used to blend between the two textures
	RenderTexture refractionRT(windowWidth, windowHeight);
	RenderTexture reflectionRT(windowWidth, windowHeight);

	renderer.setClearColor(0.55f, 0.45f, 0.45f, 1.0f);
	renderer.setClearDepth(1.0);

	Timer timer;
	timer.start();
	double renderTime = 0.0;

	while(context.isOpen())
	{
		timer.step();
		double time = timer.getElapsedTime();
		update(time, timer.getDelta());
		double renderStart = timer.getElapsedTime();

		MatrixStack viewMatrix;
		viewMatrix.push();
		viewMatrix.translate(0.0f, 0.0f, -3.0f);
		viewMatrix.rotateX(xAxisRotation);
		viewMatrix.rotateY(yAxisRotation);

		renderer.setCullState(CullStates::CullNone);
		renderer.setDepthTestState(DepthTestStates::LessThanOrEqual);
		
		colorShader.begin();
		colorShader.setUniform("projection", perspectiveMatrix);
		cube.pushTransform();
		cube.translate(0.0f, 0.0f, 0.0f);
		cube.scale(0.5f);

		// Render the geometry to be refracted, store result in rt
		refractionRT.begin();
		renderer.clearColorAndDepth();
		colorShader.setUniform("view", viewMatrix.top());
		cube.draw(GL_TRIANGLES);
		grid.draw(GL_LINES);
		refractionRT.end();

		// Render the geometry to be reflected, store result in rt
		reflectionRT.begin();
		renderer.clearColorAndDepth();
		viewMatrix.push();
		viewMatrix.scale(1.0f, -1.0f, 1.0f); // Reflect about xz-plane
		colorShader.setUniform("view", viewMatrix.top());
		cube.draw(GL_TRIANGLES);
		viewMatrix.pop();
		reflectionRT.end();

		colorShader.end();
		cube.popTransform();

		// Render the water with the previous reflection/refraction texture
		waterShader.begin();
		waterShader.setUniform("time", time);
		glActiveTexture(GL_TEXTURE0 + 0);
		refractionRT.bindTexture();
		glActiveTexture(GL_TEXTURE0 + 1);
		reflectionRT.bindTexture();
		glActiveTexture(GL_TEXTURE0 + 2);
		waterNormals.bind();
		//waterShader.setUniform("view", viewMatrix.top());
		waterShader.setUniform("refraction_tex", 0);
		waterShader.setUniform("reflection_tex", 1);
		waterShader.setUniform("water_normals_tex", 2);
		//waterShader.setUniform("light0_pos", vec3(0.0f, 1.0f, 0.0f));
		//waterShader.setUniform("light0_col", vec3(1.0f, 0.8f, 0.5f));
		//waterShader.setUniform("ambient", vec3(67.0f/255.0f, 66.0f/255.0f, 63.0f/255.0f));
		quadVbo.bind();
		waterShader.setAttributefv("position", 2, 4, 0);
		waterShader.setAttributefv("texel", 2, 4, 2);
		glDrawArrays(GL_TRIANGLES, 0, 6);
		quadVbo.unbind();
		reflectionRT.unbindTexture();
		refractionRT.unbindTexture();
		waterNormals.unbind();
		waterShader.end();
		glActiveTexture(GL_TEXTURE0 + 0);

		// Render unmirrored scene
		//colorShader.begin();
		//renderer.clearColorAndDepth();
		//renderer.setCullState(CullStates::CullNone);
		//renderer.setBlendState(BlendStates::AlphaBlend);
		//renderer.setDepthTestState(DepthTestStates::LessThanOrEqual);
		//colorShader.setUniform("projection", perspectiveMatrix);
		//colorShader.setUniform("view", viewMatrix.top());
		//cube.pushTransform();
		//cube.translate(0.0f, 0.4f, 0.0f);
		//cube.scale(0.5f);
		//cube.draw(GL_TRIANGLES);

		/*grid.pushTransform();
		grid.translate(0.0f, -0.5f, 0.0f);
		grid.draw(GL_LINES);
		grid.popTransform();*/

		// Draw mirrored scene to a rendertarget
		/*rt.begin();
		renderer.clearColorAndDepth();
		
		viewMatrix.push();
		viewMatrix.scale(1.0f, -1.0f, 1.0f);
		colorShader.setUniform("view", viewMatrix.top());
		cube.draw(GL_TRIANGLES);
		cube.popTransform();
		viewMatrix.pop();
		rt.end();*/

		// Enable stencil testing and mask out a section containing the water mesh
		//glEnable(GL_STENCIL_TEST);
		//glStencilFunc(GL_ALWAYS, 1, 0xFF); // Set any stencil to 1
		//glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
		//glStencilMask(0xFF); // Write to stencil buffer
		//glDepthMask(GL_FALSE); // Don't write to depth buffer
		//glClear(GL_STENCIL_BUFFER_BIT); // Clear stencil buffer (0 by default)

		//// Draw water mesh
		//water.pushTransform();
		//water.scale(3.0f);
		//water.draw(GL_TRIANGLES);
		//water.popTransform();
		//colorShader.end();

		//// Draw previous rendertarget as a quad masked into the water plane
		//glStencilFunc(GL_EQUAL, 1, 0xFF); // Pass test if stencil value is 1
		//glStencilMask(0x00); // Don't write anything to stencil buffer
		//glDepthMask(GL_TRUE);

		//glDisable(GL_STENCIL_TEST);

		viewMatrix.pop();

		context.display();
		renderTime = timer.getElapsedTime() - renderStart;
		if(renderTime < 0.013)
			context.sleep(0.013 - renderTime);

		if(checkGLErrors(std::cerr))
		{
			std::cin.get();
			context.close();
		}
	}

	waterNormals.dispose();
	colorShader.dispose();
	waterShader.dispose();
	vao.dispose();
	context.dispose();
}
예제 #18
0
TerrainBlock::TerrainBlock(Ogre::Vector3 position):
	m_mapPosition(position), m_blockType(BlockType::Flat), m_terrainType(BlockTerrain::Normal)
{
		createSceneNode();
		loadContent();
}
예제 #19
0
void BaseGameState::init() {
	loadContent();
}
예제 #20
0
//-----------------------------------------------------------------------------------------------------
void Section::loadSection(int section)
	{
		json.open("http://127.0.0.1:3500/section/"+ofToString(section)+"/json");

		loadContent(json,section); 
	}