Skip to content

Commit

Permalink
Add multiplayer-bomber example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarwin committed Jan 3, 2025
1 parent 8a62088 commit fe521ea
Show file tree
Hide file tree
Showing 30 changed files with 2,213 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"itest/repo-tweak",
"examples/dodge-the-creeps/rust",
"examples/hot-reload/rust",
"examples/multiplayer-bomber/rust",
]

# Note about Jetbrains IDEs: "IDE Sync" (Refresh Cargo projects) may cause static analysis errors such as
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
res://rust.gdextension
28 changes: 28 additions & 0 deletions examples/multiplayer-bomber/godot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Multiplayer Bomber Example

A multiplayer implementation of the classic bomberman game.
One of the players should press **Host**, while other player(s)
should type in the host's IP address and press **Join**.

Based on: https://github.com/godotengine/godot-demo-projects/tree/master/networking/multiplayer_bomber

Language: Rust

Renderer: Compatibility

## Controls

WSAD to move
CTRL to plant bomb


## Copying

George (`assets/chatwalk`) is an alternate LCP character by [sheep](https://opengameart.org/users/sheep), from [OpenGameArt.org](https://opengameart.org/content/alternate-lpc-character-sprites-george). CC-BY 3.0, CC-BY-SA 3.0, GPL 3.0

Bomb - Matt Hackett of Lost Decade Games, expanded by Cem Kalyoncu; CC-BY 3.0

"[LPC] Rocks" by bluecarrot16, Johann Charlot, Yar, Hyptosis, Evert, Lanea Zimmerman (Sharm), Guillaume Lecollinet, Richard Kettering (Jetrel), Zachariah Husiar (Zabin), Jetrel, Hyptosis, Redshrike, Rayane Félix (RayaneFLX), Michele Bucelli (Buch) <https://opengameart.org/users/buch>
"[LPC] Walls" by bluecarrot16, Lanea Zimmerman (Sharm), Daniel Armstrong (HughSpectrum), William Thompson (William.Thompsonj), Hyptosis, Zabin, Daniel Cook, Guido Bos, SpiderDave, Cougarmint, Stephen Challener (Redshrike), Matthew Nash, Wolthera van Hövell tot Westerflier (TheraHedwig), Reemax, bleutailfly, NaRNeRZz, Sir Spummington, Casper Nilsson, KnoblePersona. CC-BY-SA 3.0.
"[LPC] Floors" by bluecarrot16, Lanea Zimmerman (Sharm), William Thompson (William.Thompsonj), Hyptosis, SpiderDave, Cougarmint, Stephen Challener (Redshrike), Bonsaiheldin, Tyler Olsen (Roots), Jetrel, jestan, The Open Surge team (http://opensnc.sourceforge.net), Gaurav Munjal, Reemax, Silveira Neto, bleutailfly, Casper Nilsson, NaRNeRZz, Buch, keith karnage, Arthur Carvalho, Guilherme Vieira (n2liquid), Chris Hamons (maintainer). CC-BY-SA 4.0

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/multiplayer-bomber/godot/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions examples/multiplayer-bomber/godot/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=5

[application]

config/name="GodotRustMultiplayerExample"
run/main_scene="res://src/game/lobby.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility")
config/icon="res://icon.svg"

[autoload]

gamestate="*res://src/game/gamestate.tscn"

[input]

Fire={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}
jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
]
}
move_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
]
}
move_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
]
}
set_bomb={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}

[layer_names]

2d_physics/layer_1="collisions"
2d_physics/layer_2="explodable"

[rendering]

renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
15 changes: 15 additions & 0 deletions examples/multiplayer-bomber/godot/rust.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[configuration]
entry_symbol = "gdext_rust_init"
compatibility_minimum = 4.1

[libraries]
linux.debug.x86_64 = "res://../../../target/debug/libmultiplayer_bomber.so"
linux.release.x86_64 = "res://../../../target/release/libmultiplayer_bomber.so"
windows.debug.x86_64 = "res://../../../target/debug/multiplayer_bomber.dll"
windows.release.x86_64 = "res://../../../target/release/multiplayer_bomber.dll"
macos.debug = "res://../../../target/debug/libmultiplayer_bomber.dylib"
macos.release = "res://../../../target/release/libmultiplayer_bomber.dylib"
macos.debug.arm64 = "res://../../../target/debug/libmultiplayer_bomber.dylib"
macos.release.arm64 = "res://../../../target/release/libmultiplayer_bomber.dylib"
web.debug.wasm32 = "res://../../../target/wasm32-unknown-emscripten/debug/multiplayer_bomber.wasm"
web.release.wasm32 = "res://../../../target/wasm32-unknown-emscripten/release/multiplayer_bomber.wasm"
130 changes: 130 additions & 0 deletions examples/multiplayer-bomber/godot/src/entities/bomb.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[gd_scene load_steps=8 format=3 uid="uid://enwoaqi0rnei"]

[ext_resource type="Texture2D" uid="uid://cb1y8d1bbygtk" path="res://assets/brickfloor.png" id="2"]
[ext_resource type="Texture2D" uid="uid://dkhnmbca25hmy" path="res://assets/explosion.png" id="3"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_1ih13"]
size = Vector2(16, 192)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_whso6"]
size = Vector2(192, 16)

[sub_resource type="Curve" id="Curve_4yges"]
max_value = 2.0
_data = [Vector2(0.00150494, 0.398437), 0.0, 0.0, 0, 0, Vector2(0.0152287, 1.42969), 0.0, 0.0, 0, 0, Vector2(0.478607, 1.30078), 0.0, 0.0, 0, 0, Vector2(1, 0.291016), 0.0, 0.0, 0, 0]
point_count = 4

[sub_resource type="Animation" id="Animation_21j5c"]
length = 4.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:self_modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.4, 0.6, 0.8, 1.1, 1.3, 1.5, 1.8, 1.9, 2, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 3),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
}
tracks/1/type = "method"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(2.8, 3.4),
"transitions": PackedFloat32Array(1, 1),
"values": [{
"args": [],
"method": &"explode"
}, {
"args": [],
"method": &"done"
}]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Explosion1:emitting")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 2.8),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [false, true]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Explosion2:emitting")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 2.8),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [false, true]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_h2w7m"]
_data = {
"anim": SubResource("Animation_21j5c")
}

[node name="Bomb" type="Bomb"]
collision_layer = 0
collision_mask = 2
monitorable = false

[node name="Sprite" type="Sprite2D" parent="."]
position = Vector2(-2.92606, -2.92606)
texture = ExtResource("2")
region_enabled = true
region_rect = Rect2(144, 0, 48, 48)

[node name="Shape1" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_1ih13")

[node name="Shape2" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_whso6")

[node name="Explosion1" type="CPUParticles2D" parent="."]
emitting = false
lifetime = 0.5
one_shot = true
explosiveness = 0.95
texture = ExtResource("3")
emission_shape = 3
emission_rect_extents = Vector2(80, 1)
gravity = Vector2(0, 0)
initial_velocity_min = 1.0
initial_velocity_max = 1.0
angular_velocity_min = 187.35
angular_velocity_max = 188.35
scale_amount_curve = SubResource("Curve_4yges")

[node name="Explosion2" type="CPUParticles2D" parent="."]
rotation = 1.57162
emitting = false
lifetime = 0.5
one_shot = true
explosiveness = 0.95
texture = ExtResource("3")
emission_shape = 3
emission_rect_extents = Vector2(80, 1)
gravity = Vector2(0, 0)
initial_velocity_min = 1.0
initial_velocity_max = 1.0
angular_velocity_min = 187.35
angular_velocity_max = 188.35
scale_amount_curve = SubResource("Curve_4yges")

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_h2w7m")
}
autoplay = "anim"
Loading

0 comments on commit fe521ea

Please sign in to comment.