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

Adds a Placeholder Player Model #19

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Blocktest/Code/Networking/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Console.WriteLine($"Connected to server {peer.Address}:{peer.Port} as {peer.RemoteId}");

Transform newTransform = new(new Vector2Int(256, 128));
Renderable newRenderable = new(newTransform, Layer.Player, Drawable.ErrorDrawable, Color.Orange);
Renderable newRenderable = new(newTransform, Layer.Player, Drawable.PlaceholderDrawable);
LocalWorldState.PlayerPositions.Add(peer.RemoteId, newTransform);
_playerRenderables.Add(peer.RemoteId, newRenderable);
_camera.RenderedComponents.Add(newRenderable);
Expand Down Expand Up @@ -70,7 +70,7 @@
LocalTickBuffer = new TickBuffer(worldPacket.TickNum, LocalWorldState);

SendPacket(new PeerEvent {
SourceId = Server.RemoteId,

Check warning on line 73 in Blocktest/Code/Networking/Client.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
TickNum = worldPacket.TickNum,
Type = PeerEvent.PeerEventType.PlayerList
}, Server);
Expand All @@ -96,7 +96,7 @@
Console.WriteLine("New player connected");

Transform newTransform = new(new Vector2Int(256, 128));
Renderable newRenderable = new(newTransform, Layer.Player, Drawable.ErrorDrawable, Color.Orange);
Renderable newRenderable = new(newTransform, Layer.Player, Drawable.PlaceholderDrawable);
LocalWorldState.PlayerPositions.Add(peerEvent.SourceId, newTransform);
_playerRenderables.Add(peerEvent.SourceId, newRenderable);
_camera.RenderedComponents.Add(newRenderable);
Expand Down
3 changes: 2 additions & 1 deletion Blocktest/Code/Rendering/Drawable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public Drawable(string fileName, Rectangle? bounds = null) {
}

public static Drawable ErrorDrawable { get; } = new(@"Graphics\Blocks\error");

public static Drawable PlaceholderDrawable { get; } = new(@"Graphics\Player\placeholder-base");

public void Draw(RenderContext context, Rectangle dest, Color color) {
context.Draw(Texture, dest, Bounds, color);
}
Expand Down
2 changes: 1 addition & 1 deletion Blocktest/Code/Scenes/GameScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public GameScene(BlocktestGame game, bool doConnect, IPEndPoint? ip) {

//Add player to world in singleplayer
Transform newTransform = new(new Vector2Int(256, 128));
Renderable newRenderable = new(newTransform, Layer.Player, Drawable.ErrorDrawable, Color.Orange);
Renderable newRenderable = new(newTransform, Layer.Player, Drawable.PlaceholderDrawable);
_worldState.PlayerPositions.Add(0, newTransform);
_camera.RenderedComponents.Add(newRenderable);

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading