Skip to content

Running the game in Blazor #55

@devklick

Description

@devklick

Inspired by the dotnet-console-games repo, I want to add support to run Snek in the browser. As such, the feature/RunInBlazor has been created.

While this feature is currently functional, the performance is so bad that it's practically unusable. I'm putting this down to my lack of knowledge when it comes to building .Net UI's. I've copied a lot of the BlazorConsole.cs code from the previously mentioned repo, but the game code is vastly different. I'm having trouble converting my game code that was initially built to only run in the terminal to now also run asynchronously in Blazor.

The current implementation is deployed to Github Pages here: https://devklick.github.io/Snek/
As you can see, the performance is terrible. For example, when the snake crashes into a wall and it's game over, if we press r to replay, it takes around 20 seconds to re-initialize the game (something which happens instantly when running in a terminal). The snake also moves considerably slower when running in the console. Links and buttons etc are also somewhat unresponsive a lot of the time, which tells me the UI is hanging while the game is running.

I will try to brush up on my Blazor knowledge and hopefully continue working on this feature. I'd also gratefully accept any help with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededwipDevelopment has started but is yet to complete

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions