本文整理汇总了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;
}
示例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
}
示例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));
}
示例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>();
}
示例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;
}
示例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));
}
}
}
示例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));
}
}
示例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();
}
示例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)
//.........这里部分代码省略.........