Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-414] add bush mechanic #417

Merged
merged 18 commits into from May 7, 2024
Merged

[GH-414] add bush mechanic #417

merged 18 commits into from May 7, 2024

Conversation

agustinesco
Copy link
Contributor

@agustinesco agustinesco commented Mar 25, 2024

Closes #414

Now we'll have a new entity type called "Bush" that will work as a non collisionable entity to hide players from other players

The bushes will hide players under the following conditions:

  1. Players inside the bush can always see players outside the bush
  2. Players outside a bush can't see players inside of a bush
  3. If two or more players are inside of the same bush they can only see each other when they're close enough

To tests this pr:

  1. add this shape to the bushes array in the config.json file
middle bush
       {
        "position": {
          "x": 0.0,
          "y": 0.0
        },
        "vertices": [
          {
            "x": 0.0,
            "y": 1000.0
          },
          {
            "x": 1000.0,
            "y": 0.0
          },
          {
            "x": 0.0,
            "y": -1000.0
          },
          {
            "x": -1000.0,
            "y": 0.0
          }
        ],
        "radius": 0.0,
        "shape": "polygon"
      }
  1. on game_launcher.ex change this: @clients_needed 2
  2. on game_updater.ex handle_info(:update_game, %{game_state: game_state} = state) do before the last line add:
Enum.each(game_state.players, fn {player_id, player} ->
  IO.inspect(player.aditional_info.visible_players, label: "visible players for: #{player_id}")
end)

Now start a match in the game client goin to this link and you should see the visible players in the game terminal, when the bot steps on the bush while chasing you, you should disappear from the bot visible players list, something like:

visible players for: 1: []
visible players for: 2: [1]

You can also test this opening two game client windows and play around the bush

@agustinesco agustinesco changed the title [GH 414 add bush mechanic [GH-414] add bush mechanic Mar 25, 2024
@agustinesco agustinesco marked this pull request as draft March 25, 2024 19:15
@agustinesco agustinesco marked this pull request as ready for review May 2, 2024 15:20
Copy link
Contributor

@lotuuu lotuuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality looked good by following the steps you gave! Leaving a small code comment


if candidate_player.id != player_id and
(Enum.empty?(candidate_bush_collisions) or (players_in_same_bush? and players_close_enough?)) do
acc ++ [candicandidate_player_id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no reason not to use [candidate_player_id | acc] here, right?

It's the better option out of the two, as per ++ docs, and I don't think we care about what order these players are on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, not reason at all. Changed!

Also i noticed we're doing extra checks since we're running the checks for the same player, i moved the ifs a little bit so we dont do extra calculations

@lotuuu
Copy link
Contributor

lotuuu commented May 6, 2024

Also please add the steps for testing the PR that you sent me via slack in the description!

@agustinesco
Copy link
Contributor Author

Also please add the steps for testing the PR that you sent me via slack in the description!

yes! sorry i forgot about that, added

Copy link
Contributor

@tvillegas98 tvillegas98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Although I want to know why instead of implementing something like "Hey I'm on this bush, is there someone else here with me? we implemented something like “Hey, who am I seeing?”

apps/serialization/messages.proto Show resolved Hide resolved
@tvillegas98 tvillegas98 merged commit b2b1c2a into main May 7, 2024
1 check passed
@tvillegas98 tvillegas98 deleted the gh-414-add-bush-mechanic branch May 7, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bush mechanic
3 participants