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

Add multiplayer-bomber example. #910

Closed

Conversation

Yarwin
Copy link
Contributor

@Yarwin Yarwin commented Oct 2, 2024

closes: #903
A demo adapted from: https://github.com/godotengine/godot-demo-projects/tree/master/networking/multiplayer_bomber

I took few liberties, mostly related to caching references to nodes in the scene tree by using OnReady, using signals instead of parsing tree in process, and declaring gamestate autoload as engine singleton.

@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-910

@Yarwin Yarwin force-pushed the add_bomberman_multiplayer_example branch from f2a0b02 to d24ad70 Compare October 2, 2024 10:32
@ValorZard
Copy link

ValorZard commented Oct 5, 2024

Still getting this error on this pull request:

  <C++ Error>    Condition "true" is true. Continuing.
  <C++ Source>   modules/multiplayer/scene_replication_interface.cpp:782 @ on_delta_receive()

Additionally, for some reason the tile map isn't showing up properly

E 0:00:21:0723   create_tile: Cannot create tile. The tile is outside the texture or tiles are already present in the space the tile would cover.
  <C++ Error>    Condition "!room_for_tile" is true.
  <C++ Source>   scene/resources/2d/tile_set.cpp:4963 @ create_tile()

image

On further testing, this additional error popped up, which is probably a typo

E 0:00:10:0292   get_state: Property '.:player_idx' not found.
  <C++ Error>    Condition "!valid" is true. Returning: ERR_INVALID_DATA
  <C++ Source>   modules/multiplayer/multiplayer_synchronizer.cpp:167 @ get_state()

@Yarwin
Copy link
Contributor Author

Yarwin commented Oct 5, 2024

ah, my bad – I forget to update property in the editor in the gdext project (done it only on a copy outside the repo 😬)

output.mp4

@ValorZard
Copy link

ValorZard commented Oct 6, 2024

Update: everything works now, but the missing tilemap issue is still there
image

@Yarwin Yarwin force-pushed the add_bomberman_multiplayer_example branch from 3c3293e to 68a6ff1 Compare October 6, 2024 20:55
@Bromeon Bromeon added feature Adds functionality to the library c: examples Code specific to examples changed (not just follow-up from API updates) labels Oct 9, 2024
@Yarwin Yarwin force-pushed the add_bomberman_multiplayer_example branch 4 times, most recently from 16fb1af to e4f6b4c Compare January 3, 2025 20:40
@Yarwin Yarwin force-pushed the add_bomberman_multiplayer_example branch from e4f6b4c to fe521ea Compare January 3, 2025 20:45
@Yarwin
Copy link
Contributor Author

Yarwin commented Jan 3, 2025

I changed some assets in cases where their source couldn't be properly determined and added proper information about license otherwise;

I couldn't determine source of explosion.png and rock_bit.png but I do believe they were created specifically for this example.

@Yarwin
Copy link
Contributor Author

Yarwin commented Jan 4, 2025

It seems that adding this example breaks check.sh. Running it fails at cargo clippy stage with following errors:

gdext$ ./check.sh
> cargo fmt --all -- --check
> cargo clippy --all-targets --no-default-features -- -D clippy::suspicious -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings

()
error[E0432]: unresolved imports `godot::classes::PhysicsRayQueryParameters2D`, `godot::classes::TileMap`
 --> examples/multiplayer-bomber/rust/src/bomb.rs:8:30
  |
8 | use godot::classes::{Area2D, PhysicsRayQueryParameters2D, TileMap};
  |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^ no `TileMap` in `classes`
  |                              |
  |                              no `PhysicsRayQueryParameters2D` in `classes`

error[E0432]: unresolved imports `godot::classes::IMultiplayerSpawner`, `godot::classes::MultiplayerSpawner`
  --> examples/multiplayer-bomber/rust/src/bomb_spawner.rs:11:22
   |
11 | use godot::classes::{IMultiplayerSpawner, MultiplayerSpawner};
   |                      ^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^ no `MultiplayerSpawner` in `classes`
   |                      |
   |                      no `IMultiplayerSpawner` in `classes`

error[E0432]: unresolved imports `godot::classes::ENetMultiplayerPeer`, `godot::classes::MultiplayerApi`
  --> examples/multiplayer-bomber/rust/src/game_state.rs:16:22
   |
16 | use godot::classes::{ENetMultiplayerPeer, Engine, Marker2D, MultiplayerApi};
   |                      ^^^^^^^^^^^^^^^^^^^                    ^^^^^^^^^^^^^^ no `MultiplayerApi` in `classes`
   |                      |
   |                      no `ENetMultiplayerPeer` in `classes`

error[E0432]: unresolved imports `godot::classes::AcceptDialog`, `godot::classes::ItemList`, `godot::classes::LineEdit`, `godot::classes::MultiplayerApi`, `godot::classes::Panel`
  --> examples/multiplayer-bomber/rust/src/lobby.rs:14:5
   |
14 |     AcceptDialog, Button, Control, IControl, ItemList, Label, LineEdit, MultiplayerApi, Os, Panel,
   |     ^^^^^^^^^^^^                             ^^^^^^^^         ^^^^^^^^  ^^^^^^^^^^^^^^      ^^^^^ no `Panel` in `classes`
   |     |                                        |                |         |
   |     |                                        |                |         no `MultiplayerApi` in `classes`
   |     |                                        |                no `LineEdit` in `classes`
   |     |                                        no `ItemList` in `classes`
   |     no `AcceptDialog` in `classes`

error[E0432]: unresolved imports `godot::classes::AnimationPlayer`, `godot::classes::CharacterBody2D`, `godot::classes::ICharacterBody2D`, `godot::classes::MultiplayerApi`, `godot::classes::MultiplayerSynchronizer`
  --> examples/multiplayer-bomber/rust/src/player.rs:16:5
   |
16 |     AnimationPlayer, CharacterBody2D, ICharacterBody2D, Label, MultiplayerApi,
   |     ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^         ^^^^^^^^^^^^^^ no `MultiplayerApi` in `classes`
   |     |                |                |
   |     |                |                no `ICharacterBody2D` in `classes`
   |     |                no `CharacterBody2D` in `classes`
   |     no `AnimationPlayer` in `classes`
17 |     MultiplayerSynchronizer,
   |     ^^^^^^^^^^^^^^^^^^^^^^^ no `MultiplayerSynchronizer` in `classes`

error[E0432]: unresolved imports `godot::classes::AnimationPlayer`, `godot::classes::CharacterBody2D`
 --> examples/multiplayer-bomber/rust/src/rock.rs:3:22
  |
3 | use godot::classes::{AnimationPlayer, CharacterBody2D};
  |                      ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^ no `CharacterBody2D` in `classes`
  |                      |
  |                      no `AnimationPlayer` in `classes`

error[E0432]: unresolved imports `godot::classes::HBoxContainer`, `godot::classes::IHBoxContainer`
 --> examples/multiplayer-bomber/rust/src/score.rs:4:22
  |
4 | use godot::classes::{HBoxContainer, IHBoxContainer, Label};
  |                      ^^^^^^^^^^^^^  ^^^^^^^^^^^^^^ no `IHBoxContainer` in `classes`
  |                      |
  |                      no `HBoxContainer` in `classes`

error[E0433]: failed to resolve: could not find `unsafe_inherits_transitive_MultiplayerSpawner` in `class_macros`
  --> examples/multiplayer-bomber/rust/src/bomb_spawner.rs:62:20
   |
62 | #[class(init, base=MultiplayerSpawner)]
   |                    ^^^^^^^^^^^^^^^^^^ could not find `unsafe_inherits_transitive_MultiplayerSpawner` in `class_macros`

error[E0433]: failed to resolve: could not find `unsafe_inherits_transitive_CharacterBody2D` in `class_macros`
  --> examples/multiplayer-bomber/rust/src/player.rs:23:20
   |
23 | #[class(init, base=CharacterBody2D)]
   |                    ^^^^^^^^^^^^^^^ could not find `unsafe_inherits_transitive_CharacterBody2D` in `class_macros`

error[E0433]: failed to resolve: could not find `unsafe_inherits_transitive_CharacterBody2D` in `class_macros`
 --> examples/multiplayer-bomber/rust/src/rock.rs:7:20
  |
7 | #[class(init, base=CharacterBody2D)]
  |                    ^^^^^^^^^^^^^^^ could not find `unsafe_inherits_transitive_CharacterBody2D` in `class_macros`

error[E0433]: failed to resolve: could not find `unsafe_inherits_transitive_HBoxContainer` in `class_macros`
  --> examples/multiplayer-bomber/rust/src/score.rs:26:20
   |
26 | #[class(init, base=HBoxContainer)]
   |                    ^^^^^^^^^^^^^ could not find `unsafe_inherits_transitive_HBoxContainer` in `class_macros`

error[E0412]: cannot find type `MultiplayerSpawner` in module `godot::classes`
  --> examples/multiplayer-bomber/rust/src/bomb_spawner.rs:62:20
   |
62 | #[class(init, base=MultiplayerSpawner)]
   |                    ^^^^^^^^^^^^^^^^^^ not found in `godot::classes`

error[E0412]: cannot find type `CharacterBody2D` in module `godot::classes`
  --> examples/multiplayer-bomber/rust/src/player.rs:23:20
   |
23 | #[class(init, base=CharacterBody2D)]
   |                    ^^^^^^^^^^^^^^^ not found in `godot::classes`

error[E0412]: cannot find type `CharacterBody2D` in module `godot::classes`
 --> examples/multiplayer-bomber/rust/src/rock.rs:7:20
  |
7 | #[class(init, base=CharacterBody2D)]
  |                    ^^^^^^^^^^^^^^^ not found in `godot::classes`

error[E0412]: cannot find type `HBoxContainer` in module `godot::classes`
  --> examples/multiplayer-bomber/rust/src/score.rs:26:20
   |
26 | #[class(init, base=HBoxContainer)]
   |                    ^^^^^^^^^^^^^ not found in `godot::classes`

Some errors have detailed explanations: E0412, E0432, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `multiplayer-bomber` (lib) due to 15 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `multiplayer-bomber` (lib test) due to 15 previous errors

=====================
gdext: checks FAILED.
=====================

I'm not sure how should I proceed in this case.

- Add comment clarifying purpose of usage of the `experimental-godot-api` feature
@Yarwin
Copy link
Contributor Author

Yarwin commented Jan 25, 2025

closed in favor of godot-rust/demo-projects#1

@Yarwin Yarwin closed this Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: examples Code specific to examples changed (not just follow-up from API updates) feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example on how to use Godot Rust with godot's multiplayer API
4 participants