Ejemplo n.º 1
0
TextureSystem::TextureSystem(sf::RenderWindow& rw, entityx::EntityManager& entities, KeyValue& keys)
    : window(rw)
    , imageRenderEnabled(false)
    , randomTexturesEnabled(true)
    , positionTextEnabled(false)
    , entities(entities)
{
    /* This doesn't change. It maps the type shape to the vector of textures aviliable
     * under random texturing, or we use the first for no random textures */
    texturemap = {
        {    SpawnComponent::BOX, {&boxTextures,  conf::box_halfwidth*2}},
        { SpawnComponent::CIRCLE, {&ballTextures, conf::circle_radius*2}}
    };

    /* Textures for physics objects
     * `loadTextures` reads a key from an .ini consisting of colon-delimited
     * textures, and loads them into a vector */
    loadTextures(boxTextures,  keys.GetString("BOX_TEXTURES"));
    loadTextures(ballTextures, keys.GetString("BALL_TEXTURES"));

    //Load background texture and make it repeating
    bgTexture.loadFromFile(keys.GetString("BACKGROUND_TEXTURE"));
    bgTexture.setRepeated(true);
    bgSprite.setTexture(bgTexture);
    auto windsz = rw.getSize();
    bgSprite.setTextureRect(sf::IntRect(0, 0, windsz.x, windsz.y));

    //Font for displaying positions and other things
    boxFont.loadFromFile(keys.GetString("OBJECT_FONT"));
}
Ejemplo n.º 2
0
void InfoLikeBox::likeButtonCallBack(cocos2d::Ref *sender)
{
    if(_bIsLike)
    {
        //만약 라이크가 아니라면
        auto button = static_cast<ui::Button*>(sender);
        button->loadTextures("Info_LikeButtonUp_Normal-hd.png", "Info_LikeButtonDown-hd.png");
        auto lb = static_cast<Label*>(button->getChildByTag(TAG_BUTTON_STATE));
        lb->setString("LIKE IT!!");
        lb->setColor(Color3B::BLACK);
        removeLikeList();
        _bIsLike = false;
    }
    else
    {
        //만약 라이크면
        auto button = static_cast<ui::Button*>(sender);
        button->loadTextures("Info_LikeButtonUp_Selected-hd.png", "Info_LikeButtonDown-hd.png");
        auto lb = static_cast<Label*>(button->getChildByTag(TAG_BUTTON_STATE));
        lb->setString("LIKE");
        lb->setColor(Color3B::WHITE);
        saveLikeList();
        _bIsLike = true;
    }
}
Ejemplo n.º 3
0
void ModelInterface::loadMaterial(aiMaterial* ai_material, Mesh* meshTarget)
{
    aiColor3D color(0.f, 0.f, 0.f);

    float shininess = 0.0f;
    float opacity   = 1.0f;

    ai_material->Get(AI_MATKEY_COLOR_AMBIENT, color);
    meshTarget->getMeshMaterial()->mAmbient = QVector3D(color.r, color.g, color.b);

    ai_material->Get(AI_MATKEY_COLOR_DIFFUSE, color);
    meshTarget->getMeshMaterial()->mDiffuse = QVector3D(color.r, color.g, color.b);

    ai_material->Get(AI_MATKEY_COLOR_SPECULAR, color);
    meshTarget->getMeshMaterial()->mSpecular = QVector3D(color.r, color.g, color.b);

    ai_material->Get(AI_MATKEY_SHININESS, shininess);
    meshTarget->getMeshMaterial()->shininess = shininess;

    ai_material->Get(AI_MATKEY_OPACITY, opacity);
    meshTarget->getMeshMaterial()->opacity = opacity;

    QString textureFolder = ""; //fileName.left(fileName.indexOf(".")) + "/"; // - Why the hell we are using same

    loadTextures(ai_material, aiTextureType_DIFFUSE,  meshTarget->getMeshTextures()->diffuseTextureIndex,  meshTarget->getMeshTextures()->hasDiffuseTexture,  filePath + textureFolder, textureManager);
    loadTextures(ai_material, aiTextureType_SPECULAR, meshTarget->getMeshTextures()->specularTextureIndex, meshTarget->getMeshTextures()->hasSpecularTexture, filePath + textureFolder, textureManager);
    loadTextures(ai_material, aiTextureType_NORMALS,  meshTarget->getMeshTextures()->normalsTextureIndex,  meshTarget->getMeshTextures()->hasNormalsTexture,  filePath + textureFolder, textureManager);
    loadTextures(ai_material, aiTextureType_HEIGHT,   meshTarget->getMeshTextures()->heightTextureIndex,   meshTarget->getMeshTextures()->hasHeightTexture,   filePath + textureFolder, textureManager);
}
Ejemplo n.º 4
0
bool MainMenu::init(void)
{
    if ( !Layer::init() )
    {
        return false;
    }

	_uiLayer = Layer::create();
	_uiLayer->setPosition(Point(D_display.getLeftBottom()));
	addChild(_uiLayer);

	auto spBg = Sprite::create("images/mainmenu_bg.jpg");
	spBg->setPosition(D_display.getCenterPoint());
	_uiLayer->addChild(spBg);


	auto btnStart = Button::create();
    btnStart->setTouchEnabled(true);
    btnStart->loadTextures("images/btn_start.png", "", "");
	btnStart->setPosition(Point(D_display.cx, D_display.cy+43));
	btnStart->setTag(1);
    btnStart->addTouchEventListener(this, toucheventselector(MainMenu::touchEvent));
    _uiLayer->addChild(btnStart);

	auto btnExit = Button::create();
    btnExit->setTouchEnabled(true);
    btnExit->loadTextures("images/btn_exit.png", "", "");
	btnExit->setPosition(Point(D_display.cx, D_display.cy-43));
    btnExit->addTouchEventListener(this, toucheventselector(MainMenu::touchEvent));
	btnExit->setTag(2);
    _uiLayer->addChild(btnExit); 

	return true;
}
Ejemplo n.º 5
0
int main( int argc, char *argv[] )
{
	XVisualInfo			 *xvVisualInfo;
	Colormap			  cmColorMap;
	XSetWindowAttributes  winAttr;
	GLXContext  		  glXContext;
	int Attr[] = { GLX_RGBA,
				   GLX_RED_SIZE, 1,
				   GLX_GREEN_SIZE, 1,
				   GLX_BLUE_SIZE, 1,
				   GLX_DEPTH_SIZE, 16,
				   GLX_DOUBLEBUFFER,
				   None };
	
	// Connect to X Server
	dpy = XOpenDisplay(NULL);
	if(dpy == NULL) return 0; // Could not open display
	// GLX extension is supported?
	if(!glXQueryExtension(dpy, NULL, NULL)) return 0; // Return, if X server haven't GLX
	// Find visual
	xvVisualInfo = glXChooseVisual(dpy, DefaultScreen(dpy), Attr);
	if(xvVisualInfo == NULL) return 0; // If Visual info can't be shoosed
	// Create new colormap for our window
	cmColorMap = XCreateColormap(dpy, RootWindow(dpy, xvVisualInfo->screen), xvVisualInfo->visual, AllocNone);
	winAttr.colormap = cmColorMap;
	winAttr.border_pixel = 0;
	winAttr.background_pixel = 0;
	winAttr.event_mask = ExposureMask | ButtonPressMask | StructureNotifyMask | KeyPressMask;
	
	// Create window
	win = XCreateWindow(dpy, RootWindow(dpy, xvVisualInfo->screen),
						0, 0, 640, 480, 0,
						xvVisualInfo->depth,
						InputOutput,
						xvVisualInfo->visual,
						CWBorderPixel | CWColormap | CWEventMask,
						&winAttr);
	
	// Create OpenGL rendering context
	glXContext = glXCreateContext(dpy, xvVisualInfo, None, True);
	if(glXContext == NULL) return 0; // Can't create rendering context
	// Make it current	
	glXMakeCurrent(dpy, win, glXContext);
	// Map window on the display
	XMapWindow(dpy, win);
	
	initShader();
	loadTextures();
	
	// Enter to the main X loop
	event_loop();
	
	glDeleteTextures( 1, &datatexID );
	
	glDeleteObjectARB( g_vertexShader );
	glDeleteObjectARB( g_fragmentShader );
	glDeleteObjectARB( g_programObj );
	
	return 0;
}
Ejemplo n.º 6
0
void MyGLWidget::initializeGL()
{
    loadTextures();
    glEnable( GL_TEXTURE_2D );
    glShadeModel(GL_SMOOTH);   // Enables Smooth Shading
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);  // Black Background
    glClearDepth(1.0f);             // Depth Buffer Setup
    glEnable(GL_DEPTH_TEST);        // Enables Depth Testing
    glDepthFunc(GL_LEQUAL);        // The Type Of Depth Test To Do
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations

    /* Setup The Ambient Light */
    glLightfv( GL_LIGHT1, GL_AMBIENT, LightAmbient );

    /* Setup The Diffuse Light */
    glLightfv( GL_LIGHT1, GL_DIFFUSE, LightDiffuse );

    /* Position The Light */
    glLightfv( GL_LIGHT1, GL_POSITION, LightPosition );

    /* Enable Light One */
    glEnable( GL_LIGHT1 );

    /* Set The Texture Generation Mode For S To Sphere Mapping */
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    /* Set The Texture Generation Mode For T To Sphere Mapping */
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

    /* Create A Pointer To The Quadric Object */
    quadratic = gluNewQuadric( );
    /* Create Smooth Normals */
    gluQuadricNormals( quadratic, GLU_SMOOTH );
    /* Create Texture Coords */
    gluQuadricTexture( quadratic, GL_TRUE );
}
Ejemplo n.º 7
0
void main(int argc, char **argv) {
	
	srand((unsigned int) time(0));

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);      // set the display mode to double buffering
	glutInitWindowPosition(100,100);
	glutInitWindowSize(700,700);
	glutCreateWindow("Truchet Tiles");
	glutDisplayFunc(renderScene);
	glutIdleFunc(idleFunc);
	glutReshapeFunc(reshape);

	//Generate and load textures
	std::string fnames[] =  {"circle.png", "circles2.png", "triangles.png", "trump.png", "test.png", "nutest.png", "mazemaker.png",
				"terry.png", "jon.png", "doc.png", "cal.png", "gavin.png", "stephen.png"};
	loadTextures(13, fnames);

	init();

	// create the menus
	MenuGenerator(LOOPS);

	glutCreateMenu(processLeftMenuEvents);
	glutAddMenuEntry("Increase Density", MORE_TILES );
	glutAddMenuEntry("Decrease Density", LESS_TILES);
	glutAddMenuEntry("Toggle Animation", TOGGLE_ANIMATION);
	glutAttachMenu(GLUT_LEFT_BUTTON);

	glutTimerFunc(2000, ProcAnimation, 0);

	glutMainLoop();
}
ProfileSelectState::ProfileSelectState(QGLWidget* context) : GameState(context)
{
    loadTextures();

    mouse = false;

    aspectRatio = 1;
    dimension = 3;
    fieldOfView = 55;
    ph = 0;
    th = 0;

    title = new MenuItem();
    title ->setPosition(0.0, 2.1, 0.0);
    title ->setDimension(5.0, 1.2);
    title->setTexture(textures[0]);

    returnToMenu = new MenuItem();
    returnToMenu ->setPosition(3.9, -2.5, 0.0);
    returnToMenu ->setDimension(2.4, 0.6);
    returnToMenu->setTexture(textures[1]);
    selectableOptions.append(returnToMenu);

    highlight = new MenuItem();
    highlight->setTexture(textures[2]);

    selectedOption = ReturnToMenu;
}
Ejemplo n.º 9
0
void MyGLWidget::initializeGL()
{
    loadTextures();
    glShadeModel(GL_SMOOTH);   // Enables Smooth Shading
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);  // Black Background
    glClearDepth(1.0f);             // Depth Buffer Setup
    glDisable(GL_DEPTH_TEST);        // Disable Depth Testing
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    glEnable(GL_BLEND);                         // Enable Blending

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
    glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);                 // Really Nice Point Smoothing
    glEnable(GL_TEXTURE_2D);                        // Enable Texture Mapping
    glBindTexture(GL_TEXTURE_2D,texture[0]);                // Select Our Texture

    for (loop=0;loop<MAX_PARTICLES;loop++)                   // Initialize All The Textures
    {
        particle[loop].active=true;                 // Make All The Particles Active
        particle[loop].life=1.0f;                   // Give All The Particles Full Life
        particle[loop].fade=float(rand()%100)/1000.0f+0.003f;       // Random Fade Speed
        particle[loop].r=colors[loop*(12/MAX_PARTICLES)][0];        // Select Red Rainbow Color
        particle[loop].g=colors[loop*(12/MAX_PARTICLES)][1];        // Select Red Rainbow Color
        particle[loop].b=colors[loop*(12/MAX_PARTICLES)][2];        // Select Red Rainbow Color
        particle[loop].xi=float((rand()%50)-26.0f)*10.0f;       // Random Speed On X Axis
        particle[loop].yi=float((rand()%50)-25.0f)*10.0f;       // Random Speed On Y Axis
        particle[loop].zi=float((rand()%50)-25.0f)*10.0f;       // Random Speed On Z Axis
        particle[loop].xg=0.0f;                     // Set Horizontal Pull To Zero
        particle[loop].yg=-0.8f;                    // Set Vertical Pull Downward
        particle[loop].zg=0.0f;                     // Set Pull On Z Axis To Zero
    }
}
Ejemplo n.º 10
0
bool GAFAsset::initWithGAFBundle(const std::string& zipFilePath, const std::string& entryFile, GAFTextureLoadDelegate_t delegate, GAFLoader* customLoader /*= nullptr*/)
{
    m_gafFileName = zipFilePath;
    m_gafFileName.append("/" + entryFile);
    std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(zipFilePath);

    cocos2d::ZipFile bundle(fullfilePath);
    ssize_t sz = 0;
    unsigned char* gafData = bundle.getFileData(entryFile, &sz);

    bool isLoaded = false;

    if (gafData && sz)
    {
        if (customLoader)
        {
            customLoader->loadData(gafData, sz, this);
        }
        else
        {
            GAFLoader* loader = new GAFLoader();
            isLoaded = loader->loadData(gafData, sz, this);
            delete loader;
        }
    }
    if (isLoaded && m_state == State::Normal)
    {
        m_textureManager = new GAFAssetTextureManager();
        GAFShaderManager::Initialize();
        loadTextures(entryFile, delegate, &bundle);
    }

    return isLoaded;
}
Ejemplo n.º 11
0
void KrecikApp::init()
{
    win.draw(Text(L"Loading...", r.f, 30));
    win.display();

    loadTextures();
    createCar();
    createLevel();

    Sprite loadwheel(whTex);
    loadwheel.setPosition(20.0f, 20.0f);
    //loadwheel.setScale(2.0f, 2.0f);
    loadwheel.setOrigin(getCenter(loadwheel.getGlobalBounds()));
    Clock tmp;

    while(!Keyboard::isKeyPressed(Keyboard::Return))
    {
        Time elapsed = tmp.restart();
        win.clear();
        win.draw(Text("    Press <Enter> to start...",r.f, 30));
        loadwheel.rotate(elapsed.asSeconds() * 400.0f);
        win.draw(loadwheel);
        win.display();
    }
}
Ejemplo n.º 12
0
int main(int argc,char* argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(1000,1000);
    glutCreateWindow("Textures Assignment (Seth Perry)");
    //sets the function that handles window reshaping to reshape.
    glutReshapeFunc(reshape);
    //sets the display function to display
    glutDisplayFunc(display);
    //set the idle function to idle
    glutIdleFunc(idle);
    //sets the special key function to special
    glutSpecialFunc(special);
    //sets the keyboard function to key
    glutKeyboardFunc(key);

    getHourOfDay();

    loadTextures();

    determineTreeLocations();

    generateDisplayLists();

    pew=LoadOBJ("pew.obj");

    //check for errors
    ErrCheck("init");
    //gives control to GLUT so user input can be managed.
    glutMainLoop();
    return 0;
}
Ejemplo n.º 13
0
bool GAFAsset::initWithGAFBundle(const std::string& zipFilePath, const std::string& entryFile, GAFTextureLoadDelegate_t delegate /*= NULL*/)
{
    GAFLoader* loader = new GAFLoader();

    m_gafFileName = zipFilePath;
    m_gafFileName.append("/" + entryFile);
    std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(zipFilePath);

    cocos2d::ZipFile bundle(fullfilePath);
    ssize_t sz = 0;
    unsigned char* gafData = bundle.getFileData(entryFile, &sz);

    bool isLoaded = false;

    if (gafData && sz)
    {
        isLoaded = loader->loadData(gafData, sz, this);
    }
    if (isLoaded)
    {
        loadTextures(entryFile, delegate, &bundle);
    }

    delete loader;

    return isLoaded;
}
Ejemplo n.º 14
0
Content::Content()
{
        loadTextures();
        loadSounds();
        loadMusic();
        loadFonts();
}
Ejemplo n.º 15
0
void Globals::init ()
{	
  try
  {
	YAML::Node config(YAML::LoadFile("assets/config.yml"));
	config = config["game"];

	sf::Vector2u window_size(config["graphic"]["window"]["size"][0].as<unsigned>(),
		config["graphic"]["window"]["size"][1].as<unsigned>());

	window.reset(new sf::RenderWindow(sf::VideoMode(window_size.x, window_size.y), "Vegetable Crush Saga", sf::Style::Default & ~sf::Style::Resize));
	window->setFramerateLimit(60);

	YAML::Node paths(config["system"]["paths"]);
	loadTextures(config["graphic"]["textures"], paths["texture_pack"].as<std::string>());
	loadFonts(config["graphic"]["fonts"], paths["font_pack"].as<std::string>());

	YAML::Node items(config["gameplay"]["items"]);
	loadItems(items);
  }
  catch (YAML::ParserException e)
  {
	std::cerr << "Le fichier de config n'est pas aux normes !" << std::endl;
	std::cerr << e.what() << std::endl;
	exit(EXIT_FAILURE);
  }
}
Ejemplo n.º 16
0
bool GAFAsset::initWithGAFFile(const std::string& filePath, GAFTextureLoadDelegate_t delegate, GAFLoader* customLoader /*= nullptr*/)
{
    m_gafFileName = filePath;
    std::string fullfilePath = cocos2d::FileUtils::getInstance()->fullPathForFilename(filePath);

    bool isLoaded = false;
    if (customLoader)
    {
        isLoaded = customLoader->loadFile(fullfilePath, this);
    }
    else
    {
        GAFLoader* loader = new GAFLoader();
        isLoaded = loader->loadFile(fullfilePath, this);
        delete loader;
    }

    if (m_timelines.empty())
    {
        return false;
    }
    if (isLoaded && m_state == State::Normal)
    {
        m_textureManager = new GAFAssetTextureManager();
        GAFShaderManager::Initialize();
        loadTextures(fullfilePath, delegate);
    }

    return isLoaded;
}
Ejemplo n.º 17
0
World::World(sf::RenderTarget&	target, FontHolder& fonts, SoundPlayer& sounds)
	: mTarget(target)
	, mFonts(fonts)
	, mSounds(sounds)
	, mWorldView(target.getDefaultView())
	, mImages()
	, mTextures()
	, mSceneGraph()
	, mSceneLayers()
	, mWorldBounds(mWorldView.getCenter() - mWorldView.getSize() / 2.f, mWorldView.getSize())
	, mSpawnPosition(mWorldView.getSize().x / 2.f, mWorldView.getSize().y / 2.f)
	, mBossFactory(mTextures, mWorldBounds)
	, mPlayerFactory(mTextures)
	, mPlayer(nullptr)
	, mBoss(nullptr)
	, mLife(nullptr)
	, mScore(nullptr)
	, mQuadTreePrimary(1, mWorldBounds)
	, mQuadTreeSecondary(1, mWorldBounds)
	, mPlayerBulletNodes()
	, mEnemyBulletNodes()
	, mInvaders()
	, mLivesCount(3)
	, mChangeSpeed(false)
	, mDeadLine(getBattlefieldBounds().height + getBattlefieldBounds().top - Padding / 2.f)
	, mIsGameEnded(false)
{
	loadTextures();
	buildScene();

	// Prepare the view
	mWorldView.setCenter(mSpawnPosition);
}
Ejemplo n.º 18
0
Block::Block(GLuint x, GLuint y){

	/*	NOTE
	*	The grid isn't used and isn't useful right now
	*	It could come in handy when we use those bumpmaps(?)
	*/
	/*
	GLfloat xDistance = 0.05f;
	GLfloat yDistance = 0.05f;
	GLfloat yDistanceCopy = 0.05f;
	GLuint counter = 0;
	glm::vec3 initialVector(-0.15f, -0.05f, 0.0f);
	for (GLuint i = 0; i < BLOCK_HEIGHT; i++){
	for (GLuint j = 0; j < BLOCK_WIDTH; j++){
	blockCoordinates.push_back(glm::vec3(initialVector.x + xDistance, initialVector.y + yDistance, 0));
	yDistance = yDistance + 0.05f;
	blockIndices.push_back(counter);
	counter++;
	}
	yDistance = yDistanceCopy;
	xDistance = xDistance + 0.05f;
	}
	//createVAO could later be repurposed to actually create the VAO
	//createVAO();
	*/

	loadTextures(x, y);
}
//-----------------------------------------------------------------------------
// createWindow() -- create the main window
//-----------------------------------------------------------------------------
int GlutDisplay::createWindow()
{
   winId = -1;

#ifdef __FREEGLUT_EXT_H__     /* freeglut only */
      glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
#endif

   unsigned int wmode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
   if (getClearDepth() >= 0.0f) { wmode = wmode | GLUT_DEPTH; }
   if (accumBuff) { wmode = wmode | GLUT_ACCUM; }
   if (stencilBuff) { wmode = wmode | GLUT_STENCIL; }
   glutInitDisplayMode( wmode );

   GLint  vpX(0), vpY(0);                   // our initial viewport position
   GLsizei vpWidth(0), vpHeight(0);    // our initial viewport size
   getViewport(&vpX, &vpY, &vpWidth, &vpHeight);
   glutInitWindowPosition(vpX, vpY);
   glutInitWindowSize(vpWidth, vpHeight);
   winId = glutCreateWindow(getName());
   if (winId > 0) {
      if (isMessageEnabled(MSG_INFO)) {
         std::cout << "GlutDisplay::createWindow() name = " << getName() << ", winId = " << winId << std::endl;
      }

      // Configure the new window
      if (fullScreenFlg) glutFullScreen();
      glutDisplayFunc(drawFuncCB);
      glutReshapeFunc(reshapeItCB);
      glutIdleFunc(idleCB);
      glutPassiveMotionFunc(passiveMotionFuncCB);
      glutMotionFunc(motionFuncCB);
      glutKeyboardFunc(keyboardFuncCB);
      glutSpecialFunc(specialFuncCB);
      glutMouseFunc(mouseFuncCB);
      glutEntryFunc(entryFuncCB);
      registerGlutDisplay(winId, this);
      glutSetWindow(winId);
      configure();
      loadTextures();

      // Create sub windows (if any)
      if (subDisplays() != nullptr) {
         Basic::List::Item* item = subDisplays()->getFirstItem();
         while (item != nullptr) {
            Basic::Pair* pair = dynamic_cast<Basic::Pair*>(item->getValue());
            if (pair != nullptr) {
               GlutDisplay* dobj = dynamic_cast<GlutDisplay*>( pair->object() );
               if (dobj != nullptr) dobj->createSubWindow(winId);
            }
            item = item->getNext();
         }
      }

      // Select this window
      select();
   }

   return winId;
}
Ejemplo n.º 20
0
void SelectRoundLayer::createRoundButton(int round, bool isUnlock, const Point& pos) {
	auto roundButton = ui::Button::create();

	std::string normalButton;
	std::string selectedButton = s_roundButtonBackgroundSelected;
	if (isUnlock) {
		normalButton = s_roundButtonBackgroundNormal;
		roundButton->setTouchEnabled(true);
	}
	else {
		normalButton = selectedButton;
		roundButton->setTouchEnabled(false);
	}
	roundButton->loadTextures(normalButton, selectedButton, "", ui::Button::TextureResType::PLIST);
	Vec2 visibleOrigin = Director::getInstance()->getVisibleOrigin();
	const int step = 100;
	roundButton->setPosition(ccpAdd(visibleOrigin, pos));
	roundButton->setUserData((void*)round);
	addChild(roundButton);
	roundButton->addTouchEventListener(this, ui::SEL_TouchEvent(&SelectRoundLayer::onRoundButtonTouched));

	auto labelRound = LabelBMFont::create(StringUtils::toString(round+1), "fonts/boundsTestFont.fnt");
	labelRound->setPosition(ccpAdd(visibleOrigin, pos));
	addChild(labelRound);
}
Ejemplo n.º 21
0
bool loadContent()
{
	if (createMap())
	{
		cityMap.initializeMap(city, 28, 28, textureArray, 12, 11);
	}
	else
		return false;

	if (!loadTextures())
	{
		return false;
	}
	
	//seed random var
	srand(time(NULL));

	//initialize dragons
	smaug = Smaug(Vec(675, 0, 1100), Vec(5,0,5), textureArray, 3, 4, 5);
	trogdor = Trogdor(Vec(125, 0, 100), Vec(8,0,8), textureArray, 6, 7, 8, 9);
	
	//lighting init
	initLights();

	//init cam;
	cam = 0;

	//init textWriter
	textWrite = textWriter(SCREEN_WIDTH, SCREEN_HEIGHT);

	//particle engine initialization
	p1.init();

	return true;
}
Ejemplo n.º 22
0
GlassCube::GlassCube(Vector3D startPosition, GLfloat length, TextureLoader* texture_loader) :
    Drawable(startPosition, true),
    m_length(length),
    m_texture_loader(texture_loader)
{
    loadTextures();
}
Ejemplo n.º 23
0
void Game::init(sf::RenderWindow *app) {
	this->app = app;

	loadTextures();

	player = new Player(level.getWorld(), sf::Vector2f(100, 200));
}
Ejemplo n.º 24
0
void GLManager::initializeGL()
{
	glClearColor(0,0,0,0);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_TEXTURE_2D);

	// 载入所有星球的纹理
	loadTextures();

	//设置摄像机
	setCamera(Point(10.0, 2.0, 10.0), Point(0.0, 0.0, 0.0));


	//设置光照及材质
	GLfloat mat_shininess [] = {50.0};
	GLfloat light_position [] = {0,0,0,1};
	GLfloat lmodel_ambient [] = {0.8,0.8,0.8,1.0};

	glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
	glLightfv(GL_LIGHT0,GL_POSITION,light_position);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient);

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_DEPTH_TEST);
	
	
}
Ejemplo n.º 25
0
GameEngineMap::GameEngineMap(LoaderParameters* parameters, Map* map, Character* character) : GameObject(parameters)
{
	this->map = map;
	this->character = character;

	loadTextures();
}
Ejemplo n.º 26
0
World::World(sf::RenderTarget& outputTarget, FontHolder& fonts, SoundPlayer& sounds)
 : mTarget(outputTarget)
 , mSceneTexture()
 , mWorldView(outputTarget.getDefaultView())
 , mFonts(fonts)
 , mSounds(sounds)
 , mTextures()
 , mSceneGraph()
 , mSceneLayers()
 , mWorldBounds(0.f, 0.f, mWorldView.getSize().x, 2000.0f)
 , mSpawnPosition(mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 2.f)
 , mScrollSpeed(-50.f)
 , mPlayerAircraft(nullptr)
 , mEnemySpawnPoints()
 , mActiveEnemies()
 , mPostEffectsSupported(false)
{
    mPostEffectsSupported = PostEffect::isSupported();
	if(mPostEffectsSupported)
	{
        mSceneTexture.create(mTarget.getSize().x, mTarget.getSize().y);
	}
	
    loadTextures();
	buildScene();
	
	// Prepare the view.
	mWorldView.setCenter(mSpawnPosition);
}
Ejemplo n.º 27
0
World::World(sf::RenderWindow& window)
: mWindow(window)
, mWorldView(window.getDefaultView())
, mTextures() 
, mFonts()
, mSceneGraph()
, mSceneLayers()
, mWorldBounds(0.f, 0.f, mWorldView.getSize().x, WorldLeght)
, mSpawnPosition(mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 3.f)
, mScrollSpeed(-200.f)
, mPlayerSpaceship(nullptr)
, mPlanetSpawnPoints()
, mBackgroundSprite(nullptr)
, mHealthDisplay(nullptr)
, mPointsDisplay(nullptr)
, mPoints(0)
, mOldWorldCoordY(0.f)
, mDistanceForSpawnNewEnemies(WorldLeght)
{

	mFonts.load(Fonts::Main, "Media/Sansation.ttf");
	loadTextures();
	buildScene();	

	// Prepare the view
	mWorldView.setCenter(mSpawnPosition.x, mWorldBounds.height - mWorldView.getSize().y / 2.f);

}
Ejemplo n.º 28
0
Intro::Intro(){
#ifndef WIN32
	JNIUtil::jni_music_play("title.ogg");
#endif

	#ifdef FONT
	width1_=(m_pFontAtlas->GetFont(AHB_36)->GetWidth("TOUCH TO START"));
	#endif

	numframes=sizeof(intro_sequence)/sizeof(const unsigned int);

	loadTextures();

	loops=0;

	Animation* animation=new Animation();
	animation->currentFrame=0;
	animations.push_back(animation);	

	pos=Vector2D<float>(0,0);

	myTween.setup(120, 0.3f, -0.7f, Easing::SineEaseInOut,0,2);
	myTween.play();	
	//myTween2.setup(30, 0.5f, -0.5f, Easing::SineEaseInOut,0,2);
	//myTween2.play();	
}
World::World(sf::RenderTarget& outputTarget, FontHolder& fonts, SoundPlayer& sounds, bool networked)
: mTarget(outputTarget)
, mSceneTexture()
, mWorldView(outputTarget.getDefaultView())
, mTextures() 
, mFonts(fonts)
, mSounds(sounds)
, mSceneGraph()
, mSceneLayers()
, mWorldBounds(0.f, 0.f, mWorldView.getSize().x, 5000.f)
, mSpawnPosition(mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 2.f)
, mScrollSpeed(-50.f)
, mScrollSpeedCompensation(1.f)
, mPlayerAircrafts()
, mEnemySpawnPoints()
, mActiveEnemies()
, mNetworkedWorld(networked)
, mNetworkNode(nullptr)
, mFinishSprite(nullptr)
{
	mSceneTexture.create(mTarget.getSize().x, mTarget.getSize().y);

	loadTextures();
	buildScene();

	// Prepare the view
	mWorldView.setCenter(mSpawnPosition);
}
Ejemplo n.º 30
0
void Scene::initialize(char * file) {
    strncpy(filename, file, 90);
    loadTextures();
    reader.read(filename);
    model.init();

}