当前位置: 首页>>代码示例>>C++>>正文


C++ Level::GetAllObjects方法代码示例

本文整理汇总了C++中Level::GetAllObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ Level::GetAllObjects方法的具体用法?C++ Level::GetAllObjects怎么用?C++ Level::GetAllObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Level的用法示例。


在下文中一共展示了Level::GetAllObjects方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Player

	Player:: Player(String F, Level &lev, float X, float Y, float W, float H, float pX, float pY): Furniture(F, X,  Y, W,  H,  pX, pY)
{
	obj = lev.GetAllObjects();
	dx = 0;
	dy = 0;
	speed = 0;
	wrongPlace = false;
	room = 0;
}
开发者ID:DariaDar,项目名称:Reposit,代码行数:9,代码来源:Player.cpp

示例2: Subject

Enemy::Enemy(Image &image, Level &level, float X, float Y,
             float Width, float Height):
    Subject(image, X, Y, Width, Height)
{
    obj = level.GetAllObjects();
    sprite.setTextureRect(IntRect(0, 0, width, height));
    speed = 0.08;
    speed_x = 0.08;
    stateEnemy = true;//1- right, 0-left
}
开发者ID:gribo4eg,项目名称:repos1,代码行数:10,代码来源:enemyClass.cpp

示例3:

Gravitation::Gravitation(sf::Sprite sp, Level &lev, float dx, float dy, int W, int H, float X, float Y, float t) {
	object = lev.GetAllObjects();
	dx = 0;
	dy = 0;
	sprite = sp;
	time = t;
	w = W; h = H;
	x = X; y = Y;
	sprite.setTextureRect(sf::IntRect(0, 0, w, h));
}
开发者ID:kychka,项目名称:sfml-game-test,代码行数:10,代码来源:gravitation.cpp

示例4: Entity

Player::Player(Image &image, String name, Level lvl, FloatRect rect) : Entity(image, name, rect) {
	sprite.setTextureRect(IntRect(0, 0, int(PLAYER_SPRITE_BOUND), int(PLAYER_SPRITE_BOUND)));
	sprite.setPosition(rect.left, rect.top);
	action = down;
	obj = lvl.GetAllObjects();
	health = COUNT_PLAYER_HEALTH;
	armor = COUNT_PLAYER_HEALTH;
	missionComplete = false; 
	flag = false; 

	parachute = make_unique<Parachute>();
}
开发者ID:oMystique,项目名称:IIP,代码行数:12,代码来源:player_init.cpp

示例5: setOrigin

	_Mouse:: _Mouse(String F, Level &lev, float X, float Y, float W, float H, float pX, float pY)
	{
		x = pX; y = pY; w = W; h = H;
		image.loadFromFile("images/" + F);
		texture.loadFromImage(image);
		sprite.setTexture(texture);
		sprite.setTextureRect(IntRect((int)X,(int)Y,(int)w,(int)h));
		sprite. setOrigin(w / 2, h / 2);
		obj = lev.GetAllObjects();
		dx = 0;
		dy = 0;
		speed = 0;
		rightPlace = false;
		life = true;
		health = 50;
	}
开发者ID:DariaDar,项目名称:Reposit,代码行数:16,代码来源:Mouse.cpp

示例6:

Player::Player(sf::Image &image, sf::String Name, Level &lev, float X, float Y, float W, float H) :Entity(image, Name, X, Y, W, H) {
    CurrentFrame = 0;
    state = stay;
    obj = lev.GetAllObjects();   //получаем все объкты с карты
    if(name == "Hero") {
        if(heroWithPick == true) {
            sprite.setTextureRect(sf::IntRect(0,0,w,h));
        }
        if(heroWithSword == true) {
            sprite.setTextureRect(sf::IntRect(0,518,w,h));
        }
        if(normalHero == true) {
            sprite.setTextureRect(sf::IntRect(0,326,w,h));
        }
    }
}
开发者ID:AndrienkoF,项目名称:KPIRepo,代码行数:16,代码来源:classPlayer.cpp

示例7: Entity

Player::Player(Image &image, String Name, Level &level, float X, float Y, int W, int H) : Entity(image, Name, X, Y, W, H)
{
	playerScore = 0;
	state = right;
	obj = level.GetAllObjects();
	current_frame = 0;
	lives = 3;
	jump_sound_buffer.loadFromFile("music/jump.ogg");
	jump_sound.setBuffer(jump_sound_buffer);
	boost = 0;
	offset = { 0, h };
	scale = 1;
	isMove = false;
	if (name == "P1")
	{
		sprite.setTextureRect(IntRect(0, 0, w, h));
	}
}
开发者ID:MihaChug,项目名称:Game,代码行数:18,代码来源:player_init.cpp

示例8:

	PLAYER(AnimationManager &a, Level &lev,int x,int y):Entity(a,x,y)
	{
		option("Player",0,100,"stay");
        STATE=stay; hit=false;
		obj = lev.GetAllObjects();
	}
开发者ID:lemeshkob,项目名称:Repo1,代码行数:6,代码来源:Player.hpp

示例9: StartGame

bool StartGame(RenderWindow & window, Game & game)
{
	Level lvl;
	lvl.LoadFromFile(GetLevelNumb(game));
	Image image;
	Texture texture;
	if (!image.loadFromFile("images/lvl1.png"))
		cout << "Error loading image from file " << endl;
	image.createMaskFromColor(Color(0, 128, 0));
	if (!texture.loadFromImage(image))
		cout << "Error loading texture from image " << endl;

	Sprite heartSprite;
	heartSprite.setTexture(texture);
	heartSprite.setTextureRect(IntRect(395, 151, 54, 46));
	heartSprite.setScale(0.3f, 0.3f);

	Sprite lifeSprite;
	lifeSprite.setTexture(texture);
	lifeSprite.setTextureRect(IntRect(457, 149, 29, 29));
	lifeSprite.setScale(0.8f, 0.8f);

	Font font;
	font.loadFromFile("fonts/pixel.ttf");
	Text text("", font, 25);

	game.graphic.statistic.heart = heartSprite;
	game.graphic.statistic.life = lifeSprite;
	game.graphic.text = text;
	game.isPause = true;
	game.restart = false;

	vector <Enemy*>  enemies;
	std::vector<Object> e = lvl.GetObjects("easyEnemy");
	for (Object i : e)
		enemies.push_back(new Enemy(texture, "easyEnemy", i.rect.left, i.rect.top, 53, 28));

	e = lvl.GetObjects("flyEnemy");
	for (Object i : e)
		enemies.push_back(new Enemy(texture, "flyEnemy", i.rect.left, i.rect.top, 38, 36));
	
	
	if (lvl.IsExist("trap"))
	{
		e = lvl.GetObjects("trap");
		for (Object i : e)
			enemies.push_back(new Enemy(texture, "trap", i.rect.left, i.rect.top, 32, 18));
	}


	vector <Portal*> portals;
	vector <Bullet*> bullets;
	vector <Object> objects = lvl.GetAllObjects();
	Clock clock;

	SoundBuffer shootBuffer;
	shootBuffer.loadFromFile("sound/shoot.wav");
	Sound shoot(shootBuffer);

	SoundBuffer portalBuffer;
	portalBuffer.loadFromFile("sound/portal.wav");
	Sound portal(portalBuffer);

	SoundBuffer teleportBuffer;
	teleportBuffer.loadFromFile("sound/teleport.wav");
	Sound teleport(teleportBuffer);

	SoundBuffer damageBuffer;
	damageBuffer.loadFromFile("sound/damage.wav");
	Sound damage(damageBuffer);

	SoundBuffer deathBuffer;
	deathBuffer.loadFromFile("sound/damage.wav");
	Sound gameOver(deathBuffer);

	Music music;
	music.openFromFile("sound/musicGame.ogg");
	music.play();

	Object playerObject = lvl.GetObject("player");
	Player player(texture, "Player1", playerObject.rect.left, playerObject.rect.top, 32, 32);
	player.health = game.health;
	player.heart = game.hearts;

	while (window.isOpen() && (!game.restart))
	{
		float time = float(clock.getElapsedTime().asMicroseconds());
		clock.restart();
		time = time / 800;
		Event event;
		Vector2i pixelPos = Mouse::getPosition(window);
		Vector2f pos = window.mapPixelToCoords(pixelPos);
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed || (Keyboard::isKeyPressed(Keyboard::Escape) && game.isPause))
			{
				window.close();
				game.restart = false;
			}
			if (event.type == Event::MouseButtonPressed)
//.........这里部分代码省略.........
开发者ID:Lokdemok,项目名称:Informatics-and-Programming,代码行数:101,代码来源:main.cpp


注:本文中的Level::GetAllObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。