示例#1
0
bool loadMedia( Tile* tiles[] )
{
	//Loading success flag
	bool success = true;

	//Load dot texture
	if( !gDotTexture.loadFromFile( "39_tiling/dot.bmp" ) )
	{
		printf( "Failed to load dot texture!\n" );
		success = false;
	}

	//Load tile texture
	if( !gTileTexture.loadFromFile( "39_tiling/tiles.png" ) )
	{
		printf( "Failed to load tile set texture!\n" );
		success = false;
	}

	//Load tile map
	if( !setTiles( tiles ) )
	{
		printf( "Failed to load tile set!\n" );
		success = false;
	}

	return success;
}
//Static Methods
bool Tile::init(SDL_Renderer *renderer)
{
	bool success = true;

	sTileTexture.setRenderer(renderer);

	if (!sTileTexture.textureIsLoaded())
	{
		if (!sTileTexture.loadFromFile("39_tiling/tiles.png"))
		{
			printf("Filed to load tile set texture!\n");
			success = false;
		}

		//Load tile map
		if (!setTiles())
		{
			printf("Failed to load tile set!\n");
			success = false;
		}
	}
	else
	{
		printf("Warning: Tile Texture and Set already Loaded!\n");
	}
	return success;
}
示例#3
0
void WallComponent::updateDisabled() {
	if(_prevEnabled) {
		setTiles(false);
	}

	_prevEnabled = false;
}
示例#4
0
void WallComponent::update() {
	if(!_prevEnabled) {
		setTiles(true);
	}

	_prevEnabled = true;
}
示例#5
0
文件: Floor.cpp 项目: Kloxx/LD35
Floor::Floor(SDL_Renderer* const& renderer, std::string const& tileSetPath, 
std::string const& mapPath) :
	m_renderer(renderer), m_tileSet(NULL), m_mapData(mapPath.c_str()), m_totalTiles(0)
{
	bool success = loadTexture(tileSetPath);
    assert( success );
	success = setTiles();
	assert( success );
}
示例#6
0
void ktSettings::setup()
{
    //we set the tile size to 4x4
    tileSizeX = 4;
    tileSizeY = 4;
    //init to 5x5 by default - this will be set through TCP feedback
    setTiles(5, 5);
    
    //tube soft settings
    tubeSpacing = 1.0f;
    tubeScaleX = 0.6f;
    tubeScaleY = 0.6f;
    tubeHeight = 5.0f;
    tubeMaxHeight = 10.0f;
    
    ofAddListener(ktEvent::events, this, &ktSettings::guiSettingsEvent);
}
示例#7
0
文件: base.cpp 项目: ohargro/capstone
void theGame()
{
    SDL_WM_SetCaption("WASD: Move, BACKSPACE: Start Screen, ENTER: Fullscreen", NULL);
    Sprite mew("testChar2.png", 32, 156, 0); //load mew and set R 32, G 156, B 0 to be transparent.  Set width to 33 and height to 69

    Tile *tiles[TOTAL_TILES];
    Enemy *enemies[TOTAL_ENEMIES];

    enemies[0] = new Enemy(225, 0, ENEMY_ROBOT);
    enemies[0]->setVelX(50);

    enemies[1] = new Enemy(225, 0, ENEMY_ROBOT);
    enemies[1]->setVelX(100);

    enemies[2] = new Enemy(225, 0, ENEMY_ANDROID);
    enemies[2]->setVelX(-75);

    bool playing = true;

    if(setTiles(tiles) == false)
    {
        cleanUp();
        exit(0);
    }

    //game loop
    delta.start();
    while(playing)
    {
        fps.start();
        while(SDL_PollEvent(&event))
        {
            mew.handle_input();
            myWindow.handle_window();
            handleMusic();

            if(event.key.keysym.sym == SDLK_BACKSPACE)
            {
                deleteTiles(tiles);
                deleteEnemies(enemies);
                startScreen();
            }
            if(event.type == SDL_QUIT)
                playing = false;
        }
        if (myWindow.error())
        {
            cleanUp();
            exit(0);
        }

        mew.move(delta.get_ticks(), tiles, enemies);

        for (int e = 0; e < TOTAL_ENEMIES; e++)
        {
            enemies[e]->walk(delta.get_ticks(), tiles);
        }

        delta.start(); //restart delta after movement
        mew.setCamera();

        for( int t = 0; t < TOTAL_TILES; t++ )
            tiles[t]->show();
        mew.show();
        for (int e = 0; e < TOTAL_ENEMIES; e++)
            enemies[e]->show();

        if(SDL_Flip(screen) == -1)
        {
            cleanUp();
            exit(0);
        }

        if(fps.get_ticks() < (1000 / FRAMES_PER_SECOND))
            SDL_Delay(1000 / FRAMES_PER_SECOND - fps.get_ticks());

    }

    deleteTiles(tiles);
    deleteEnemies(enemies);
    exit(0);
}