Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Fog of War  (Read 1815 times)

0 Members and 1 Guest are viewing this topic.

Strikerklm96

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Fog of War
« on: September 29, 2013, 05:41:48 pm »
I am making a multiplayer 2D game.
The world is made out of tiles(squares) which have a fixture, a sprite, and other data. My original plan was to have tiles color default to black if the players line of sight wasnt able to see the tile.(calculated using ray traces)
But that doesn't work for a multiplayer game, because if two people are on opposite sides of a wall, they will be able to see what the other can see.

One solution I came up with was that since each player will have his own window, if an object is raytraced by a certain player. Each tile has a true false value for each player that could or couldn't see it. So if player one sees it, the true false value for that player is set to true, while the others is false(since he can't see it) Later on, when each players window comes by to draw the tile, one players will draw it, and the others wont.

I posted because I wan't to know if there is a better solution.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Fog of War
« Reply #1 on: September 29, 2013, 10:31:34 pm »
Given the lack of answer I assume, people have difficulty understanding your question.

My original plan was to have tiles color default to black if the players line of sight wasnt able to see the tile.
So the player could only see like 5 tiles into the direction they are facing?

But that doesn't work for a multiplayer game, because if two people are on opposite sides of a wall, they will be able to see what the other can see.
What kind of multiplayer are you implementing then? If its in the same screen, yeah then it's normal that you'll see what the other player sees. If you're playing it over the network, then it doesn't make sense to render the lightning only once for both palyers, but each one should have their own game world rendering.
The same thing applies to multiple windows. You separate the game logic for each player.

One solution I came up with was that since each player will have his own window, if an object is raytraced by a certain player. Each tile has a true false value for each player that could or couldn't see it. So if player one sees it, the true false value for that player is set to true, while the others is false(since he can't see it) Later on, when each players window comes by to draw the tile, one players will draw it, and the others wont.

I posted because I wan't to know if there is a better solution.
[/quote]
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything