Skip to content

Commit

Permalink
add display build number
Browse files Browse the repository at this point in the history
removed vertical limit on rescue missions
  • Loading branch information
fallahn committed Sep 9, 2016
1 parent 00a7864 commit bde44c4
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 21 deletions.
2 changes: 2 additions & 0 deletions LunarMooner/include/BGStarfield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace lm
sf::FloatRect globalBounds() const override { return m_bounds; }

void setVelocity(const sf::Vector2f&);
void setSpeedRatio(float v) { m_speedRatio = std::abs(v); }

private:

Expand All @@ -73,6 +74,7 @@ namespace lm
}
};
std::vector<Star> m_stars;
float m_speedRatio;

sf::Vector2f m_position;
sf::Vector2f m_velocity;
Expand Down
3 changes: 2 additions & 1 deletion LunarMooner/include/CommandIds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ enum LMCommandID
UI = 0x20,
Item = 0x40,
DropShip = 0x80,
TerrainObject = 0x100
TerrainObject = 0x100,
Background = 0x200
};

enum LMInputFlags
Expand Down
4 changes: 4 additions & 0 deletions LunarMooner/include/MenuBackgroundState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ source distribution.
#include <xygine/ShaderResource.hpp>

#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Text.hpp>

namespace xy
{
Expand Down Expand Up @@ -64,13 +65,16 @@ class MenuBackgroundState final : public xy::State

xy::TextureResource m_textureResource;
xy::ShaderResource m_shaderResource;
xy::FontResource m_fontResource;
xy::SoundResource m_soundResource;
std::vector<std::string> m_musicFiles;

sf::Shader* m_normalMapShader;

void setup();

sf::Text m_versionText;

sf::Sprite m_loadingSprite;
void updateLoadingScreen(float, sf::RenderWindow&) override;
};
Expand Down
5 changes: 3 additions & 2 deletions LunarMooner/src/BGStarField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace

Starfield::Starfield(xy::MessageBus& mb, xy::TextureResource& tr)
: xy::Component (mb, this),
m_speedRatio (1.f),
m_velocity (1.f, 0.f),
m_starTexture (&tr.get("assets/images/background/star.png"))
{
Expand Down Expand Up @@ -86,12 +87,12 @@ Starfield::Starfield(xy::MessageBus& mb, xy::TextureResource& tr)
//public
void Starfield::entityUpdate(xy::Entity&, float dt)
{
m_position += m_velocity * dt * backgroundSpeed;
m_position += m_velocity * dt * backgroundSpeed * m_speedRatio;

m_vertices.clear();
for (auto& s : m_stars)
{
s.move(m_velocity * starSpeed * dt * s.depth);
s.move(m_velocity * starSpeed * m_speedRatio * dt * s.depth);

auto pos = s.getPosition();
if (pos.x < -10.f)
Expand Down
5 changes: 3 additions & 2 deletions LunarMooner/src/LMGameController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,13 +906,14 @@ void GameController::createTerrain()
entity->setPosition(alienArea.left + alienArea.width, 0.f);
m_scene.addEntity(entity, xy::Scene::Layer::BackRear);

collision = m_collisionWorld.addComponent(getMessageBus(), sizes[1], lm::CollisionComponent::ID::Bounds, true);
//top / bottom
/*collision = m_collisionWorld.addComponent(getMessageBus(), sizes[1], lm::CollisionComponent::ID::Bounds, true);
qtc = xy::Component::create<xy::QuadTreeComponent>(getMessageBus(), sizes[1]);
entity = xy::Entity::create(getMessageBus());
entity->addComponent(collision);
entity->addComponent(qtc);
entity->setPosition(alienArea.left, -40.f);
m_scene.addEntity(entity, xy::Scene::Layer::BackRear);
m_scene.addEntity(entity, xy::Scene::Layer::BackRear);*/

collision = m_collisionWorld.addComponent(getMessageBus(), sizes[1], lm::CollisionComponent::ID::Bounds, true);
qtc = xy::Component::create<xy::QuadTreeComponent>(getMessageBus(), sizes[1]);
Expand Down
26 changes: 25 additions & 1 deletion LunarMooner/src/LMPlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ source distribution.
#include <LMAsteroidController.hpp>
#include <LMAlienController.hpp>
#include <LMPlayerDrawable.hpp>
#include <BGStarfield.hpp>
#include <CommandIds.hpp>
#include <Game.hpp>

#include <xygine/Entity.hpp>
#include <xygine/Scene.hpp>
#include <xygine/util/Vector.hpp>
#include <xygine/util/Rectangle.hpp>
#include <xygine/Reports.hpp>
Expand Down Expand Up @@ -279,7 +281,9 @@ void PlayerController::collisionCallback(CollisionComponent* cc)

m_entity->move(normal * manifold.z);
m_velocity = xy::Util::Vector::reflect(m_velocity, normal);
m_velocity *= damping;
m_velocity *= 0.3f;// damping;
//auto force = normal * manifold.z * 0.9f;// damping;
//m_velocity += force;
}
break;
case CollisionComponent::ID::Mothership:
Expand Down Expand Up @@ -504,6 +508,26 @@ void PlayerController::flyingState(xy::Entity& entity, float dt)
//move ship
entity.move(m_velocity * dt);

//if our position < someval vertically, move the camera & background
if (entity.getPosition().y < 100.f)
{
xy::Command cmd;
cmd.category = LMCommandID::Background;
cmd.action = [this](xy::Entity& e, float dt)
{
e.move(0.f, m_velocity.y * dt);

//REPORT("Speed", std::to_string(m_velocity.y));

if (auto stars = e.getComponent<Starfield>())
{
stars->setVelocity({ 0.f, m_velocity.y });
stars->setSpeedRatio(m_velocity.y / 400.f);
}
};
entity.getScene()->sendCommand(cmd);
}

//see if we're near the gound and do a collision check
auto position = entity.getPosition();
if (position.y > m_highestTerrainPoint)
Expand Down
4 changes: 3 additions & 1 deletion LunarMooner/src/LMPlayerInfoDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ void ScoreDisplay::draw(sf::RenderTarget& rt, sf::RenderStates states) const
{
rt.draw(s, states);
}
rt.draw(m_activePlayerSprite, sf::BlendAdd);
states.blendMode = sf::BlendAdd;
rt.draw(m_activePlayerSprite, states);
states.blendMode = sf::BlendAlpha;

if(m_showMessage) rt.draw(m_messageText, states);

Expand Down
22 changes: 13 additions & 9 deletions LunarMooner/src/LMState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,21 +920,24 @@ void LunarMoonerState::buildBackground()
};
fw->addMessageHandler(mh);

auto entity = xy::Entity::create(m_messageBus);
entity->addComponent(ne);
entity->addComponent(nukeAudio);
entity->addComponent(finalWarning);
entity->setPosition(xy::DefaultSceneSize / 2.f);
m_scene.setActiveCamera(entity->addComponent(camera));
m_scene.addEntity(entity, xy::Scene::Layer::FrontFront);
auto camEntity = xy::Entity::create(m_messageBus);
camEntity->addComponent(ne);
camEntity->addComponent(nukeAudio);
camEntity->addComponent(finalWarning);
camEntity->setPosition(xy::DefaultSceneSize / 2.f);
camEntity->addCommandCategories(LMCommandID::Background);
m_scene.setActiveCamera(camEntity->addComponent(camera));
m_scene.addEntity(camEntity, xy::Scene::Layer::FrontFront);

//background
auto background = xy::Component::create<lm::Starfield>(m_messageBus, m_resources.textureResource);
background->setVelocity({ 0.f, 1.f });
auto scoreMask = xy::Component::create<lm::ScoreMask>(m_messageBus, alienArea, m_resources.textureResource.get("assets/images/game/console/panel.png"));

m_scene.getLayer(xy::Scene::Layer::BackRear).addComponent(background);
m_scene.getLayer(xy::Scene::Layer::BackRear).addCommandCategories(LMCommandID::Background);
m_scene.getLayer(xy::Scene::Layer::UI).addComponent(scoreMask);
m_scene.getLayer(xy::Scene::Layer::UI).addCommandCategories(LMCommandID::Background);

auto moon = xy::Component::create<lm::PlanetDrawable>(m_messageBus, moonWidth);
moon->setBaseNormal(m_resources.textureResource.get("assets/images/background/sphere_normal.png"));
Expand All @@ -945,10 +948,10 @@ void LunarMoonerState::buildBackground()
moon->setNormalShader(m_resources.shaderResource.get(Shader::NormalMapPlanet));
moon->setRotationVelocity({ 0.f, 0.009f });

entity = xy::Entity::create(m_messageBus);
auto entity = xy::Entity::create(m_messageBus);
entity->setPosition((xy::DefaultSceneSize.x / 2.f) - (moonWidth), xy::DefaultSceneSize.y / 2.f);
entity->addComponent(moon);
m_scene.addEntity(entity, xy::Scene::Layer::BackRear);
m_scene.addEntity(entity, xy::Scene::Layer::BackMiddle);

//background lighting
auto lc = xy::Component::create<xy::PointLight>(m_messageBus, 1200.f, 250.f);
Expand All @@ -959,6 +962,7 @@ void LunarMoonerState::buildBackground()
entity = xy::Entity::create(m_messageBus);
entity->setPosition(alienArea.left + alienArea.width, xy::DefaultSceneSize.y / 2.f);
entity->addComponent(lc);

m_scene.addEntity(entity, xy::Scene::Layer::FrontFront);
}

Expand Down
9 changes: 8 additions & 1 deletion LunarMooner/src/MenuBackgroundState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ source distribution.
namespace
{
const float maxMusicVol = 35.f;
const std::string version = "0.1." + std::string(__TIME__) + __DATE__;
}

MenuBackgroundState::MenuBackgroundState(xy::StateStack& ss, Context context)
Expand All @@ -74,6 +75,11 @@ MenuBackgroundState::MenuBackgroundState(xy::StateStack& ss, Context context)
m_normalMapShader = &m_shaderResource.get(Shader::NormalMapPlanet);
m_normalMapShader->setUniform("u_ambientColour", sf::Glsl::Vec3(0.03f, 0.03f, 0.01f));

m_versionText.setPosition(20.f, xy::DefaultSceneSize.y - 40.f);
m_versionText.setString(version);
m_versionText.setCharacterSize(26u);
m_versionText.setFont(m_fontResource.get("version_font"));

setup();

quitLoadingScreen();
Expand Down Expand Up @@ -119,7 +125,8 @@ void MenuBackgroundState::draw()
{
auto& rw = getContext().renderWindow;
rw.draw(m_scene);
//rw.setView(getContext().defaultView);
rw.setView(getContext().defaultView);
rw.draw(m_versionText);
}

bool MenuBackgroundState::handleEvent(const sf::Event&)
Expand Down
8 changes: 4 additions & 4 deletions LunarMooner/src/MenuPauseState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void MenuPauseState::buildMenu(const sf::Font& font)
auto button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
button->setText("Continue");
button->setAlignment(xy::UI::Alignment::Centre);
button->setPosition(centreX, 475.f);
button->setPosition(centreX, 425.f);
button->addCallback([this]()
{
close();
Expand All @@ -134,7 +134,7 @@ void MenuPauseState::buildMenu(const sf::Font& font)
button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
button->setText("Options");
button->setAlignment(xy::UI::Alignment::Centre);
button->setPosition(centreX, 575.f);
button->setPosition(centreX, 525.f);
button->addCallback([this]()
{
close();
Expand All @@ -145,7 +145,7 @@ void MenuPauseState::buildMenu(const sf::Font& font)
button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
button->setText("Quit to Main");
button->setAlignment(xy::UI::Alignment::Centre);
button->setPosition(centreX, 675.f);
button->setPosition(centreX, 625.f);
button->addCallback([this]()
{
close();
Expand All @@ -157,7 +157,7 @@ void MenuPauseState::buildMenu(const sf::Font& font)
button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
button->setText("Exit to Desktop");
button->setAlignment(xy::UI::Alignment::Centre);
button->setPosition(centreX, 775.f);
button->setPosition(centreX, 725.f);
button->addCallback([this]()
{
xy::App::quit();
Expand Down

0 comments on commit bde44c4

Please sign in to comment.