Skip to content

Instantly share code, notes, and snippets.

@David-Mimnagh
Created December 8, 2014 18:33
Show Gist options
  • Save David-Mimnagh/cea8bc251f4008ffd304 to your computer and use it in GitHub Desktop.
Save David-Mimnagh/cea8bc251f4008ffd304 to your computer and use it in GitHub Desktop.
void GameState::inrange_lights()
{
//do comparison code in here
/*
if the player is within the light
then take that lights x and y pos & compare that wil all other lights returning distance_between
if the distance_between is < 300
draw a shadow within that light
else
move on to the next light
set that light to not being in range;
*/
for (auto& light : lights_)
{
if (light.can_teleport() == true)
{
if (lights_.at(i).Shape().getOrigin().x - light.Shape().getOrigin().x < 300 &&
lights_.at(i).Shape().getOrigin().y - light.Shape().getOrigin().y < 300)
{
light.inrange_light();
}
else
{
!light.inrange_light();
}
}
}
}
void GameState::render()
{
sf::RenderWindow& window = state_manager_.get_render_window();
window.draw(player_.Shape());
for (const auto& light : lights_)
{
window.draw(light.Shape());
for (auto& shadow : shadows_)
{
if (light.inrange_light() == true);
shadow.Shape().setPosition(lights_.at(i).Shape().getPosition());
window.draw(shadow.Shape());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment